diff options
author | Othmar Gsenger <otti@anytun.org> | 2008-03-17 20:10:22 +0000 |
---|---|---|
committer | Othmar Gsenger <otti@anytun.org> | 2008-03-17 20:10:22 +0000 |
commit | ee2024f7bdc61c887068a66f844e28e0a44dc495 (patch) | |
tree | 03ea2fc19f00ccc89ea892565e73d01e533e115e | |
parent | added port window to command handler (diff) |
enabled port window
-rw-r--r-- | anyrtpproxy/commandHandler.cpp | 12 |
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); |