From 857363dbf558f65592349198e9c3aa68fe16b75b Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Wed, 2 Sep 2009 08:30:22 +0000 Subject: [PATCH] - fixes discrepancy between outbound_proxy format (URI) and request.next_hop, which now also accepts a URI. In the case of a SIP URI (other types are not supported anyway), only the hostname and port are used. - fixes a possible memory leak in SipCtrlInterface (in case set_next_hop() failed). git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1489 8eb893ce-cfd4-0310-b710-fb5ebe64c474 --- core/AmB2ABSession.cpp | 4 ---- core/AmSipMsg.h | 2 +- core/plug-in/sipctrl/SipCtrlInterface.cpp | 25 +++++++++++------------ 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/core/AmB2ABSession.cpp b/core/AmB2ABSession.cpp index b1f634da..96dd61de 100644 --- a/core/AmB2ABSession.cpp +++ b/core/AmB2ABSession.cpp @@ -306,10 +306,6 @@ void AmB2ABCalleeSession::onB2ABEvent(B2ABEvent* ev) dlg.remote_party = co_ev->remote_party; dlg.remote_uri = co_ev->remote_uri; - // set outbound proxy as next hop - if (!AmConfig::OutboundProxy.empty()) - dlg.next_hop = AmConfig::OutboundProxy; - setCallgroup(co_ev->callgroup); setNegotiateOnReply(true); diff --git a/core/AmSipMsg.h b/core/AmSipMsg.h index 07b15ed0..5eae3a51 100644 --- a/core/AmSipMsg.h +++ b/core/AmSipMsg.h @@ -9,7 +9,7 @@ class _AmSipMsgInDlg { public: string method; - string next_hop; + string next_hop; // URI string route; string contact; diff --git a/core/plug-in/sipctrl/SipCtrlInterface.cpp b/core/plug-in/sipctrl/SipCtrlInterface.cpp index df52b3b9..31ed045a 100644 --- a/core/plug-in/sipctrl/SipCtrlInterface.cpp +++ b/core/plug-in/sipctrl/SipCtrlInterface.cpp @@ -324,18 +324,17 @@ int SipCtrlInterface::send(const AmSipRequest &req, char* serKey, unsigned int& if(!req.next_hop.empty()){ string next_port; - const char* c = req.next_hop.c_str(); - while(*c != 0){ - if(*c == ':'){ - next_port = string(c+1); - if(str2i(next_port,next_port_i)){ - ERROR("Could not convert port number in req.next_hop"); - ERROR("Using default outbound proxy"); - next_hop = SipCtrlInterfaceFactory::outbound_host; - next_port_i = SipCtrlInterfaceFactory::outbound_port; - } - break; - } + sip_uri parsed_uri; + if (parse_uri(&parsed_uri, (char *)req.next_hop.c_str(), + req.next_hop.length()) < 0) { + ERROR("invalid next hop URI\n"); + ERROR("Using default outbound proxy"); + next_hop = SipCtrlInterfaceFactory::outbound_host; + next_port_i = SipCtrlInterfaceFactory::outbound_port; + } else { + next_hop = c2stlstr(parsed_uri.host); + if (parsed_uri.port) { + next_port_i= parsed_uri.port; } next_hop += *(c++); } } @@ -350,7 +349,7 @@ int SipCtrlInterface::send(const AmSipRequest &req, char* serKey, unsigned int& &msg->remote_ip) < 0){ // TODO: error handling DBG("set_next_hop failed\n"); - //delete msg; + delete msg; return -1; }