[Freeswitch-svn] [commit] r2875 - in freeswitch/trunk: conf src/mod/endpoints/mod_sofia
Freeswitch SVN
anthm at freeswitch.org
Fri Sep 29 20:00:07 EDT 2006
Author: anthm
Date: Fri Sep 29 20:00:07 2006
New Revision: 2875
Modified:
freeswitch/trunk/conf/freeswitch.xml
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
Log:
break everything in sofia as you know it but add in/out reg + auth, look in the default config for the new syntax
Modified: freeswitch/trunk/conf/freeswitch.xml
==============================================================================
--- freeswitch/trunk/conf/freeswitch.xml (original)
+++ freeswitch/trunk/conf/freeswitch.xml Fri Sep 29 20:00:07 2006
@@ -3,491 +3,507 @@
<section name="configuration" description="Various Configuration">
<configuration name="switch.conf" description="Modules">
<settings>
- <!--Most channels to allow at once -->
- <param name="max-sessions" value="1000"/>
+ <!--Most channels to allow at once -->
+ <param name="max-sessions" value="1000"/>
</settings>
</configuration>
<configuration name="modules.conf" description="Modules">
<modules>
- <!-- Loggers (I'd load these first) -->
- <load module="mod_console"/>
- <!-- <load module="mod_syslog"/> -->
+ <!-- Loggers (I'd load these first) -->
+ <load module="mod_console"/>
+ <!-- <load module="mod_syslog"/> -->
- <!-- XML Interfaces -->
- <!-- <load module="mod_xml_rpc"/> -->
-
- <!-- Event Handlers -->
- <!-- <load module="mod_event_multicast"/> -->
- <!-- <load module="mod_event_test"/> -->
- <!-- <load module="mod_zeroconf"/> -->
- <!-- <load module="mod_xmpp_event"/> -->
- <!-- <load module="mod_event_socket"/> -->
+ <!-- XML Interfaces -->
+ <!-- <load module="mod_xml_rpc"/> -->
+
+ <!-- Event Handlers -->
+ <!-- <load module="mod_event_multicast"/> -->
+ <!-- <load module="mod_event_test"/> -->
+ <!-- <load module="mod_zeroconf"/> -->
+ <!-- <load module="mod_xmpp_event"/> -->
+ <!-- <load module="mod_event_socket"/> -->
- <!-- Directory Interfaces -->
- <!-- <load module="mod_ldap"/> -->
-
- <!-- Endpoints -->
- <load module="mod_exosip"/>
- <!--<load module="mod_iax"/>-->
- <load module="mod_portaudio"/>
- <!-- <load module="mod_woomera"/> -->
- <!-- <load module="mod_wanpipe"/> -->
- <!-- <load module="mod_dingaling"/> -->
-
- <!-- Applications -->
- <load module="mod_bridgecall"/>
- <load module="mod_echo"/>
- <load module="mod_dptools"/>
- <!-- <load module="mod_ivrtest"/> -->
- <load module="mod_playback"/>
- <load module="mod_commands"/>
- <!-- <load module="mod_commands"/> -->
-
- <!-- Dialplan Interfaces -->
- <load module="mod_dialplan_xml"/>
- <!-- <load module="mod_dialplan_directory"/> -->
+ <!-- Directory Interfaces -->
+ <!-- <load module="mod_ldap"/> -->
+
+ <!-- Endpoints -->
+ <load module="mod_exosip"/>
+ <!--<load module="mod_iax"/>-->
+ <load module="mod_portaudio"/>
+ <!-- <load module="mod_woomera"/> -->
+ <!-- <load module="mod_wanpipe"/> -->
+ <!-- <load module="mod_dingaling"/> -->
+
+ <!-- Applications -->
+ <load module="mod_bridgecall"/>
+ <load module="mod_echo"/>
+ <load module="mod_dptools"/>
+ <!-- <load module="mod_ivrtest"/> -->
+ <load module="mod_playback"/>
+ <load module="mod_commands"/>
+ <!-- <load module="mod_commands"/> -->
+
+ <!-- Dialplan Interfaces -->
+ <load module="mod_dialplan_xml"/>
+ <!-- <load module="mod_dialplan_directory"/> -->
- <!-- Codec Interfaces -->
- <load module="mod_g711"/>
- <load module="mod_gsm"/>
- <load module="mod_l16"/>
- <!-- <load module="mod_speex"/> -->
- <!-- <load module="mod_ilbc"/> -->
-
- <!-- File Format Interfaces -->
- <load module="mod_sndfile"/>
-
- <!-- Timers -->
- <load module="mod_softtimer"/>
-
- <!-- Languages -->
- <!-- <load module="mod_spidermonkey"/> -->
- <!-- <load module="mod_perl"/> -->
-
- <!-- ASR /TTS -->
- <!-- <load module="mod_cepstral"/> -->
- <!-- <load module="mod_rss"/> -->
+ <!-- Codec Interfaces -->
+ <load module="mod_g711"/>
+ <load module="mod_gsm"/>
+ <load module="mod_l16"/>
+ <!-- <load module="mod_speex"/> -->
+ <!-- <load module="mod_ilbc"/> -->
+
+ <!-- File Format Interfaces -->
+ <load module="mod_sndfile"/>
+
+ <!-- Timers -->
+ <load module="mod_softtimer"/>
+
+ <!-- Languages -->
+ <!-- <load module="mod_spidermonkey"/> -->
+ <!-- <load module="mod_perl"/> -->
+
+ <!-- ASR /TTS -->
+ <!-- <load module="mod_cepstral"/> -->
+ <!-- <load module="mod_rss"/> -->
- <!-- Conference Bridges -->
- <!--<load module="mod_conference"/>-->
+ <!-- Conference Bridges -->
+ <!--<load module="mod_conference"/>-->
- </modules>
+ </modules>
</configuration>
<configuration name="event_multicast.conf" description="Multicast Event">
<settings>
- <param name="address" value="225.1.1.1"/>
- <param name="port" value="4242"/>
- <param name="bindings" value="all"/>
+ <param name="address" value="225.1.1.1"/>
+ <param name="port" value="4242"/>
+ <param name="bindings" value="all"/>
</settings>
</configuration>
<configuration name="event_socket.conf" description="Socket Client">
<settings>
- <param name="listen-ip" value="127.0.0.1"/>
- <param name="listen-port" value="8021"/>
- <param name="password" value="ClueCon"/>
+ <param name="listen-ip" value="127.0.0.1"/>
+ <param name="listen-port" value="8021"/>
+ <param name="password" value="ClueCon"/>
</settings>
</configuration>
<configuration name="iax.conf" description="IAX Configuration">
<settings>
- <param name="debug" value="0"/>
- <!-- <param name="ip" value="1.2.3.4"> -->
- <param name="port" value="4569"/>
- <param name="dialplan" value="XML"/>
- <param name="codec-prefs" value="PCMU at 20i,PCMA,speex,L16"/>
- <param name="codec-master" value="us"/>
- <param name="codec-rates" value="8"/>
+ <param name="debug" value="0"/>
+ <!-- <param name="ip" value="1.2.3.4"> -->
+ <param name="port" value="4569"/>
+ <param name="dialplan" value="XML"/>
+ <param name="codec-prefs" value="PCMU at 20i,PCMA,speex,L16"/>
+ <param name="codec-master" value="us"/>
+ <param name="codec-rates" value="8"/>
</settings>
</configuration>
-
+
<configuration name="console.conf" description="Console Logger">
<!-- pick a file name, a function name or 'all' -->
<!-- map as many as you need for specific debugging -->
<mappings>
- <!-- <param name="log_event" value="DEBUG"/> -->
- <param name="all" value="DEBUG"/>
+ <!-- <param name="log_event" value="DEBUG"/> -->
+ <param name="all" value="DEBUG"/>
</mappings>
</configuration>
<configuration name="sofia.conf" description="sofia Endpoint">
- <profile name="test">
- <param name="debug" value="1"/>
- <param name="rfc2833-pt" value="101"/>
- <param name="sip-port" value="5060"/>
- <param name="dialplan" value="XML"/>
- <param name="dtmf-duration" value="100"/>
- <param name="codec-prefs" value="PCMU at 20i"/>
- <param name="codec-ms" value="20"/>
- <param name="use-rtp-timer" value="true"/>
- <param name="rtp-timer-name" value="soft"/>
- <param name="rtp-ip" value="192.168.1.20"/>
- <param name="sip-ip" value="192.168.1.20"/>
+ <profiles>
+ <profile name="test">
+ <registrations>
+ <registration name="asterlink">
+ <param name="register-scheme" value="Digest"/>
+ <param name="register-realm" value=""/>
+ <param name="register-username" value="1001"/>
+ <param name="register-password" value="nhy65tgb"/>
+ <param name="register-from" value="sip:1001 at 208.64.200.40"/>
+ <param name="register-to" value="sip:1001 at 66.250.68.194"/>
+ <param name="register-proxy" value="sip:66.250.68.194:5060"/>
+ <param name="register-frequency" value="20"/>
+ </registration>
+ </registrations>
+ <settings>
+ <param name="debug" value="1"/>
+ <param name="rfc2833-pt" value="101"/>
+ <param name="sip-port" value="5060"/>
+ <param name="dialplan" value="XML"/>
+ <param name="dtmf-duration" value="100"/>
+ <param name="codec-prefs" value="PCMU at 20i"/>
+ <param name="codec-ms" value="20"/>
+ <param name="use-rtp-timer" value="true"/>
+ <param name="rtp-timer-name" value="soft"/>
+ <param name="rtp-ip" value="192.168.1.20"/>
+ <param name="sip-ip" value="192.168.1.20"/>
- <!-- this lets anything register -->
- <!-- comment the next line and uncomment one or both of the other 2 lines for call authentication -->
- <param name="accept-blind-reg" value="true"/>
+ <!-- this lets anything register -->
+ <!-- comment the next line and uncomment one or both of the other 2 lines for call authentication -->
+ <param name="accept-blind-reg" value="true"/>
+
+ <!--<param name="auth-calls" value="true"/>-->
+ <!-- on authed calls, authenticate *all* the packets not just invite -->
+ <!--<param name="auth-all-packets" value="true"/>-->
- <!--<param name="auth-calls" value="true"/>-->
- <!-- on authed calls, authenticate *all* the packets not just invite --->
- <!--<param name="auth-all-packets" value="true"/>-->
-
- <!-- optional ; -->
- <!-- <param name="ext-rtp-ip" value="stun:stun.server.com"/>-->
- <!-- <param name="ext-rtp-ip" value="100.101.102.103"/> -->
- <!-- VAD choose one (out is a good choice); -->
- <!-- <param name="vad" value="in"/> -->
- <!-- <param name="vad" value="out"/> -->
- <!-- <param name="vad" value="both"/> -->
- <!--<param name="alias" value="sip:10.0.1.251:5555"/>-->
- </profile>
+ <!-- optional ; -->
+ <!-- <param name="ext-rtp-ip" value="stun:stun.server.com"/>-->
+ <!-- <param name="ext-rtp-ip" value="100.101.102.103"/> -->
+ <!-- VAD choose one (out is a good choice); -->
+ <!-- <param name="vad" value="in"/> -->
+ <!-- <param name="vad" value="out"/> -->
+ <!-- <param name="vad" value="both"/> -->
+ <!--<param name="alias" value="sip:10.0.1.251:5555"/>-->
+ </settings>
+ </profile>
+ </profiles>
</configuration>
<configuration name="syslog.conf" description="Syslog Logger">
- <!-- SYSLOG -->
- <!-- emerg - system is unusable -->
- <!-- alert - action must be taken immediately -->
- <!-- crit - critical conditions -->
- <!-- err - error conditions -->
- <!-- warning - warning conditions -->
- <!-- notice - normal, but significant, condition -->
- <!-- info - informational message -->
- <!-- debug - debug-level message -->
+ <!-- SYSLOG -->
+ <!-- emerg - system is unusable -->
+ <!-- alert - action must be taken immediately -->
+ <!-- crit - critical conditions -->
+ <!-- err - error conditions -->
+ <!-- warning - warning conditions -->
+ <!-- notice - normal, but significant, condition -->
+ <!-- info - informational message -->
+ <!-- debug - debug-level message -->
<settings>
- <param name="ident" value="freeswitch"/>
- <param name="facility" value="user"/>
- <param name="format" value="${time} - ${message}"/>
- <param name="level" value="debug,info,warning-alert"/>
+ <param name="ident" value="freeswitch"/>
+ <param name="facility" value="user"/>
+ <param name="format" value="${time} - ${message}"/>
+ <param name="level" value="debug,info,warning-alert"/>
</settings>
</configuration>
-
+
<configuration name="exosip.conf" description="Exosip Endpoint">
<settings>
- <param name="port" value="5060"/>
- <param name="dialplan" value="XML"/>
- <param name="dtmf-duration" value="100"/>
- <!-- the @20 is optional number of ms you want to use. Use it only
- if you know the codec supports it -->
- <param name="codec-prefs" value="PCMU at 20i,PCMA at 20i"/>
- <!-- Example to call for speex in wideband 16k mode
- you can have up to 2 '@; after the codec name followed by either
- 'i' (interval eg 20i for 20ms) or 'k' (kilohertz eg 16000k for 16khz)-->
- <!--<param name="codec-prefs" value="SPEEX at 16000k"/>-->
- <!-- Payload number to bind DTMF to-->
- <param name="rfc2833-pt" value="101"/>
- <!-- disable to trade async for more calls -->
- <param name="use-rtp-timer" value="true"/>
- <!-- auto sense NAT issues and adjust accordingly -->
- <param name="use-rtp-auto-adjust" value="true"/>
- <!-- pick one (default if not specified is 'guess'); -->
- <param name="rtp-ip" value="guess"/>
- <!-- <param name-"rtp-ip" value="10.0.0.1"/> -->
- <!-- leave commented or 0.0.0.0 for all ip -->
- <!-- <param name="sip-ip" value="127.0.0.1"/> -->
-
- <!-- optional ; -->
- <!-- <param name="ext-rtp-ip" value="stun:stun.server.com"/> -->
- <!-- <param name="ext-rtp-ip" value="100.101.102.103"/> -->
-
- <!-- specify 'myrealm' with certian key -->
- <!-- use !myrealm! at beginning of url to activate -->
- <!-- exosip/!myrealm!1000 at dest -->
- <!-- srtp:<param name="myrealm" value="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"/> -->
-
- <!-- VAD choose one (out is a good choice); -->
- <!-- <param name="vad" value="in"/> -->
- <!-- <param name="vad" value="out"/> -->
- <!-- <param name="vad" value="both"/> -->
+ <param name="port" value="5060"/>
+ <param name="dialplan" value="XML"/>
+ <param name="dtmf-duration" value="100"/>
+ <!-- the @20 is optional number of ms you want to use. Use it only
+ if you know the codec supports it -->
+ <param name="codec-prefs" value="PCMU at 20i,PCMA at 20i"/>
+ <!-- Example to call for speex in wideband 16k mode
+ you can have up to 2 '@; after the codec name followed by either
+ 'i' (interval eg 20i for 20ms) or 'k' (kilohertz eg 16000k for 16khz)-->
+ <!--<param name="codec-prefs" value="SPEEX at 16000k"/>-->
+ <!-- Payload number to bind DTMF to-->
+ <param name="rfc2833-pt" value="101"/>
+ <!-- disable to trade async for more calls -->
+ <param name="use-rtp-timer" value="true"/>
+ <!-- auto sense NAT issues and adjust accordingly -->
+ <param name="use-rtp-auto-adjust" value="true"/>
+ <!-- pick one (default if not specified is 'guess'); -->
+ <param name="rtp-ip" value="guess"/>
+ <!-- <param name-"rtp-ip" value="10.0.0.1"/> -->
+ <!-- leave commented or 0.0.0.0 for all ip -->
+ <!-- <param name="sip-ip" value="127.0.0.1"/> -->
+
+ <!-- optional ; -->
+ <!-- <param name="ext-rtp-ip" value="stun:stun.server.com"/> -->
+ <!-- <param name="ext-rtp-ip" value="100.101.102.103"/> -->
+
+ <!-- specify 'myrealm' with certian key -->
+ <!-- use !myrealm! at beginning of url to activate -->
+ <!-- exosip/!myrealm!1000 at dest -->
+ <!-- srtp:<param name="myrealm" value="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"/> -->
+
+ <!-- VAD choose one (out is a good choice); -->
+ <!-- <param name="vad" value="in"/> -->
+ <!-- <param name="vad" value="out"/> -->
+ <!-- <param name="vad" value="both"/> -->
</settings>
</configuration>
-
+
<configuration name="woomera.conf" description="Woomera Endpoint">
<settings>
- <param name="debug" value="0"/>
+ <param name="debug" value="0"/>
</settings>
<interface>
- <param name="host" value="localhost"/>
- <param name="port" value="42420"/>
- <param name="audio-ip" value="127.0.0.1"/>
- <param name="dialplan" value="XML"/>
+ <param name="host" value="localhost"/>
+ <param name="port" value="42420"/>
+ <param name="audio-ip" value="127.0.0.1"/>
+ <param name="dialplan" value="XML"/>
</interface>
</configuration>
<configuration name="wanpipe.conf" description="Sangoma Wanpipe Endpoint">
<settings>
- <param name="debug" value="1"/>
- <param name="dialplan" value="XML"/>
- <param name="mtu" value="320"/>
- <param name="dtmf-on" value="800"/>
- <param name="dtmf-off" value="100"/>
- <param name="supress-dtmf-tone" value="yes"/>
+ <param name="debug" value="1"/>
+ <param name="dialplan" value="XML"/>
+ <param name="mtu" value="320"/>
+ <param name="dtmf-on" value="800"/>
+ <param name="dtmf-off" value="100"/>
+ <param name="supress-dtmf-tone" value="yes"/>
</settings>
<span>
- <param name="span" value="1"/>
- <param name="node" value="cpe"/>
- <!-- <param name="switch" value="ni2"/> -->
- <param name="switch" value="dms100"/>
- <!-- <param name="switch" value="lucent5e"/> -->
- <!-- <param name="switch" value="att4ess"/> -->
- <!-- <param name="switch" value="euroisdn"/> -->
- <!-- <param name="switch" value="gr303eoc"/> -->
- <!-- <param name="switch" value="gr303tmc"/> -->
- <param name="dp" value="national"/>
- <!-- <param name="dp" value="international"/> -->
- <!-- <param name="dp" value="local"/> -->
- <!-- <param name="dp" value="private"/> -->
- <!-- <param name="dp" value="unknown"/> -->
- <param name="l1" value="ulaw"/>
- <!-- <param name="l1" value="alaw"/> -->
- <param name="bchan" value="1-23"/>
- <param name="dchan" value="24"/>
- <param name="dialplan" value="XML"/>
+ <param name="span" value="1"/>
+ <param name="node" value="cpe"/>
+ <!-- <param name="switch" value="ni2"/> -->
+ <param name="switch" value="dms100"/>
+ <!-- <param name="switch" value="lucent5e"/> -->
+ <!-- <param name="switch" value="att4ess"/> -->
+ <!-- <param name="switch" value="euroisdn"/> -->
+ <!-- <param name="switch" value="gr303eoc"/> -->
+ <!-- <param name="switch" value="gr303tmc"/> -->
+ <param name="dp" value="national"/>
+ <!-- <param name="dp" value="international"/> -->
+ <!-- <param name="dp" value="local"/> -->
+ <!-- <param name="dp" value="private"/> -->
+ <!-- <param name="dp" value="unknown"/> -->
+ <param name="l1" value="ulaw"/>
+ <!-- <param name="l1" value="alaw"/> -->
+ <param name="bchan" value="1-23"/>
+ <param name="dchan" value="24"/>
+ <param name="dialplan" value="XML"/>
</span>
</configuration>
-
+
<configuration name="portaudio.conf" description="Soundcard Endpoint">
<settings>
- <param name="debug" value="2"/>
- <param name="dialplan" value="XML"/>
-
- <!-- partial string match on something in the name or the device # -->
- <param name="indev" value="USB"/>
- <param name="outdev" value="USB"/>
-
- <param name="cid-name" value="FreeSwitch"/>
- <param name="cid-num" value="5555551212"/>
+ <param name="debug" value="2"/>
+ <param name="dialplan" value="XML"/>
+
+ <!-- partial string match on something in the name or the device # -->
+ <param name="indev" value="USB"/>
+ <param name="outdev" value="USB"/>
+
+ <param name="cid-name" value="FreeSwitch"/>
+ <param name="cid-num" value="5555551212"/>
</settings>
</configuration>
-
+
<configuration name="zeroconf.conf" description="Zeroconf Event Handler">
<settings>
- <param name="publish" value="yes"/>
- <param name="browse" value="_sip._udp"/>
+ <param name="publish" value="yes"/>
+ <param name="browse" value="_sip._udp"/>
</settings>
</configuration>
-
+
<configuration name="xmpp_event.conf" description="XMPP Event Handler">
<settings>
- <param name="#debug" value="1"/>
- <param name="jid" value="freeswitch at my.jabber.com/me"/>
- <param name="passwd" value="mypass"/>
- <param name="target-jid" value="freeswitch at reader.org/him"/>
+ <param name="#debug" value="1"/>
+ <param name="jid" value="freeswitch at my.jabber.com/me"/>
+ <param name="passwd" value="mypass"/>
+ <param name="target-jid" value="freeswitch at reader.org/him"/>
</settings>
</configuration>
-
+
<configuration name="dialplan_directory.conf" description="Dialplan Directory">
<settings>
- <param name="directory-name" value="ldap"/>
- <param name="host" value="ldap.freeswitch.org"/>
- <param name="dn" value="cn=Manager,dc=freeswitch,dc=org"/>
- <param name="pass" value="test"/>
- <param name="base" value="dc=freeswitch,dc=org"/>
+ <param name="directory-name" value="ldap"/>
+ <param name="host" value="ldap.freeswitch.org"/>
+ <param name="dn" value="cn=Manager,dc=freeswitch,dc=org"/>
+ <param name="pass" value="test"/>
+ <param name="base" value="dc=freeswitch,dc=org"/>
</settings>
</configuration>
-
+
<configuration name="dingaling.conf" description="XMPP Jingle Endpoint">
<settings>
- <param name="debug" value="0"/>
- <param name="codec-prefs" value="PCMU"/>
+ <param name="debug" value="0"/>
+ <param name="codec-prefs" value="PCMU"/>
</settings>
<!-- *NOTE* your resource (after the /) MUST contain the string "talk" (upper or lower case is ok) -->
<!-- *NOTE* as of May 2 2006 you must set"auto-login" to"true" if you want to be able to auto-login on startup"/> -->
<interface>
- <param name="name" value="jingle"/>
- <param name="login" value="myjid at myserver.com/talk"/>
- <param name="password" value="mypass"/>
- <param name="dialplan" value="XML"/>
- <param name="message" value="Jingle all the way"/>
- <param name="rtp-ip" value="10.0.0.1"/>
- <param name="auto-login" value="true"/>
- <!-- SASL "plain" or "md5" -->
- <param name="sasl" value="plain"/>
- <!-- if the server where the jabber is hosted is not the same
- as the one in the jid -->
- <!--<param name="server" value="alternate.server.com"/>-->
- <!-- Enable TLS or not -->
- <param name="tls" value="true"/>
- <!-- disable to trade async for more calls -->
- <param name="use-rtp-timer" value="true"/>
- <!-- or -->
- <!-- <param name="rtp-ip" value="my_lan_ip"/> -->
- <!-- <param name="ext-rtp-ip" value="stun:stun.server.com"/> -->
- <!-- default extension (if one cannot be determined) -->
- <param name="exten" value="888"/>
- <!-- VAD choose one -->
- <!-- <param name="vad" value="in"/> -->
- <!-- <param name="vad" value="out"/> -->
- <param name="vad" value="both"/>
+ <param name="name" value="jingle"/>
+ <param name="login" value="myjid at myserver.com/talk"/>
+ <param name="password" value="mypass"/>
+ <param name="dialplan" value="XML"/>
+ <param name="message" value="Jingle all the way"/>
+ <param name="rtp-ip" value="10.0.0.1"/>
+ <param name="auto-login" value="true"/>
+ <!-- SASL "plain" or "md5" -->
+ <param name="sasl" value="plain"/>
+ <!-- if the server where the jabber is hosted is not the same
+ as the one in the jid -->
+ <!--<param name="server" value="alternate.server.com"/>-->
+ <!-- Enable TLS or not -->
+ <param name="tls" value="true"/>
+ <!-- disable to trade async for more calls -->
+ <param name="use-rtp-timer" value="true"/>
+ <!-- or -->
+ <!-- <param name="rtp-ip" value="my_lan_ip"/> -->
+ <!-- <param name="ext-rtp-ip" value="stun:stun.server.com"/> -->
+ <!-- default extension (if one cannot be determined) -->
+ <param name="exten" value="888"/>
+ <!-- VAD choose one -->
+ <!-- <param name="vad" value="in"/> -->
+ <!-- <param name="vad" value="out"/> -->
+ <param name="vad" value="both"/>
</interface>
</configuration>
<configuration name="xml_rpc.conf" description="XML RPC">
<settings>
- <!-- The port where you want to run the http service (default 8080) -->
- <param name="http-port" value="8080"/>
- <!-- if all 3 of the following params exist all http traffic will require auth -->
- <param name="auth-realm" value="freeswitch"/>
- <param name="auth-user" value="freeswitch"/>
- <param name="auth-pass" value="works"/>
- <!-- The url to a gateway cgi that can generate xml similar to
- what's in this file only on-the-fly (leave it commented if you dont
- need it) -->
- <!-- one or more |-delim of configuration|directory|dialplan -->
- <!-- <param name="gateway-url" value="http://www.server.com/gateway.cgi" bindings="configuration"/> -->
+ <!-- The port where you want to run the http service (default 8080) -->
+ <param name="http-port" value="8080"/>
+ <!-- if all 3 of the following params exist all http traffic will require auth -->
+ <param name="auth-realm" value="freeswitch"/>
+ <param name="auth-user" value="freeswitch"/>
+ <param name="auth-pass" value="works"/>
+ <!-- The url to a gateway cgi that can generate xml similar to
+ what's in this file only on-the-fly (leave it commented if you dont
+ need it) -->
+ <!-- one or more |-delim of configuration|directory|dialplan -->
+ <!-- <param name="gateway-url" value="http://www.server.com/gateway.cgi" bindings="configuration"/> -->
</settings>
</configuration>
<configuration name="rss.conf" description="RSS Parser">
<feeds>
- <!-- Just download the files to wherever and refer to them here -->
- <!-- <feed name="Slash Dot">/home/rss/rss.rss</feed> -->
- <!-- <feed name="News Forge">/home/rss/newsforge.rss</feed> -->
+ <!-- Just download the files to wherever and refer to them here -->
+ <!-- <feed name="Slash Dot">/home/rss/rss.rss</feed> -->
+ <!-- <feed name="News Forge">/home/rss/newsforge.rss</feed> -->
</feeds>
</configuration>
<!-- None of these paths are real if you want any of these options
- you need to really set them up -->
+ you need to really set them up -->
<configuration name="conference.conf" description="Audio Conference">
<!-- Profiles are collections of settings you can reference by name. -->
<profiles>
- <profile name="default">
- <!-- Sample Rate-->
- <param name="rate" value="8000"/>
- <!-- Number of milliseconds per frame -->
- <param name="interval" value="20"/>
- <!-- Energy level required for audio to be sent to the other users -->
- <param name="energy-level" value="300"/>
- <!-- TTS Engine to use -->
- <!--<param name="tts-engine" value="cepstral"/>-->
- <!-- TTS Voice to use -->
- <!--<param name="tts-voice" value="david"/>-->
+ <profile name="default">
+ <!-- Sample Rate-->
+ <param name="rate" value="8000"/>
+ <!-- Number of milliseconds per frame -->
+ <param name="interval" value="20"/>
+ <!-- Energy level required for audio to be sent to the other users -->
+ <param name="energy-level" value="300"/>
+ <!-- TTS Engine to use -->
+ <!--<param name="tts-engine" value="cepstral"/>-->
+ <!-- TTS Voice to use -->
+ <!--<param name="tts-voice" value="david"/>-->
- <!-- If TTS is enabled all audio-file params not beginning with '/'
- will be considered text to say with TTS -->
+ <!-- If TTS is enabled all audio-file params not beginning with '/'
+ will be considered text to say with TTS -->
- <!-- File to play to acknowledge succees -->
- <!--<param name="ack-sound" value="/soundfiles/beep.wav"/>-->
- <!-- File to play to acknowledge failure -->
- <!--<param name="nack-sound" value="/soundfiles/beeperr.wav"/>-->
- <!-- File to play to acknowledge muted -->
- <!--<param name="muted-sound" value="/soundfiles/muted.wav"/>-->
- <!-- File to play to acknowledge unmuted -->
- <!--<param name="unmuted-sound" value="/soundfiles/unmuted.wav"/>-->
- <!-- File to play if you are alone in the conference -->
- <!--<param name="alone-sound" value="/soundfiles/yactopitc.wav"/>-->
- <!-- File to play when you join the conference -->
- <!--<param name="enter-sound" value="/soundfiles/welcome.wav"/>-->
- <!-- File to play when you leave the conference -->
- <!--<param name="exit-sound" value="/soundfiles/exit.wav"/>-->
- <!-- File to play when you ae ejected from the conference -->
- <!--<param name="kicked-sound" value="/soundfiles/kicked.wav"/>-->
- <!-- File to play when the conference is locked -->
- <!--<param name="locked-sound" value="/soundfiles/locked.wav"/>-->
- <!-- File to play to prompt for a pin -->
- <!--<param name="pin-sound" value="/soundfiles/pin.wav"/>-->
- <!-- File to play to when the pin is invalid -->
- <!--<param name="bad-pin-sound" value="/soundfiles/invalid-pin.wav"/>-->
- <!-- Conference pin -->
- <!--<param name="pin" value="12345"/>-->
- <!-- Default Caller ID Name for outbound calls -->
- <param name="caller-id-name" value="FreeSWITCH"/>
- <!-- Default Caller ID Number for outbound calls -->
- <param name="caller-id-number" value="8777423583"/>
- </profile>
+ <!-- File to play to acknowledge succees -->
+ <!--<param name="ack-sound" value="/soundfiles/beep.wav"/>-->
+ <!-- File to play to acknowledge failure -->
+ <!--<param name="nack-sound" value="/soundfiles/beeperr.wav"/>-->
+ <!-- File to play to acknowledge muted -->
+ <!--<param name="muted-sound" value="/soundfiles/muted.wav"/>-->
+ <!-- File to play to acknowledge unmuted -->
+ <!--<param name="unmuted-sound" value="/soundfiles/unmuted.wav"/>-->
+ <!-- File to play if you are alone in the conference -->
+ <!--<param name="alone-sound" value="/soundfiles/yactopitc.wav"/>-->
+ <!-- File to play when you join the conference -->
+ <!--<param name="enter-sound" value="/soundfiles/welcome.wav"/>-->
+ <!-- File to play when you leave the conference -->
+ <!--<param name="exit-sound" value="/soundfiles/exit.wav"/>-->
+ <!-- File to play when you ae ejected from the conference -->
+ <!--<param name="kicked-sound" value="/soundfiles/kicked.wav"/>-->
+ <!-- File to play when the conference is locked -->
+ <!--<param name="locked-sound" value="/soundfiles/locked.wav"/>-->
+ <!-- File to play to prompt for a pin -->
+ <!--<param name="pin-sound" value="/soundfiles/pin.wav"/>-->
+ <!-- File to play to when the pin is invalid -->
+ <!--<param name="bad-pin-sound" value="/soundfiles/invalid-pin.wav"/>-->
+ <!-- Conference pin -->
+ <!--<param name="pin" value="12345"/>-->
+ <!-- Default Caller ID Name for outbound calls -->
+ <param name="caller-id-name" value="FreeSWITCH"/>
+ <!-- Default Caller ID Number for outbound calls -->
+ <param name="caller-id-number" value="8777423583"/>
+ </profile>
</profiles>
</configuration>
</section>
<section name="dialplan" description="Regex/XML Dialplan">
<!-- Valid fields in conditions:
- "dialplan, caller_id_name, ani, ani2, caller_id_number,
- network_addr, rdnis, destination_number, uuid, source,
- context, chan_name" -->
+ "dialplan, caller_id_name, ani, ani2, caller_id_number,
+ network_addr, rdnis, destination_number, uuid, source,
+ context, chan_name" -->
<!-- *NOTE* The special context name 'any' will match any context -->
<context name="default">
<extension name="tollfree">
- <condition field="destination_number" expression="^(18(0{2}|8{2}|7{2}|6{2})\d{7})$">
- <action application="bridge" data="exosip/$1-freeswitch at voip.trxtel.com"/>
- </condition>
+ <condition field="destination_number" expression="^(18(0{2}|8{2}|7{2}|6{2})\d{7})$">
+ <action application="bridge" data="exosip/$1-freeswitch at voip.trxtel.com"/>
+ </condition>
</extension>
<!--<extension name="devconf">
- <condition field="destination_number" expression="^888$">
- <action application="bridge" data="exosip/888 at 66.250.68.194"/>
- </condition>
- </extension> -->
+ <condition field="destination_number" expression="^888$">
+ <action application="bridge" data="exosip/888 at 66.250.68.194"/>
+ </condition>
+ </extension> -->
<extension name="testmusic">
- <condition field="destination_number" expression="^1234$">
- <action application="bridge" data="exosip/1234 at 66.250.68.194"/>
- </condition>
+ <condition field="destination_number" expression="^1234$">
+ <action application="bridge" data="exosip/1234 at 66.250.68.194"/>
+ </condition>
</extension>
<!-- Enter an existing conference -->
<extension name="1000">
- <condition field="destination_number" expression="^1000$">
- <action application="conference" data="freeswitch"/>
- </condition>
+ <condition field="destination_number" expression="^1000$">
+ <action application="conference" data="freeswitch"/>
+ </condition>
</extension>
<!-- Start a dynamic conference and call someone at the same time -->
<extension name="2000">
- <condition field="destination_number" expression="^2000$">
- <action application="conference" data="bridge:mydynaconf:exosip/1234 at 66.250.68.194"/>
- </condition>
+ <condition field="destination_number" expression="^2000$">
+ <action application="conference" data="bridge:mydynaconf:exosip/1234 at 66.250.68.194"/>
+ </condition>
</extension>
<!-- if the destination is an exact match on the extension name
- you do not need any regex in the condition
- <extension name="999">
- <condition><action application="bridge" data="exosip/888 at 66.250.68.194"/></condition>
- </extension>-->
+ you do not need any regex in the condition
+ <extension name="999">
+ <condition><action application="bridge" data="exosip/888 at 66.250.68.194"/></condition>
+ </extension>-->
<!-- extensions starting with 4, all the numbers after 4 form a numeric filename
- continue=true means keep looking for more extensions to match
- *NOTE* The entire dialplan is parsed ONCE when the call starts
- so any call info acquired after the various actions cannot
- be taken into consideration.
+ continue=true means keep looking for more extensions to match
+ *NOTE* The entire dialplan is parsed ONCE when the call starts
+ so any call info acquired after the various actions cannot
+ be taken into consideration.
- The first match will play a beep and the second one plays
- the desired file. This is for demo purposes both actions
- could have been under the same <extension> tag as well.
- -->
+The first match will play a beep and the second one plays
+the desired file. This is for demo purposes both actions
+could have been under the same <extension> tag as well.
+ -->
<extension name="playsound1" continue="true">
- <condition field="source" expression="mod_exosip"/>
- <condition field="destination_number" expression="^4(\d+)">
- <action application="playback" data="/var/sounds/beep.gsm"/>
- </condition>
+ <condition field="source" expression="mod_exosip"/>
+ <condition field="destination_number" expression="^4(\d+)">
+ <action application="playback" data="/var/sounds/beep.gsm"/>
+ </condition>
</extension>
<extension name="playsound2">
- <condition field="source" expression="mod_exosip"/>
- <condition field="destination_number" expression="^4(\d+)">
- <action application="playback" data="/root/$1.raw"/>
- </condition>
+ <condition field="source" expression="mod_exosip"/>
+ <condition field="destination_number" expression="^4(\d+)">
+ <action application="playback" data="/root/$1.raw"/>
+ </condition>
</extension>
<!-- send everything with a certian RDNIS to Wanpipe ISDN -->
<extension name="To PRI">
- <condition field="rdnis" expression="8881231234"/>
- <condition field="destination_number" expression="(.*)">
- <action application="bridge" data="wanpipe/a/a/$1"/>
- </condition>
+ <condition field="rdnis" expression="8881231234"/>
+ <condition field="destination_number" expression="(.*)">
+ <action application="bridge" data="wanpipe/a/a/$1"/>
+ </condition>
</extension>
<!-- Call *MUST* originate from mod_iax and also be dialing ext 9999-->
<extension name="9999">
- <condition field="source" expression="mod_iax"/>
- <condition field="destination_number" expression="9999">
- <action application="playback" data="/var/sounds/beep.gsm"/>
- </condition>
+ <condition field="source" expression="mod_iax"/>
+ <condition field="destination_number" expression="9999">
+ <action application="playback" data="/var/sounds/beep.gsm"/>
+ </condition>
</extension>
<!-- Call the FreeSWITCH conference via SIP -->
<extension name="FreeSWITCH Conference SIP">
- <condition field="destination_number" expression="^888$">
- <action application="bridge" data="exosip/888 at 66.250.68.194"/>
- </condition>
+ <condition field="destination_number" expression="^888$">
+ <action application="bridge" data="exosip/888 at 66.250.68.194"/>
+ </condition>
</extension>
<!-- Call the FreeSWITCH conference via IAX -->
<extension name="FreeSWITCH Conference IAX">
- <condition field="destination_number" expression="^8888$">
- <action application="bridge" data="iax/guest at 66.250.68.194/888"/>
- </condition>
+ <condition field="destination_number" expression="^8888$">
+ <action application="bridge" data="iax/guest at 66.250.68.194/888"/>
+ </condition>
</extension>
</context>
</section>
@@ -495,16 +511,16 @@
<section name="directory" description="User Directory">
<!--the domain or ip (the right hand side of the @ in the addr-->
<domain name="mydomain.com">
- <!--the user id (the left hand side of the @ in the addr-->
+ <!--the user id (the left hand side of the @ in the addr-->
<user id="1000">
<!-- omit password for authless registration -->
<param name="password" value="mypass"/>
<!--various endpoints and application will look for user specific settings here -->
<param name="mypref" value="myval"/>
- </user>
+ </user>
</domain>
</section>
</document>
-
+
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Fri Sep 29 20:00:07 2006
@@ -39,13 +39,23 @@
#define HAVE_APR
#include <switch.h>
+struct outbound_reg;
+typedef struct outbound_reg outbound_reg_t;
+
struct sofia_profile;
typedef struct sofia_profile sofia_profile_t;
#define NUA_MAGIC_T sofia_profile_t
+struct sofia_private {
+ switch_core_session_t *session;
+ outbound_reg_t *oreg;
+};
+
+typedef struct sofia_private sofia_private_t;
+
struct private_object;
typedef struct private_object private_object_t;
-#define NUA_HMAGIC_T switch_core_session_t
+#define NUA_HMAGIC_T sofia_private_t
#define MY_EVENT_REGISTER "sofia::register"
#define MY_EVENT_EXPIRE "sofia::expire"
@@ -77,10 +87,6 @@
" expires INTEGER(8)"
");\n";
-
-
-
-
static const char modname[] = "mod_sofia";
#define STRLEN 15
@@ -133,6 +139,41 @@
switch_mutex_t *mutex;
} globals;
+typedef enum {
+ REG_FLAG_AUTHED = (1 << 0),
+} reg_flags_t;
+
+typedef enum {
+ REG_STATE_UNREGED,
+ REG_STATE_TRYING,
+ REG_STATE_REGISTER,
+ REG_STATE_REGED,
+ REG_STATE_FAILED,
+ REG_STATE_EXPIRED
+} reg_state_t;
+
+struct outbound_reg {
+ sofia_private_t sofia_private;
+ nua_handle_t *nh;
+ sofia_profile_t *profile;
+ char *name;
+ char *register_scheme;
+ char *register_realm;
+ char *register_username;
+ char *register_password;
+ char *register_from;
+ char *register_to;
+ char *register_proxy;
+ char *expires_str;
+ uint32_t freq;
+ time_t expires;
+ time_t retry;
+ uint32_t flags;
+ reg_state_t state;
+ switch_memory_pool_t *pool;
+ struct outbound_reg *next;
+};
+
struct sofia_profile {
int debug;
char *name;
@@ -163,12 +204,14 @@
sip_alias_node_t *aliases;
switch_payload_t te;
uint32_t codec_flags;
- switch_mutex_t *reg_mutex;
+ switch_mutex_t *ireg_mutex;
+ switch_mutex_t *oreg_mutex;
+ outbound_reg_t *registrations;
};
-
struct private_object {
+ sofia_private_t sofia_private;
uint32_t flags;
switch_core_session_t *session;
switch_frame_t read_frame;
@@ -263,21 +306,21 @@
nua_t *nua,
sofia_profile_t *profile,
nua_handle_t *nh,
- switch_core_session_t *session,
+ sofia_private_t *sofia_private,
sip_t const *sip,
tagi_t tags[]);
static void sip_i_invite(nua_t *nua,
sofia_profile_t *profile,
nua_handle_t *nh,
- switch_core_session_t *session,
+ sofia_private_t *sofia_private,
sip_t const *sip,
tagi_t tags[]);
static void sip_i_register(nua_t *nua,
sofia_profile_t *profile,
nua_handle_t *nh,
- switch_core_session_t *session,
+ sofia_private_t *sofia_private,
sip_t const *sip,
tagi_t tags[]);
@@ -287,7 +330,7 @@
nua_t *nua,
sofia_profile_t *profile,
nua_handle_t *nh,
- switch_core_session_t *session,
+ sofia_private_t *sofia_private,
sip_t const *sip,
tagi_t tags[]);
@@ -356,7 +399,7 @@
}
if (switch_strlen_zero(np)) {
- if (!get_auth_data(profile->dbname, nonce, np, nplen, profile->reg_mutex)) {
+ if (!get_auth_data(profile->dbname, nonce, np, nplen, profile->ireg_mutex)) {
ret = AUTH_STALE;
goto end;
}
@@ -468,7 +511,7 @@
return;
}
- switch_mutex_lock(profile->reg_mutex);
+ switch_mutex_lock(profile->ireg_mutex);
snprintf(sql, sizeof(sql), "select '%s',* from sip_registrations where expires > 0 and expires < %ld", profile->name, (long) now);
switch_core_db_exec(db, sql, del_callback, NULL, &errmsg);
@@ -482,7 +525,7 @@
switch_core_db_persistant_execute(db, sql, 25);
snprintf(sql, sizeof(sql), "delete from sip_authentication where expires > 0 and expires < %ld", (long) now);
switch_core_db_persistant_execute(db, sql, 25);
- switch_mutex_unlock(profile->reg_mutex);
+ switch_mutex_unlock(profile->ireg_mutex);
switch_core_db_close(db);
}
@@ -500,7 +543,7 @@
cbt.val = val;
cbt.len = len;
- switch_mutex_lock(profile->reg_mutex);
+ switch_mutex_lock(profile->ireg_mutex);
if (host) {
snprintf(val, len, "select contact from sip_registrations where user='%s' and host='%s'", user, host);
} else {
@@ -515,7 +558,7 @@
errmsg = NULL;
}
- switch_mutex_unlock(profile->reg_mutex);
+ switch_mutex_unlock(profile->ireg_mutex);
switch_core_db_close(db);
return cbt.matches ? val : NULL;
@@ -723,7 +766,8 @@
switch_set_flag_locked(tech_pvt, TFLAG_READY);
tech_pvt->nh = nua_handle(tech_pvt->profile->nua, NULL, SIPTAG_TO_STR(tech_pvt->dest), TAG_END());
- nua_handle_bind(tech_pvt->nh, session);
+ tech_pvt->sofia_private.session = session;
+ nua_handle_bind(tech_pvt->nh, &tech_pvt->sofia_private);
nua_invite(tech_pvt->nh,
SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
SOATAG_RTP_SORT(SOA_RTP_SORT_REMOTE),
@@ -1593,7 +1637,7 @@
nua_t *nua,
sofia_profile_t *profile,
nua_handle_t *nh,
- switch_core_session_t *session,
+ sofia_private_t *sofia_private,
sip_t const *sip,
tagi_t tags[])
@@ -1604,7 +1648,8 @@
int ss_state = nua_callstate_init;
switch_channel_t *channel = NULL;
private_object_t *tech_pvt = NULL;
-
+ switch_core_session_t *session = sofia_private ? sofia_private->session : NULL;
+
tl_gets(tags,
NUTAG_CALLSTATE_REF(ss_state),
NUTAG_OFFER_RECV_REF(offer_recv),
@@ -1842,7 +1887,6 @@
static uint8_t handle_register(nua_t *nua,
sofia_profile_t *profile,
nua_handle_t *nh,
- switch_core_session_t *session,
sip_t const *sip,
sofia_regtype_t regtype,
char *key,
@@ -1852,7 +1896,6 @@
sip_expires_t const *expires = sip->sip_expires;
sip_authorization_t const *authorization = sip->sip_authorization;
sip_contact_t const *contact = sip->sip_contact;
-
switch_xml_t domain, xml, user, param;
char params[1024] = "";
char *sql;
@@ -1865,9 +1908,9 @@
char *passwd = NULL;
uint8_t stale = 0, ret = 0, forbidden = 0;
auth_res_t auth_res;
-
long exptime = 60;
+
if (expires) {
exptime = expires->ex_delta;
} else if (contact->m_expires) {
@@ -1979,7 +2022,7 @@
}
- execute_sql(profile->dbname, sql, profile->reg_mutex);
+ execute_sql(profile->dbname, sql, profile->ireg_mutex);
switch_core_db_free(sql);
switch_core_db_free(auth_str);
ret = 1;
@@ -2025,7 +2068,7 @@
}
if (sql) {
- execute_sql(profile->dbname, sql, profile->reg_mutex);
+ execute_sql(profile->dbname, sql, profile->ireg_mutex);
switch_core_db_free(sql);
sql = NULL;
}
@@ -2051,17 +2094,17 @@
static void sip_i_invite(nua_t *nua,
sofia_profile_t *profile,
nua_handle_t *nh,
- switch_core_session_t *session,
+ sofia_private_t *sofia_private,
sip_t const *sip,
tagi_t tags[])
{
-
+ switch_core_session_t *session = sofia_private ? sofia_private->session : NULL;
char key[128] = "";
if (!session) {
if ((profile->pflags & PFLAG_AUTH_CALLS)) {
- if (handle_register(nua, profile, nh, session, sip, REG_INVITE, key, sizeof(key))) {
+ if (handle_register(nua, profile, nh, sip, REG_INVITE, key, sizeof(key))) {
return;
}
}
@@ -2119,7 +2162,8 @@
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
}
switch_set_flag_locked(tech_pvt, TFLAG_INBOUND);
- nua_handle_bind(nh, session);
+ tech_pvt->sofia_private.session = session;
+ nua_handle_bind(nh, &tech_pvt->sofia_private);
}
}
}
@@ -2127,25 +2171,94 @@
static void sip_i_register(nua_t *nua,
sofia_profile_t *profile,
nua_handle_t *nh,
- switch_core_session_t *session,
+ sofia_private_t *sofia_private,
sip_t const *sip,
tagi_t tags[])
{
- handle_register(nua, profile, nh, session, sip, REG_REGISTER, NULL, 0);
+ //switch_core_session_t *session = sofia_private ? sofia_private->session : NULL;
+ handle_register(nua, profile, nh, sip, REG_REGISTER, NULL, 0);
}
-static void event_callback(nua_event_t event,
- int status,
- char const *phrase,
- nua_t *nua,
- sofia_profile_t *profile,
+
+
+static void sip_r_register(int status,
+ char const *phrase,
+ nua_t *nua,
+ sofia_profile_t *profile,
nua_handle_t *nh,
- switch_core_session_t *session,
- sip_t const *sip,
- tagi_t tags[])
+ sofia_private_t *sofia_private,
+ sip_t const *sip,
+ tagi_t tags[])
{
+ outbound_reg_t *oreg = NULL;
+ sip_www_authenticate_t const *authenticate = NULL;
+
+ if (sofia_private) {
+ if (sofia_private->oreg) {
+ oreg = sofia_private->oreg;
+ } else if (profile) {
+ /* NOTE
+ this is a linked list, when nua_identity comes
+ we need to actually pick the right one...
+ */
+ oreg = profile->registrations;
+ }
+ }
+
+ if (!oreg) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No authentication available!\n");
+ return;
+ }
+
+ if (sip->sip_www_authenticate) {
+ authenticate = sip->sip_www_authenticate;
+ } else if (sip->sip_proxy_authenticate) {
+ authenticate = sip->sip_proxy_authenticate;
+ }
+
+ if (authenticate) {
+ char const *realm = (char const *) *authenticate->au_params;
+ char const *scheme = (char const *) authenticate->au_scheme;
+ char authentication[256] = "";
+ int ss_state;
+
+ snprintf(authentication, sizeof(authentication), "%s:%s:%s:%s", scheme, strstr(realm, "=") + 1,
+ oreg->register_username,
+ oreg->register_password);
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Authenticating '%s' with '%s'.\n",
+ profile->username, authentication);
+
+
+ ss_state = nua_callstate_authenticating;
+
+ tl_gets(tags,
+ NUTAG_CALLSTATE_REF(ss_state),
+ SIPTAG_WWW_AUTHENTICATE_REF(authenticate),
+ TAG_END());
+
+ nua_authenticate(nh, NUTAG_AUTH(authentication), TAG_END());
+
+ } else if (status == 200) {
+ if (!sofia_private->session) {
+ oreg->state = REG_STATE_REGISTER;
+ }
+ }
+}
+
+static void event_callback(nua_event_t event,
+ int status,
+ char const *phrase,
+ nua_t *nua,
+ sofia_profile_t *profile,
+ nua_handle_t *nh,
+ sofia_private_t *sofia_private,
+ sip_t const *sip,
+ tagi_t tags[])
+{
struct private_object *tech_pvt = NULL;
auth_res_t auth_res = AUTH_FORBIDDEN;
+ switch_core_session_t *session = sofia_private ? sofia_private->session : NULL;
if (session) {
if (switch_core_session_read_lock(session) != SWITCH_STATUS_SUCCESS) {
@@ -2184,107 +2297,104 @@
switch (event) {
case nua_r_shutdown:
- //sip_r_shutdown(status, phrase, nua, profile, nh, session, sip, tags);
+ //sip_r_shutdown(status, phrase, nua, profile, nh, sofia_private, sip, tags);
break;
case nua_r_get_params:
- //sip_r_get_params(status, phrase, nua, profile, nh, session, sip, tags);
+ //sip_r_get_params(status, phrase, nua, profile, nh, sofia_private, sip, tags);
break;
+ case nua_r_invite:
case nua_r_register:
- //sip_r_register(status, phrase, nua, profile, nh, session, sip, tags);
+ sip_r_register(status, phrase, nua, profile, nh, sofia_private, sip, tags);
break;
case nua_r_unregister:
- //sip_r_unregister(status, phrase, nua, profile, nh, session, sip, tags);
+ //sip_r_unregister(status, phrase, nua, profile, nh, sofia_private, sip, tags);
break;
case nua_r_options:
- //sip_r_options(status, phrase, nua, profile, nh, session, sip, tags);
+ //sip_r_options(status, phrase, nua, profile, nh, sofia_private, sip, tags);
break;
- case nua_r_invite:
- //sip_r_invite(status, phrase, nua, profile, nh, session, sip, tags);
- break;
-
case nua_i_fork:
- //sip_i_fork(status, phrase, nua, profile, nh, session, sip, tags);
+ //sip_i_fork(status, phrase, nua, profile, nh, sofia_private, sip, tags);
break;
case nua_i_invite:
- sip_i_invite(nua, profile, nh, session, sip, tags);
+ sip_i_invite(nua, profile, nh, sofia_private, sip, tags);
break;
case nua_i_register:
- sip_i_register (nua, profile, nh, session, sip, tags);
+ sip_i_register (nua, profile, nh, sofia_private, sip, tags);
break;
case nua_i_prack:
- //sip_i_prack(nua, profile, nh, session, sip, tags);
+ //sip_i_prack(nua, profile, nh, sofia_private, sip, tags);
break;
case nua_i_state:
- sip_i_state(status, phrase, nua, profile, nh, session, sip, tags);
+ sip_i_state(status, phrase, nua, profile, nh, sofia_private, sip, tags);
break;
case nua_r_bye:
- //sip_r_bye(status, phrase, nua, profile, nh, session, sip, tags);
+ //sip_r_bye(status, phrase, nua, profile, nh, sofia_private, sip, tags);
break;
case nua_i_bye:
- //sip_i_bye(nua, profile, nh, session, sip, tags);
+ //sip_i_bye(nua, profile, nh, sofia_private, sip, tags);
break;
case nua_r_message:
- //sip_r_message(status, phrase, nua, profile, nh, session, sip, tags);
+ //sip_r_message(status, phrase, nua, profile, nh, sofia_private, sip, tags);
break;
case nua_i_message:
- //sip_i_message(nua, profile, nh, session, sip, tags);
+ //sip_i_message(nua, profile, nh, sofia_private, sip, tags);
break;
case nua_r_info:
- //sip_r_info(status, phrase, nua, profile, nh, session, sip, tags);
+ //sip_r_info(status, phrase, nua, profile, nh, sofia_private, sip, tags);
break;
case nua_i_info:
- //sip_i_info(nua, profile, nh, session, sip, tags);
+ //sip_i_info(nua, profile, nh, sofia_private, sip, tags);
break;
case nua_r_refer:
- //sip_r_refer(status, phrase, nua, profile, nh, session, sip, tags);
+ //sip_r_refer(status, phrase, nua, profile, nh, sofia_private, sip, tags);
break;
case nua_i_refer:
- //sip_i_refer(nua, profile, nh, session, sip, tags);
+ //sip_i_refer(nua, profile, nh, sofia_private, sip, tags);
break;
case nua_r_subscribe:
- //sip_r_subscribe(status, phrase, nua, profile, nh, session, sip, tags);
+ //sip_r_subscribe(status, phrase, nua, profile, nh, sofia_private, sip, tags);
break;
case nua_r_unsubscribe:
- //sip_r_unsubscribe(status, phrase, nua, profile, nh, session, sip, tags);
+ //sip_r_unsubscribe(status, phrase, nua, profile, nh, sofia_private, sip, tags);
break;
case nua_r_publish:
- //sip_r_publish(status, phrase, nua, profile, nh, session, sip, tags);
+ //sip_r_publish(status, phrase, nua, profile, nh, sofia_private, sip, tags);
break;
case nua_r_notify:
- //sip_r_notify(status, phrase, nua, profile, nh, session, sip, tags);
+ //sip_r_notify(status, phrase, nua, profile, nh, sofia_private, sip, tags);
break;
case nua_i_notify:
- //sip_i_notify(nua, profile, nh, session, sip, tags);
+ //sip_i_notify(nua, profile, nh, sofia_private, sip, tags);
break;
case nua_i_cancel:
- //sip_i_cancel(nua, profile, nh, session, sip, tags);
+ //sip_i_cancel(nua, profile, nh, sofia_private, sip, tags);
break;
case nua_i_error:
- //sip_i_error(nua, profile, nh, session, status, phrase, tags);
+ //sip_i_error(nua, profile, nh, sofia_private, status, phrase, tags);
break;
case nua_i_active:
@@ -2309,15 +2419,67 @@
}
}
-#define REG_SECONDS 30
+static void check_oreg(sofia_profile_t *profile, time_t now)
+{
+ outbound_reg_t *oregp;
+ for (oregp = profile->registrations; oregp; oregp = oregp->next) {
+ int ss_state = nua_callstate_authenticating;
+ reg_state_t ostate = oregp->state;
+
+ switch(ostate) {
+ case REG_STATE_REGISTER:
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "registered %s\n", oregp->name);
+ oregp->expires = now + oregp->freq;
+ oregp->state = REG_STATE_REGED;
+ oregp->retry = 0;
+ break;
+ case REG_STATE_UNREGED:
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "registering %s\n", oregp->name);
+ if ((oregp->nh = nua_handle(oregp->profile->nua, NULL,
+ NUTAG_URL(oregp->register_proxy),
+ SIPTAG_TO_STR(oregp->register_to),
+ NUTAG_CALLSTATE_REF(ss_state),
+ SIPTAG_FROM_STR(oregp->register_from), TAG_END()))) {
+
+ oregp->sofia_private.oreg = oregp;
+ nua_handle_bind(oregp->nh, &oregp->sofia_private);
+ nua_register(oregp->nh,
+ SIPTAG_FROM_STR(oregp->register_from),
+ SIPTAG_CONTACT_STR(oregp->register_from),
+ SIPTAG_EXPIRES_STR(oregp->expires_str),
+ NUTAG_REGISTRAR(oregp->register_proxy),
+ TAG_NULL());
+ oregp->state = REG_STATE_TRYING;
+ oregp->retry = now + 10;
+ }
+ break;
+ default:
+ if (oregp->retry && now >= oregp->retry) {
+ oregp->state = REG_STATE_UNREGED;
+ oregp->retry = 0;
+ }
+ if (oregp->expires && now >= oregp->expires) {
+ oregp->state = REG_STATE_UNREGED;
+ oregp->expires = 0;
+ }
+ break;
+ }
+ }
+
+}
+
+#define IREG_SECONDS 30
+#define OREG_SECONDS 1
static void *SWITCH_THREAD_FUNC profile_thread_run(switch_thread_t *thread, void *obj)
{
sofia_profile_t *profile = (sofia_profile_t *) obj;
switch_memory_pool_t *pool;
sip_alias_node_t *node;
- uint32_t loops = 0;
+ uint32_t ireg_loops = 0;
+ uint32_t oreg_loops = 0;
switch_core_db_t *db;
+
profile->s_root = su_root_create(NULL);
profile->nua = nua_create(profile->s_root, /* Event loop */
event_callback, /* Callback for processing events */
@@ -2363,20 +2525,27 @@
}
switch_core_db_close(db);
- switch_mutex_init(&profile->reg_mutex, SWITCH_MUTEX_NESTED, profile->pool);
+ switch_mutex_init(&profile->ireg_mutex, SWITCH_MUTEX_NESTED, profile->pool);
+ switch_mutex_init(&profile->oreg_mutex, SWITCH_MUTEX_NESTED, profile->pool);
switch_mutex_lock(globals.mutex);
globals.running = 1;
switch_mutex_unlock(globals.mutex);
- loops = REG_SECONDS;
+ ireg_loops = IREG_SECONDS;
+ oreg_loops = OREG_SECONDS;
while(globals.running == 1) {
- if (++loops >= REG_SECONDS) {
+ if (++ireg_loops >= IREG_SECONDS) {
check_expire(profile, time(NULL));
- loops = 0;
+ ireg_loops = 0;
}
+ if (++oreg_loops >= OREG_SECONDS) {
+ check_oreg(profile, time(NULL));
+ oreg_loops = 0;
+ }
+
su_root_step(profile->s_root, 1000);
//su_root_run(profile->s_root);
}
@@ -2411,8 +2580,10 @@
static switch_status_t config_sofia(int reload)
{
char *cf = "sofia.conf";
- switch_xml_t cfg, xml = NULL, xprofile, param;
+ switch_xml_t cfg, xml = NULL, xprofile, param, settings, profiles, registration, registrations;
switch_status_t status = SWITCH_STATUS_SUCCESS;
+ sofia_profile_t *profile = NULL;
+ char url[512] = "";
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
@@ -2420,150 +2591,233 @@
goto done;
}
- for (xprofile = switch_xml_child(cfg, "profile"); xprofile; xprofile = xprofile->next) {
- char *xprofilename = (char *) switch_xml_attr_soft(xprofile, "name");
- sofia_profile_t *profile;
- switch_memory_pool_t *pool = NULL;
- char url[512] = "";
+ if ((profiles = switch_xml_child(cfg, "profiles"))) {
+ for (xprofile = switch_xml_child(profiles, "profile"); xprofile; xprofile = xprofile->next) {
+ if (!(settings = switch_xml_child(xprofile, "settings"))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Settings, check the new config!\n", cf);
+ } else {
+ char *xprofilename = (char *) switch_xml_attr_soft(xprofile, "name");
+ switch_memory_pool_t *pool = NULL;
- /* Setup the pool */
- if ((status = switch_core_new_memory_pool(&pool)) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
- goto done;
- }
+
+ /* Setup the pool */
+ if ((status = switch_core_new_memory_pool(&pool)) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
+ goto done;
+ }
- if (!(profile = (sofia_profile_t *) switch_core_alloc(pool, sizeof(*profile)))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
- goto done;
- }
+ if (!(profile = (sofia_profile_t *) switch_core_alloc(pool, sizeof(*profile)))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
+ goto done;
+ }
- if (!xprofilename) {
- xprofilename = "unnamed";
- }
+ if (!xprofilename) {
+ xprofilename = "unnamed";
+ }
- profile->pool = pool;
+ profile->pool = pool;
- profile->name = switch_core_strdup(profile->pool, xprofilename);
- snprintf(url, sizeof(url), "sofia_reg_%s", xprofilename);
- profile->dbname = switch_core_strdup(profile->pool, url);
+ profile->name = switch_core_strdup(profile->pool, xprofilename);
+ snprintf(url, sizeof(url), "sofia_reg_%s", xprofilename);
+ profile->dbname = switch_core_strdup(profile->pool, url);
- profile->dtmf_duration = 100;
- profile->codec_ms = 20;
+ profile->dtmf_duration = 100;
+ profile->codec_ms = 20;
- for (param = switch_xml_child(xprofile, "param"); param; param = param->next) {
- char *var = (char *) switch_xml_attr_soft(param, "name");
- char *val = (char *) switch_xml_attr_soft(param, "value");
+ for (param = switch_xml_child(settings, "param"); param; param = param->next) {
+ char *var = (char *) switch_xml_attr_soft(param, "name");
+ char *val = (char *) switch_xml_attr_soft(param, "value");
- if (!strcasecmp(var, "debug")) {
- profile->debug = atoi(val);
- } else if (!strcasecmp(var, "use-rtp-timer") && switch_true(val)) {
- switch_set_flag(profile, TFLAG_TIMER);
- } else if (!strcasecmp(var, "rfc2833-pt")) {
- profile->te = (switch_payload_t) atoi(val);
- } else if (!strcasecmp(var, "sip-port")) {
- profile->sip_port = atoi(val);
- } else if (!strcasecmp(var, "vad")) {
- if (!strcasecmp(val, "in")) {
- switch_set_flag(profile, TFLAG_VAD_IN);
- } else if (!strcasecmp(val, "out")) {
- switch_set_flag(profile, TFLAG_VAD_OUT);
- } else if (!strcasecmp(val, "both")) {
- switch_set_flag(profile, TFLAG_VAD_IN);
- switch_set_flag(profile, TFLAG_VAD_OUT);
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invald option %s for VAD\n", val);
+ if (!strcasecmp(var, "debug")) {
+ profile->debug = atoi(val);
+ } else if (!strcasecmp(var, "use-rtp-timer") && switch_true(val)) {
+ switch_set_flag(profile, TFLAG_TIMER);
+ } else if (!strcasecmp(var, "rfc2833-pt")) {
+ profile->te = (switch_payload_t) atoi(val);
+ } else if (!strcasecmp(var, "sip-port")) {
+ profile->sip_port = atoi(val);
+ } else if (!strcasecmp(var, "vad")) {
+ if (!strcasecmp(val, "in")) {
+ switch_set_flag(profile, TFLAG_VAD_IN);
+ } else if (!strcasecmp(val, "out")) {
+ switch_set_flag(profile, TFLAG_VAD_OUT);
+ } else if (!strcasecmp(val, "both")) {
+ switch_set_flag(profile, TFLAG_VAD_IN);
+ switch_set_flag(profile, TFLAG_VAD_OUT);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invald option %s for VAD\n", val);
+ }
+ } else if (!strcasecmp(var, "ext-rtp-ip")) {
+ profile->extrtpip = switch_core_strdup(profile->pool, val);
+ } else if (!strcasecmp(var, "rtp-ip")) {
+ profile->rtpip = switch_core_strdup(profile->pool, val);
+ } else if (!strcasecmp(var, "sip-ip")) {
+ profile->sipip = switch_core_strdup(profile->pool, val);
+ } else if (!strcasecmp(var, "sip-domain")) {
+ profile->sipdomain = switch_core_strdup(profile->pool, val);
+ } else if (!strcasecmp(var, "rtp-timer-name")) {
+ profile->timer_name = switch_core_strdup(profile->pool, val);
+ } else if (!strcasecmp(var, "auth-calls")) {
+ if (switch_true(val)) {
+ profile->pflags |= PFLAG_AUTH_CALLS;
+ }
+ } else if (!strcasecmp(var, "accept-blind-reg")) {
+ if (switch_true(val)) {
+ profile->pflags |= PFLAG_BLIND_REG;
+ }
+ } else if (!strcasecmp(var, "auth-all-packets")) {
+ if (switch_true(val)) {
+ profile->pflags |= PFLAG_AUTH_ALL;
+ }
+ } else if (!strcasecmp(var, "ext-sip-ip")) {
+ profile->extsipip = switch_core_strdup(profile->pool, val);
+ } else if (!strcasecmp(var, "bitpacking")) {
+ if (!strcasecmp(val, "aal2")) {
+ profile->codec_flags = SWITCH_CODEC_FLAG_AAL2;
+ }
+ } else if (!strcasecmp(var, "username")) {
+ profile->username = switch_core_strdup(profile->pool, val);
+ } else if (!strcasecmp(var, "context")) {
+ profile->context = switch_core_strdup(profile->pool, val);
+ } else if (!strcasecmp(var, "alias")) {
+ sip_alias_node_t *node;
+ if ((node = switch_core_alloc(profile->pool, sizeof(*node)))) {
+ if ((node->url = switch_core_strdup(profile->pool, val))) {
+ node->next = profile->aliases;
+ profile->aliases = node;
+ }
+ }
+ } else if (!strcasecmp(var, "dialplan")) {
+ profile->dialplan = switch_core_strdup(profile->pool, val);
+ } else if (!strcasecmp(var, "max-calls")) {
+ profile->max_calls = atoi(val);
+ } else if (!strcasecmp(var, "codec-prefs")) {
+ profile->codec_string = switch_core_strdup(profile->pool, val);
+ profile->codec_order_last = switch_separate_string(profile->codec_string, ',', profile->codec_order, SWITCH_MAX_CODECS);
+ } else if (!strcasecmp(var, "codec-ms")) {
+ profile->codec_ms = atoi(val);
+ } else if (!strcasecmp(var, "dtmf-duration")) {
+ int dur = atoi(val);
+ if (dur > 10 && dur < 8000) {
+ profile->dtmf_duration = dur;
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Duration out of bounds!\n");
+ }
+ }
}
- } else if (!strcasecmp(var, "ext-rtp-ip")) {
- profile->extrtpip = switch_core_strdup(profile->pool, val);
- } else if (!strcasecmp(var, "rtp-ip")) {
- profile->rtpip = switch_core_strdup(profile->pool, val);
- } else if (!strcasecmp(var, "sip-ip")) {
- profile->sipip = switch_core_strdup(profile->pool, val);
- } else if (!strcasecmp(var, "sip-domain")) {
- profile->sipdomain = switch_core_strdup(profile->pool, val);
- } else if (!strcasecmp(var, "rtp-timer-name")) {
- profile->timer_name = switch_core_strdup(profile->pool, val);
- } else if (!strcasecmp(var, "auth-calls")) {
- if (switch_true(val)) {
- profile->pflags |= PFLAG_AUTH_CALLS;
+
+ if (switch_test_flag(profile, TFLAG_TIMER) && !profile->timer_name) {
+ profile->timer_name = switch_core_strdup(profile->pool, "soft");
}
- } else if (!strcasecmp(var, "accept-blind-reg")) {
- if (switch_true(val)) {
- profile->pflags |= PFLAG_BLIND_REG;
+
+ if (!profile->username) {
+ profile->username = switch_core_strdup(profile->pool, "FreeSWITCH");
}
- } else if (!strcasecmp(var, "auth-all-packets")) {
- if (switch_true(val)) {
- profile->pflags |= PFLAG_AUTH_ALL;
+
+ if (!profile->rtpip) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Setting ip to '127.0.0.1'\n");
+ profile->rtpip = switch_core_strdup(profile->pool, "127.0.0.1");
}
- } else if (!strcasecmp(var, "ext-sip-ip")) {
- profile->extsipip = switch_core_strdup(profile->pool, val);
- } else if (!strcasecmp(var, "bitpacking")) {
- if (!strcasecmp(val, "aal2")) {
- profile->codec_flags = SWITCH_CODEC_FLAG_AAL2;
- }
- } else if (!strcasecmp(var, "username")) {
- profile->username = switch_core_strdup(profile->pool, val);
- } else if (!strcasecmp(var, "context")) {
- profile->context = switch_core_strdup(profile->pool, val);
- } else if (!strcasecmp(var, "alias")) {
- sip_alias_node_t *node;
- if ((node = switch_core_alloc(profile->pool, sizeof(*node)))) {
- if ((node->url = switch_core_strdup(profile->pool, val))) {
- node->next = profile->aliases;
- profile->aliases = node;
- }
+
+ if (!profile->sip_port) {
+ profile->sip_port = 5060;
}
- } else if (!strcasecmp(var, "dialplan")) {
- profile->dialplan = switch_core_strdup(profile->pool, val);
- } else if (!strcasecmp(var, "max-calls")) {
- profile->max_calls = atoi(val);
- } else if (!strcasecmp(var, "codec-prefs")) {
- profile->codec_string = switch_core_strdup(profile->pool, val);
- profile->codec_order_last = switch_separate_string(profile->codec_string, ',', profile->codec_order, SWITCH_MAX_CODECS);
- } else if (!strcasecmp(var, "codec-ms")) {
- profile->codec_ms = atoi(val);
- } else if (!strcasecmp(var, "dtmf-duration")) {
- int dur = atoi(val);
- if (dur > 10 && dur < 8000) {
- profile->dtmf_duration = dur;
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Duration out of bounds!\n");
+
+ if (!profile->dialplan) {
+ profile->dialplan = switch_core_strdup(profile->pool, "default");
}
- }
- }
- if (switch_test_flag(profile, TFLAG_TIMER) && !profile->timer_name) {
- profile->timer_name = switch_core_strdup(profile->pool, "soft");
- }
+ if (!profile->sipdomain) {
+ profile->sipdomain = switch_core_strdup(profile->pool, profile->sipip);
+ }
- if (!profile->username) {
- profile->username = switch_core_strdup(profile->pool, "FreeSWITCH");
- }
+ snprintf(url, sizeof(url), "sip:%s:%d", profile->sipip, profile->sip_port);
+ profile->url = switch_core_strdup(profile->pool, url);
+ }
+ if (profile) {
+ if ((registrations = switch_xml_child(xprofile, "registrations"))) {
+ uint32_t reg_count = 0;
+ for (registration = switch_xml_child(registrations, "registration"); registration; registration = registration->next) {
+ char *name = (char *) switch_xml_attr_soft(registration, "name");
+ outbound_reg_t *oreg;
- if (!profile->rtpip) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Setting ip to '127.0.0.1'\n");
- profile->rtpip = switch_core_strdup(profile->pool, "127.0.0.1");
- }
+ if (++reg_count > 1) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+ "Sorry, only one registration per profile for now =(:::, ask the sofia team for NUTAG_IDENTITY!!!!\n");
+ }
+ if (switch_strlen_zero(name)) {
+ name = "anonymous";
+ }
- if (!profile->sip_port) {
- profile->sip_port = 5060;
- }
+ if ((oreg = switch_core_alloc(profile->pool, sizeof(*oreg)))) {
+ oreg->pool = profile->pool;
+ oreg->profile = profile;
+ oreg->name = switch_core_strdup(oreg->pool, name);
+ oreg->freq = 60;
- if (!profile->dialplan) {
- profile->dialplan = switch_core_strdup(profile->pool, "default");
- }
+ for (param = switch_xml_child(registration, "param"); param; param = param->next) {
+ char *var = (char *) switch_xml_attr_soft(param, "name");
+ char *val = (char *) switch_xml_attr_soft(param, "value");
+
+ if (!strcmp(var, "register-scheme")) {
+ oreg->register_scheme = switch_core_strdup(oreg->pool, val);
+ } else if (!strcmp(var, "register-realm")) {
+ oreg->register_realm = switch_core_strdup(oreg->pool, val);
+ } else if (!strcmp(var, "register-username")) {
+ oreg->register_username = switch_core_strdup(oreg->pool, val);
+ } else if (!strcmp(var, "register-password")) {
+ oreg->register_password = switch_core_strdup(oreg->pool, val);
+ } else if (!strcmp(var, "register-from")) {
+ oreg->register_from = switch_core_strdup(oreg->pool, val);
+ } else if (!strcmp(var, "register-to")) {
+ oreg->register_to = switch_core_strdup(oreg->pool, val);
+ } else if (!strcmp(var, "register-proxy")) {
+ oreg->register_proxy = switch_core_strdup(oreg->pool, val);
+ } else if (!strcmp(var, "register-frequency")) {
+ oreg->expires_str = switch_core_strdup(oreg->pool, val);
+ oreg->freq = atoi(val);
+ }
+ }
+ if (switch_strlen_zero(oreg->register_scheme)) {
+ oreg->register_scheme = switch_core_strdup(oreg->pool, "Digest");
+ }
+ if (switch_strlen_zero(oreg->register_realm)) {
+ oreg->register_realm = switch_core_strdup(oreg->pool, "freeswitch.org");
+ }
+ if (switch_strlen_zero(oreg->register_username)) {
+ oreg->register_username = switch_core_strdup(oreg->pool, "freeswitch");
+ }
+ if (switch_strlen_zero(oreg->register_password)) {
+ oreg->register_password = switch_core_strdup(oreg->pool, "works");
+ }
+ if (switch_strlen_zero(oreg->register_from)) {
+ oreg->register_from = switch_core_strdup(oreg->pool, "FreeSWITCH <sip:freeswitch at freeswitch.org>");
+ }
+ if (switch_strlen_zero(oreg->register_to)) {
+ oreg->register_to = switch_core_strdup(oreg->pool, "sip:freeswitch at freeswitch.org");
+ }
+ if (switch_strlen_zero(oreg->register_proxy)) {
+ oreg->register_proxy = switch_core_strdup(oreg->pool, "sip:freeswitch at freeswitch.org");
+ }
- if (!profile->sipdomain) {
- profile->sipdomain = switch_core_strdup(profile->pool, profile->sipip);
- }
+ if (switch_strlen_zero(oreg->expires_str)) {
+ oreg->expires_str = switch_core_strdup(oreg->pool, "300");
+ }
- snprintf(url, sizeof(url), "sip:%s:%d", profile->sipip, profile->sip_port);
- profile->url = switch_core_strdup(profile->pool, url);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Started Profile %s [%s]\n", profile->name, url);
- launch_profile_thread(profile);
+ oreg->freq = atoi(oreg->expires_str);
+ oreg->next = profile->registrations;
+ profile->registrations = oreg;
+ }
+ }
+ }
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Started Profile %s [%s]\n", profile->name, url);
+ launch_profile_thread(profile);
+ profile = NULL;
+ }
+ }
}
-
done:
if (xml) {
switch_xml_free(xml);
@@ -2612,7 +2866,7 @@
}
if (sql) {
- execute_sql(profile->dbname, sql, profile->reg_mutex);
+ execute_sql(profile->dbname, sql, profile->ireg_mutex);
switch_core_db_free(sql);
sql = NULL;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Propagating registration for %s@%s->%s@%s\n",
More information about the Freeswitch-svn
mailing list