* SIP control now sets next_hop and next_port from outbound_proxy config

variable (if specified).


git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@773 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Juha Heinanen 19 years ago
parent b88151a267
commit b5923a965d

@ -34,6 +34,9 @@ using std::stack;
EXPORT_CONTROL_INTERFACE_FACTORY(SipCtrlInterfaceFactory,MOD_NAME);
string SipCtrlInterfaceFactory::outbound_host = "";
unsigned int SipCtrlInterfaceFactory::outbound_port = 0;
AmCtrlInterface* SipCtrlInterfaceFactory::instance()
{
SipCtrlInterface* ctrl = new SipCtrlInterface(bind_addr,bind_port);
@ -51,6 +54,19 @@ int SipCtrlInterfaceFactory::onLoad()
INFO("SIP bind_addr: `%s'.\n", bind_addr.c_str());
INFO("SIP bind_port: `%i'.\n", bind_port);
if (!AmConfig::OutboundProxy.empty()) {
sip_uri parsed_uri;
if (parse_uri(&parsed_uri, (char *)AmConfig::OutboundProxy.c_str(),
AmConfig::OutboundProxy.length()) < 0) {
ERROR("invalid outbound_proxy specified\n");
return -1;
}
SipCtrlInterfaceFactory::outbound_host = c2stlstr(parsed_uri.host);
if (parsed_uri.port) {
SipCtrlInterfaceFactory::outbound_port = parsed_uri.port;
}
}
return 0;
}

@ -27,6 +27,10 @@ class SipCtrlInterfaceFactory: public AmCtrlInterfaceFactory
unsigned short bind_port;
public:
static string outbound_host;
static unsigned int outbound_port;
SipCtrlInterfaceFactory(const string& name): AmCtrlInterfaceFactory(name) {}
~SipCtrlInterfaceFactory() {}

@ -17,6 +17,7 @@
#include "SipCtrlInterface.h"
#include "AmUtils.h"
#include "AmSipMsg.h"
#include "AmConfig.h"
#include <sys/socket.h>
#include <netinet/in.h>
@ -287,9 +288,14 @@ int trans_layer::set_next_hop(list<sip_header*>& route_hdrs,
}
}
next_hop = c2stlstr(na.uri.host);
next_port = na.uri.port;
if (SipCtrlInterfaceFactory::outbound_host.empty()) {
next_hop = c2stlstr(na.uri.host);
next_port = na.uri.port;
} else {
next_hop = SipCtrlInterfaceFactory::outbound_host;
next_port = SipCtrlInterfaceFactory::outbound_port;
}
if(!is_lr){
@ -379,17 +385,23 @@ int trans_layer::set_next_hop(list<sip_header*>& route_hdrs,
}
else {
sip_uri parsed_r_uri;
err = parse_uri(&parsed_r_uri,r_uri.s,r_uri.len);
if(err < 0){
ERROR("Invalid Request URI\n");
return -1;
if (SipCtrlInterfaceFactory::outbound_host.empty()) {
sip_uri parsed_r_uri;
err = parse_uri(&parsed_r_uri,r_uri.s,r_uri.len);
if(err < 0){
ERROR("Invalid Request URI\n");
return -1;
}
next_hop = c2stlstr(parsed_r_uri.host);
next_port = parsed_r_uri.port;
} else {
next_hop = SipCtrlInterfaceFactory::outbound_host;
next_port = SipCtrlInterfaceFactory::outbound_port;
}
next_hop = c2stlstr(parsed_r_uri.host);
next_port = parsed_r_uri.port;
}
DBG("next_hop:next_port is <%s:%u>\n", next_hop.c_str(), next_port);
err = resolver::instance()->resolve_name(next_hop.c_str(),
remote_ip,IPv4,UDP);
if(err < 0){

Loading…
Cancel
Save