break everything in sofia as you know it but add in/out reg + auth, look in the default config for the new syntax

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2875 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2006-09-30 00:00:07 +00:00
parent 82d7918546
commit 8d716e6ab9
2 changed files with 830 additions and 560 deletions

View File

@ -3,491 +3,507 @@
<section name="configuration" description="Various Configuration"> <section name="configuration" description="Various Configuration">
<configuration name="switch.conf" description="Modules"> <configuration name="switch.conf" description="Modules">
<settings> <settings>
<!--Most channels to allow at once --> <!--Most channels to allow at once -->
<param name="max-sessions" value="1000"/> <param name="max-sessions" value="1000"/>
</settings> </settings>
</configuration> </configuration>
<configuration name="modules.conf" description="Modules"> <configuration name="modules.conf" description="Modules">
<modules> <modules>
<!-- Loggers (I'd load these first) --> <!-- Loggers (I'd load these first) -->
<load module="mod_console"/> <load module="mod_console"/>
<!-- <load module="mod_syslog"/> --> <!-- <load module="mod_syslog"/> -->
<!-- XML Interfaces --> <!-- XML Interfaces -->
<!-- <load module="mod_xml_rpc"/> --> <!-- <load module="mod_xml_rpc"/> -->
<!-- Event Handlers --> <!-- Event Handlers -->
<!-- <load module="mod_event_multicast"/> --> <!-- <load module="mod_event_multicast"/> -->
<!-- <load module="mod_event_test"/> --> <!-- <load module="mod_event_test"/> -->
<!-- <load module="mod_zeroconf"/> --> <!-- <load module="mod_zeroconf"/> -->
<!-- <load module="mod_xmpp_event"/> --> <!-- <load module="mod_xmpp_event"/> -->
<!-- <load module="mod_event_socket"/> --> <!-- <load module="mod_event_socket"/> -->
<!-- Directory Interfaces --> <!-- Directory Interfaces -->
<!-- <load module="mod_ldap"/> --> <!-- <load module="mod_ldap"/> -->
<!-- Endpoints --> <!-- Endpoints -->
<load module="mod_exosip"/> <load module="mod_exosip"/>
<!--<load module="mod_iax"/>--> <!--<load module="mod_iax"/>-->
<load module="mod_portaudio"/> <load module="mod_portaudio"/>
<!-- <load module="mod_woomera"/> --> <!-- <load module="mod_woomera"/> -->
<!-- <load module="mod_wanpipe"/> --> <!-- <load module="mod_wanpipe"/> -->
<!-- <load module="mod_dingaling"/> --> <!-- <load module="mod_dingaling"/> -->
<!-- Applications --> <!-- Applications -->
<load module="mod_bridgecall"/> <load module="mod_bridgecall"/>
<load module="mod_echo"/> <load module="mod_echo"/>
<load module="mod_dptools"/> <load module="mod_dptools"/>
<!-- <load module="mod_ivrtest"/> --> <!-- <load module="mod_ivrtest"/> -->
<load module="mod_playback"/> <load module="mod_playback"/>
<load module="mod_commands"/> <load module="mod_commands"/>
<!-- <load module="mod_commands"/> --> <!-- <load module="mod_commands"/> -->
<!-- Dialplan Interfaces --> <!-- Dialplan Interfaces -->
<load module="mod_dialplan_xml"/> <load module="mod_dialplan_xml"/>
<!-- <load module="mod_dialplan_directory"/> --> <!-- <load module="mod_dialplan_directory"/> -->
<!-- Codec Interfaces --> <!-- Codec Interfaces -->
<load module="mod_g711"/> <load module="mod_g711"/>
<load module="mod_gsm"/> <load module="mod_gsm"/>
<load module="mod_l16"/> <load module="mod_l16"/>
<!-- <load module="mod_speex"/> --> <!-- <load module="mod_speex"/> -->
<!-- <load module="mod_ilbc"/> --> <!-- <load module="mod_ilbc"/> -->
<!-- File Format Interfaces --> <!-- File Format Interfaces -->
<load module="mod_sndfile"/> <load module="mod_sndfile"/>
<!-- Timers --> <!-- Timers -->
<load module="mod_softtimer"/> <load module="mod_softtimer"/>
<!-- Languages --> <!-- Languages -->
<!-- <load module="mod_spidermonkey"/> --> <!-- <load module="mod_spidermonkey"/> -->
<!-- <load module="mod_perl"/> --> <!-- <load module="mod_perl"/> -->
<!-- ASR /TTS --> <!-- ASR /TTS -->
<!-- <load module="mod_cepstral"/> --> <!-- <load module="mod_cepstral"/> -->
<!-- <load module="mod_rss"/> --> <!-- <load module="mod_rss"/> -->
<!-- Conference Bridges --> <!-- Conference Bridges -->
<!--<load module="mod_conference"/>--> <!--<load module="mod_conference"/>-->
</modules> </modules>
</configuration> </configuration>
<configuration name="event_multicast.conf" description="Multicast Event"> <configuration name="event_multicast.conf" description="Multicast Event">
<settings> <settings>
<param name="address" value="225.1.1.1"/> <param name="address" value="225.1.1.1"/>
<param name="port" value="4242"/> <param name="port" value="4242"/>
<param name="bindings" value="all"/> <param name="bindings" value="all"/>
</settings> </settings>
</configuration> </configuration>
<configuration name="event_socket.conf" description="Socket Client"> <configuration name="event_socket.conf" description="Socket Client">
<settings> <settings>
<param name="listen-ip" value="127.0.0.1"/> <param name="listen-ip" value="127.0.0.1"/>
<param name="listen-port" value="8021"/> <param name="listen-port" value="8021"/>
<param name="password" value="ClueCon"/> <param name="password" value="ClueCon"/>
</settings> </settings>
</configuration> </configuration>
<configuration name="iax.conf" description="IAX Configuration"> <configuration name="iax.conf" description="IAX Configuration">
<settings> <settings>
<param name="debug" value="0"/> <param name="debug" value="0"/>
<!-- <param name="ip" value="1.2.3.4"> --> <!-- <param name="ip" value="1.2.3.4"> -->
<param name="port" value="4569"/> <param name="port" value="4569"/>
<param name="dialplan" value="XML"/> <param name="dialplan" value="XML"/>
<param name="codec-prefs" value="PCMU@20i,PCMA,speex,L16"/> <param name="codec-prefs" value="PCMU@20i,PCMA,speex,L16"/>
<param name="codec-master" value="us"/> <param name="codec-master" value="us"/>
<param name="codec-rates" value="8"/> <param name="codec-rates" value="8"/>
</settings> </settings>
</configuration> </configuration>
<configuration name="console.conf" description="Console Logger"> <configuration name="console.conf" description="Console Logger">
<!-- pick a file name, a function name or 'all' --> <!-- pick a file name, a function name or 'all' -->
<!-- map as many as you need for specific debugging --> <!-- map as many as you need for specific debugging -->
<mappings> <mappings>
<!-- <param name="log_event" value="DEBUG"/> --> <!-- <param name="log_event" value="DEBUG"/> -->
<param name="all" value="DEBUG"/> <param name="all" value="DEBUG"/>
</mappings> </mappings>
</configuration> </configuration>
<configuration name="sofia.conf" description="sofia Endpoint"> <configuration name="sofia.conf" description="sofia Endpoint">
<profile name="test"> <profiles>
<param name="debug" value="1"/> <profile name="test">
<param name="rfc2833-pt" value="101"/> <registrations>
<param name="sip-port" value="5060"/> <registration name="asterlink">
<param name="dialplan" value="XML"/> <param name="register-scheme" value="Digest"/>
<param name="dtmf-duration" value="100"/> <param name="register-realm" value=""/>
<param name="codec-prefs" value="PCMU@20i"/> <param name="register-username" value="1001"/>
<param name="codec-ms" value="20"/> <param name="register-password" value="nhy65tgb"/>
<param name="use-rtp-timer" value="true"/> <param name="register-from" value="sip:1001@208.64.200.40"/>
<param name="rtp-timer-name" value="soft"/> <param name="register-to" value="sip:1001@66.250.68.194"/>
<param name="rtp-ip" value="192.168.1.20"/> <param name="register-proxy" value="sip:66.250.68.194:5060"/>
<param name="sip-ip" value="192.168.1.20"/> <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@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 --> <!-- this lets anything register -->
<!-- comment the next line and uncomment one or both of the other 2 lines for call authentication --> <!-- 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="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"/>--> <!-- optional ; -->
<!-- on authed calls, authenticate *all* the packets not just invite ---> <!-- <param name="ext-rtp-ip" value="stun:stun.server.com"/>-->
<!--<param name="auth-all-packets" value="true"/>--> <!-- <param name="ext-rtp-ip" value="100.101.102.103"/> -->
<!-- VAD choose one (out is a good choice); -->
<!-- optional ; --> <!-- <param name="vad" value="in"/> -->
<!-- <param name="ext-rtp-ip" value="stun:stun.server.com"/>--> <!-- <param name="vad" value="out"/> -->
<!-- <param name="ext-rtp-ip" value="100.101.102.103"/> --> <!-- <param name="vad" value="both"/> -->
<!-- VAD choose one (out is a good choice); --> <!--<param name="alias" value="sip:10.0.1.251:5555"/>-->
<!-- <param name="vad" value="in"/> --> </settings>
<!-- <param name="vad" value="out"/> --> </profile>
<!-- <param name="vad" value="both"/> --> </profiles>
<!--<param name="alias" value="sip:10.0.1.251:5555"/>-->
</profile>
</configuration> </configuration>
<configuration name="syslog.conf" description="Syslog Logger"> <configuration name="syslog.conf" description="Syslog Logger">
<!-- SYSLOG --> <!-- SYSLOG -->
<!-- emerg - system is unusable --> <!-- emerg - system is unusable -->
<!-- alert - action must be taken immediately --> <!-- alert - action must be taken immediately -->
<!-- crit - critical conditions --> <!-- crit - critical conditions -->
<!-- err - error conditions --> <!-- err - error conditions -->
<!-- warning - warning conditions --> <!-- warning - warning conditions -->
<!-- notice - normal, but significant, condition --> <!-- notice - normal, but significant, condition -->
<!-- info - informational message --> <!-- info - informational message -->
<!-- debug - debug-level message --> <!-- debug - debug-level message -->
<settings> <settings>
<param name="ident" value="freeswitch"/> <param name="ident" value="freeswitch"/>
<param name="facility" value="user"/> <param name="facility" value="user"/>
<param name="format" value="${time} - ${message}"/> <param name="format" value="${time} - ${message}"/>
<param name="level" value="debug,info,warning-alert"/> <param name="level" value="debug,info,warning-alert"/>
</settings> </settings>
</configuration> </configuration>
<configuration name="exosip.conf" description="Exosip Endpoint"> <configuration name="exosip.conf" description="Exosip Endpoint">
<settings> <settings>
<param name="port" value="5060"/> <param name="port" value="5060"/>
<param name="dialplan" value="XML"/> <param name="dialplan" value="XML"/>
<param name="dtmf-duration" value="100"/> <param name="dtmf-duration" value="100"/>
<!-- the @20 is optional number of ms you want to use. Use it only <!-- the @20 is optional number of ms you want to use. Use it only
if you know the codec supports it --> if you know the codec supports it -->
<param name="codec-prefs" value="PCMU@20i,PCMA@20i"/> <param name="codec-prefs" value="PCMU@20i,PCMA@20i"/>
<!-- Example to call for speex in wideband 16k mode <!-- Example to call for speex in wideband 16k mode
you can have up to 2 '@; after the codec name followed by either 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)--> 'i' (interval eg 20i for 20ms) or 'k' (kilohertz eg 16000k for 16khz)-->
<!--<param name="codec-prefs" value="SPEEX@16000k"/>--> <!--<param name="codec-prefs" value="SPEEX@16000k"/>-->
<!-- Payload number to bind DTMF to--> <!-- Payload number to bind DTMF to-->
<param name="rfc2833-pt" value="101"/> <param name="rfc2833-pt" value="101"/>
<!-- disable to trade async for more calls --> <!-- disable to trade async for more calls -->
<param name="use-rtp-timer" value="true"/> <param name="use-rtp-timer" value="true"/>
<!-- auto sense NAT issues and adjust accordingly --> <!-- auto sense NAT issues and adjust accordingly -->
<param name="use-rtp-auto-adjust" value="true"/> <param name="use-rtp-auto-adjust" value="true"/>
<!-- pick one (default if not specified is 'guess'); --> <!-- pick one (default if not specified is 'guess'); -->
<param name="rtp-ip" value="guess"/> <param name="rtp-ip" value="guess"/>
<!-- <param name-"rtp-ip" value="10.0.0.1"/> --> <!-- <param name-"rtp-ip" value="10.0.0.1"/> -->
<!-- leave commented or 0.0.0.0 for all ip --> <!-- leave commented or 0.0.0.0 for all ip -->
<!-- <param name="sip-ip" value="127.0.0.1"/> --> <!-- <param name="sip-ip" value="127.0.0.1"/> -->
<!-- optional ; --> <!-- optional ; -->
<!-- <param name="ext-rtp-ip" value="stun:stun.server.com"/> --> <!-- <param name="ext-rtp-ip" value="stun:stun.server.com"/> -->
<!-- <param name="ext-rtp-ip" value="100.101.102.103"/> --> <!-- <param name="ext-rtp-ip" value="100.101.102.103"/> -->
<!-- specify 'myrealm' with certian key --> <!-- specify 'myrealm' with certian key -->
<!-- use !myrealm! at beginning of url to activate --> <!-- use !myrealm! at beginning of url to activate -->
<!-- exosip/!myrealm!1000@dest --> <!-- exosip/!myrealm!1000@dest -->
<!-- srtp:<param name="myrealm" value="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"/> --> <!-- srtp:<param name="myrealm" value="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"/> -->
<!-- VAD choose one (out is a good choice); --> <!-- VAD choose one (out is a good choice); -->
<!-- <param name="vad" value="in"/> --> <!-- <param name="vad" value="in"/> -->
<!-- <param name="vad" value="out"/> --> <!-- <param name="vad" value="out"/> -->
<!-- <param name="vad" value="both"/> --> <!-- <param name="vad" value="both"/> -->
</settings> </settings>
</configuration> </configuration>
<configuration name="woomera.conf" description="Woomera Endpoint"> <configuration name="woomera.conf" description="Woomera Endpoint">
<settings> <settings>
<param name="debug" value="0"/> <param name="debug" value="0"/>
</settings> </settings>
<interface> <interface>
<param name="host" value="localhost"/> <param name="host" value="localhost"/>
<param name="port" value="42420"/> <param name="port" value="42420"/>
<param name="audio-ip" value="127.0.0.1"/> <param name="audio-ip" value="127.0.0.1"/>
<param name="dialplan" value="XML"/> <param name="dialplan" value="XML"/>
</interface> </interface>
</configuration> </configuration>
<configuration name="wanpipe.conf" description="Sangoma Wanpipe Endpoint"> <configuration name="wanpipe.conf" description="Sangoma Wanpipe Endpoint">
<settings> <settings>
<param name="debug" value="1"/> <param name="debug" value="1"/>
<param name="dialplan" value="XML"/> <param name="dialplan" value="XML"/>
<param name="mtu" value="320"/> <param name="mtu" value="320"/>
<param name="dtmf-on" value="800"/> <param name="dtmf-on" value="800"/>
<param name="dtmf-off" value="100"/> <param name="dtmf-off" value="100"/>
<param name="supress-dtmf-tone" value="yes"/> <param name="supress-dtmf-tone" value="yes"/>
</settings> </settings>
<span> <span>
<param name="span" value="1"/> <param name="span" value="1"/>
<param name="node" value="cpe"/> <param name="node" value="cpe"/>
<!-- <param name="switch" value="ni2"/> --> <!-- <param name="switch" value="ni2"/> -->
<param name="switch" value="dms100"/> <param name="switch" value="dms100"/>
<!-- <param name="switch" value="lucent5e"/> --> <!-- <param name="switch" value="lucent5e"/> -->
<!-- <param name="switch" value="att4ess"/> --> <!-- <param name="switch" value="att4ess"/> -->
<!-- <param name="switch" value="euroisdn"/> --> <!-- <param name="switch" value="euroisdn"/> -->
<!-- <param name="switch" value="gr303eoc"/> --> <!-- <param name="switch" value="gr303eoc"/> -->
<!-- <param name="switch" value="gr303tmc"/> --> <!-- <param name="switch" value="gr303tmc"/> -->
<param name="dp" value="national"/> <param name="dp" value="national"/>
<!-- <param name="dp" value="international"/> --> <!-- <param name="dp" value="international"/> -->
<!-- <param name="dp" value="local"/> --> <!-- <param name="dp" value="local"/> -->
<!-- <param name="dp" value="private"/> --> <!-- <param name="dp" value="private"/> -->
<!-- <param name="dp" value="unknown"/> --> <!-- <param name="dp" value="unknown"/> -->
<param name="l1" value="ulaw"/> <param name="l1" value="ulaw"/>
<!-- <param name="l1" value="alaw"/> --> <!-- <param name="l1" value="alaw"/> -->
<param name="bchan" value="1-23"/> <param name="bchan" value="1-23"/>
<param name="dchan" value="24"/> <param name="dchan" value="24"/>
<param name="dialplan" value="XML"/> <param name="dialplan" value="XML"/>
</span> </span>
</configuration> </configuration>
<configuration name="portaudio.conf" description="Soundcard Endpoint"> <configuration name="portaudio.conf" description="Soundcard Endpoint">
<settings> <settings>
<param name="debug" value="2"/> <param name="debug" value="2"/>
<param name="dialplan" value="XML"/> <param name="dialplan" value="XML"/>
<!-- partial string match on something in the name or the device # --> <!-- partial string match on something in the name or the device # -->
<param name="indev" value="USB"/> <param name="indev" value="USB"/>
<param name="outdev" value="USB"/> <param name="outdev" value="USB"/>
<param name="cid-name" value="FreeSwitch"/> <param name="cid-name" value="FreeSwitch"/>
<param name="cid-num" value="5555551212"/> <param name="cid-num" value="5555551212"/>
</settings> </settings>
</configuration> </configuration>
<configuration name="zeroconf.conf" description="Zeroconf Event Handler"> <configuration name="zeroconf.conf" description="Zeroconf Event Handler">
<settings> <settings>
<param name="publish" value="yes"/> <param name="publish" value="yes"/>
<param name="browse" value="_sip._udp"/> <param name="browse" value="_sip._udp"/>
</settings> </settings>
</configuration> </configuration>
<configuration name="xmpp_event.conf" description="XMPP Event Handler"> <configuration name="xmpp_event.conf" description="XMPP Event Handler">
<settings> <settings>
<param name="#debug" value="1"/> <param name="#debug" value="1"/>
<param name="jid" value="freeswitch@my.jabber.com/me"/> <param name="jid" value="freeswitch@my.jabber.com/me"/>
<param name="passwd" value="mypass"/> <param name="passwd" value="mypass"/>
<param name="target-jid" value="freeswitch@reader.org/him"/> <param name="target-jid" value="freeswitch@reader.org/him"/>
</settings> </settings>
</configuration> </configuration>
<configuration name="dialplan_directory.conf" description="Dialplan Directory"> <configuration name="dialplan_directory.conf" description="Dialplan Directory">
<settings> <settings>
<param name="directory-name" value="ldap"/> <param name="directory-name" value="ldap"/>
<param name="host" value="ldap.freeswitch.org"/> <param name="host" value="ldap.freeswitch.org"/>
<param name="dn" value="cn=Manager,dc=freeswitch,dc=org"/> <param name="dn" value="cn=Manager,dc=freeswitch,dc=org"/>
<param name="pass" value="test"/> <param name="pass" value="test"/>
<param name="base" value="dc=freeswitch,dc=org"/> <param name="base" value="dc=freeswitch,dc=org"/>
</settings> </settings>
</configuration> </configuration>
<configuration name="dingaling.conf" description="XMPP Jingle Endpoint"> <configuration name="dingaling.conf" description="XMPP Jingle Endpoint">
<settings> <settings>
<param name="debug" value="0"/> <param name="debug" value="0"/>
<param name="codec-prefs" value="PCMU"/> <param name="codec-prefs" value="PCMU"/>
</settings> </settings>
<!-- *NOTE* your resource (after the /) MUST contain the string "talk" (upper or lower case is ok) --> <!-- *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"/> --> <!-- *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> <interface>
<param name="name" value="jingle"/> <param name="name" value="jingle"/>
<param name="login" value="myjid@myserver.com/talk"/> <param name="login" value="myjid@myserver.com/talk"/>
<param name="password" value="mypass"/> <param name="password" value="mypass"/>
<param name="dialplan" value="XML"/> <param name="dialplan" value="XML"/>
<param name="message" value="Jingle all the way"/> <param name="message" value="Jingle all the way"/>
<param name="rtp-ip" value="10.0.0.1"/> <param name="rtp-ip" value="10.0.0.1"/>
<param name="auto-login" value="true"/> <param name="auto-login" value="true"/>
<!-- SASL "plain" or "md5" --> <!-- SASL "plain" or "md5" -->
<param name="sasl" value="plain"/> <param name="sasl" value="plain"/>
<!-- if the server where the jabber is hosted is not the same <!-- if the server where the jabber is hosted is not the same
as the one in the jid --> as the one in the jid -->
<!--<param name="server" value="alternate.server.com"/>--> <!--<param name="server" value="alternate.server.com"/>-->
<!-- Enable TLS or not --> <!-- Enable TLS or not -->
<param name="tls" value="true"/> <param name="tls" value="true"/>
<!-- disable to trade async for more calls --> <!-- disable to trade async for more calls -->
<param name="use-rtp-timer" value="true"/> <param name="use-rtp-timer" value="true"/>
<!-- or --> <!-- or -->
<!-- <param name="rtp-ip" value="my_lan_ip"/> --> <!-- <param name="rtp-ip" value="my_lan_ip"/> -->
<!-- <param name="ext-rtp-ip" value="stun:stun.server.com"/> --> <!-- <param name="ext-rtp-ip" value="stun:stun.server.com"/> -->
<!-- default extension (if one cannot be determined) --> <!-- default extension (if one cannot be determined) -->
<param name="exten" value="888"/> <param name="exten" value="888"/>
<!-- VAD choose one --> <!-- VAD choose one -->
<!-- <param name="vad" value="in"/> --> <!-- <param name="vad" value="in"/> -->
<!-- <param name="vad" value="out"/> --> <!-- <param name="vad" value="out"/> -->
<param name="vad" value="both"/> <param name="vad" value="both"/>
</interface> </interface>
</configuration> </configuration>
<configuration name="xml_rpc.conf" description="XML RPC"> <configuration name="xml_rpc.conf" description="XML RPC">
<settings> <settings>
<!-- The port where you want to run the http service (default 8080) --> <!-- The port where you want to run the http service (default 8080) -->
<param name="http-port" value="8080"/> <param name="http-port" value="8080"/>
<!-- if all 3 of the following params exist all http traffic will require auth --> <!-- if all 3 of the following params exist all http traffic will require auth -->
<param name="auth-realm" value="freeswitch"/> <param name="auth-realm" value="freeswitch"/>
<param name="auth-user" value="freeswitch"/> <param name="auth-user" value="freeswitch"/>
<param name="auth-pass" value="works"/> <param name="auth-pass" value="works"/>
<!-- The url to a gateway cgi that can generate xml similar to <!-- 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 what's in this file only on-the-fly (leave it commented if you dont
need it) --> need it) -->
<!-- one or more |-delim of configuration|directory|dialplan --> <!-- one or more |-delim of configuration|directory|dialplan -->
<!-- <param name="gateway-url" value="http://www.server.com/gateway.cgi" bindings="configuration"/> --> <!-- <param name="gateway-url" value="http://www.server.com/gateway.cgi" bindings="configuration"/> -->
</settings> </settings>
</configuration> </configuration>
<configuration name="rss.conf" description="RSS Parser"> <configuration name="rss.conf" description="RSS Parser">
<feeds> <feeds>
<!-- Just download the files to wherever and refer to them here --> <!-- Just download the files to wherever and refer to them here -->
<!-- <feed name="Slash Dot">/home/rss/rss.rss</feed> --> <!-- <feed name="Slash Dot">/home/rss/rss.rss</feed> -->
<!-- <feed name="News Forge">/home/rss/newsforge.rss</feed> --> <!-- <feed name="News Forge">/home/rss/newsforge.rss</feed> -->
</feeds> </feeds>
</configuration> </configuration>
<!-- None of these paths are real if you want any of these options <!-- 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"> <configuration name="conference.conf" description="Audio Conference">
<!-- Profiles are collections of settings you can reference by name. --> <!-- Profiles are collections of settings you can reference by name. -->
<profiles> <profiles>
<profile name="default"> <profile name="default">
<!-- Sample Rate--> <!-- Sample Rate-->
<param name="rate" value="8000"/> <param name="rate" value="8000"/>
<!-- Number of milliseconds per frame --> <!-- Number of milliseconds per frame -->
<param name="interval" value="20"/> <param name="interval" value="20"/>
<!-- Energy level required for audio to be sent to the other users --> <!-- Energy level required for audio to be sent to the other users -->
<param name="energy-level" value="300"/> <param name="energy-level" value="300"/>
<!-- TTS Engine to use --> <!-- TTS Engine to use -->
<!--<param name="tts-engine" value="cepstral"/>--> <!--<param name="tts-engine" value="cepstral"/>-->
<!-- TTS Voice to use --> <!-- TTS Voice to use -->
<!--<param name="tts-voice" value="david"/>--> <!--<param name="tts-voice" value="david"/>-->
<!-- If TTS is enabled all audio-file params not beginning with '/' <!-- If TTS is enabled all audio-file params not beginning with '/'
will be considered text to say with TTS --> will be considered text to say with TTS -->
<!-- File to play to acknowledge succees --> <!-- File to play to acknowledge succees -->
<!--<param name="ack-sound" value="/soundfiles/beep.wav"/>--> <!--<param name="ack-sound" value="/soundfiles/beep.wav"/>-->
<!-- File to play to acknowledge failure --> <!-- File to play to acknowledge failure -->
<!--<param name="nack-sound" value="/soundfiles/beeperr.wav"/>--> <!--<param name="nack-sound" value="/soundfiles/beeperr.wav"/>-->
<!-- File to play to acknowledge muted --> <!-- File to play to acknowledge muted -->
<!--<param name="muted-sound" value="/soundfiles/muted.wav"/>--> <!--<param name="muted-sound" value="/soundfiles/muted.wav"/>-->
<!-- File to play to acknowledge unmuted --> <!-- File to play to acknowledge unmuted -->
<!--<param name="unmuted-sound" value="/soundfiles/unmuted.wav"/>--> <!--<param name="unmuted-sound" value="/soundfiles/unmuted.wav"/>-->
<!-- File to play if you are alone in the conference --> <!-- File to play if you are alone in the conference -->
<!--<param name="alone-sound" value="/soundfiles/yactopitc.wav"/>--> <!--<param name="alone-sound" value="/soundfiles/yactopitc.wav"/>-->
<!-- File to play when you join the conference --> <!-- File to play when you join the conference -->
<!--<param name="enter-sound" value="/soundfiles/welcome.wav"/>--> <!--<param name="enter-sound" value="/soundfiles/welcome.wav"/>-->
<!-- File to play when you leave the conference --> <!-- File to play when you leave the conference -->
<!--<param name="exit-sound" value="/soundfiles/exit.wav"/>--> <!--<param name="exit-sound" value="/soundfiles/exit.wav"/>-->
<!-- File to play when you ae ejected from the conference --> <!-- File to play when you ae ejected from the conference -->
<!--<param name="kicked-sound" value="/soundfiles/kicked.wav"/>--> <!--<param name="kicked-sound" value="/soundfiles/kicked.wav"/>-->
<!-- File to play when the conference is locked --> <!-- File to play when the conference is locked -->
<!--<param name="locked-sound" value="/soundfiles/locked.wav"/>--> <!--<param name="locked-sound" value="/soundfiles/locked.wav"/>-->
<!-- File to play to prompt for a pin --> <!-- File to play to prompt for a pin -->
<!--<param name="pin-sound" value="/soundfiles/pin.wav"/>--> <!--<param name="pin-sound" value="/soundfiles/pin.wav"/>-->
<!-- File to play to when the pin is invalid --> <!-- File to play to when the pin is invalid -->
<!--<param name="bad-pin-sound" value="/soundfiles/invalid-pin.wav"/>--> <!--<param name="bad-pin-sound" value="/soundfiles/invalid-pin.wav"/>-->
<!-- Conference pin --> <!-- Conference pin -->
<!--<param name="pin" value="12345"/>--> <!--<param name="pin" value="12345"/>-->
<!-- Default Caller ID Name for outbound calls --> <!-- Default Caller ID Name for outbound calls -->
<param name="caller-id-name" value="FreeSWITCH"/> <param name="caller-id-name" value="FreeSWITCH"/>
<!-- Default Caller ID Number for outbound calls --> <!-- Default Caller ID Number for outbound calls -->
<param name="caller-id-number" value="8777423583"/> <param name="caller-id-number" value="8777423583"/>
</profile> </profile>
</profiles> </profiles>
</configuration> </configuration>
</section> </section>
<section name="dialplan" description="Regex/XML Dialplan"> <section name="dialplan" description="Regex/XML Dialplan">
<!-- Valid fields in conditions: <!-- Valid fields in conditions:
"dialplan, caller_id_name, ani, ani2, caller_id_number, "dialplan, caller_id_name, ani, ani2, caller_id_number,
network_addr, rdnis, destination_number, uuid, source, network_addr, rdnis, destination_number, uuid, source,
context, chan_name" --> context, chan_name" -->
<!-- *NOTE* The special context name 'any' will match any context --> <!-- *NOTE* The special context name 'any' will match any context -->
<context name="default"> <context name="default">
<extension name="tollfree"> <extension name="tollfree">
<condition field="destination_number" expression="^(18(0{2}|8{2}|7{2}|6{2})\d{7})$"> <condition field="destination_number" expression="^(18(0{2}|8{2}|7{2}|6{2})\d{7})$">
<action application="bridge" data="exosip/$1-freeswitch@voip.trxtel.com"/> <action application="bridge" data="exosip/$1-freeswitch@voip.trxtel.com"/>
</condition> </condition>
</extension> </extension>
<!--<extension name="devconf"> <!--<extension name="devconf">
<condition field="destination_number" expression="^888$"> <condition field="destination_number" expression="^888$">
<action application="bridge" data="exosip/888@66.250.68.194"/> <action application="bridge" data="exosip/888@66.250.68.194"/>
</condition> </condition>
</extension> --> </extension> -->
<extension name="testmusic"> <extension name="testmusic">
<condition field="destination_number" expression="^1234$"> <condition field="destination_number" expression="^1234$">
<action application="bridge" data="exosip/1234@66.250.68.194"/> <action application="bridge" data="exosip/1234@66.250.68.194"/>
</condition> </condition>
</extension> </extension>
<!-- Enter an existing conference --> <!-- Enter an existing conference -->
<extension name="1000"> <extension name="1000">
<condition field="destination_number" expression="^1000$"> <condition field="destination_number" expression="^1000$">
<action application="conference" data="freeswitch"/> <action application="conference" data="freeswitch"/>
</condition> </condition>
</extension> </extension>
<!-- Start a dynamic conference and call someone at the same time --> <!-- Start a dynamic conference and call someone at the same time -->
<extension name="2000"> <extension name="2000">
<condition field="destination_number" expression="^2000$"> <condition field="destination_number" expression="^2000$">
<action application="conference" data="bridge:mydynaconf:exosip/1234@66.250.68.194"/> <action application="conference" data="bridge:mydynaconf:exosip/1234@66.250.68.194"/>
</condition> </condition>
</extension> </extension>
<!-- if the destination is an exact match on the extension name <!-- if the destination is an exact match on the extension name
you do not need any regex in the condition you do not need any regex in the condition
<extension name="999"> <extension name="999">
<condition><action application="bridge" data="exosip/888@66.250.68.194"/></condition> <condition><action application="bridge" data="exosip/888@66.250.68.194"/></condition>
</extension>--> </extension>-->
<!-- extensions starting with 4, all the numbers after 4 form a numeric filename <!-- extensions starting with 4, all the numbers after 4 form a numeric filename
continue=true means keep looking for more extensions to match continue=true means keep looking for more extensions to match
*NOTE* The entire dialplan is parsed ONCE when the call starts *NOTE* The entire dialplan is parsed ONCE when the call starts
so any call info acquired after the various actions cannot so any call info acquired after the various actions cannot
be taken into consideration. be taken into consideration.
The first match will play a beep and the second one plays The first match will play a beep and the second one plays
the desired file. This is for demo purposes both actions the desired file. This is for demo purposes both actions
could have been under the same <extension> tag as well. could have been under the same <extension> tag as well.
--> -->
<extension name="playsound1" continue="true"> <extension name="playsound1" continue="true">
<condition field="source" expression="mod_exosip"/> <condition field="source" expression="mod_exosip"/>
<condition field="destination_number" expression="^4(\d+)"> <condition field="destination_number" expression="^4(\d+)">
<action application="playback" data="/var/sounds/beep.gsm"/> <action application="playback" data="/var/sounds/beep.gsm"/>
</condition> </condition>
</extension> </extension>
<extension name="playsound2"> <extension name="playsound2">
<condition field="source" expression="mod_exosip"/> <condition field="source" expression="mod_exosip"/>
<condition field="destination_number" expression="^4(\d+)"> <condition field="destination_number" expression="^4(\d+)">
<action application="playback" data="/root/$1.raw"/> <action application="playback" data="/root/$1.raw"/>
</condition> </condition>
</extension> </extension>
<!-- send everything with a certian RDNIS to Wanpipe ISDN --> <!-- send everything with a certian RDNIS to Wanpipe ISDN -->
<extension name="To PRI"> <extension name="To PRI">
<condition field="rdnis" expression="8881231234"/> <condition field="rdnis" expression="8881231234"/>
<condition field="destination_number" expression="(.*)"> <condition field="destination_number" expression="(.*)">
<action application="bridge" data="wanpipe/a/a/$1"/> <action application="bridge" data="wanpipe/a/a/$1"/>
</condition> </condition>
</extension> </extension>
<!-- Call *MUST* originate from mod_iax and also be dialing ext 9999--> <!-- Call *MUST* originate from mod_iax and also be dialing ext 9999-->
<extension name="9999"> <extension name="9999">
<condition field="source" expression="mod_iax"/> <condition field="source" expression="mod_iax"/>
<condition field="destination_number" expression="9999"> <condition field="destination_number" expression="9999">
<action application="playback" data="/var/sounds/beep.gsm"/> <action application="playback" data="/var/sounds/beep.gsm"/>
</condition> </condition>
</extension> </extension>
<!-- Call the FreeSWITCH conference via SIP --> <!-- Call the FreeSWITCH conference via SIP -->
<extension name="FreeSWITCH Conference SIP"> <extension name="FreeSWITCH Conference SIP">
<condition field="destination_number" expression="^888$"> <condition field="destination_number" expression="^888$">
<action application="bridge" data="exosip/888@66.250.68.194"/> <action application="bridge" data="exosip/888@66.250.68.194"/>
</condition> </condition>
</extension> </extension>
<!-- Call the FreeSWITCH conference via IAX --> <!-- Call the FreeSWITCH conference via IAX -->
<extension name="FreeSWITCH Conference IAX"> <extension name="FreeSWITCH Conference IAX">
<condition field="destination_number" expression="^8888$"> <condition field="destination_number" expression="^8888$">
<action application="bridge" data="iax/guest@66.250.68.194/888"/> <action application="bridge" data="iax/guest@66.250.68.194/888"/>
</condition> </condition>
</extension> </extension>
</context> </context>
</section> </section>
@ -495,16 +511,16 @@
<section name="directory" description="User Directory"> <section name="directory" description="User Directory">
<!--the domain or ip (the right hand side of the @ in the addr--> <!--the domain or ip (the right hand side of the @ in the addr-->
<domain name="mydomain.com"> <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"> <user id="1000">
<!-- omit password for authless registration --> <!-- omit password for authless registration -->
<param name="password" value="mypass"/> <param name="password" value="mypass"/>
<!--various endpoints and application will look for user specific settings here --> <!--various endpoints and application will look for user specific settings here -->
<param name="mypref" value="myval"/> <param name="mypref" value="myval"/>
</user> </user>
</domain> </domain>
</section> </section>
</document> </document>

View File

@ -39,13 +39,23 @@
#define HAVE_APR #define HAVE_APR
#include <switch.h> #include <switch.h>
struct outbound_reg;
typedef struct outbound_reg outbound_reg_t;
struct sofia_profile; struct sofia_profile;
typedef struct sofia_profile sofia_profile_t; typedef struct sofia_profile sofia_profile_t;
#define NUA_MAGIC_T 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; struct private_object;
typedef struct private_object private_object_t; 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_REGISTER "sofia::register"
#define MY_EVENT_EXPIRE "sofia::expire" #define MY_EVENT_EXPIRE "sofia::expire"
@ -77,10 +87,6 @@ static char auth_sql[] =
" expires INTEGER(8)" " expires INTEGER(8)"
");\n"; ");\n";
static const char modname[] = "mod_sofia"; static const char modname[] = "mod_sofia";
#define STRLEN 15 #define STRLEN 15
@ -133,6 +139,41 @@ static struct {
switch_mutex_t *mutex; switch_mutex_t *mutex;
} globals; } 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 { struct sofia_profile {
int debug; int debug;
char *name; char *name;
@ -163,12 +204,14 @@ struct sofia_profile {
sip_alias_node_t *aliases; sip_alias_node_t *aliases;
switch_payload_t te; switch_payload_t te;
uint32_t codec_flags; 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 { struct private_object {
sofia_private_t sofia_private;
uint32_t flags; uint32_t flags;
switch_core_session_t *session; switch_core_session_t *session;
switch_frame_t read_frame; switch_frame_t read_frame;
@ -263,21 +306,21 @@ static void sip_i_state(int status,
nua_t *nua, nua_t *nua,
sofia_profile_t *profile, sofia_profile_t *profile,
nua_handle_t *nh, nua_handle_t *nh,
switch_core_session_t *session, sofia_private_t *sofia_private,
sip_t const *sip, sip_t const *sip,
tagi_t tags[]); tagi_t tags[]);
static void sip_i_invite(nua_t *nua, static void sip_i_invite(nua_t *nua,
sofia_profile_t *profile, sofia_profile_t *profile,
nua_handle_t *nh, nua_handle_t *nh,
switch_core_session_t *session, sofia_private_t *sofia_private,
sip_t const *sip, sip_t const *sip,
tagi_t tags[]); tagi_t tags[]);
static void sip_i_register(nua_t *nua, static void sip_i_register(nua_t *nua,
sofia_profile_t *profile, sofia_profile_t *profile,
nua_handle_t *nh, nua_handle_t *nh,
switch_core_session_t *session, sofia_private_t *sofia_private,
sip_t const *sip, sip_t const *sip,
tagi_t tags[]); tagi_t tags[]);
@ -287,7 +330,7 @@ static void event_callback(nua_event_t event,
nua_t *nua, nua_t *nua,
sofia_profile_t *profile, sofia_profile_t *profile,
nua_handle_t *nh, nua_handle_t *nh,
switch_core_session_t *session, sofia_private_t *sofia_private,
sip_t const *sip, sip_t const *sip,
tagi_t tags[]); tagi_t tags[]);
@ -356,7 +399,7 @@ static auth_res_t parse_auth(sofia_profile_t *profile, sip_authorization_t const
} }
if (switch_strlen_zero(np)) { 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; ret = AUTH_STALE;
goto end; goto end;
} }
@ -468,7 +511,7 @@ static void check_expire(sofia_profile_t *profile, time_t now)
return; 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); 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); switch_core_db_exec(db, sql, del_callback, NULL, &errmsg);
@ -482,7 +525,7 @@ static void check_expire(sofia_profile_t *profile, time_t now)
switch_core_db_persistant_execute(db, sql, 25); switch_core_db_persistant_execute(db, sql, 25);
snprintf(sql, sizeof(sql), "delete from sip_authentication where expires > 0 and expires < %ld", (long) now); 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_core_db_persistant_execute(db, sql, 25);
switch_mutex_unlock(profile->reg_mutex); switch_mutex_unlock(profile->ireg_mutex);
switch_core_db_close(db); switch_core_db_close(db);
} }
@ -500,7 +543,7 @@ static char *find_reg_url(sofia_profile_t *profile, char *user, char *host, char
cbt.val = val; cbt.val = val;
cbt.len = len; cbt.len = len;
switch_mutex_lock(profile->reg_mutex); switch_mutex_lock(profile->ireg_mutex);
if (host) { if (host) {
snprintf(val, len, "select contact from sip_registrations where user='%s' and host='%s'", user, host); snprintf(val, len, "select contact from sip_registrations where user='%s' and host='%s'", user, host);
} else { } else {
@ -515,7 +558,7 @@ static char *find_reg_url(sofia_profile_t *profile, char *user, char *host, char
errmsg = NULL; errmsg = NULL;
} }
switch_mutex_unlock(profile->reg_mutex); switch_mutex_unlock(profile->ireg_mutex);
switch_core_db_close(db); switch_core_db_close(db);
return cbt.matches ? val : NULL; return cbt.matches ? val : NULL;
@ -723,7 +766,8 @@ static void do_invite(switch_core_session_t *session)
switch_set_flag_locked(tech_pvt, TFLAG_READY); 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()); 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, nua_invite(tech_pvt->nh,
SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
SOATAG_RTP_SORT(SOA_RTP_SORT_REMOTE), SOATAG_RTP_SORT(SOA_RTP_SORT_REMOTE),
@ -1593,7 +1637,7 @@ static void sip_i_state(int status,
nua_t *nua, nua_t *nua,
sofia_profile_t *profile, sofia_profile_t *profile,
nua_handle_t *nh, nua_handle_t *nh,
switch_core_session_t *session, sofia_private_t *sofia_private,
sip_t const *sip, sip_t const *sip,
tagi_t tags[]) tagi_t tags[])
@ -1604,7 +1648,8 @@ static void sip_i_state(int status,
int ss_state = nua_callstate_init; int ss_state = nua_callstate_init;
switch_channel_t *channel = NULL; switch_channel_t *channel = NULL;
private_object_t *tech_pvt = NULL; private_object_t *tech_pvt = NULL;
switch_core_session_t *session = sofia_private ? sofia_private->session : NULL;
tl_gets(tags, tl_gets(tags,
NUTAG_CALLSTATE_REF(ss_state), NUTAG_CALLSTATE_REF(ss_state),
NUTAG_OFFER_RECV_REF(offer_recv), NUTAG_OFFER_RECV_REF(offer_recv),
@ -1842,7 +1887,6 @@ typedef enum {
static uint8_t handle_register(nua_t *nua, static uint8_t handle_register(nua_t *nua,
sofia_profile_t *profile, sofia_profile_t *profile,
nua_handle_t *nh, nua_handle_t *nh,
switch_core_session_t *session,
sip_t const *sip, sip_t const *sip,
sofia_regtype_t regtype, sofia_regtype_t regtype,
char *key, char *key,
@ -1852,7 +1896,6 @@ static uint8_t handle_register(nua_t *nua,
sip_expires_t const *expires = sip->sip_expires; sip_expires_t const *expires = sip->sip_expires;
sip_authorization_t const *authorization = sip->sip_authorization; sip_authorization_t const *authorization = sip->sip_authorization;
sip_contact_t const *contact = sip->sip_contact; sip_contact_t const *contact = sip->sip_contact;
switch_xml_t domain, xml, user, param; switch_xml_t domain, xml, user, param;
char params[1024] = ""; char params[1024] = "";
char *sql; char *sql;
@ -1865,9 +1908,9 @@ static uint8_t handle_register(nua_t *nua,
char *passwd = NULL; char *passwd = NULL;
uint8_t stale = 0, ret = 0, forbidden = 0; uint8_t stale = 0, ret = 0, forbidden = 0;
auth_res_t auth_res; auth_res_t auth_res;
long exptime = 60; long exptime = 60;
if (expires) { if (expires) {
exptime = expires->ex_delta; exptime = expires->ex_delta;
} else if (contact->m_expires) { } else if (contact->m_expires) {
@ -1979,7 +2022,7 @@ static uint8_t handle_register(nua_t *nua,
} }
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(sql);
switch_core_db_free(auth_str); switch_core_db_free(auth_str);
ret = 1; ret = 1;
@ -2025,7 +2068,7 @@ static uint8_t handle_register(nua_t *nua,
} }
if (sql) { if (sql) {
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(sql);
sql = NULL; sql = NULL;
} }
@ -2051,17 +2094,17 @@ static uint8_t handle_register(nua_t *nua,
static void sip_i_invite(nua_t *nua, static void sip_i_invite(nua_t *nua,
sofia_profile_t *profile, sofia_profile_t *profile,
nua_handle_t *nh, nua_handle_t *nh,
switch_core_session_t *session, sofia_private_t *sofia_private,
sip_t const *sip, sip_t const *sip,
tagi_t tags[]) tagi_t tags[])
{ {
switch_core_session_t *session = sofia_private ? sofia_private->session : NULL;
char key[128] = ""; char key[128] = "";
if (!session) { if (!session) {
if ((profile->pflags & PFLAG_AUTH_CALLS)) { 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; return;
} }
} }
@ -2119,7 +2162,8 @@ static void sip_i_invite(nua_t *nua,
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile); switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
} }
switch_set_flag_locked(tech_pvt, TFLAG_INBOUND); 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_invite(nua_t *nua,
static void sip_i_register(nua_t *nua, static void sip_i_register(nua_t *nua,
sofia_profile_t *profile, sofia_profile_t *profile,
nua_handle_t *nh, nua_handle_t *nh,
switch_core_session_t *session, sofia_private_t *sofia_private,
sip_t const *sip, sip_t const *sip,
tagi_t tags[]) 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, static void sip_r_register(int status,
nua_t *nua, char const *phrase,
sofia_profile_t *profile, nua_t *nua,
sofia_profile_t *profile,
nua_handle_t *nh, nua_handle_t *nh,
switch_core_session_t *session, sofia_private_t *sofia_private,
sip_t const *sip, sip_t const *sip,
tagi_t tags[]) 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; struct private_object *tech_pvt = NULL;
auth_res_t auth_res = AUTH_FORBIDDEN; auth_res_t auth_res = AUTH_FORBIDDEN;
switch_core_session_t *session = sofia_private ? sofia_private->session : NULL;
if (session) { if (session) {
if (switch_core_session_read_lock(session) != SWITCH_STATUS_SUCCESS) { if (switch_core_session_read_lock(session) != SWITCH_STATUS_SUCCESS) {
@ -2184,107 +2297,104 @@ static void event_callback(nua_event_t event,
switch (event) { switch (event) {
case nua_r_shutdown: 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; break;
case nua_r_get_params: 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_register:
//sip_r_register(status, phrase, nua, profile, nh, session, sip, tags);
break;
case nua_r_unregister:
//sip_r_unregister(status, phrase, nua, profile, nh, session, sip, tags);
break;
case nua_r_options:
//sip_r_options(status, phrase, nua, profile, nh, session, sip, tags);
break; break;
case nua_r_invite: case nua_r_invite:
//sip_r_invite(status, phrase, nua, profile, nh, session, sip, tags); case nua_r_register:
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, sofia_private, sip, tags);
break;
case nua_r_options:
//sip_r_options(status, phrase, nua, profile, nh, sofia_private, sip, tags);
break; break;
case nua_i_fork: 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; break;
case nua_i_invite: case nua_i_invite:
sip_i_invite(nua, profile, nh, session, sip, tags); sip_i_invite(nua, profile, nh, sofia_private, sip, tags);
break; break;
case nua_i_register: case nua_i_register:
sip_i_register (nua, profile, nh, session, sip, tags); sip_i_register (nua, profile, nh, sofia_private, sip, tags);
break; break;
case nua_i_prack: case nua_i_prack:
//sip_i_prack(nua, profile, nh, session, sip, tags); //sip_i_prack(nua, profile, nh, sofia_private, sip, tags);
break; break;
case nua_i_state: 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; break;
case nua_r_bye: 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; break;
case nua_i_bye: case nua_i_bye:
//sip_i_bye(nua, profile, nh, session, sip, tags); //sip_i_bye(nua, profile, nh, sofia_private, sip, tags);
break; break;
case nua_r_message: 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; break;
case nua_i_message: case nua_i_message:
//sip_i_message(nua, profile, nh, session, sip, tags); //sip_i_message(nua, profile, nh, sofia_private, sip, tags);
break; break;
case nua_r_info: 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; break;
case nua_i_info: case nua_i_info:
//sip_i_info(nua, profile, nh, session, sip, tags); //sip_i_info(nua, profile, nh, sofia_private, sip, tags);
break; break;
case nua_r_refer: 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; break;
case nua_i_refer: case nua_i_refer:
//sip_i_refer(nua, profile, nh, session, sip, tags); //sip_i_refer(nua, profile, nh, sofia_private, sip, tags);
break; break;
case nua_r_subscribe: 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; break;
case nua_r_unsubscribe: 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; break;
case nua_r_publish: 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; break;
case nua_r_notify: 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; break;
case nua_i_notify: case nua_i_notify:
//sip_i_notify(nua, profile, nh, session, sip, tags); //sip_i_notify(nua, profile, nh, sofia_private, sip, tags);
break; break;
case nua_i_cancel: case nua_i_cancel:
//sip_i_cancel(nua, profile, nh, session, sip, tags); //sip_i_cancel(nua, profile, nh, sofia_private, sip, tags);
break; break;
case nua_i_error: 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; break;
case nua_i_active: case nua_i_active:
@ -2309,15 +2419,67 @@ static void event_callback(nua_event_t event,
} }
} }
#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) static void *SWITCH_THREAD_FUNC profile_thread_run(switch_thread_t *thread, void *obj)
{ {
sofia_profile_t *profile = (sofia_profile_t *) obj; sofia_profile_t *profile = (sofia_profile_t *) obj;
switch_memory_pool_t *pool; switch_memory_pool_t *pool;
sip_alias_node_t *node; sip_alias_node_t *node;
uint32_t loops = 0; uint32_t ireg_loops = 0;
uint32_t oreg_loops = 0;
switch_core_db_t *db; switch_core_db_t *db;
profile->s_root = su_root_create(NULL); profile->s_root = su_root_create(NULL);
profile->nua = nua_create(profile->s_root, /* Event loop */ profile->nua = nua_create(profile->s_root, /* Event loop */
event_callback, /* Callback for processing events */ event_callback, /* Callback for processing events */
@ -2363,18 +2525,25 @@ static void *SWITCH_THREAD_FUNC profile_thread_run(switch_thread_t *thread, void
} }
switch_core_db_close(db); 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); switch_mutex_lock(globals.mutex);
globals.running = 1; globals.running = 1;
switch_mutex_unlock(globals.mutex); switch_mutex_unlock(globals.mutex);
loops = REG_SECONDS; ireg_loops = IREG_SECONDS;
oreg_loops = OREG_SECONDS;
while(globals.running == 1) { while(globals.running == 1) {
if (++loops >= REG_SECONDS) { if (++ireg_loops >= IREG_SECONDS) {
check_expire(profile, time(NULL)); 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_step(profile->s_root, 1000);
@ -2411,8 +2580,10 @@ static void launch_profile_thread(sofia_profile_t *profile)
static switch_status_t config_sofia(int reload) static switch_status_t config_sofia(int reload)
{ {
char *cf = "sofia.conf"; 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; switch_status_t status = SWITCH_STATUS_SUCCESS;
sofia_profile_t *profile = NULL;
char url[512] = "";
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
@ -2420,150 +2591,233 @@ static switch_status_t config_sofia(int reload)
goto done; goto done;
} }
for (xprofile = switch_xml_child(cfg, "profile"); xprofile; xprofile = xprofile->next) { if ((profiles = switch_xml_child(cfg, "profiles"))) {
char *xprofilename = (char *) switch_xml_attr_soft(xprofile, "name"); for (xprofile = switch_xml_child(profiles, "profile"); xprofile; xprofile = xprofile->next) {
sofia_profile_t *profile; if (!(settings = switch_xml_child(xprofile, "settings"))) {
switch_memory_pool_t *pool = NULL; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Settings, check the new config!\n", cf);
char url[512] = ""; } 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) { /* Setup the pool */
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n"); if ((status = switch_core_new_memory_pool(&pool)) != SWITCH_STATUS_SUCCESS) {
goto done; 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)))) { if (!(profile = (sofia_profile_t *) switch_core_alloc(pool, sizeof(*profile)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
goto done; goto done;
} }
if (!xprofilename) { if (!xprofilename) {
xprofilename = "unnamed"; xprofilename = "unnamed";
} }
profile->pool = pool; profile->pool = pool;
profile->name = switch_core_strdup(profile->pool, xprofilename); profile->name = switch_core_strdup(profile->pool, xprofilename);
snprintf(url, sizeof(url), "sofia_reg_%s", xprofilename); snprintf(url, sizeof(url), "sofia_reg_%s", xprofilename);
profile->dbname = switch_core_strdup(profile->pool, url); profile->dbname = switch_core_strdup(profile->pool, url);
profile->dtmf_duration = 100; profile->dtmf_duration = 100;
profile->codec_ms = 20; profile->codec_ms = 20;
for (param = switch_xml_child(xprofile, "param"); param; param = param->next) { for (param = switch_xml_child(settings, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name"); char *var = (char *) switch_xml_attr_soft(param, "name");
char *val = (char *) switch_xml_attr_soft(param, "value"); char *val = (char *) switch_xml_attr_soft(param, "value");
if (!strcasecmp(var, "debug")) { if (!strcasecmp(var, "debug")) {
profile->debug = atoi(val); profile->debug = atoi(val);
} else if (!strcasecmp(var, "use-rtp-timer") && switch_true(val)) { } else if (!strcasecmp(var, "use-rtp-timer") && switch_true(val)) {
switch_set_flag(profile, TFLAG_TIMER); switch_set_flag(profile, TFLAG_TIMER);
} else if (!strcasecmp(var, "rfc2833-pt")) { } else if (!strcasecmp(var, "rfc2833-pt")) {
profile->te = (switch_payload_t) atoi(val); profile->te = (switch_payload_t) atoi(val);
} else if (!strcasecmp(var, "sip-port")) { } else if (!strcasecmp(var, "sip-port")) {
profile->sip_port = atoi(val); profile->sip_port = atoi(val);
} else if (!strcasecmp(var, "vad")) { } else if (!strcasecmp(var, "vad")) {
if (!strcasecmp(val, "in")) { if (!strcasecmp(val, "in")) {
switch_set_flag(profile, TFLAG_VAD_IN); switch_set_flag(profile, TFLAG_VAD_IN);
} else if (!strcasecmp(val, "out")) { } else if (!strcasecmp(val, "out")) {
switch_set_flag(profile, TFLAG_VAD_OUT); switch_set_flag(profile, TFLAG_VAD_OUT);
} else if (!strcasecmp(val, "both")) { } else if (!strcasecmp(val, "both")) {
switch_set_flag(profile, TFLAG_VAD_IN); switch_set_flag(profile, TFLAG_VAD_IN);
switch_set_flag(profile, TFLAG_VAD_OUT); switch_set_flag(profile, TFLAG_VAD_OUT);
} else { } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invald option %s for VAD\n", val); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invald option %s for VAD\n", val);
} }
} else if (!strcasecmp(var, "ext-rtp-ip")) { } else if (!strcasecmp(var, "ext-rtp-ip")) {
profile->extrtpip = switch_core_strdup(profile->pool, val); profile->extrtpip = switch_core_strdup(profile->pool, val);
} else if (!strcasecmp(var, "rtp-ip")) { } else if (!strcasecmp(var, "rtp-ip")) {
profile->rtpip = switch_core_strdup(profile->pool, val); profile->rtpip = switch_core_strdup(profile->pool, val);
} else if (!strcasecmp(var, "sip-ip")) { } else if (!strcasecmp(var, "sip-ip")) {
profile->sipip = switch_core_strdup(profile->pool, val); profile->sipip = switch_core_strdup(profile->pool, val);
} else if (!strcasecmp(var, "sip-domain")) { } else if (!strcasecmp(var, "sip-domain")) {
profile->sipdomain = switch_core_strdup(profile->pool, val); profile->sipdomain = switch_core_strdup(profile->pool, val);
} else if (!strcasecmp(var, "rtp-timer-name")) { } else if (!strcasecmp(var, "rtp-timer-name")) {
profile->timer_name = switch_core_strdup(profile->pool, val); profile->timer_name = switch_core_strdup(profile->pool, val);
} else if (!strcasecmp(var, "auth-calls")) { } else if (!strcasecmp(var, "auth-calls")) {
if (switch_true(val)) { if (switch_true(val)) {
profile->pflags |= PFLAG_AUTH_CALLS; profile->pflags |= PFLAG_AUTH_CALLS;
} }
} else if (!strcasecmp(var, "accept-blind-reg")) { } else if (!strcasecmp(var, "accept-blind-reg")) {
if (switch_true(val)) { if (switch_true(val)) {
profile->pflags |= PFLAG_BLIND_REG; profile->pflags |= PFLAG_BLIND_REG;
} }
} else if (!strcasecmp(var, "auth-all-packets")) { } else if (!strcasecmp(var, "auth-all-packets")) {
if (switch_true(val)) { if (switch_true(val)) {
profile->pflags |= PFLAG_AUTH_ALL; profile->pflags |= PFLAG_AUTH_ALL;
} }
} else if (!strcasecmp(var, "ext-sip-ip")) { } else if (!strcasecmp(var, "ext-sip-ip")) {
profile->extsipip = switch_core_strdup(profile->pool, val); profile->extsipip = switch_core_strdup(profile->pool, val);
} else if (!strcasecmp(var, "bitpacking")) { } else if (!strcasecmp(var, "bitpacking")) {
if (!strcasecmp(val, "aal2")) { if (!strcasecmp(val, "aal2")) {
profile->codec_flags = SWITCH_CODEC_FLAG_AAL2; profile->codec_flags = SWITCH_CODEC_FLAG_AAL2;
} }
} else if (!strcasecmp(var, "username")) { } else if (!strcasecmp(var, "username")) {
profile->username = switch_core_strdup(profile->pool, val); profile->username = switch_core_strdup(profile->pool, val);
} else if (!strcasecmp(var, "context")) { } else if (!strcasecmp(var, "context")) {
profile->context = switch_core_strdup(profile->pool, val); profile->context = switch_core_strdup(profile->pool, val);
} else if (!strcasecmp(var, "alias")) { } else if (!strcasecmp(var, "alias")) {
sip_alias_node_t *node; sip_alias_node_t *node;
if ((node = switch_core_alloc(profile->pool, sizeof(*node)))) { if ((node = switch_core_alloc(profile->pool, sizeof(*node)))) {
if ((node->url = switch_core_strdup(profile->pool, val))) { if ((node->url = switch_core_strdup(profile->pool, val))) {
node->next = profile->aliases; node->next = profile->aliases;
profile->aliases = node; 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, "dialplan")) {
profile->dialplan = switch_core_strdup(profile->pool, val); if (switch_test_flag(profile, TFLAG_TIMER) && !profile->timer_name) {
} else if (!strcasecmp(var, "max-calls")) { profile->timer_name = switch_core_strdup(profile->pool, "soft");
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->username) {
profile->username = switch_core_strdup(profile->pool, "FreeSWITCH");
}
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 (!profile->sip_port) {
profile->sip_port = 5060;
}
if (!profile->dialplan) {
profile->dialplan = switch_core_strdup(profile->pool, "default");
}
if (!profile->sipdomain) {
profile->sipdomain = switch_core_strdup(profile->pool, profile->sipip);
}
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 (++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 ((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;
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@freeswitch.org>");
}
if (switch_strlen_zero(oreg->register_to)) {
oreg->register_to = switch_core_strdup(oreg->pool, "sip:freeswitch@freeswitch.org");
}
if (switch_strlen_zero(oreg->register_proxy)) {
oreg->register_proxy = switch_core_strdup(oreg->pool, "sip:freeswitch@freeswitch.org");
}
if (switch_strlen_zero(oreg->expires_str)) {
oreg->expires_str = switch_core_strdup(oreg->pool, "300");
}
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;
} }
} }
if (switch_test_flag(profile, TFLAG_TIMER) && !profile->timer_name) {
profile->timer_name = switch_core_strdup(profile->pool, "soft");
}
if (!profile->username) {
profile->username = switch_core_strdup(profile->pool, "FreeSWITCH");
}
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 (!profile->sip_port) {
profile->sip_port = 5060;
}
if (!profile->dialplan) {
profile->dialplan = switch_core_strdup(profile->pool, "default");
}
if (!profile->sipdomain) {
profile->sipdomain = switch_core_strdup(profile->pool, profile->sipip);
}
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);
} }
done: done:
if (xml) { if (xml) {
switch_xml_free(xml); switch_xml_free(xml);
@ -2612,7 +2866,7 @@ static void event_handler(switch_event_t *event)
} }
if (sql) { if (sql) {
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(sql);
sql = NULL; sql = NULL;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Propagating registration for %s@%s->%s@%s\n", switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Propagating registration for %s@%s->%s@%s\n",