<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">I have one Kamailio that makes an outbound register on two Asterisk.<br></div><div dir="ltr">I have a dispatcher with that same two Asterisk destinations, on INVITE message I call replace_from("", ) in order<div>to call a internal extension and on failure route I receive 401 and call </div><div><br></div><div>the process of authorization is OK.</div><div><br></div><div>The problem is that if the first Asterisk fail and I get 500 on failure route I can not call replace_from() because</div><div>is not valid on the block.</div><div><br></div><div>Is there any way to make this type of authorization process after receiving a 500 on failure route of dispatcher ?</div><div><br></div><div>Below my cfg file.<br></div><div><br></div><div>Thanks in advance.</div><div>Antonio Couto</div><div><br></div><div><pre style="box-sizing:border-box;margin-top:0px;margin-bottom:0px;padding:0.5em;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;font-size:14px;line-height:inherit;font-family:"Courier New",Courier,monospace;vertical-align:baseline;width:2000px;overflow-x:auto;background:rgb(240,240,240);color:rgb(68,68,68)"><span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)">#!KAMAILIO</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)">#!ifdef WITH_DEBUG</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)">#!define DBGLEVEL 3</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)">#!else</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)">#!define DBGLEVEL 2</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)">#!endif</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># - flags</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># FLT_ - per transaction (message) flags</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># FLB_ - per branch flags</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)">#!define FLT_ACC 1</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)">#!define FLT_ACCMISSED 2</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)">#!define FLT_ACCFAILED 3</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)">#!define FLT_NATS 5</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)">#!define FLB_NATB 6</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)">#!define FLB_NATSIPPING 7</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)">####### Global Parameters #########</span>
/* LOG Levels: 3=DBG, 2=INFO, 1=NOTICE, 0=WARN, -1=ERR, ... */
debug=DBGLEVEL
/* <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(57,115,0)">set</span> to <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">'yes'</span> to <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(57,115,0)">print</span> <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(57,115,0)">log</span> messages to terminal or use <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">'-E'</span> cli option */
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(57,115,0)">log</span>_stderror=no
memdbg=5
memlog=5
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(57,115,0)">log</span>_facility=LOG_LOCAL0
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(57,115,0)">log</span>_prefix=<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"{<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$mt</span> <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$hdr</span>(CSeq) <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$ci</span>} "</span>
children=8
auto_aliases=no
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(57,115,0)">enable</span>_tls=no
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(57,115,0)">enable</span>_sctp=no
tcp_accept_no_cl=yes
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># SIP port</span>
listen=udp:<a href="http://192.168.0.201:5060" target="_blank">192.168.0.201:5060</a>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># xhttp port</span>
listen=tcp:<a href="http://127.0.0.1:8181" target="_blank">127.0.0.1:8181</a>
loadmodule <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"xhttp.so"</span>
loadmodule <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"jsonrpcs.so"</span>
loadmodule <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"kex.so"</span>
loadmodule <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"corex.so"</span>
loadmodule <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"tm.so"</span>
loadmodule <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"tmx.so"</span>
loadmodule <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"sl.so"</span>
loadmodule <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"rr.so"</span>
loadmodule <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"pv.so"</span>
loadmodule <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"maxfwd.so"</span>
loadmodule <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"textops.so"</span>
loadmodule <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"siputils.so"</span>
loadmodule <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"xlog.so"</span>
loadmodule <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"sanity.so"</span>
loadmodule <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"ctl.so"</span>
loadmodule <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"acc.so"</span>
loadmodule <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"dispatcher.so"</span>
loadmodule <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"htable.so"</span>
loadmodule <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"db_text.so"</span>
loadmodule <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"dialog.so"</span>
loadmodule <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"uac.so"</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># ----------------- setting module-specific parameters ---------------</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># ----- jsonrpcs params -----</span>
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"jsonrpcs"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"pretty_format"</span>, 1)
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"jsonrpcs"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"transport"</span>, 1)
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># ----- sanity params -----</span>
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"sanity"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"autodrop"</span>, 0)
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># ----- tm params -----</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># default retransmission timeout: 2sec</span>
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"tm"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"fr_timer"</span>, 1500)
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># default invite retransmission timeout after 1xx: 40sec</span>
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"tm"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"fr_inv_timer"</span>, 40000)
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># ----- rr params -----</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># set next param to 1 to add value to ;lr param (helps with some UAs)</span>
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"rr"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"enable_full_lr"</span>, 0)
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"rr"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"append_fromtag"</span>, 1)
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># account triggers (flags)</span>
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"acc"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"log_flag"</span>, FLT_ACC)
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"acc"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"failed_transaction_flag"</span>, FLT_ACCFAILED)
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"acc"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"log_extra"</span>,
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"src_user=<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$fU</span>;src_domain=<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$fd</span>;src_ip=<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$si</span>;"</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"dst_ouser=<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$tU</span>;dst_user=<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$rU</span>;dst_domain=<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$rd</span>"</span>)
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># ----- dispatcher params -----</span>
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"dispatcher"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"list_file"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"/etc/kamailio/dispatcher.list"</span>)
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"dispatcher"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"flags"</span>, 2)
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"dispatcher"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"xavp_dst"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"_dsdst_"</span>)
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"dispatcher"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"xavp_ctx"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"_dsctx_"</span>)
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"dispatcher"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"ds_ping_method"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"OPTIONS"</span>)
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"dispatcher"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"ds_ping_from"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"<a href="mailto:sip%3Aproxy@kamailio.org" target="_blank">sip:proxy@kamailio.org</a>"</span>)
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"dispatcher"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"ds_ping_interval"</span>, 1)
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"dispatcher"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"ds_probing_mode"</span>, 1)
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"dispatcher"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"ds_probing_threshold"</span>, 1)
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"dispatcher"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"ds_inactive_threshold"</span>, 1)
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"dispatcher"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"ds_timer_mode"</span>, 1)
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"db_text"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"db_mode"</span>, 1)
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"db_text"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"emptystring"</span>, 1)
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"dialog"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"dlg_flag"</span>, 4)
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"dialog"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"track_cseq_updates"</span>, 1)
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"uac"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"restore_dlg"</span>, 1)
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"uac"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"reg_db_url"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"text:///etc/kamailio/dbtext"</span>)
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"uac"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"reg_db_table"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"uacreg"</span>)
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"uac"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"reg_timer_interval"</span>, 60)
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"uac"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"reg_retry_interval"</span>, 60)
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"uac"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"reg_contact_addr"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"<a href="http://192.168.0.201:5060" target="_blank">192.168.0.201:5060</a>"</span>)
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"uac"</span>,<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"auth_username_avp"</span>,<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$avp</span>(auser)"</span>)
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"uac"</span>,<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"auth_password_avp"</span>,<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$avp</span>(apass)"</span>)
modparam(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"uac"</span>,<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"auth_realm_avp"</span>,<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$avp</span>(arealm)"</span>)
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)">####### Routing Logic ########</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># main request routing logic</span>
request_route {
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># per request initial checks</span>
route(REQINIT);
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># CANCEL processing</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span> (is_method(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"CANCEL"</span>)) {
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span> (t_check_trans()) {
route(RELAY);
}
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(57,115,0)">exit</span>;
}
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># handle retransmissions</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span> (!is_method(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"ACK"</span>)) {
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span>(t_precheck_trans()) {
t_check_trans();
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(57,115,0)">exit</span>;
}
t_check_trans();
}
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># handle requests within SIP dialogs</span>
route(WITHINDLG);
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># record routing for dialog forming requests (in case they are routed)</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># - remove preloaded route headers</span>
remove_hf(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"Route"</span>);
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span> (is_method(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"INVITE|SUBSCRIBE"</span>)) {
record_route();
}
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># account only INVITEs</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span> (is_method(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"INVITE"</span>)) {
setflag(FLT_ACC); <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># do accounting</span>
}
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span> (<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$rU</span>==<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$null</span>) {
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># request with no Username in RURI</span>
sl_send_reply(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"484"</span>,<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"Address Incomplete"</span>);
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(57,115,0)">exit</span>;
}
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># dispatch destinations</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span> (is_method(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"INVITE"</span>)) {
route(DISPATCH);
}
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">else</span> {
sl_send_reply(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"501"</span>,<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"Not Implemented"</span>);
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(57,115,0)">exit</span>;
}
}
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># Dispatch requests</span>
route[DISPATCH] {
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span> (<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$si</span> == <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"192.168.0.44"</span> and <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$sp</span> == 5060) {
xlog(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"L_ALERT"</span>,<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"from switch <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$si</span>:<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$sp</span>)\n"</span>);
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$var</span>(groupid) = <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"2"</span>;
}
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">else</span>{
xlog(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"L_ALERT"</span>,<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"from others <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$si</span>:<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$sp</span>)\n"</span>);
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$var</span>(groupid) = <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"1"</span>;
}
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span>(!ds_select_dst(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$var</span>(groupid), <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"11"</span>)) {
send_reply(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"503"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"Service Unavailable"</span>);
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(57,115,0)">exit</span>;
}
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span> (<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$du</span> =~ <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"192.168.0.210"</span>) {
xlog(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"L_ALERT"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"SCRIPT: uac_replace_from\n"</span>);
uac_replace_from(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">""</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"<a href="http://sip:4000@192.168.0.201:5060" target="_blank">sip:4000@192.168.0.201:5060</a>"</span>);
}
xlog(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"L_ALERT"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"SCRIPT: going to <<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$ru</span>> via <<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$du</span>> (attrs: <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$xavp</span>(_dsdst_=>attrs))\n"</span>);
t_on_failure(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"RTF_DISPATCH"</span>);
route(RELAY);
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(57,115,0)">exit</span>;
}
failure_route[RTF_DISPATCH] {
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$var</span>(ts) = t_get_status_code();
xlog(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"L_ALERT"</span>,<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"ALERT: failure_route[RTF_DISPATCH]] from <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$si</span>:<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$rp</span> status:<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$var</span>(ts)\n"</span>);
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span> (t_is_canceled()) {
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(57,115,0)">exit</span>;
}
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span>(t_check_status(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"401|407"</span>)) {
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$avp</span>(auser) = <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"4000"</span>;
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$avp</span>(apass) = <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"1234"</span>;
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$avp</span>(arealm) = <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"asterisk"</span>;
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span> (uac_auth()) {
route(RELAY);
}
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(57,115,0)">exit</span>;
}
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span> (t_check_status(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"500"</span>) or (t_branch_timeout() and !t_branch_replied())) {
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span> (ds_next_dst()) {
xlog(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"L_ALERT"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"retrying to <<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$ru</span>> via <<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$du</span>> (attrs: <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$xavp</span>(_dsdst_=>attrs))\n"</span>);
t_on_failure(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"RTF_DISPATCH"</span>);
route(RELAY);
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(57,115,0)">exit</span>;
}
}
}
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># Per SIP request initial checks</span>
route[REQINIT] {
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span>(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$ua</span> =~ <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"friendly|scanner|sipcli|sipvicious|VaxSIPUserAgent"</span>) {
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># silent drop for scanners - uncomment next line if want to reply</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># sl_send_reply("200", "OK");</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(57,115,0)">exit</span>;
}
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span> (!mf_process_maxfwd_header(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"10"</span>)) {
sl_send_reply(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"483"</span>,<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"Too Many Hops"</span>);
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(57,115,0)">exit</span>;
}
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span>(is_method(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"OPTIONS"</span>) && uri==myself && <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$rU</span>==<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$null</span>) {
sl_send_reply(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"200"</span>,<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"Keepalive"</span>);
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(57,115,0)">exit</span>;
}
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span>(!sanity_check(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"17895"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"7"</span>)) {
xlog(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"Malformed SIP request from <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$si</span>:<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$sp</span>\n"</span>);
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(57,115,0)">exit</span>;
}
}
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># Handle requests within SIP dialogs</span>
route[WITHINDLG] {
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span> (!has_totag()) {
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(57,115,0)">return</span>;
}
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># sequential request withing a dialog should</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># take the path determined by record-routing</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span> (loose_route()) {
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span> (is_method(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"BYE"</span>)) {
setflag(FLT_ACC); <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># do accounting ...</span>
setflag(FLT_ACCFAILED); <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># ... even if the transaction fails</span>
}
route(RELAY);
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(57,115,0)">exit</span>;
}
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span> (is_method(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"ACK"</span>)) {
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span> (t_check_trans()) {
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># no loose-route, but stateful ACK;</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># must be an ACK after a 487</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># or e.g. 404 from upstream server</span>
route(RELAY);
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(57,115,0)">exit</span>;
} <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">else</span> {
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># ACK without matching transaction ... ignore and discard</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(57,115,0)">exit</span>;
}
}
sl_send_reply(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"500"</span>,<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"Server Internal Error"</span>);
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(57,115,0)">exit</span>;
}
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># Wrapper for relaying requests</span>
route[RELAY] {
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># enable additional event routes for forwarded requests</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># - serial forking, RTP relaying handling, a.s.o.</span>
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span> (is_method(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"INVITE|BYE|SUBSCRIBE|UPDATE"</span>)) {
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span>(!t_is_<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(57,115,0)">set</span>(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"branch_route"</span>)) t_on_branch(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"MANAGE_BRANCH"</span>);
}
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span> (is_method(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"INVITE|SUBSCRIBE|UPDATE"</span>)) {
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span>(!t_is_<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(57,115,0)">set</span>(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"onreply_route"</span>)) t_on_reply(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"MANAGE_REPLY"</span>);
}
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span> (is_method(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"INVITE"</span>)) {
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span>(!t_is_<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(57,115,0)">set</span>(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"failure_route"</span>)) t_on_failure(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"MANAGE_FAILURE"</span>);
}
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span> (!t_relay()) {
sl_reply_error();
}
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(57,115,0)">exit</span>;
}
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,136,136)"># jsonrpc dispatch</span>
event_route[xhttp:request] {
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">if</span> (<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$hu</span> =~ <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"^/RPC"</span>) {
jsonrpc_dispatch();
}
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:700;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline">else</span> {
xhttp_reply(<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"200"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"OK"</span>, <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"text/html"</span>,
<span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(136,0,0)">"<html><body>Wrong URL <span style="box-sizing:border-box;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(188,96,96)">$hu</span></body></html>"</span>);
}
}</pre></div><div><br></div><div></div></div>
</div></div>