Hi everyone<br><br>I&#39;m trying to integrate Asterisk with Kamailio for voicemail.<br>I tried to follow this tutorial: <a href="http://kb.asipto.com/asterisk:realtime:kamailio-3.3.x-asterisk-10.7.0-astdb">http://kb.asipto.com/asterisk:realtime:kamailio-3.3.x-asterisk-10.7.0-astdb</a><br>
BUT:<br><br>- I had to adapt it because I use LDAP authentication with Kamailio<br>- I had problems with Asterisk 10.7 (problems with chan_sip module crashing) so I&#39;ve installed Asterisk 11 on another VM<br>- we have high-availability with 2 Kamailio servers, with Kamailio listening on TCP (constraint from our SSL gateway in front of Kamailio) on a &quot;virtual IP&quot; (created by keep-alive): this VIP is not visible with ifconfig, but you can see it with the command &quot;ip addr sh eth0&quot;<br>
<br>For now, we use Linphone on Windows as SIP clients to test.<br>If I don&#39;t define WITH_ASTERISK, calls work, I can call someone@domain.tld<br>However, if I define WITH_ASTERISK, calls fail (even with destination registered and available) and I have these errors in the logfile:<br>
<br>Nov 15 11:45:08 kamailio1 /usr/sbin/kamailio[25308]: ERROR: tm [ut.h:333]: no corresponding socket for af 2<br>Nov 15 11:45:08 kamailio1 /usr/sbin/kamailio[25308]: ERROR: tm [t_fwd.c:424]: ERROR: can&#39;t fwd to af 2, proto 1  (no corresponding listening socket)<br>
Nov 15 11:45:08 kamailio1 /usr/sbin/kamailio[25308]: ERROR: tm [t_fwd.c:1530]: ERROR: t_forward_nonack: failure to add branches<br>Nov 15 11:45:08 kamailio1 /usr/sbin/kamailio[25308]: INFO: &lt;script&gt;: reply error<br>
Nov 15 11:45:08 kamailio1 /usr/sbin/kamailio[25308]: ERROR: sl [sl_funcs.c:371]: ERROR: sl_reply_error used: I&#39;m terribly sorry, server error occurred (1/SL)<br><br>It seems to happen on the if (!t_relay()) line in ROUTE[RELAY]<br>
<br>192.168.14.25 is the real IP of the Kamailio server, <br>192.168.14.24 is the VIP of the Kamailio &quot;cluster&quot;<br>192.168.14.28 is the IP of the Mysql server<br>192.168.14.32 is the IP of the Asterisk server<br>
<br>I can&#39;t find why the relay doesn&#39;t work. I&#39;ve tried to bypass the VIP and have Kamailio listen on the real IP, but it still doesn&#39;t work: I don&#39;t seem to have the same errors as above, but I don&#39;t see any traffic between Kamailio and Asterisk.<br>
<br>What could be the problem? Thanks for your help<br><br>Christophe<br><br><br><br><br><br>Below is my kamailio.cfg:<br><br><br>#!WITH_DEBUG<br><br>#!KAMAILIO<br>#<br># Kamailio (OpenSER) SIP Server v3.2 - default configuration script<br>
#     - web: <a href="http://www.kamailio.org">http://www.kamailio.org</a><br>#     - git: <a href="http://sip-router.org">http://sip-router.org</a><br>#<br># Direct your questions about this file to: &lt;<a href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a>&gt;<br>
#<br># Refer to the Core CookBook at <a href="http://www.kamailio.org/dokuwiki/doku.php">http://www.kamailio.org/dokuwiki/doku.php</a><br># for an explanation of possible statements, functions and parameters.<br>#<br># Several features can be enabled using &#39;#!define WITH_FEATURE&#39; directives:<br>
#<br># *** To run in debug mode: <br>#     - define WITH_DEBUG<br>#<br># *** To enable mysql: <br>#     - define WITH_MYSQL<br>#<br># *** To enable authentication execute:<br>#     - enable mysql<br>#     - define WITH_AUTH<br>
#     - add users using &#39;kamctl&#39;<br>#<br># *** To enable IP authentication execute:<br>#     - enable mysql<br>#     - enable authentication<br>#     - define WITH_IPAUTH<br>#     - add IP addresses with group id &#39;1&#39; to &#39;address&#39; table<br>
#<br># *** To enable persistent user location execute:<br>#     - enable mysql<br>#     - define WITH_USRLOCDB<br>#<br># *** To enable presence server execute:<br>#     - enable mysql<br>#     - define WITH_PRESENCE<br>#<br>
# *** To enable nat traversal execute:<br>#     - define WITH_NAT<br>#     - install RTPProxy: <a href="http://www.rtpproxy.org">http://www.rtpproxy.org</a><br>#     - start RTPProxy:<br>#        rtpproxy -l _your_public_ip_ -s udp:localhost:7722<br>
#<br>###!define WITH_NAT<br><br># *** To enable PSTN gateway routing execute:<br>#     - define WITH_PSTN<br>#     - set the value of pstn.gw_ip<br>#     - check route[PSTN] for regexp routing condition<br>#<br># *** To enable database aliases lookup execute:<br>
#     - enable mysql<br>#     - define WITH_ALIASDB<br>#<br># *** To enable speed dial lookup execute:<br>#     - enable mysql<br>#     - define WITH_SPEEDDIAL<br>#<br># *** To enable multi-domain support execute:<br>#     - enable mysql<br>
#     - define WITH_MULTIDOMAIN<br>#<br># *** To enable TLS support execute:<br>#     - adjust CFGDIR/tls.cfg as needed<br>#     - define WITH_TLS<br>#<br># *** To enable XMLRPC support execute:<br>#     - define WITH_XMLRPC<br>
#     - adjust route[XMLRPC] for access policy<br>#<br># *** To enable anti-flood detection execute:<br>#     - adjust pike and htable=&gt;ipban settings as needed (default is<br>#       block if more than 16 requests in 2 seconds and ban for 300 seconds)<br>
#     - define WITH_ANTIFLOOD<br>#<br># *** To block 3XX redirect replies execute:<br>#     - define WITH_BLOCK3XX<br>#<br># *** To enable VoiceMail routing execute:<br>#     - define WITH_VOICEMAIL<br>#     - set the value of voicemail.srv_ip<br>
#     - adjust the value of voicemail.srv_port<br>#<br># *** To enhance accounting execute:<br>#     - enable mysql<br>#     - define WITH_ACCDB<br>#     - add following columns to database<br>#!ifdef ACCDB_COMMENT<br>  ALTER TABLE acc ADD COLUMN src_user VARCHAR(64) NOT NULL DEFAULT &#39;&#39;;<br>
  ALTER TABLE acc ADD COLUMN src_domain VARCHAR(128) NOT NULL DEFAULT &#39;&#39;;<br>  ALTER TABLE acc ADD COLUMN src_ip varchar(64) NOT NULL default &#39;&#39;;<br>  ALTER TABLE acc ADD COLUMN dst_ouser VARCHAR(64) NOT NULL DEFAULT &#39;&#39;;<br>
  ALTER TABLE acc ADD COLUMN dst_user VARCHAR(64) NOT NULL DEFAULT &#39;&#39;;<br>  ALTER TABLE acc ADD COLUMN dst_domain VARCHAR(128) NOT NULL DEFAULT &#39;&#39;;<br>  ALTER TABLE missed_calls ADD COLUMN src_user VARCHAR(64) NOT NULL DEFAULT &#39;&#39;;<br>
  ALTER TABLE missed_calls ADD COLUMN src_domain VARCHAR(128) NOT NULL DEFAULT &#39;&#39;;<br>  ALTER TABLE missed_calls ADD COLUMN src_ip varchar(64) NOT NULL default &#39;&#39;;<br>  ALTER TABLE missed_calls ADD COLUMN dst_ouser VARCHAR(64) NOT NULL DEFAULT &#39;&#39;;<br>
  ALTER TABLE missed_calls ADD COLUMN dst_user VARCHAR(64) NOT NULL DEFAULT &#39;&#39;;<br>  ALTER TABLE missed_calls ADD COLUMN dst_domain VARCHAR(128) NOT NULL DEFAULT &#39;&#39;;<br>#!endif<br><br>###!define WITH_ASTERISK<br>
###!define WITH_VOICEMAIL<br>#!define WITH_LDAP<br>#!define WITH_AUTH<br>#!define WITH_MYSQL<br>####### Defined Values #########<br><br># *** Value defines - IDs used later in config<br>#!ifdef WITH_MYSQL<br># - database URL - used to connect to database server by modules such<br>
#       as: auth_db, acc, usrloc, a.s.o.<br>#!define DBURL &quot;mysql://<a href="http://openserrw:openserrw@192.168.14.28/openser">openserrw:openserrw@192.168.14.28/openser</a>&quot;<br><br>#!ifdef WITH_ASTERISK<br>#!define DBASTURL &quot;mysql://<a href="http://asterisk:asteriskpwd@192.168.14.28/asterisk">asterisk:asteriskpwd@192.168.14.28/asterisk</a>&quot;<br>
#!endif<br><br>#!endif<br>#!ifdef WITH_MULTIDOMAIN<br># - the value for &#39;use_domain&#39; parameters<br>#!define MULTIDOMAIN 1<br>#!else<br>#!define MULTIDOMAIN 0<br>#!endif<br><br># - flags<br>#   FLT_ - per transaction (message) flags<br>
#    FLB_ - per branch flags<br>#!define FLT_ACC 1<br>#!define FLT_ACCMISSED 2<br>#!define FLT_ACCFAILED 3<br>#!define FLT_NATS 5<br><br>#!define FLB_NATB 6<br>#!define FLB_NATSIPPING 7<br><br>####### Global Parameters #########<br>
<br>#!ifdef WITH_DEBUG<br>debug=4<br>log_stderror=no<br>#!else<br>debug=2<br>log_stderror=no<br>#!endif<br><br>memdbg=5<br>memlog=5<br><br>log_facility=LOG_LOCAL6<br><br>fork=yes<br>children=4<br><br>/* uncomment the next line to disable TCP (default on) */<br>
#disable_tcp=yes<br><br>/* uncomment the next line to disable the auto discovery of local aliases<br>   based on reverse DNS on IPs (default on) */<br>auto_aliases=no<br><br>/* add local domain aliases */<br>alias=&quot;mydomain.corp&quot;<br>
<br>/* uncomment and configure the following line if you want Kamailio to <br>   bind on a specific interface/port/proto (default bind on all available) */<br>listen=tcp:<a href="http://192.168.14.24:5060">192.168.14.24:5060</a><br>
#listen=tcp:<a href="http://192.168.14.25:5060">192.168.14.25:5060</a><br><br>/* port to listen to<br> * - can be specified more than once if needed to listen on many ports */<br>#port=5060<br><br>#!ifdef WITH_TLS<br>enable_tls=yes<br>
#!endif<br><br># life time of TCP connection when there is no traffic<br># - a bit higher than registration expires to cope with UA behind NAT<br>tcp_connection_lifetime=3605<br><br>####### Custom Parameters #########<br>
<br># These parameters can be modified runtime via RPC interface<br># - see the documentation of &#39;cfg_rpc&#39; module.<br>#<br># Format: <a href="http://group.id">group.id</a> = value &#39;desc&#39; description<br># Access: $sel(<a href="http://cfg_get.group.id">cfg_get.group.id</a>) or @<a href="http://cfg_get.group.id">cfg_get.group.id</a><br>
#<br><br>#!ifdef WITH_PSTN<br># PSTN GW Routing<br>#<br># - pstn.gw_ip: valid IP or hostname as string value, example:<br># pstn.gw_ip = &quot;10.0.0.101&quot; desc &quot;My PSTN GW Address&quot;<br>#<br># - by default is empty to avoid misrouting<br>
pstn.gw_ip = &quot;&quot; desc &quot;PSTN GW Address&quot;<br>#!endif<br><br>#!ifdef WITH_VOICEMAIL<br># VoiceMail Routing on offline, busy or no answer<br>#<br># - by default Voicemail server IP is empty to avoid misrouting<br>
voicemail.srv_ip = &quot;192.168.14.32&quot; desc &quot;VoiceMail IP Address&quot;<br>voicemail.srv_port = &quot;5060&quot; desc &quot;VoiceMail Port&quot;<br>#!endif<br><br>#!ifdef WITH_ASTERISK<br>asterisk.bindip = &quot;192.168.14.32&quot; desc &quot;Asterisk IP Address&quot;<br>
asterisk.bindport = &quot;5060&quot; desc &quot;Asterisk Port&quot;<br>kamailio.bindip = &quot;192.168.14.24&quot; desc &quot;Kamailio IP Address&quot;<br>kamailio.bindport = &quot;5060&quot; desc &quot;Kamailio Port&quot;<br>
#!endif<br><br><br>####### Modules Section ########<br><br># set paths to location of modules (to sources or installation folders)<br>#!ifdef WITH_SRCPATH<br>mpath=&quot;modules_k:modules&quot;<br>#!else<br>mpath=&quot;/usr/lib/kamailio/modules_k/:/usr/lib/kamailio/modules/&quot;<br>
#!endif<br><br>#!ifdef WITH_MYSQL<br>loadmodule &quot;db_mysql.so&quot;<br>#!endif<br><br>loadmodule &quot;mi_fifo.so&quot;<br>loadmodule &quot;kex.so&quot;<br>loadmodule &quot;tm.so&quot;<br>loadmodule &quot;tmx.so&quot;<br>
loadmodule &quot;sl.so&quot;<br>loadmodule &quot;rr.so&quot;<br>loadmodule &quot;pv.so&quot;<br>loadmodule &quot;maxfwd.so&quot;<br>loadmodule &quot;usrloc.so&quot;<br>loadmodule &quot;registrar.so&quot;<br>loadmodule &quot;textops.so&quot;<br>
loadmodule &quot;siputils.so&quot;<br>loadmodule &quot;xlog.so&quot;<br># loadmodule &quot;sanity.so&quot;<br>loadmodule &quot;ctl.so&quot;<br>loadmodule &quot;cfg_rpc.so&quot;<br>loadmodule &quot;mi_rpc.so&quot;<br>loadmodule &quot;acc.so&quot;<br>
<br>#!ifdef WITH_AUTH<br>loadmodule &quot;auth.so&quot;<br>loadmodule &quot;auth_db.so&quot; #chris<br>loadmodule &quot;ldap.so&quot;<br>modparam (&quot;ldap&quot;, &quot;config_file&quot;, &quot;/etc/kamailio/ldap.cfg&quot;)<br>
#!ifdef WITH_IPAUTH<br>loadmodule &quot;permissions.so&quot;<br>#!endif<br>#!endif<br><br>#!ifdef WITH_ALIASDB<br>loadmodule &quot;alias_db.so&quot;<br>#!endif<br><br>#!ifdef WITH_SPEEDDIAL<br>loadmodule &quot;speeddial.so&quot;<br>
#!endif<br><br>#!ifdef WITH_MULTIDOMAIN<br>loadmodule &quot;domain.so&quot;<br>#!endif<br><br>#!ifdef WITH_PRESENCE<br>loadmodule &quot;presence.so&quot;<br>loadmodule &quot;presence_xml.so&quot;<br>#!endif<br><br>#!ifdef WITH_NAT<br>
loadmodule &quot;nathelper.so&quot;<br>loadmodule &quot;rtpproxy.so&quot;<br>#!endif<br><br>#!ifdef WITH_TLS<br>loadmodule &quot;tls.so&quot;<br>#!endif<br><br>#!ifdef WITH_ANTIFLOOD<br>loadmodule &quot;htable.so&quot;<br>
loadmodule &quot;pike.so&quot;<br>#!endif<br><br>#!ifdef WITH_XMLRPC<br>loadmodule &quot;xmlrpc.so&quot;<br>#!endif<br><br>#!ifdef WITH_DEBUG<br>loadmodule &quot;debugger.so&quot;<br>#!endif<br><br>#!ifdef WITH_ASTERISK<br>
loadmodule &quot;uac.so&quot;<br>#!endif<br><br><br># ----------------- setting module-specific parameters ---------------<br><br><br># ----- mi_fifo params -----<br>#modparam(&quot;mi_fifo&quot;, &quot;fifo_name&quot;, &quot;/tmp/kamailio_fifo&quot;)<br>
modparam(&quot;mi_fifo&quot;, &quot;fifo_name&quot;, &quot;/tmp/kamailio_tmp&quot;)<br><br><br># ----- tm params -----<br># auto-discard branches from previous serial forking leg<br>modparam(&quot;tm&quot;, &quot;failure_reply_mode&quot;, 3)<br>
# default retransmission timeout: 30sec<br>modparam(&quot;tm&quot;, &quot;fr_timer&quot;, 30000)<br># default invite retransmission timeout after 1xx: 120sec<br>modparam(&quot;tm&quot;, &quot;fr_inv_timer&quot;, 120000)<br>
<br># suppress the check for the CSEQ method<br># modparam(&quot;sanity&quot;, &quot;default_checks&quot;, 967)<br><br># ----- rr params -----<br># add value to ;lr param to cope with most of the UAs<br>modparam(&quot;rr&quot;, &quot;enable_full_lr&quot;, 1)<br>
# do not append from tag to the RR (no need for this script)<br>#edit asterisk<br>#!ifdef WITH_ASTERISK<br>modparam(&quot;rr&quot;, &quot;append_fromtag&quot;, 1)<br>#!else<br>modparam(&quot;rr&quot;, &quot;append_fromtag&quot;, 0)<br>
#!endif<br><br># ----- registrar params -----<br>modparam(&quot;registrar&quot;, &quot;method_filtering&quot;, 1)<br>/* uncomment the next line to disable parallel forking via location */<br># modparam(&quot;registrar&quot;, &quot;append_branches&quot;, 0)<br>
/* uncomment the next line not to allow more than 10 contacts per AOR */<br>modparam(&quot;registrar&quot;, &quot;max_contacts&quot;, 256)<br># max value for expires of registrations<br>modparam(&quot;registrar&quot;, &quot;max_expires&quot;, 3600)<br>
<br><br># ----- acc params -----<br>/* what special events should be accounted ? */<br>modparam(&quot;acc&quot;, &quot;early_media&quot;, 0)<br>modparam(&quot;acc&quot;, &quot;report_ack&quot;, 0)<br>modparam(&quot;acc&quot;, &quot;report_cancels&quot;, 0)<br>
/* by default ww do not adjust the direct of the sequential requests.<br>   if you enable this parameter, be sure the enable &quot;append_fromtag&quot;<br>   in &quot;rr&quot; module */<br>modparam(&quot;acc&quot;, &quot;detect_direction&quot;, 0)<br>
/* account triggers (flags) */<br>modparam(&quot;acc&quot;, &quot;log_flag&quot;, FLT_ACC)<br>modparam(&quot;acc&quot;, &quot;log_missed_flag&quot;, FLT_ACCMISSED)<br>modparam(&quot;acc&quot;, &quot;log_extra&quot;, <br>    &quot;src_user=$fU;src_domain=$fd;src_ip=$si;&quot;<br>
    &quot;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd&quot;)<br>modparam(&quot;acc&quot;, &quot;failed_transaction_flag&quot;, FLT_ACCFAILED)<br>/* enhanced DB accounting */<br>#!ifdef WITH_ACCDB<br>modparam(&quot;acc&quot;, &quot;db_flag&quot;, FLT_ACC)<br>
modparam(&quot;acc&quot;, &quot;db_missed_flag&quot;, FLT_ACCMISSED)<br>modparam(&quot;acc&quot;, &quot;db_url&quot;, DBURL)<br>modparam(&quot;acc&quot;, &quot;db_extra&quot;,<br>    &quot;src_user=$fU;src_domain=$fd;src_ip=$si;&quot;<br>
    &quot;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd&quot;)<br>#!endif<br><br><br># ----- usrloc params -----<br>/* enable DB persistency for location entries */<br>#!ifdef WITH_USRLOCDB<br>modparam(&quot;usrloc&quot;, &quot;db_url&quot;, DBURL)<br>
modparam(&quot;usrloc&quot;, &quot;db_mode&quot;, 2)<br>modparam(&quot;usrloc&quot;, &quot;use_domain&quot;, MULTIDOMAIN)<br>#!endif<br><br>#chris commented out this part<br># ----- auth_db params -----<br>#!ifdef WITH_AUTH<br>
modparam(&quot;auth_db&quot;, &quot;calculate_ha1&quot;, yes)<br>modparam(&quot;auth_db&quot;, &quot;load_credentials&quot;, &quot;&quot;)<br>#!ifdef WITH_ASTERISK<br>modparam(&quot;auth_db&quot;, &quot;user_column&quot;, &quot;username&quot;)<br>
modparam(&quot;auth_db&quot;, &quot;password_column&quot;, &quot;sippasswd&quot;)<br>modparam(&quot;auth_db&quot;, &quot;db_url&quot;, DBASTURL)<br>modparam(&quot;auth_db&quot;, &quot;version_table&quot;, 0)<br>#!else<br>
modparam(&quot;auth_db&quot;, &quot;db_url&quot;, DBURL)<br>modparam(&quot;auth_db&quot;, &quot;password_column&quot;, &quot;password&quot;)<br>modparam(&quot;auth_db&quot;, &quot;use_domain&quot;, MULTIDOMAIN)<br>#!endif<br>
<br># ----- permissions params -----<br>#!ifdef WITH_IPAUTH<br>modparam(&quot;permissions&quot;, &quot;db_url&quot;, DBURL)<br>modparam(&quot;permissions&quot;, &quot;db_mode&quot;, 1)<br>#!endif<br><br>#!endif<br><br><br>
# ----- alias_db params -----<br>#!ifdef WITH_ALIASDB<br>modparam(&quot;alias_db&quot;, &quot;db_url&quot;, DBURL)<br>modparam(&quot;alias_db&quot;, &quot;use_domain&quot;, MULTIDOMAIN)<br>#!endif<br><br><br># ----- speedial params -----<br>
#!ifdef WITH_SPEEDDIAL<br>modparam(&quot;speeddial&quot;, &quot;db_url&quot;, DBURL)<br>modparam(&quot;speeddial&quot;, &quot;use_domain&quot;, MULTIDOMAIN)<br>#!endif<br><br><br># ----- domain params -----<br>#!ifdef WITH_MULTIDOMAIN<br>
modparam(&quot;domain&quot;, &quot;db_url&quot;, DBURL)<br># use caching<br>modparam(&quot;domain&quot;, &quot;db_mode&quot;, 1)<br># register callback to match myself condition with domains list<br>modparam(&quot;domain&quot;, &quot;register_myself&quot;, 1)<br>
#!endif<br><br><br>#!ifdef WITH_PRESENCE<br># ----- presence params -----<br>modparam(&quot;presence&quot;, &quot;db_url&quot;, DBURL)<br><br># ----- presence_xml params -----<br>modparam(&quot;presence_xml&quot;, &quot;db_url&quot;, DBURL)<br>
modparam(&quot;presence_xml&quot;, &quot;force_active&quot;, 1)<br>#!endif<br><br><br>#!ifdef WITH_NAT<br># ----- rtpproxy params -----<br>modparam(&quot;rtpproxy&quot;, &quot;rtpproxy_sock&quot;, &quot;udp:<a href="http://192.168.14.25:22222">192.168.14.25:22222</a>&quot;)<br>
<br># ----- nathelper params -----<br>modparam(&quot;nathelper&quot;, &quot;natping_interval&quot;, 30)<br>modparam(&quot;nathelper&quot;, &quot;ping_nated_only&quot;, 1)<br>modparam(&quot;nathelper&quot;, &quot;sipping_bflag&quot;, FLB_NATSIPPING)<br>
modparam(&quot;nathelper&quot;, &quot;sipping_from&quot;, &quot;sip:pinger@teopad-toip.corp&quot;)<br><br># params needed for NAT traversal in other modules<br>modparam(&quot;nathelper|registrar&quot;, &quot;received_avp&quot;, &quot;$avp(RECEIVED)&quot;)<br>
modparam(&quot;usrloc&quot;, &quot;nat_bflag&quot;, FLB_NATB)<br>#!endif<br><br><br>#!ifdef WITH_TLS<br># ----- tls params -----<br>modparam(&quot;tls&quot;, &quot;config&quot;, &quot;/etc/kamailio/tls.cfg&quot;)<br>#!endif<br>
<br>#!ifdef WITH_ANTIFLOOD<br># ----- pike params -----<br>modparam(&quot;pike&quot;, &quot;sampling_time_unit&quot;, 2)<br>modparam(&quot;pike&quot;, &quot;reqs_density_per_unit&quot;, 16)<br>modparam(&quot;pike&quot;, &quot;remove_latency&quot;, 4)<br>
<br># ----- htable params -----<br># ip ban htable with autoexpire after 5 minutes<br>modparam(&quot;htable&quot;, &quot;htable&quot;, &quot;ipban=&gt;size=8;autoexpire=300;&quot;)<br>#!endif<br><br>#!ifdef WITH_XMLRPC<br>
# ----- xmlrpc params -----<br>modparam(&quot;xmlrpc&quot;, &quot;route&quot;, &quot;XMLRPC&quot;);<br>modparam(&quot;xmlrpc&quot;, &quot;url_match&quot;, &quot;^/RPC&quot;)<br>#!endif<br><br>#!ifdef WITH_DEBUG<br># ----- debugger params -----<br>
modparam(&quot;debugger&quot;, &quot;cfgtrace&quot;, 1)<br>#!endif<br><br>####### Routing Logic ########<br><br><br># Main SIP request routing logic<br># - processing of any incoming SIP request starts with this route<br>
# - note: this is the same as route { ... }<br>request_route {<br><br>    # per request initial checks<br>    route(REQINIT);<br>    xlog(&quot;L_INFO&quot;,&quot;apres REQINIT&quot;);<br>    <br>    # NAT detection<br>    route(NATDETECT);<br>
    xlog(&quot;L_INFO&quot;,&quot;apres NATDETECT&quot;);<br><br>    # handle requests within SIP dialogs<br>    route(WITHINDLG);<br>    xlog(&quot;L_INFO&quot;,&quot;apres WITHINDLG&quot;);<br><br>    ### only initial requests (no To tag)<br>
<br>    # CANCEL processing<br>    if (is_method(&quot;CANCEL&quot;))<br>    {<br>        if (t_check_trans())<br>            t_relay();<br>        exit;<br>    }<br><br>    t_check_trans();<br>    xlog(&quot;L_INFO&quot;,&quot;apres t_check_trans&quot;);<br>
<br>    # authentication<br>    route(AUTH);<br>    xlog(&quot;L_INFO&quot;,&quot;apres AUTH&quot;);<br><br>    # record routing for dialog forming requests (in case they are routed)<br>    # - remove preloaded route headers<br>
    remove_hf(&quot;Route&quot;);<br>    if (is_method(&quot;INVITE|SUBSCRIBE&quot;))<br>        record_route();<br>    xlog(&quot;L_INFO&quot;,&quot;apres RECORD ROUTE&quot;);<br><br>    # account only INVITEs<br>    if (is_method(&quot;INVITE&quot;))<br>
    {<br>        setflag(FLT_ACC); # do accounting<br>    }<br>    xlog(&quot;L_INFO&quot;,&quot;apres INVITE&quot;);<br><br>    # dispatch requests to foreign domains<br>    route(SIPOUT);<br>    xlog(&quot;L_INFO&quot;,&quot;apres SIPOUT&quot;);<br>
<br>    ### requests for my local domains<br><br>    # handle presence related requests<br>    route(PRESENCE);<br>    xlog(&quot;L_INFO&quot;,&quot;apres PRESENCE&quot;);<br><br>    # handle registrations<br>    route(REGISTRAR);<br>
    xlog(&quot;L_INFO&quot;,&quot;apres REGISTRAR&quot;);<br><br>    if ($rU==$null)<br>    {<br>        # request with no Username in RURI<br>        sl_send_reply(&quot;484&quot;,&quot;Address Incomplete&quot;);<br>        exit;<br>
    }<br><br>    # dispatch destinations to PSTN<br>    route(PSTN);<br>    xlog(&quot;L_INFO&quot;,&quot;apres PSTN&quot;);<br><br>    # user location service<br>    route(LOCATION);<br>    xlog(&quot;L_INFO&quot;,&quot;apres LOCATION&quot;);<br>
<br>    route(RELAY);<br>    xlog(&quot;L_INFO&quot;,&quot;apres RELAY&quot;);<br>}<br><br><br>route[RELAY] {<br><br>    # enable additional event routes for forwarded requests<br>    # - serial forking, RTP relaying handling, a.s.o.<br>
    xlog(&quot;L_INFO&quot;,&quot;Dans route relay&quot;);<br>    if (is_method(&quot;INVITE|SUBSCRIBE&quot;)) {<br>        xlog(&quot;L_INFO&quot;,&quot;avant manage branch&quot;);<br>        t_on_branch(&quot;MANAGE_BRANCH&quot;);<br>
        xlog(&quot;L_INFO&quot;,&quot;avant manage reply&quot;);<br>        t_on_reply(&quot;MANAGE_REPLY&quot;);<br>    }<br>    if (is_method(&quot;INVITE&quot;)) {<br>        xlog(&quot;L_INFO&quot;,&quot;avant manage failure&quot;);<br>
        t_on_failure(&quot;MANAGE_FAILURE&quot;);<br>    }<br><br>    if (!t_relay()) {<br>        xlog(&quot;L_INFO&quot;,&quot;reply error&quot;);<br>        sl_reply_error();<br>    }<br>    exit;<br>}<br><br># Per SIP request initial checks<br>
route[REQINIT] {<br>#!ifdef WITH_ANTIFLOOD<br>    # flood dection from same IP and traffic ban for a while<br>    # be sure you exclude checking trusted peers, such as pstn gateways<br>    # - local host excluded (e.g., loop to self)<br>
    if(src_ip!=myself)<br>    {<br>        if($sht(ipban=&gt;$si)!=$null)<br>        {<br>            # ip is already blocked<br>            xdbg(&quot;request from blocked IP - $rm from $fu (IP:$si:$sp)\n&quot;);<br>            exit;<br>
        }<br>        if (!pike_check_req())<br>        {<br>            xlog(&quot;L_ALERT&quot;,&quot;ALERT: pike blocking $rm from $fu (IP:$si:$sp)\n&quot;);<br>            $sht(ipban=&gt;$si) = 1;<br>            exit;<br>
        }<br>    }<br>#!endif<br><br>    if (!mf_process_maxfwd_header(&quot;10&quot;)) {<br>        sl_send_reply(&quot;483&quot;,&quot;Too Many Hops&quot;);<br>        exit;<br>    }<br><br>#    if(!sanity_check(&quot;1511&quot;, &quot;7&quot;))<br>
#    {<br>#        xlog(&quot;Malformed SIP message from $si:$sp\n&quot;);<br>#        exit;<br>#    }<br>}<br><br># Handle requests within SIP dialogs<br>route[WITHINDLG] {<br>    xlog(&quot;L_INFO&quot;,&quot;Dans WITHINDLG&quot;);<br>
    if (has_totag()) {<br>        xlog(&quot;L_INFO&quot;,&quot;dans has totag&quot;);<br>        # sequential request withing a dialog should<br>        # take the path determined by record-routing<br>        if (loose_route()) {<br>
            xlog(&quot;L_INFO&quot;,&quot;looseroute&quot;);<br>            if (is_method(&quot;BYE&quot;)) {<br>                setflag(FLT_ACC); # do accounting ...<br>                setflag(FLT_ACCFAILED); # ... even if the transaction fails<br>
            }<br>            if ( is_method(&quot;ACK&quot;) ) {<br>            xlog(&quot;L_INFO&quot;,&quot;ack&quot;);<br>                # ACK is forwarded statelessy<br>                route(NATMANAGE);<br>            }<br>
            xlog(&quot;L_INFO&quot;,&quot;relay&quot;);<br>            route(RELAY);<br>        } else {<br>            xlog(&quot;L_INFO&quot;,&quot;else&quot;);<br>            if (is_method(&quot;SUBSCRIBE&quot;) &amp;&amp; uri == myself) {<br>
                # in-dialog subscribe requests<br>                xlog(&quot;L_INFO&quot;,&quot;subscribe avant presence&quot;);<br>                route(PRESENCE);<br>                xlog (&quot;L_INFO&quot;,&quot;apres presence&quot;);<br>
                exit;<br>            }<br>            if ( is_method(&quot;ACK&quot;) ) {<br>                xlog(&quot;L_INFO&quot;,&quot;else ack&quot;);<br>                if ( t_check_trans() ) {<br>                    # no loose-route, but stateful ACK;<br>
                    # must be an ACK after a 487<br>                    # or e.g. 404 from upstream server<br>                xlog(&quot;L_INFO&quot;,&quot;else ack avant relay&quot;);<br>                    t_relay();<br>
                xlog(&quot;L_INFO&quot;,&quot;else ack apres relay&quot;);<br>                    exit;<br>                } else {<br>                    # ACK without matching transaction ... ignore and discard<br>                    xlog(&quot;L_INFO&quot;,&quot;else final&quot;);<br>
                    exit;<br>                }<br>            }<br>            sl_send_reply(&quot;404&quot;,&quot;Not here&quot;);<br>        }<br>        exit;<br>    }<br>}<br><br># Handle SIP registrations<br>route[REGISTRAR] {<br>
    if (is_method(&quot;REGISTER&quot;))<br>    {<br>        if(isflagset(FLT_NATS))<br>        {<br>            setbflag(FLB_NATB);<br>            # uncomment next line to do SIP NAT pinging <br>             setbflag(FLB_NATSIPPING);<br>
        }<br>        if (!save(&quot;location&quot;))<br>            sl_reply_error();<br>#edit asterisk<br>#!ifdef WITH_ASTERISK<br>        xlog (&quot;L_INFO&quot;,&quot;avant regfwd dans registrar&quot;);<br>        route(REGFWD);<br>
        xlog (&quot;L_INFO&quot;,&quot;apres regfwd dans registrar&quot;);<br><br>#!endif<br><br>        exit;<br>    }<br>}<br><br># USER location service<br>route[LOCATION] {<br><br>#!ifdef WITH_SPEEDIAL<br>    # search for short dialing - 2-digit extension<br>
    if($rU=~&quot;^[0-9][0-9]$&quot;)<br>        if(sd_lookup(&quot;speed_dial&quot;))<br>            route(SIPOUT);<br>#!endif<br><br>#!ifdef WITH_ALIASDB<br>    # search in DB-based aliases<br>    if(alias_db_lookup(&quot;dbaliases&quot;))<br>
        route(SIPOUT);<br>#!endif<br><br>#edit asterisk<br>#!ifdef WITH_ASTERISK<br>    if(is_method(&quot;INVITE&quot;) &amp;&amp; (!route(FROMASTERISK))) {<br>        #if new call from out there - send to Asterisk<br>        # - non-INVITE requests are routed directly by Kamailio<br>
        # - traffic from Asterisk is router also directly by Kamailio<br>        xlog (&quot;L_INFO&quot;, &quot;avant toasterisk dans location&quot;);<br>        route(TOASTERISK);<br>        xlog (&quot;L_INFO&quot;, &quot;apres toasterisk dans location&quot;);<br>
        exit;<br>    }<br>#!endif<br>    $avp(oexten) = $rU;<br>    if (!lookup(&quot;location&quot;)) {<br>        $var(rc) = $rc;<br>        route(TOVOICEMAIL);<br>        t_newtran();<br>        switch ($var(rc)) {<br>
            case -1:<br>            case -3:<br>                send_reply(&quot;404&quot;, &quot;Not Found&quot;);<br>                exit;<br>            case -2:<br>                send_reply(&quot;405&quot;, &quot;Method Not Allowed&quot;);<br>
                exit;<br>        }<br>    }<br><br>    # when routing via usrloc, log the missed calls also<br>    if (is_method(&quot;INVITE&quot;))<br>    {<br>        setflag(FLT_ACCMISSED);<br>    }<br>}<br><br># Presence server route<br>
route[PRESENCE] {<br>    if(!is_method(&quot;PUBLISH|SUBSCRIBE&quot;))<br>        return;<br><br>#!ifdef WITH_PRESENCE<br>    if (!t_newtran())<br>    {<br>        sl_reply_error();<br>        exit;<br>    };<br><br>    if(is_method(&quot;PUBLISH&quot;))<br>
    {<br>        handle_publish();<br>        t_release();<br>    }<br>    else<br>    if( is_method(&quot;SUBSCRIBE&quot;))<br>    {<br>        handle_subscribe();<br>        t_release();<br>    }<br>    exit;<br>#!endif<br>
    <br>    # if presence enabled, this part will not be executed<br>    if (is_method(&quot;PUBLISH&quot;) || $rU==$null)<br>    {<br>        sl_send_reply(&quot;404&quot;, &quot;Not here&quot;);<br>        exit;<br>    }<br>
    return;<br>}<br><br># Authentication route<br>route[AUTH] {<br>#!ifdef WITH_AUTH<br><br>#edit asterisk<br>#!ifdef WITH_ASTERISK<br>    #do not auth traffic from Asterisk: trusted!<br>    xlog (&quot;L_INFO&quot;, &quot;avant if route fromasterisk&quot;);<br>
    if(route(FROMASTERISK))<br>        return;<br>#!endif<br><br>    if (is_method(&quot;REGISTER&quot;))<br>#    {<br>#        # authenticate the REGISTER requests (uncomment to enable auth)<br>#        if (!www_authorize(&quot;$td&quot;, &quot;subscriber&quot;))<br>
#        {<br>#            www_challenge(&quot;$td&quot;, &quot;0&quot;);<br>#            exit;<br>#        }<br>#<br>#        if ($au!=$tU)<br>#        {<br>#            sl_send_reply(&quot;403&quot;,&quot;Forbidden auth ID&quot;);<br>
#            exit;<br>#        }<br><br>    {<br><br>#edit asterisk<br>##!ifdef WITH_ASTERISK<br>#    xlog (&quot;L_INFO&quot;, &quot;dans auth / authcheck sipusers&quot;);<br>#    if (!auth_check(&quot;$fd&quot;,&quot;sipusers&quot;,&quot;1&quot;)) <br>
##!else<br>        if(is_present_hf(&quot;Authorization&quot;))<br>##!endif<br><br>        {<br>            # ldap search<br>           if (!ldap_search(&quot;ldap://sipaccounts/OU=SIP,OU=Utilisateurs,DC=teopad-toip,DC=corp?teopad-Sip-Username,teopadSipPassword?one?(teopad-Sip-Username=$fU)&quot;))<br>
#           if (!ldap_search(&quot;ldap://sipaccounts/OU=SIP,OU=Utilisateurs,DC=teopad-toip,DC=corp?sAMAccountName,?one?(sAMAccountName=$fU)&quot;))<br>            {<br>                switch ($retcode)<br>                {<br>
                    case -1:<br>                       # no LDAP entry found<br>                       sl_send_reply(&quot;404&quot;, &quot;User Not Found&quot;);<br>                    xlog(&quot;L_INFO&quot;, &quot;ldap_search: NO found [$retcode] entries for (uid=$fU)&quot;);<br>
                       exit;<br><br>                    case -2:<br>                       # internal error<br>                       sl_send_reply(&quot;500&quot;, &quot;Internal server error&quot;);<br>                       exit;<br>
                    <br>            default:<br>                       exit;<br>                }<br>            }<br>            ldap_result(&quot;teopad-Sip-Username/$avp(s:username)&quot;);<br>            ldap_result(&quot;teopadSipPassword/$avp(s:password)&quot;);<br>
            xlog(&quot;L_INFO&quot;, &quot;ldap_search: found [$retcode] entries for (uid=$fU)&quot;);<br>            if(!pv_www_authenticate(&quot;$td&quot;, &quot;$avp(s:password)&quot;, &quot;0&quot;)) {<br>        xlog (&quot;L_INFO&quot;, &quot;ldap pv_authenticate failed&quot;) ;<br>
                www_challenge(&quot;$td&quot;,&quot;1&quot;);<br>                exit;<br>            }<br>        save(&quot;location&quot;);<br>            sl_send_reply(&quot;200&quot;, &quot;ok&quot;);<br>        xlog (&quot;L_INFO&quot;, &quot;ldap pv_authenticate ok&quot;) ;<br>
            exit;<br>        } else {<br>            www_challenge(&quot;$td&quot;,&quot;1&quot;);<br>            exit;<br>        }<br><br><br><br><br>    } else {<br><br>#!ifdef WITH_IPAUTH<br>        if(allow_source_address())<br>
        {<br>            # source IP allowed<br>            return;<br>        }<br>#!endif<br><br>#        # authenticate if from local subscriber<br>        if (from_uri==myself)<br>        {<br>#            if (!proxy_authorize(&quot;$fd&quot;, &quot;subscriber&quot;)) {<br>
#                proxy_challenge(&quot;$fd&quot;, &quot;0&quot;);<br>#                exit;<br>#            }<br>            if (is_method(&quot;PUBLISH&quot;))<br>            {<br>                xlog (&quot;L_INFO&quot;, &quot;au = $au&quot;) ;<br>
                xlog (&quot;L_INFO&quot;, &quot;fU = $fU&quot;) ;<br>                xlog (&quot;L_INFO&quot;, &quot;tU = $tU&quot;) ;<br>                xlog (&quot;L_INFO&quot;, &quot;fd = $fd&quot;) ;<br>                xlog (&quot;L_INFO&quot;, &quot;rd = $rd&quot;) ;<br>
                <br>                if ($au!=$fU || $au!=$tU) {<br>                    sl_send_reply(&quot;403&quot;,&quot;Forbidden auth ID au!=fu ou au!=tu&quot;);<br>                    exit;<br>                }<br>                if ($au!=$rU) {<br>
                    sl_send_reply(&quot;403&quot;,&quot;Forbidden R-URI&quot;);<br>                    exit;<br>                }<br>#!ifdef WITH_MULTIDOMAIN<br>                if ($fd!=$rd) {<br>                    sl_send_reply(&quot;403&quot;,&quot;Forbidden R-URI domain&quot;);<br>
                    exit;<br>                }<br>#!endif<br>            } else {<br>                xlog (&quot;L_INFO&quot;, &quot;au = $au&quot;) ;<br>                xlog (&quot;L_INFO&quot;, &quot;fU = $fU&quot;) ;<br>
            #    if ($au!=$fU) {<br>            #        sl_send_reply(&quot;403&quot;,&quot;Forbidden auth ID au!=fu&quot;);<br>            #        exit;<br>            #    }<br>            }<br><br>            #consume_credentials();<br>
            # caller authenticated<br>        } else {<br>            # caller is not local subscriber, then check if it calls<br>            # a local destination, otherwise deny, not an open relay here<br>            if (!uri==myself)<br>
            {<br>                sl_send_reply(&quot;403&quot;,&quot;Not relaying&quot;);<br>                exit;<br>            }<br>        }<br>    }<br>#!endif<br>    return;<br>}<br><br># Caller NAT detection route<br>
route[NATDETECT] {<br>#!ifdef WITH_NAT<br>    force_rport();<br>    if (nat_uac_test(&quot;19&quot;)) {<br>        if (is_method(&quot;REGISTER&quot;)) {<br>            fix_nated_register();<br>        } else {<br>            fix_nated_contact();<br>
        }<br>        setflag(FLT_NATS);<br>    }<br>#!endif<br>    return;<br>}<br><br># RTPProxy control<br>route[NATMANAGE] {<br>#!ifdef WITH_NAT<br>    if (is_request()) {<br>        if(has_totag()) {<br>            if(check_route_param(&quot;nat=yes&quot;)) {<br>
                setbflag(FLB_NATB);<br>            }<br>        }<br>    }<br>    if (!(isflagset(FLT_NATS) || isbflagset(FLB_NATB)))<br>        return;<br><br>    rtpproxy_manage();<br>    #rtpproxy_manage(&quot;co&quot;,&quot;82.127.95.167&quot;);<br>
<br>    if (is_request()) {<br>        if (!has_totag()) {<br>            add_rr_param(&quot;;nat=yes&quot;);<br>        }<br>    }<br>    if (is_reply()) {<br>        if(isbflagset(FLB_NATB)) {<br>            fix_nated_contact();<br>
        }<br>    }<br>#!endif<br>    return;<br>}<br><br># Routing to foreign domains<br>route[SIPOUT] {<br>    if (!uri==myself)<br>    {<br>        append_hf(&quot;P-hint: outbound\r\n&quot;);<br>        route(RELAY);<br>
    }<br>}<br><br># PSTN GW routing<br>route[PSTN] {<br>#!ifdef WITH_PSTN<br>    # check if PSTN GW IP is defined<br>    if (strempty($sel(cfg_get.pstn.gw_ip))) {<br>        xlog(&quot;SCRIPT: PSTN rotuing enabled but pstn.gw_ip not defined\n&quot;);<br>
        return;<br>    }<br><br>    # route to PSTN dialed numbers starting with &#39;+&#39; or &#39;00&#39;<br>    #     (international format)<br>    # - update the condition to match your dialing rules for PSTN routing<br>
    if(!($rU=~&quot;^(\+|00)[1-9][0-9]{3,20}$&quot;))<br>        return;<br><br>    # only local users allowed to call<br>    if(from_uri!=myself) {<br>        sl_send_reply(&quot;403&quot;, &quot;Not Allowed&quot;);<br>        exit;<br>
    }<br><br>    $ru = &quot;sip:&quot; + $rU + &quot;@&quot; + $sel(cfg_get.pstn.gw_ip);<br><br>    route(RELAY);<br>    exit;<br>#!endif<br><br>    return;<br>}<br><br># XMLRPC routing<br>#!ifdef WITH_XMLRPC<br>route[XMLRPC] {<br>
    # allow XMLRPC from localhost<br>    if ((method==&quot;POST&quot; || method==&quot;GET&quot;)<br>            &amp;&amp; (src_ip==127.0.0.1)) {<br>        # close connection only for xmlrpclib user agents (there is a bug in<br>
        # xmlrpclib: it waits for EOF before interpreting the response).<br>        if ($hdr(User-Agent) =~ &quot;xmlrpclib&quot;)<br>            set_reply_close();<br>        set_reply_no_connect();<br>        dispatch_rpc();<br>
        exit;<br>    }<br>    send_reply(&quot;403&quot;, &quot;Forbidden&quot;);<br>    exit;<br>}<br>#!endif<br><br># route to voicemail server<br>route[TOVOICEMAIL] {<br>#!ifdef WITH_VOICEMAIL<br>    if(!is_method(&quot;INVITE&quot;))<br>
        return;<br><br>    # check if VoiceMail server IP is defined<br>    if (strempty($sel(cfg_get.voicemail.srv_ip))) {<br>        xlog(&quot;SCRIPT: VoiceMail rotuing enabled but IP not defined\n&quot;);<br>        return;<br>
    }<br>    if($avp(oexten)==$null)<br>        return;<br><br>    $ru = &quot;tcp:&quot; + $avp(oexten) + &quot;@&quot; + $sel(cfg_get.voicemail.srv_ip)<br>                + &quot;:&quot; + $sel(cfg_get.voicemail.srv_port);<br>
    xlog(&quot;L_INFO&quot;,&quot;tovoicemail ru: $ru&quot;);<br>    route(RELAY);<br>    exit;<br>#!endif<br><br>    return;<br>}<br><br># manage outgoing branches<br>branch_route[MANAGE_BRANCH] {<br>    xdbg(&quot;new branch [$T_branch_idx] to $ru\n&quot;);<br>
    route(NATMANAGE);<br>}<br><br># manage incoming replies<br>onreply_route[MANAGE_REPLY] {<br>    xlog(&quot;L_INFO&quot;,&quot;dans managereply&quot;);<br>    xdbg(&quot;incoming reply\n&quot;);<br>    if(status=~&quot;[12][0-9][0-9]&quot;){<br>
        xlog(&quot;L_INFO&quot;,&quot;avant route natmanage&quot;);<br>        route(NATMANAGE);<br>    }<br>}<br><br># manage failure routing cases<br>failure_route[MANAGE_FAILURE] {<br>    route(NATMANAGE);<br><br>    if (t_is_canceled()) {<br>
        exit;<br>    }<br><br>#!ifdef WITH_BLOCK3XX<br>    # block call redirect based on 3xx replies.<br>    if (t_check_status(&quot;3[0-9][0-9]&quot;)) {<br>        t_reply(&quot;404&quot;,&quot;Not found&quot;);<br>        exit;<br>
    }<br>#!endif<br><br>#!ifdef WITH_VOICEMAIL<br>    # serial forking<br>    # - route to voicemail on busy or no answer (timeout)<br>    if (t_check_status(&quot;486|408&quot;)) {<br>        route(TOVOICEMAIL);<br>        exit;<br>
    }<br>#!endif<br>}<br><br>#edit asterisk<br>#!ifdef WITH_ASTERISK<br># Test if coming from Asterisk<br>route[FROMASTERISK] {<br>    xlog (&quot;L_INFO&quot;, &quot;Dans FROMASTERISK? $si / $sp&quot;);<br>    if($si==$sel(cfg_get.asterisk.bindip)<br>
            &amp;&amp; $sp==$sel(cfg_get.asterisk.bindport))<br>        return 1;<br>    return -1;<br>}<br> <br># Send to Asterisk<br>route[TOASTERISK] {<br>    $du = &quot;sip:&quot; + $sel(cfg_get.asterisk.bindip) + &quot;:&quot;<br>
            + $sel(cfg_get.asterisk.bindport);<br>    xlog (&quot;L_INFO&quot;, &quot;Dans TOASTERISK $du&quot;) ;<br>    xlog (&quot;L_INFO&quot;, &quot;Juste avant route relay&quot;);<br>    route(RELAY);<br>    exit;<br>
}<br> <br># Forward REGISTER to Asterisk<br>route[REGFWD] {<br>    xlog(&quot;L_INFO&quot;, &quot;Dans REGFWD&quot;);<br>    if(!is_method(&quot;REGISTER&quot;))<br>    {<br>        return;<br>    }<br>    $var(rip) = $sel(cfg_get.asterisk.bindip);<br>
    $uac_req(method)=&quot;REGISTER&quot;;<br>    $uac_req(ruri)=&quot;sip:&quot; + $var(rip) + &quot;:&quot; + $sel(cfg_get.asterisk.bindport);<br>    $uac_req(furi)=&quot;sip:&quot; + $au + &quot;@&quot; + $var(rip);<br>
    $uac_req(turi)=&quot;sip:&quot; + $au + &quot;@&quot; + $var(rip);<br>    $uac_req(hdrs)=&quot;Contact: &lt;sip:&quot; + $au + &quot;@&quot;<br>                + $sel(cfg_get.kamailio.bindip)<br>                + &quot;:&quot; + $sel(cfg_get.kamailio.bindport) + &quot;&gt;\r\n&quot;;<br>
    xlog(&quot;L_INFO&quot;,&quot;avant if dans regfwd&quot;);<br>    if($sel(contact.expires) != $null)<br>        $uac_req(hdrs)= $uac_req(hdrs) + &quot;Expires: &quot; + $sel(contact.expires) + &quot;\r\n&quot;;<br>    else<br>
        $uac_req(hdrs)= $uac_req(hdrs) + &quot;Expires: &quot; + $hdr(Expires) + &quot;\r\n&quot;;<br>    uac_req_send();<br>}<br>#!endif<br><br><br><br>