summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOthmar Gsenger <otti@anytun.org>2008-03-17 20:10:22 +0000
committerOthmar Gsenger <otti@anytun.org>2008-03-17 20:10:22 +0000
commitee2024f7bdc61c887068a66f844e28e0a44dc495 (patch)
tree03ea2fc19f00ccc89ea892565e73d01e533e115e
parentadded port window to command handler (diff)
enabled port window
-rw-r--r--anyrtpproxy/commandHandler.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/anyrtpproxy/commandHandler.cpp b/anyrtpproxy/commandHandler.cpp
index dd37fcc..78cff4b 100644
--- a/anyrtpproxy/commandHandler.cpp
+++ b/anyrtpproxy/commandHandler.cpp
@@ -170,10 +170,14 @@ string CommandHandler::handleRequest(string modifiers, string call_id, string ad
RtpSession& session = gRtpSessionTable.getOrNewSession(call_id, is_new);
if(is_new)
{
- static u_int16_t port1 = 35000; // TODO: get next available port
- static u_int16_t port2 = 35001; // TODO: get next available port
- port1+=2;
- port2+=2;
+ u_int16_t port1 = port_window_.newPort(); // TODO: get next available port
+ u_int16_t port2 = port_window_.newPort(); // TODO: get next available port
+ if( !port1 || !port2)
+ {
+ if( port1) port_window_.freePort(port1);
+ if( port2) port_window_.freePort(port2);
+ throw std::runtime_error("no free port found");
+ }
session.setLocalAddr("0.0.0.0"); // TODO: read this from config
session.setLocalPort1(port1);