Skip to content

Commit

Permalink
Separate MCPTT floor and media port ranges
Browse files Browse the repository at this point in the history
tomhenderson committed Jan 4, 2024
1 parent 587e27c commit 9464034
Showing 3 changed files with 50 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/psc/helper/mcptt-call-helper.cc
Original file line number Diff line number Diff line change
@@ -206,8 +206,8 @@ McpttCallHelper::AddCall(ApplicationContainer clients,
Ptr<McpttPttApp> app = clients.Get(i)->GetObject<McpttPttApp>();
clientUserIds.push_back(app->GetUserId());
// McpttPttApp uses a static integer for allocating unique port numbers
uint16_t floorPort = McpttPttApp::AllocateNextPortNumber();
uint16_t mediaPort = McpttPttApp::AllocateNextPortNumber();
uint16_t floorPort = McpttPttApp::AllocateNextFloorPortNumber();
uint16_t mediaPort = McpttPttApp::AllocateNextMediaPortNumber();
NS_LOG_DEBUG("Port from " << app->GetNode()->GetId() << " to server: floor " << floorPort
<< " media " << mediaPort);
// Each application gets its own instance of a McpttCall object
31 changes: 26 additions & 5 deletions src/psc/model/mcptt-ptt-app.cc
Original file line number Diff line number Diff line change
@@ -72,18 +72,39 @@ namespace psc

NS_OBJECT_ENSURE_REGISTERED(McpttPttApp);

uint16_t McpttPttApp::s_portNumber = 9000; // Media ports typically 9000-10999
uint16_t McpttPttApp::s_mediaPortNumber = 9000; // Media ports typically 9000-10999
uint16_t McpttPttApp::s_floorPortNumber =
11000; // Arbitrarily set this range after media port range

// Legacy method, to preserve test code for the moment
uint16_t
McpttPttApp::GetCurrentPortNumber()
McpttPttApp::AllocateNextPortNumber()
{
return s_portNumber;
return s_mediaPortNumber++;
}

uint16_t
McpttPttApp::AllocateNextPortNumber()
McpttPttApp::GetCurrentMediaPortNumber(void)
{
return s_mediaPortNumber;
}

uint16_t
McpttPttApp::AllocateNextMediaPortNumber(void)
{
return s_mediaPortNumber++;
}

uint16_t
McpttPttApp::GetCurrentFloorPortNumber(void)
{
return s_floorPortNumber;
}

uint16_t
McpttPttApp::AllocateNextFloorPortNumber(void)
{
return s_portNumber++;
return s_floorPortNumber++;
}

TypeId
28 changes: 22 additions & 6 deletions src/psc/model/mcptt-ptt-app.h
Original file line number Diff line number Diff line change
@@ -106,16 +106,31 @@ class McpttPttApp : public Application, public McpttMediaSink
* \return pointer to SipAgent
*/
Ptr<sip::SipAgent> GetSipAgent(void) const;
/**
* Gets the current port number
* \returns The current port number.
*/
static uint16_t GetCurrentPortNumber(void);
/**
* Gets the next port number to use.
* \returns The next port number.
*/
static uint16_t AllocateNextPortNumber(void);
/**
* Gets the current media port number
* \returns The current media port number.
*/
static uint16_t GetCurrentMediaPortNumber(void);
/**
* Gets the next media port number to use.
* \returns The next media port number.
*/
static uint16_t AllocateNextMediaPortNumber(void);
/**
* Gets the current floor port number
* \returns The current floor port number.
*/
static uint16_t GetCurrentFloorPortNumber(void);
/**
* Gets the next floor port number to use.
* \returns The next floor port number.
*/
static uint16_t AllocateNextFloorPortNumber(void);
/**
* Accepts a call.
*/
@@ -343,7 +358,8 @@ class McpttPttApp : public Application, public McpttMediaSink
const char* event);

private:
static uint16_t s_portNumber; //!< A port number.
static uint16_t s_mediaPortNumber; //!< Media port number.
static uint16_t s_floorPortNumber; //!< Floor port number.
bool m_isRunning; //!< Whether application is running or not
uint16_t m_callIdAllocator; //!< Counter to allocate call IDs
std::map<uint16_t, Ptr<McpttChannel>> m_callChannels; //!< Map of call channels

0 comments on commit 9464034

Please sign in to comment.