From 0f088b891cc7a69028d15dae7451994ca14907d5 Mon Sep 17 00:00:00 2001 From: Stefan Sayer Date: Wed, 6 Feb 2008 16:12:39 +0000 Subject: [PATCH] sipctrl using LocalSIPIP/LocalSIPPort. LocalSIPIP a config option (sip_ip) git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@674 8eb893ce-cfd4-0310-b710-fb5ebe64c474 --- core/AmConfig.cpp | 3 +++ core/etc/sems.conf.sample | 33 ++++++++++++++++------- core/plug-in/sipctrl/SipCtrlInterface.cpp | 21 +++------------ core/sems.cpp | 10 +++++-- 4 files changed, 39 insertions(+), 28 deletions(-) diff --git a/core/AmConfig.cpp b/core/AmConfig.cpp index 11e2c7ab..7fb5aad3 100644 --- a/core/AmConfig.cpp +++ b/core/AmConfig.cpp @@ -184,6 +184,9 @@ int AmConfig::readConfiguration() } } + if(cfg.hasParameter("sip_ip")) + LocalSIPIP = cfg.getParameter("sip_ip"); + // outbound_proxy OutboundProxy = cfg.getParameter("outbound_proxy"); diff --git a/core/etc/sems.conf.sample b/core/etc/sems.conf.sample index e60801d2..66e6cd2e 100644 --- a/core/etc/sems.conf.sample +++ b/core/etc/sems.conf.sample @@ -65,8 +65,7 @@ plugin_path=/usr/local/lib/sems/plug-in/ # ('blacklist'). This has only effect it load_plugins is empty. # If empty, all modules in plugin_path are loaded. # -exclude_plugins=binrpcctrl; - +exclude_plugins=binrpcctrl;sipctrl; # optional parameter: exclude_payloads= # @@ -120,15 +119,31 @@ media_processor_threads=1 # listen=10.0.0.34 # listen=eth0 +# optional parameter: sip_ip= +# +# - this informs SEMS about the SIP IP where its SIP stack is +# bound to or should be bound to. If 'sipctrl' SIP stack is used, +# the SIP stack will bind to this address. This also sets +# the value used for contact header in outgoing calls and +# registrations. +# It defaults to the value of 'listen' (see above). +# +# Example : +# sip_ip=10.0.0.34 +# +# default: +# +#sip_ip=10.0.0.34 + # optional parameter: sip_port= # -# - this informs SEMS about the port where its SER is -# bound to. SEMS needs this information to correctly set -# the contact header in outgoing calls and registrations. -# Should be set to equal the 'port' configuration option -# in ser_sems.cfg. -# This does not need to be set if outgoing calls and -# registrations from SEMS are not used. +# - this informs SEMS about the port where its SIP stack is +# bound to or should be bound to. SEMS needs this information +# to correctly set the contact header in outgoing calls +# and registrations. Should be set to equal the 'port' +# configuration option in ser_sems.cfg. +# This does not need to be set if sipctrl SIP stack, outgoing +# calls and registrations from SEMS are not used. # # default: 5060 # diff --git a/core/plug-in/sipctrl/SipCtrlInterface.cpp b/core/plug-in/sipctrl/SipCtrlInterface.cpp index 6e982b39..add8e8fe 100644 --- a/core/plug-in/sipctrl/SipCtrlInterface.cpp +++ b/core/plug-in/sipctrl/SipCtrlInterface.cpp @@ -44,24 +44,11 @@ AmCtrlInterface* SipCtrlInterfaceFactory::instance() int SipCtrlInterfaceFactory::onLoad() { - AmConfigReader cfg; + bind_addr = AmConfig::LocalSIPIP; + bind_port = AmConfig::LocalSIPPort; - if (cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf"))) { - - WARN("failed to read/parse config file `%s' - assuming defaults\n", - (AmConfig::ModConfigPath + string(MOD_NAME ".conf")).c_str()); - - bind_addr = AmConfig::LocalIP; - bind_port = AmConfig::LocalSIPPort; - } - else { - - bind_addr = cfg.getParameter("bind_addr", AmConfig::LocalIP); - bind_port = cfg.getParameterInt("bind_port", AmConfig::LocalSIPPort); - } - - INFO("bind_addr: `%s'.\n", bind_addr.c_str()); - INFO("bind_port: `%i'.\n", bind_port); + INFO("SIP bind_addr: `%s'.\n", bind_addr.c_str()); + INFO("SIP bind_port: `%i'.\n", bind_port); return 0; diff --git a/core/sems.cpp b/core/sems.cpp index e7407ab7..9a3029dc 100644 --- a/core/sems.cpp +++ b/core/sems.cpp @@ -242,19 +242,25 @@ int main(int argc, char* argv[]) } AmConfig::LocalIP = getLocalIP(AmConfig::LocalIP); - AmConfig::LocalSIPIP = AmConfig::LocalIP; + if (AmConfig::LocalSIPIP.empty()) { + AmConfig::LocalSIPIP = AmConfig::LocalIP; + } print_version(); printf( "\n\nConfiguration:\n" " configuration file: %s\n" " plug-in path: %s\n" " daemon mode: %i\n" - " local IP: %s\n" + " local SIP IP: %s\n" + " local SIP port: %i\n" + " local media IP: %s\n" " default application: %s\n" "\n", AmConfig::ConfigurationFile.c_str(), AmConfig::PlugInPath.c_str(), AmConfig::DaemonMode, + AmConfig::LocalSIPIP.c_str(), + AmConfig::LocalSIPPort, AmConfig::LocalIP.c_str(), AmConfig::DefaultApplication.empty()? "":AmConfig::DefaultApplication.c_str()