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; }