Resources.PuaXmppConfig History

Hide minor edits - Show changes to output

May 09, 2013, at 01:48 PM by 109.99.235.212 -
Changed lines 1-5 from:
[[Resources.PuaExtensions#pua_xmpp | <-Back]]

[[http://opensips.org/uploads/Resources/opensips_xmpp.cfg| Download]]

<pre><span style="color: #800;"># OpenSIPS SIP-XMPP Gateway</span><span style="color: #000;"><br><br>debug</span><span style="color: #660;">=</span><span style="color: #066;">3</span><span style="color: #000;"><br>log_stderror</span><span style="color: #660;">=</span><span style="color: #008;">no</span><span style="color: #000;"><br>log_facility</span><span style="color: #660;">=</span><span style="color: #000;">LOG_LOCAL0<br><br>fork</span><span style="color: #660;">=</span><span style="color: #000;">yes<br>children</span><span style="color: #660;">=</span><span style="color: #066;">4</span><span style="color: #000;"><br><br>listen</span><span style="color: #660;">=</span><span style="color: #000;">udp</span><span style="color: #660;">:</span><span style="color: #066;">10.10.10.10</span><span style="color: #660;">:</span><span style="color: #066;">5060</span><span style="color: #000;"><br></span><span style="color: #008;">alias</span><span style="color: #660;">=</span><span style="color: #080;">"sip.domain.com"</span><span style="color: #000;"><br><br></span><span style="color: #800;"># ------------------ module loading ----------------------------------</span><span style="color: #000;"><br><br>mpath</span><span style="color: #660;">=</span><span style="color: #080;">"/usr/local/lib/opensips/modules/"</span><span style="color: #000;"><br><br>loadmodule </span><span style="color: #080;">"db_mysql.so"</span><span style="color: #000;"><br>loadmodule </span><span style="color: #080;">"textops.so"</span><span style="color: #000;"><br>loadmodule </span><span style="color: #080;">"maxfwd.so"</span><span style="color: #000;"><br>loadmodule </span><span style="color: #080;">"rr.so"</span><span style="color: #000;"><br>loadmodule </span><span style="color: #080;">"sl.so"</span><span style="color: #000;"><br>loadmodule </span><span style="color: #080;">"tm.so"</span><span style="color: #000;"><br>loadmodule </span><span style="color: #080;">"signaling.so"</span><span style="color: #000;"><br>loadmodule </span><span style="color: #080;">"usrloc.so"</span><span style="color: #000;"><br>loadmodule </span><span style="color: #080;">"registrar.so"</span><span style="color: #000;"><br>loadmodule </span><span style="color: #080;">"mi_fifo.so"</span><span style="color: #000;"><br>loadmodule </span><span style="color: #080;">"uri.so"</span><span style="color: #000;"><br><br>loadmodule </span><span style="color: #080;">"xmpp.so"</span><span style="color: #000;"><br>loadmodule </span><span style="color: #080;">"pua.so"</span><span style="color: #000;"><br>loadmodule </span><span style="color: #080;">"pua_xmpp.so"</span><span style="color: #000;"><br>loadmodule </span><span style="color: #080;">"presence.so"</span><span style="color: #000;"><br>loadmodule </span><span style="color: #080;">"presence_xml.so"</span><span style="color: #000;"><br><br></span><span style="color: #800;"># ----------------- setting module-specific parameters ---------------</span><span style="color: #000;"><br>modparam</span><span style="color: #660;">(</span><span style="color: #080;">"usrloc|presence|presence_xml|pua"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"db_url"</span><span style="color: #660;">,</span><span style="color: #000;"> &nbsp;</span><span style="color: #080;">"mysql://opensips:opensipsrw@localhost/opensips"</span><span style="color: #660;">)</span><span style="color: #000;"><br>modparam</span><span style="color: #660;">(</span><span style="color: #080;">"presence|pua_xmpp"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"server_address"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"sip:sa@10.10.10.10:5060"</span><span style="color: #660;">)</span><span style="color: #000;"><br>modparam</span><span style="color: #660;">(</span><span style="color: #080;">"presence_xml"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"force_active"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #066;">1</span><span style="color: #660;">)</span><span style="color: #000;"><br>modparam</span><span style="color: #660;">(</span><span style="color: #080;">"pua_xmpp"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"presence_server"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"sip:sa@10.10.10.10:5060"</span><span style="color: #660;">)</span><span style="color: #000;"><br><br>modparam</span><span style="color: #660;">(</span><span style="color: #080;">"xmpp"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"xmpp_domain"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"sip.domain.com"</span><span style="color: #660;">)</span><span style="color: #000;"> &nbsp;</span><span style="color: #800;"># the name that OpenSIPS will register with as a component to the jabber server</span><span style="color: #000;"><br>modparam</span><span style="color: #660;">(</span><span style="color: #080;">"xmpp"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"xmpp_host"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"xmpp.domain.com"</span><span style="color: #660;">)</span><span style="color: #000;"> &nbsp; </span><span style="color: #800;"># the location of the jabber server</span><span style="color: #000;"><br>modparam</span><span style="color: #660;">(</span><span style="color: #080;">"xmpp"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"sip_domain"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"sip.domain.com"</span><span style="color: #660;">)</span><span style="color: #000;"> &nbsp; </span><span style="color: #800;"># the domain of the sip users visible to the xmpp users </span><span style="color: #000;"><br>modparam</span><span style="color: #660;">(</span><span style="color: #080;">"xmpp"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"backend"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"component"</span><span style="color: #660;">)</span><span style="color: #000;"><br>modparam</span><span style="color: #660;">(</span><span style="color: #080;">"xmpp"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"outbound_proxy"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"sip:10.10.10.10:5060"</span><span style="color: #660;">)</span><span style="color: #000;"><br><br>modparam</span><span style="color: #660;">(</span><span style="color: #080;">"mi_fifo"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"fifo_name"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"/tmp/opensips_fifo"</span><span style="color: #660;">)</span><span style="color: #000;"><br>modparam</span><span style="color: #660;">(</span><span style="color: #080;">"usrloc"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"db_mode"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #066;">2</span><span style="color: #660;">)</span><span style="color: #000;"><br><br>route </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(!</span><span style="color: #000;">mf_process_maxfwd_header</span><span style="color: #660;">(</span><span style="color: #080;">"10"</span><span style="color: #660;">))</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; sl_send_reply</span><span style="color: #660;">(</span><span style="color: #080;">"483"</span><span style="color: #660;">,</span><span style="color: #080;">"Too Many Hops"</span><span style="color: #660;">);</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;">has_totag</span><span style="color: #660;">())</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;"># sequential request withing a dialog should</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;"># take the path determined by record-routing</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;">loose_route</span><span style="color: #660;">())</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;">is_method</span><span style="color: #660;">(</span><span style="color: #080;">"BYE"</span><span style="color: #660;">))</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setflag</span><span style="color: #660;">(</span><span style="color: #066;">1</span><span style="color: #660;">);</span><span style="color: #000;"> </span><span style="color: #800;"># do accounting ...</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setflag</span><span style="color: #660;">(</span><span style="color: #066;">3</span><span style="color: #660;">);</span><span style="color: #000;"> </span><span style="color: #800;"># ... even if the transaction fails</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"> </span><span style="color: #008;">else</span><span style="color: #000;"> </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;">is_method</span><span style="color: #660;">(</span><span style="color: #080;">"INVITE"</span><span style="color: #660;">))</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;"># even if in most of the cases is useless, do RR for</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;"># re-INVITEs alos, as some buggy clients do change route set</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;"># during the dialog.</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; record_route</span><span style="color: #660;">();</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;"># route it out to whatever destination was set by loose_route()</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;"># in $du (destination URI).</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; route</span><span style="color: #660;">(</span><span style="color: #066;">1</span><span style="color: #660;">);</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"> </span><span style="color: #008;">else</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">/* uncomment the following lines if you want to enable presence */</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;">is_method</span><span style="color: #660;">(</span><span style="color: #080;">"SUBSCRIBE|NOTIFY"</span><span style="color: #660;">))</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">## &nbsp;# in-dialog subscribe requests</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; route</span><span style="color: #660;">(</span><span style="color: #066;">2</span><span style="color: #660;">);</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;"> is_method</span><span style="color: #660;">(</span><span style="color: #080;">"ACK"</span><span style="color: #660;">)</span><span style="color: #000;"> </span><span style="color: #660;">)</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;"> t_check_trans</span><span style="color: #660;">()</span><span style="color: #000;"> </span><span style="color: #660;">)</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;"># non loose-route, but stateful ACK; must be an ACK after </span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;"># a 487 or e.g. 404 from upstream server</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t_relay</span><span style="color: #660;">();</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"> </span><span style="color: #008;">else</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;"># ACK without matching transaction -&gt;</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;"># ignore and discard</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sl_send_reply</span><span style="color: #660;">(</span><span style="color: #080;">"404"</span><span style="color: #660;">,</span><span style="color: #080;">"Not here"</span><span style="color: #660;">);</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">#initial requests</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #800;"># CANCEL processing</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;">is_method</span><span style="color: #660;">(</span><span style="color: #080;">"CANCEL"</span><span style="color: #660;">))</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;">t_check_trans</span><span style="color: #660;">())</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t_relay</span><span style="color: #660;">();</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br><br>&nbsp; &nbsp; t_check_trans</span><span style="color: #660;">();</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #800;"># authenticate if from local subscriber (uncomment to enable auth)</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;"># authenticate all initial non-REGISTER request that pretend to be</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;"># generated by local subscriber (domain from FROM URI is local)</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">##if (!(method=="REGISTER") &amp;&amp; from_uri==myself) /*no multidomain version*/</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">##if (!(method=="REGISTER") &amp;&amp; is_from_local()) &nbsp;/*multidomain version*/</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">##{</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">## &nbsp;if (!proxy_authorize("", "subscriber")) {</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">## &nbsp; &nbsp; &nbsp;proxy_challenge("", "0");</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">## &nbsp; &nbsp; &nbsp;exit;</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">## &nbsp;}</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">## &nbsp;if (!db_check_from()) {</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">## &nbsp; &nbsp; &nbsp;sl_send_reply("403","Forbidden auth ID");</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">## &nbsp; &nbsp; &nbsp;exit;</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">## &nbsp;}</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">##</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">## &nbsp;consume_credentials();</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">## &nbsp;# caller authenticated</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">##}</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #800;"># preloaded route checking</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;">loose_route</span><span style="color: #660;">())</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; xlog</span><span style="color: #660;">(</span><span style="color: #080;">"L_ERR"</span><span style="color: #660;">,</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #080;">"Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]"</span><span style="color: #660;">);</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(!</span><span style="color: #000;">is_method</span><span style="color: #660;">(</span><span style="color: #080;">"ACK"</span><span style="color: #660;">))</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sl_send_reply</span><span style="color: #660;">(</span><span style="color: #080;">"403"</span><span style="color: #660;">,</span><span style="color: #080;">"Preload Route denied"</span><span style="color: #660;">);</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br>&nbsp; <br>&nbsp; &nbsp; </span><span style="color: #800;"># handle initial presence messages</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #660;">(</span><span style="color: #000;">uri</span><span style="color: #660;">==</span><span style="color: #000;">myself </span><span style="color: #660;">||</span><span style="color: #000;"> uri</span><span style="color: #660;">=~</span><span style="color: #080;">"sip:.+gmail.com"</span><span style="color: #000;"> </span><span style="color: #660;">||</span><span style="color: #000;"> uri</span><span style="color: #660;">=~</span><span style="color: #080;">"sip:.+@xmpp.domain.com"</span><span style="color: #660;">)</span><span style="color: #000;"> </span><span style="color: #800;"># detect if it's for an XMPP user</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #660;">(</span><span style="color: #000;"> is_method</span><span style="color: #660;">(</span><span style="color: #080;">"PUBLISH|SUBSCRIBE"</span><span style="color: #660;">))</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; route</span><span style="color: #660;">(</span><span style="color: #066;">2</span><span style="color: #660;">);</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">};</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #800;"># handle xmpp messages</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #660;">(</span><span style="color: #000;">is_method</span><span style="color: #660;">(</span><span style="color: #080;">"MESSAGE"</span><span style="color: #660;">)</span><span style="color: #000;"> </span><span style="color: #660;">&amp;&amp;</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;">uri</span><span style="color: #660;">=~</span><span style="color: #080;">"sip:.+gmail.com"</span><span style="color: #000;"> </span><span style="color: #660;">||</span><span style="color: #000;"> uri</span><span style="color: #660;">=~</span><span style="color: #080;">"sip:.+@xmpp.domain.com"</span><span style="color: #660;">))</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #660;">(!</span><span style="color: #000;">t_newtran</span><span style="color: #660;">())</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sl_reply_error</span><span style="color: #660;">();</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;">xmpp_send_message</span><span style="color: #660;">())</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t_reply</span><span style="color: #660;">(</span><span style="color: #080;">"200"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"Accepted"</span><span style="color: #660;">);</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"> </span><span style="color: #008;">else</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t_reply</span><span style="color: #660;">(</span><span style="color: #080;">"404"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"Not found"</span><span style="color: #660;">);</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">};</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #800;"># record routing</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(!</span><span style="color: #000;">is_method</span><span style="color: #660;">(</span><span style="color: #080;">"REGISTER|MESSAGE"</span><span style="color: #660;">))</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; record_route</span><span style="color: #660;">();</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #800;"># account only INVITEs</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;">is_method</span><span style="color: #660;">(</span><span style="color: #080;">"INVITE"</span><span style="color: #660;">))</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; setflag</span><span style="color: #660;">(</span><span style="color: #066;">1</span><span style="color: #660;">);</span><span style="color: #000;"> </span><span style="color: #800;"># do accounting</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(!</span><span style="color: #000;">uri</span><span style="color: #660;">==</span><span style="color: #000;">myself</span><span style="color: #660;">)</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">## replace with following line if multi-domain support is used</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">##if (!is_uri_host_local())</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; append_hf</span><span style="color: #660;">(</span><span style="color: #080;">"P-hint: outbound\r\n"</span><span style="color: #660;">);</span><span style="color: #000;"> <br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;"># if you have some interdomain connections via TLS</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">##if($rd=="tls_domain1.net") {</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">## &nbsp;t_relay("tls:domain1.net");</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">## &nbsp;exit;</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">##} else if($rd=="tls_domain2.net") {</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">## &nbsp;t_relay("tls:domain2.net");</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">## &nbsp;exit;</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">##}</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; route</span><span style="color: #660;">(</span><span style="color: #066;">1</span><span style="color: #660;">);</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #800;"># requests for my domain</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;">is_method</span><span style="color: #660;">(</span><span style="color: #080;">"REGISTER"</span><span style="color: #660;">))</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;"># authenticate the REGISTER requests (uncomment to enable auth)</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">##if (!www_authorize("", "subscriber"))</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">##{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">## &nbsp;www_challenge("", "0");</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">## &nbsp;exit;</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">##}</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">##</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">##if (!db_check_to()) </span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">##{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">## &nbsp;sl_send_reply("403","Forbidden auth ID");</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">## &nbsp;exit;</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">##}</span><span style="color: #000;"><br><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(!</span><span style="color: #000;">save</span><span style="color: #660;">(</span><span style="color: #080;">"location"</span><span style="color: #660;">))</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sl_reply_error</span><span style="color: #660;">();</span><span style="color: #000;"><br><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;">$rU</span><span style="color: #660;">==</span><span style="color: #000;">NULL</span><span style="color: #660;">)</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;"># request with no Username in RURI</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; sl_send_reply</span><span style="color: #660;">(</span><span style="color: #080;">"484"</span><span style="color: #660;">,</span><span style="color: #080;">"Address Incomplete"</span><span style="color: #660;">);</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #800;"># apply DB based aliases (uncomment to enable)</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">##alias_db_lookup("dbaliases");</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #800;"># do lookup with method filtering</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(!</span><span style="color: #000;">lookup</span><span style="color: #660;">(</span><span style="color: #080;">"location"</span><span style="color: #660;">,</span><span style="color: #080;">"m"</span><span style="color: #660;">))</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">switch</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;">$retcode</span><span style="color: #660;">)</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">case</span><span style="color: #000;"> </span><span style="color: #660;">-</span><span style="color: #066;">1</span><span style="color: #660;">:</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">case</span><span style="color: #000;"> </span><span style="color: #660;">-</span><span style="color: #066;">3</span><span style="color: #660;">:</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t_newtran</span><span style="color: #660;">();</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t_reply</span><span style="color: #660;">(</span><span style="color: #080;">"404"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"Not Found"</span><span style="color: #660;">);</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">case</span><span style="color: #000;"> </span><span style="color: #660;">-</span><span style="color: #066;">2</span><span style="color: #660;">:</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sl_send_reply</span><span style="color: #660;">(</span><span style="color: #080;">"405"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"Method Not Allowed"</span><span style="color: #660;">);</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #800;"># when routing via usrloc, log the missed calls also</span><span style="color: #000;"><br>&nbsp; &nbsp; setflag</span><span style="color: #660;">(</span><span style="color: #066;">2</span><span style="color: #660;">);</span><span style="color: #000;"><br><br>&nbsp; &nbsp; route</span><span style="color: #660;">(</span><span style="color: #066;">1</span><span style="color: #660;">);</span><span style="color: #000;"><br></span><span style="color: #660;">}</span><span style="color: #000;"><br><br><br>route</span><span style="color: #660;">[</span><span style="color: #066;">1</span><span style="color: #660;">]</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;"># send it out now; use stateful forwarding as it works reliably</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;"># even for UDP2TCP</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(!</span><span style="color: #000;">t_relay</span><span style="color: #660;">())</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; sl_reply_error</span><span style="color: #660;">();</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">};</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br></span><span style="color: #660;">}</span><span style="color: #000;"><br><br>route</span><span style="color: #660;">[</span><span style="color: #066;">2</span><span style="color: #660;">]</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;"># create new transaction to catch retransmissions</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #660;">(!</span><span style="color: #000;">t_newtran</span><span style="color: #660;">())</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; sl_reply_error</span><span style="color: #660;">();</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #800;"># if it is Notify - for xmpp gateway</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #660;">(</span><span style="color: #000;"> is_method</span><span style="color: #660;">(</span><span style="color: #080;">"NOTIFY"</span><span style="color: #660;">))</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; t_reply</span><span style="color: #660;">(</span><span style="color: #080;">"200"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"OK"</span><span style="color: #660;">);</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; pua_xmpp_notify</span><span style="color: #660;">();</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #800;"># handle presence specific messages</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #660;">(</span><span style="color: #000;">is_method</span><span style="color: #660;">(</span><span style="color: #080;">"PUBLISH"</span><span style="color: #660;">))</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; handle_publish</span><span style="color: #660;">();</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">else</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #660;">(</span><span style="color: #000;">is_method</span><span style="color: #660;">(</span><span style="color: #080;">"SUBSCRIBE"</span><span style="color: #660;">))</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; handle_subscribe</span><span style="color: #660;">();</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #660;">(</span><span style="color: #000;">$hdr</span><span style="color: #660;">(</span><span style="color: #606;">Event</span><span style="color: #660;">)==</span><span style="color: #000;"> </span><span style="color: #080;">"presence"</span><span style="color: #000;"> </span><span style="color: #660;">&amp;&amp;</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;">uri</span><span style="color: #660;">=~</span><span style="color: #080;">"sip:.+gmail.com"</span><span style="color: #000;"> </span><span style="color: #660;">||</span><span style="color: #000;"> uri</span><span style="color: #660;">=~</span><span style="color: #080;">"sip:.+@xmpp.domain.com"</span><span style="color: #660;">)</span><span style="color: #000;"> </span><span style="color: #660;">)</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pua_xmpp_req_winfo</span><span style="color: #660;">(</span><span style="color: #080;">"$ruri"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"$hdr(Expires)"</span><span style="color: #660;">);</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br></span><span style="color: #660;">}</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span></pre>
to:
(:redirect Documentation/Tutorials-Presence-PuaXmppConfig quiet=1:)
November 04, 2010, at 12:10 PM by anca_vamanu -
Changed line 3 from:
[[xmpp_config_txt | http://opensips.org/uploads/Resources/opensips_xmpp.cfg]]
to:
[[http://opensips.org/uploads/Resources/opensips_xmpp.cfg| Download]]
November 04, 2010, at 12:09 PM by anca_vamanu -
Changed line 3 from:
[[xmpp_config_txt | uploads/Resources/opensips_xmpp.cfg]]
to:
[[xmpp_config_txt | http://opensips.org/uploads/Resources/opensips_xmpp.cfg]]
November 04, 2010, at 12:09 PM by anca_vamanu -
Changed line 3 from:
[[xmpp_config_txt | Download file]]
to:
[[xmpp_config_txt | uploads/Resources/opensips_xmpp.cfg]]
November 04, 2010, at 12:01 PM by anca_vamanu -
Changed line 3 from:
[[xmpp_config_txt | Download text]]
to:
[[xmpp_config_txt | Download file]]
November 04, 2010, at 12:01 PM by anca_vamanu -
Added line 3:
[[xmpp_config_txt | Download text]]
November 04, 2010, at 11:57 AM by anca_vamanu -
Changed lines 3-253 from:
[+[@
#
# OpenSIPS configuration file
#
# XMPP - SIP gateway : messaging and presence
#

# ----------- global configuration parameters ------------------------

/* Uncomment these lines to enter debugging mode */
debug=7 # debug level (cmd line: -dddddddddd)
fork=yes
log_stderror=yes

sip_warning=0

check_via=no # (cmd. line: -v)
dns=no # (cmd. line: -r)
rev_dns=no # (cmd. line: -R)
listen=udp:10.10.10.10:5060
children=4
#fifo="/tmp/opensips_fifo"

#
# uncomment the following lines for TLS support
#disable_tls = 0
#listen = tls:your_IP:5061
#tls_verify_server = 1
#tls_verify_client = 1
#tls_require_client_certificate = 0
#tls_method = TLSv1
#tls_certificate = "/usr/local/etc/opensips/tls/user/user-cert.pem"
#tls_private_key = "/usr/local/etc/opensips/tls/user/user-privkey.pem"
#tls_ca_list = "/usr/local/etc/opensips/tls/user/user-calist.pem"

# ------------------ module loading ----------------------------------
mpath="/usr/local/opensips/lib/modules/"

loadmodule "db_mysql.so"
loadmodule "sl.so"
loadmodule "maxfwd.so"
loadmodule "textops.so"
loadmodule "tm.so"
loadmodule "rr.so"
loadmodule "presence.so"
loadmodule "presence_xml.so"
loadmodule "mi_fifo.so"
loadmodule "usrloc.so"
loadmodule "registrar.so"
loadmodule "pua.so"
loadmodule "xmpp.so"
loadmodule "pua_xmpp.so"
# for 1.5 you must load also signaling module; uncomment the next line
#loadmodule "signaling.so"


# Uncomment this if you want digest authentication
# mysql.so must be loaded !
#loadmodule "auth.so"
#loadmodule "auth_db.so"

# ----------------- setting module-specific parameters ---------------

# --mi_fifo params --
modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")

# -- usrloc params --
modparam("usrloc", "db_mode", 2)
modparam("usrloc", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")

# -- auth params --
# Uncomment if you are using auth module
#
#modparam("auth_db", "calculate_ha1", yes)
#
# If you set "calculate_ha1" parameter to yes (which true in this config),
# uncomment also the following parameter)
#
#modparam("auth_db", "password_column", "password")

# -- rr params --
# add value to ;lr param to make some broken UAs happy
modparam("rr", "enable_full_lr", 1)

# -- presence and presence_xml params --
modparam("presence|presence_xml", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")
modparam("presence", "server_address", "sip:sa@10.10.10.10:5060")
modparam("presence_xml", "force_active", 1)

# -- pua and pua_xmpp params --
modparam("pua", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")
modparam("pua_xmpp", "server_address", "sip:sa@10.10.10.10:5060")

# -- xmpp parameters --
modparam("xmpp", "domain_separator", "*")
modparam("xmpp", "gateway_domain", "sip-xmpp.siphub.ro")
modparam("xmpp", "xmpp_domain", "xmpp-sip.siphub.ro")
modparam("xmpp", "xmpp_host", "xmpp.siphub.ro")
modparam("xmpp", "backend", "component")


# ------------------------- request routing logic -------------------

# main routing logic


route{

# initial sanity checks -- messages with
# max_forwards==0, or excessively long requests
if (!mf_process_maxfwd_header("10")) {
sl_send_reply("483","Too Many Hops");
exit;
};

if (msg:len >= 2048 ) {
sl_send_reply("513", "Message too big");
exit;
};

# we record-route all messages -- to make sure that
# subsequent messages will go through our proxy; that's
# particularly good if upstream and downstream entities
# use different transport protocol
if (!method=="REGISTER")
record_route();

# subsequent messages withing a dialog should take the
# path determined by record-routing
if (loose_route()) {
# mark routing logic in request
append_hf("P-hint: rr-enforced\r\n");
route(1);
};
if(method == "INVITE")
setflag(5);

if( uri=~"sip:.+@sip-xmpp.siphub.ro" ||
uri=~"sip:.+@sip-xmpp.siphub.ro")
{
if( is_method("PUBLISH|SUBSCRIBE|NOTIFY"))
route(2);
}

if( uri=~"sip:.+@sip-xmpp.siphub.ro")
{
# absorb retransmissions ###
if (!t_newtran()) {
sl_reply_error();
return;
}
if (method == "MESSAGE") {
log("*** xmpp-handled MESSAGE message.\n");
if (xmpp_send_message()) {
t_reply("200", "Accepted");
} else {
t_reply("404", "Not found");
}
return;
}else {
t_reply("403","not supported");
exit;
}

}

if (!uri==myself) {
# mark routing logic in request
append_hf("P-hint: outbound\r\n");
# if you have some interdomain connections via TLS
#if(uri=~"@tls_domain1.net") {
# t_relay("tls:domain1.net");
# exit;
#} else if(uri=~"@tls_domain2.net") {
# t_relay("tls:domain2.net");
# exit;
#}
route(1);
};

# if the request is for other domain use UsrLoc
# (in case, it does not work, use the following command
# with proper names and addresses in it)
if (uri==myself) {

if( is_method("PUBLISH|SUBSCRIBE|NOTIFY"))
route(2);

if (method=="REGISTER") {

# Uncomment this if you want to use digest authentication
#if (!www_authorize("opensips.org", "subscriber")) {
# www_challenge("opensips.org", "0");
# exit;
#};

save("location");
exit;
};

# native SIP destinations are handled using our USRLOC DB
if (!lookup("location")) {
sl_send_reply("404", "Not Found");
exit;
};
append_hf("P-hint: usrloc applied\r\n");
};

route(1);
}


route[1] {
# send it out now; use stateful forwarding as it works reliably
# even for UDP2TCP
if (!t_relay()) {
sl_reply_error();
};
exit;
}

route[2]
{
if ( !t_newtran() ){
sl_reply_error();
exit;
};

if( is_method("NOTIFY") && uri=~"sip:.+@sip-xmpp.siphub.ro"){
pua_xmpp_notify();
t_reply("200", "OK");
exit;
}

if(is_method("PUBLISH")){
handle_publish();
t_release();
/* the call to t_release is no longer needed in 1.5 */
}
else
if( is_method("SUBSCRIBE")){
handle_subscribe();
if( uri=~"sip:.+@sip-xmpp.siphub.ro" && $hdr(Event)== "presence"){
pua_xmpp_req_winfo("$ruri", "$hdr(Expires)");
}
t_release();
/* the call to t_release is no longer needed in 1.5 */
}

exit;
}@]+]
to:

<pre><span style="color: #800;"># OpenSIPS SIP-XMPP Gateway</span><span style="color: #000;"><br><br>debug</span><span style="color: #660;">=</span><span style="color: #066;">3</span><span style="color: #000;"><br>log_stderror</span><span style="color: #660;">=</span><span style="color: #008;">no</span><span style="color: #000;"><br>log_facility</span><span style="color: #660;">=</span><span style="color: #000;">LOG_LOCAL0<br><br>fork</span><span style="color: #660;">=</span><span style="color: #000;">yes<br>children</span><span style="color: #660;">=</span><span style="color: #066;">4</span><span style="color: #000;"><br><br>listen</span><span style="color: #660;">=</span><span style="color: #000;">udp</span><span style="color: #660;">:</span><span style="color: #066;">10.10.10.10</span><span style="color: #660;">:</span><span style="color: #066;">5060</span><span style="color: #000;"><br></span><span style="color: #008;">alias</span><span style="color: #660;">=</span><span style="color: #080;">"sip.domain.com"</span><span style="color: #000;"><br><br></span><span style="color: #800;"># ------------------ module loading ----------------------------------</span><span style="color: #000;"><br><br>mpath</span><span style="color: #660;">=</span><span style="color: #080;">"/usr/local/lib/opensips/modules/"</span><span style="color: #000;"><br><br>loadmodule </span><span style="color: #080;">"db_mysql.so"</span><span style="color: #000;"><br>loadmodule </span><span style="color: #080;">"textops.so"</span><span style="color: #000;"><br>loadmodule </span><span style="color: #080;">"maxfwd.so"</span><span style="color: #000;"><br>loadmodule </span><span style="color: #080;">"rr.so"</span><span style="color: #000;"><br>loadmodule </span><span style="color: #080;">"sl.so"</span><span style="color: #000;"><br>loadmodule </span><span style="color: #080;">"tm.so"</span><span style="color: #000;"><br>loadmodule </span><span style="color: #080;">"signaling.so"</span><span style="color: #000;"><br>loadmodule </span><span style="color: #080;">"usrloc.so"</span><span style="color: #000;"><br>loadmodule </span><span style="color: #080;">"registrar.so"</span><span style="color: #000;"><br>loadmodule </span><span style="color: #080;">"mi_fifo.so"</span><span style="color: #000;"><br>loadmodule </span><span style="color: #080;">"uri.so"</span><span style="color: #000;"><br><br>loadmodule </span><span style="color: #080;">"xmpp.so"</span><span style="color: #000;"><br>loadmodule </span><span style="color: #080;">"pua.so"</span><span style="color: #000;"><br>loadmodule </span><span style="color: #080;">"pua_xmpp.so"</span><span style="color: #000;"><br>loadmodule </span><span style="color: #080;">"presence.so"</span><span style="color: #000;"><br>loadmodule </span><span style="color: #080;">"presence_xml.so"</span><span style="color: #000;"><br><br></span><span style="color: #800;"># ----------------- setting module-specific parameters ---------------</span><span style="color: #000;"><br>modparam</span><span style="color: #660;">(</span><span style="color: #080;">"usrloc|presence|presence_xml|pua"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"db_url"</span><span style="color: #660;">,</span><span style="color: #000;"> &nbsp;</span><span style="color: #080;">"mysql://opensips:opensipsrw@localhost/opensips"</span><span style="color: #660;">)</span><span style="color: #000;"><br>modparam</span><span style="color: #660;">(</span><span style="color: #080;">"presence|pua_xmpp"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"server_address"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"sip:sa@10.10.10.10:5060"</span><span style="color: #660;">)</span><span style="color: #000;"><br>modparam</span><span style="color: #660;">(</span><span style="color: #080;">"presence_xml"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"force_active"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #066;">1</span><span style="color: #660;">)</span><span style="color: #000;"><br>modparam</span><span style="color: #660;">(</span><span style="color: #080;">"pua_xmpp"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"presence_server"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"sip:sa@10.10.10.10:5060"</span><span style="color: #660;">)</span><span style="color: #000;"><br><br>modparam</span><span style="color: #660;">(</span><span style="color: #080;">"xmpp"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"xmpp_domain"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"sip.domain.com"</span><span style="color: #660;">)</span><span style="color: #000;"> &nbsp;</span><span style="color: #800;"># the name that OpenSIPS will register with as a component to the jabber server</span><span style="color: #000;"><br>modparam</span><span style="color: #660;">(</span><span style="color: #080;">"xmpp"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"xmpp_host"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"xmpp.domain.com"</span><span style="color: #660;">)</span><span style="color: #000;"> &nbsp; </span><span style="color: #800;"># the location of the jabber server</span><span style="color: #000;"><br>modparam</span><span style="color: #660;">(</span><span style="color: #080;">"xmpp"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"sip_domain"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"sip.domain.com"</span><span style="color: #660;">)</span><span style="color: #000;"> &nbsp; </span><span style="color: #800;"># the domain of the sip users visible to the xmpp users </span><span style="color: #000;"><br>modparam</span><span style="color: #660;">(</span><span style="color: #080;">"xmpp"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"backend"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"component"</span><span style="color: #660;">)</span><span style="color: #000;"><br>modparam</span><span style="color: #660;">(</span><span style="color: #080;">"xmpp"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"outbound_proxy"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"sip:10.10.10.10:5060"</span><span style="color: #660;">)</span><span style="color: #000;"><br><br>modparam</span><span style="color: #660;">(</span><span style="color: #080;">"mi_fifo"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"fifo_name"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"/tmp/opensips_fifo"</span><span style="color: #660;">)</span><span style="color: #000;"><br>modparam</span><span style="color: #660;">(</span><span style="color: #080;">"usrloc"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"db_mode"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #066;">2</span><span style="color: #660;">)</span><span style="color: #000;"><br><br>route </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(!</span><span style="color: #000;">mf_process_maxfwd_header</span><span style="color: #660;">(</span><span style="color: #080;">"10"</span><span style="color: #660;">))</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; sl_send_reply</span><span style="color: #660;">(</span><span style="color: #080;">"483"</span><span style="color: #660;">,</span><span style="color: #080;">"Too Many Hops"</span><span style="color: #660;">);</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;">has_totag</span><span style="color: #660;">())</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;"># sequential request withing a dialog should</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;"># take the path determined by record-routing</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;">loose_route</span><span style="color: #660;">())</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;">is_method</span><span style="color: #660;">(</span><span style="color: #080;">"BYE"</span><span style="color: #660;">))</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setflag</span><span style="color: #660;">(</span><span style="color: #066;">1</span><span style="color: #660;">);</span><span style="color: #000;"> </span><span style="color: #800;"># do accounting ...</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setflag</span><span style="color: #660;">(</span><span style="color: #066;">3</span><span style="color: #660;">);</span><span style="color: #000;"> </span><span style="color: #800;"># ... even if the transaction fails</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"> </span><span style="color: #008;">else</span><span style="color: #000;"> </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;">is_method</span><span style="color: #660;">(</span><span style="color: #080;">"INVITE"</span><span style="color: #660;">))</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;"># even if in most of the cases is useless, do RR for</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;"># re-INVITEs alos, as some buggy clients do change route set</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;"># during the dialog.</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; record_route</span><span style="color: #660;">();</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;"># route it out to whatever destination was set by loose_route()</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;"># in $du (destination URI).</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; route</span><span style="color: #660;">(</span><span style="color: #066;">1</span><span style="color: #660;">);</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"> </span><span style="color: #008;">else</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">/* uncomment the following lines if you want to enable presence */</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;">is_method</span><span style="color: #660;">(</span><span style="color: #080;">"SUBSCRIBE|NOTIFY"</span><span style="color: #660;">))</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">## &nbsp;# in-dialog subscribe requests</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; route</span><span style="color: #660;">(</span><span style="color: #066;">2</span><span style="color: #660;">);</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;"> is_method</span><span style="color: #660;">(</span><span style="color: #080;">"ACK"</span><span style="color: #660;">)</span><span style="color: #000;"> </span><span style="color: #660;">)</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;"> t_check_trans</span><span style="color: #660;">()</span><span style="color: #000;"> </span><span style="color: #660;">)</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;"># non loose-route, but stateful ACK; must be an ACK after </span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;"># a 487 or e.g. 404 from upstream server</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t_relay</span><span style="color: #660;">();</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"> </span><span style="color: #008;">else</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;"># ACK without matching transaction -&gt;</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;"># ignore and discard</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sl_send_reply</span><span style="color: #660;">(</span><span style="color: #080;">"404"</span><span style="color: #660;">,</span><span style="color: #080;">"Not here"</span><span style="color: #660;">);</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">#initial requests</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #800;"># CANCEL processing</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;">is_method</span><span style="color: #660;">(</span><span style="color: #080;">"CANCEL"</span><span style="color: #660;">))</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;">t_check_trans</span><span style="color: #660;">())</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t_relay</span><span style="color: #660;">();</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br><br>&nbsp; &nbsp; t_check_trans</span><span style="color: #660;">();</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #800;"># authenticate if from local subscriber (uncomment to enable auth)</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;"># authenticate all initial non-REGISTER request that pretend to be</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;"># generated by local subscriber (domain from FROM URI is local)</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">##if (!(method=="REGISTER") &amp;&amp; from_uri==myself) /*no multidomain version*/</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">##if (!(method=="REGISTER") &amp;&amp; is_from_local()) &nbsp;/*multidomain version*/</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">##{</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">## &nbsp;if (!proxy_authorize("", "subscriber")) {</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">## &nbsp; &nbsp; &nbsp;proxy_challenge("", "0");</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">## &nbsp; &nbsp; &nbsp;exit;</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">## &nbsp;}</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">## &nbsp;if (!db_check_from()) {</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">## &nbsp; &nbsp; &nbsp;sl_send_reply("403","Forbidden auth ID");</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">## &nbsp; &nbsp; &nbsp;exit;</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">## &nbsp;}</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">##</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">## &nbsp;consume_credentials();</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">## &nbsp;# caller authenticated</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">##}</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #800;"># preloaded route checking</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;">loose_route</span><span style="color: #660;">())</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; xlog</span><span style="color: #660;">(</span><span style="color: #080;">"L_ERR"</span><span style="color: #660;">,</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #080;">"Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]"</span><span style="color: #660;">);</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(!</span><span style="color: #000;">is_method</span><span style="color: #660;">(</span><span style="color: #080;">"ACK"</span><span style="color: #660;">))</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sl_send_reply</span><span style="color: #660;">(</span><span style="color: #080;">"403"</span><span style="color: #660;">,</span><span style="color: #080;">"Preload Route denied"</span><span style="color: #660;">);</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br>&nbsp; <br>&nbsp; &nbsp; </span><span style="color: #800;"># handle initial presence messages</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #660;">(</span><span style="color: #000;">uri</span><span style="color: #660;">==</span><span style="color: #000;">myself </span><span style="color: #660;">||</span><span style="color: #000;"> uri</span><span style="color: #660;">=~</span><span style="color: #080;">"sip:.+gmail.com"</span><span style="color: #000;"> </span><span style="color: #660;">||</span><span style="color: #000;"> uri</span><span style="color: #660;">=~</span><span style="color: #080;">"sip:.+@xmpp.domain.com"</span><span style="color: #660;">)</span><span style="color: #000;"> </span><span style="color: #800;"># detect if it's for an XMPP user</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #660;">(</span><span style="color: #000;"> is_method</span><span style="color: #660;">(</span><span style="color: #080;">"PUBLISH|SUBSCRIBE"</span><span style="color: #660;">))</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; route</span><span style="color: #660;">(</span><span style="color: #066;">2</span><span style="color: #660;">);</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">};</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #800;"># handle xmpp messages</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #660;">(</span><span style="color: #000;">is_method</span><span style="color: #660;">(</span><span style="color: #080;">"MESSAGE"</span><span style="color: #660;">)</span><span style="color: #000;"> </span><span style="color: #660;">&amp;&amp;</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;">uri</span><span style="color: #660;">=~</span><span style="color: #080;">"sip:.+gmail.com"</span><span style="color: #000;"> </span><span style="color: #660;">||</span><span style="color: #000;"> uri</span><span style="color: #660;">=~</span><span style="color: #080;">"sip:.+@xmpp.domain.com"</span><span style="color: #660;">))</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #660;">(!</span><span style="color: #000;">t_newtran</span><span style="color: #660;">())</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sl_reply_error</span><span style="color: #660;">();</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;">xmpp_send_message</span><span style="color: #660;">())</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t_reply</span><span style="color: #660;">(</span><span style="color: #080;">"200"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"Accepted"</span><span style="color: #660;">);</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"> </span><span style="color: #008;">else</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t_reply</span><span style="color: #660;">(</span><span style="color: #080;">"404"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"Not found"</span><span style="color: #660;">);</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">};</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #800;"># record routing</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(!</span><span style="color: #000;">is_method</span><span style="color: #660;">(</span><span style="color: #080;">"REGISTER|MESSAGE"</span><span style="color: #660;">))</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; record_route</span><span style="color: #660;">();</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #800;"># account only INVITEs</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;">is_method</span><span style="color: #660;">(</span><span style="color: #080;">"INVITE"</span><span style="color: #660;">))</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; setflag</span><span style="color: #660;">(</span><span style="color: #066;">1</span><span style="color: #660;">);</span><span style="color: #000;"> </span><span style="color: #800;"># do accounting</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(!</span><span style="color: #000;">uri</span><span style="color: #660;">==</span><span style="color: #000;">myself</span><span style="color: #660;">)</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">## replace with following line if multi-domain support is used</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">##if (!is_uri_host_local())</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; append_hf</span><span style="color: #660;">(</span><span style="color: #080;">"P-hint: outbound\r\n"</span><span style="color: #660;">);</span><span style="color: #000;"> <br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;"># if you have some interdomain connections via TLS</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">##if($rd=="tls_domain1.net") {</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">## &nbsp;t_relay("tls:domain1.net");</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">## &nbsp;exit;</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">##} else if($rd=="tls_domain2.net") {</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">## &nbsp;t_relay("tls:domain2.net");</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">## &nbsp;exit;</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">##}</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; route</span><span style="color: #660;">(</span><span style="color: #066;">1</span><span style="color: #660;">);</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #800;"># requests for my domain</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;">is_method</span><span style="color: #660;">(</span><span style="color: #080;">"REGISTER"</span><span style="color: #660;">))</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;"># authenticate the REGISTER requests (uncomment to enable auth)</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">##if (!www_authorize("", "subscriber"))</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">##{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">## &nbsp;www_challenge("", "0");</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">## &nbsp;exit;</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">##}</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">##</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">##if (!db_check_to()) </span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">##{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">## &nbsp;sl_send_reply("403","Forbidden auth ID");</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">## &nbsp;exit;</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;">##}</span><span style="color: #000;"><br><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(!</span><span style="color: #000;">save</span><span style="color: #660;">(</span><span style="color: #080;">"location"</span><span style="color: #660;">))</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sl_reply_error</span><span style="color: #660;">();</span><span style="color: #000;"><br><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;">$rU</span><span style="color: #660;">==</span><span style="color: #000;">NULL</span><span style="color: #660;">)</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;"># request with no Username in RURI</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; sl_send_reply</span><span style="color: #660;">(</span><span style="color: #080;">"484"</span><span style="color: #660;">,</span><span style="color: #080;">"Address Incomplete"</span><span style="color: #660;">);</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #800;"># apply DB based aliases (uncomment to enable)</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;">##alias_db_lookup("dbaliases");</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #800;"># do lookup with method filtering</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(!</span><span style="color: #000;">lookup</span><span style="color: #660;">(</span><span style="color: #080;">"location"</span><span style="color: #660;">,</span><span style="color: #080;">"m"</span><span style="color: #660;">))</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">switch</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;">$retcode</span><span style="color: #660;">)</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">case</span><span style="color: #000;"> </span><span style="color: #660;">-</span><span style="color: #066;">1</span><span style="color: #660;">:</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">case</span><span style="color: #000;"> </span><span style="color: #660;">-</span><span style="color: #066;">3</span><span style="color: #660;">:</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t_newtran</span><span style="color: #660;">();</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t_reply</span><span style="color: #660;">(</span><span style="color: #080;">"404"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"Not Found"</span><span style="color: #660;">);</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">case</span><span style="color: #000;"> </span><span style="color: #660;">-</span><span style="color: #066;">2</span><span style="color: #660;">:</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sl_send_reply</span><span style="color: #660;">(</span><span style="color: #080;">"405"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"Method Not Allowed"</span><span style="color: #660;">);</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #800;"># when routing via usrloc, log the missed calls also</span><span style="color: #000;"><br>&nbsp; &nbsp; setflag</span><span style="color: #660;">(</span><span style="color: #066;">2</span><span style="color: #660;">);</span><span style="color: #000;"><br><br>&nbsp; &nbsp; route</span><span style="color: #660;">(</span><span style="color: #066;">1</span><span style="color: #660;">);</span><span style="color: #000;"><br></span><span style="color: #660;">}</span><span style="color: #000;"><br><br><br>route</span><span style="color: #660;">[</span><span style="color: #066;">1</span><span style="color: #660;">]</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;"># send it out now; use stateful forwarding as it works reliably</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;"># even for UDP2TCP</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #000;"> </span><span style="color: #660;">(!</span><span style="color: #000;">t_relay</span><span style="color: #660;">())</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; sl_reply_error</span><span style="color: #660;">();</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">};</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br></span><span style="color: #660;">}</span><span style="color: #000;"><br><br>route</span><span style="color: #660;">[</span><span style="color: #066;">2</span><span style="color: #660;">]</span><span style="color: #000;"> </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #800;"># create new transaction to catch retransmissions</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #660;">(!</span><span style="color: #000;">t_newtran</span><span style="color: #660;">())</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; sl_reply_error</span><span style="color: #660;">();</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #800;"># if it is Notify - for xmpp gateway</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #660;">(</span><span style="color: #000;"> is_method</span><span style="color: #660;">(</span><span style="color: #080;">"NOTIFY"</span><span style="color: #660;">))</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; t_reply</span><span style="color: #660;">(</span><span style="color: #080;">"200"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"OK"</span><span style="color: #660;">);</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; pua_xmpp_notify</span><span style="color: #660;">();</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span><span style="color: #800;"># handle presence specific messages</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #660;">(</span><span style="color: #000;">is_method</span><span style="color: #660;">(</span><span style="color: #080;">"PUBLISH"</span><span style="color: #660;">))</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; handle_publish</span><span style="color: #660;">();</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">else</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #660;">(</span><span style="color: #000;">is_method</span><span style="color: #660;">(</span><span style="color: #080;">"SUBSCRIBE"</span><span style="color: #660;">))</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">{</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; handle_subscribe</span><span style="color: #660;">();</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #008;">if</span><span style="color: #660;">(</span><span style="color: #000;">$hdr</span><span style="color: #660;">(</span><span style="color: #606;">Event</span><span style="color: #660;">)==</span><span style="color: #000;"> </span><span style="color: #080;">"presence"</span><span style="color: #000;"> </span><span style="color: #660;">&amp;&amp;</span><span style="color: #000;"> </span><span style="color: #660;">(</span><span style="color: #000;">uri</span><span style="color: #660;">=~</span><span style="color: #080;">"sip:.+gmail.com"</span><span style="color: #000;"> </span><span style="color: #660;">||</span><span style="color: #000;"> uri</span><span style="color: #660;">=~</span><span style="color: #080;">"sip:.+@xmpp.domain.com"</span><span style="color: #660;">)</span><span style="color: #000;"> </span><span style="color: #660;">)</span><span style="color: #000;"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pua_xmpp_req_winfo</span><span style="color: #660;">(</span><span style="color: #080;">"$ruri"</span><span style="color: #660;">,</span><span style="color: #000;"> </span><span style="color: #080;">"$hdr(Expires)"</span><span style="color: #660;">);</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #660;">}</span><span style="color: #000;"><br>&nbsp; &nbsp; </span><span style="color: #008;">exit</span><span style="color: #660;">;</span><span style="color: #000;"><br></span><span style="color: #660;">}</span><span style="color: #000;"><br><br>&nbsp; &nbsp; </span></pre>
March 24, 2009, at 01:03 PM by anca_vamanu -
Changed lines 55-57 from:
to:
# for 1.5 you must load also signaling module; uncomment the next line
#loadmodule "signaling.so"
March 09, 2009, at 02:40 PM by anca_vamanu -
Changed line 1 from:
[[Resources.PuaExtensions#pua_mi | <-Back]]
to:
[[Resources.PuaExtensions#pua_xmpp | <-Back]]
March 09, 2009, at 02:39 PM by anca_vamanu -
Changed lines 1-2 from:
[[Resources.PuaExtensions | <-Back]]
to:
[[Resources.PuaExtensions#pua_mi | <-Back]]
Added line 238:
/* the call to t_release is no longer needed in 1.5 */
Added line 247:
/* the call to t_release is no longer needed in 1.5 */
October 27, 2008, at 04:33 PM by 81.180.102.217 -
Changed line 87 from:
modparam("presence", "server_address", "sip:10.10.10.10:5060")
to:
modparam("presence", "server_address", "sip:sa@10.10.10.10:5060")
Changed lines 92-93 from:
modparam("pua_xmpp", "server_address", "sip:10.10.10.10:5060")
to:
modparam("pua_xmpp", "server_address", "sip:sa@10.10.10.10:5060")
October 27, 2008, at 12:14 PM by 81.180.102.217 -
Changed line 86 from:
modparam("presence", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")
to:
modparam("presence|presence_xml", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")
July 29, 2008, at 02:26 PM by 81.180.102.217 -
Changed line 3 from:
[++[@
to:
[+[@
Changed line 249 from:
}@]++]
to:
}@]+]
July 29, 2008, at 02:25 PM by 81.180.102.217 -
Added lines 1-2:
[[Resources.PuaExtensions | <-Back]]
July 29, 2008, at 01:21 PM by 81.180.102.217 -
Changed line 12 from:
fork=no
to:
fork=yes
July 29, 2008, at 01:11 PM by 81.180.102.217 -
Added line 1:
[++[@
Changed line 8 from:
[++[@# ----------- global configuration parameters ------------------------
to:
# ----------- global configuration parameters ------------------------
July 29, 2008, at 01:11 PM by 81.180.102.217 -
Added lines 1-246:
#
# OpenSIPS configuration file
#
# XMPP - SIP gateway : messaging and presence
#

[++[@# ----------- global configuration parameters ------------------------

/* Uncomment these lines to enter debugging mode */
debug=7 # debug level (cmd line: -dddddddddd)
fork=no
log_stderror=yes

sip_warning=0

check_via=no # (cmd. line: -v)
dns=no # (cmd. line: -r)
rev_dns=no # (cmd. line: -R)
listen=udp:10.10.10.10:5060
children=4
#fifo="/tmp/opensips_fifo"

#
# uncomment the following lines for TLS support
#disable_tls = 0
#listen = tls:your_IP:5061
#tls_verify_server = 1
#tls_verify_client = 1
#tls_require_client_certificate = 0
#tls_method = TLSv1
#tls_certificate = "/usr/local/etc/opensips/tls/user/user-cert.pem"
#tls_private_key = "/usr/local/etc/opensips/tls/user/user-privkey.pem"
#tls_ca_list = "/usr/local/etc/opensips/tls/user/user-calist.pem"

# ------------------ module loading ----------------------------------
mpath="/usr/local/opensips/lib/modules/"

loadmodule "db_mysql.so"
loadmodule "sl.so"
loadmodule "maxfwd.so"
loadmodule "textops.so"
loadmodule "tm.so"
loadmodule "rr.so"
loadmodule "presence.so"
loadmodule "presence_xml.so"
loadmodule "mi_fifo.so"
loadmodule "usrloc.so"
loadmodule "registrar.so"
loadmodule "pua.so"
loadmodule "xmpp.so"
loadmodule "pua_xmpp.so"


# Uncomment this if you want digest authentication
# mysql.so must be loaded !
#loadmodule "auth.so"
#loadmodule "auth_db.so"

# ----------------- setting module-specific parameters ---------------

# --mi_fifo params --
modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")

# -- usrloc params --
modparam("usrloc", "db_mode", 2)
modparam("usrloc", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")

# -- auth params --
# Uncomment if you are using auth module
#
#modparam("auth_db", "calculate_ha1", yes)
#
# If you set "calculate_ha1" parameter to yes (which true in this config),
# uncomment also the following parameter)
#
#modparam("auth_db", "password_column", "password")

# -- rr params --
# add value to ;lr param to make some broken UAs happy
modparam("rr", "enable_full_lr", 1)

# -- presence and presence_xml params --
modparam("presence", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")
modparam("presence", "server_address", "sip:10.10.10.10:5060")
modparam("presence_xml", "force_active", 1)

# -- pua and pua_xmpp params --
modparam("pua", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")
modparam("pua_xmpp", "server_address", "sip:10.10.10.10:5060")

# -- xmpp parameters --
modparam("xmpp", "domain_separator", "*")
modparam("xmpp", "gateway_domain", "sip-xmpp.siphub.ro")
modparam("xmpp", "xmpp_domain", "xmpp-sip.siphub.ro")
modparam("xmpp", "xmpp_host", "xmpp.siphub.ro")
modparam("xmpp", "backend", "component")


# ------------------------- request routing logic -------------------

# main routing logic


route{

# initial sanity checks -- messages with
# max_forwards==0, or excessively long requests
if (!mf_process_maxfwd_header("10")) {
sl_send_reply("483","Too Many Hops");
exit;
};

if (msg:len >= 2048 ) {
sl_send_reply("513", "Message too big");
exit;
};

# we record-route all messages -- to make sure that
# subsequent messages will go through our proxy; that's
# particularly good if upstream and downstream entities
# use different transport protocol
if (!method=="REGISTER")
record_route();

# subsequent messages withing a dialog should take the
# path determined by record-routing
if (loose_route()) {
# mark routing logic in request
append_hf("P-hint: rr-enforced\r\n");
route(1);
};
if(method == "INVITE")
setflag(5);

if( uri=~"sip:.+@sip-xmpp.siphub.ro" ||
uri=~"sip:.+@sip-xmpp.siphub.ro")
{
if( is_method("PUBLISH|SUBSCRIBE|NOTIFY"))
route(2);
}

if( uri=~"sip:.+@sip-xmpp.siphub.ro")
{
# absorb retransmissions ###
if (!t_newtran()) {
sl_reply_error();
return;
}
if (method == "MESSAGE") {
log("*** xmpp-handled MESSAGE message.\n");
if (xmpp_send_message()) {
t_reply("200", "Accepted");
} else {
t_reply("404", "Not found");
}
return;
}else {
t_reply("403","not supported");
exit;
}

}

if (!uri==myself) {
# mark routing logic in request
append_hf("P-hint: outbound\r\n");
# if you have some interdomain connections via TLS
#if(uri=~"@tls_domain1.net") {
# t_relay("tls:domain1.net");
# exit;
#} else if(uri=~"@tls_domain2.net") {
# t_relay("tls:domain2.net");
# exit;
#}
route(1);
};

# if the request is for other domain use UsrLoc
# (in case, it does not work, use the following command
# with proper names and addresses in it)
if (uri==myself) {

if( is_method("PUBLISH|SUBSCRIBE|NOTIFY"))
route(2);

if (method=="REGISTER") {

# Uncomment this if you want to use digest authentication
#if (!www_authorize("opensips.org", "subscriber")) {
# www_challenge("opensips.org", "0");
# exit;
#};

save("location");
exit;
};

# native SIP destinations are handled using our USRLOC DB
if (!lookup("location")) {
sl_send_reply("404", "Not Found");
exit;
};
append_hf("P-hint: usrloc applied\r\n");
};

route(1);
}


route[1] {
# send it out now; use stateful forwarding as it works reliably
# even for UDP2TCP
if (!t_relay()) {
sl_reply_error();
};
exit;
}

route[2]
{
if ( !t_newtran() ){
sl_reply_error();
exit;
};

if( is_method("NOTIFY") && uri=~"sip:.+@sip-xmpp.siphub.ro"){
pua_xmpp_notify();
t_reply("200", "OK");
exit;
}

if(is_method("PUBLISH")){
handle_publish();
t_release();
}
else
if( is_method("SUBSCRIBE")){
handle_subscribe();
if( uri=~"sip:.+@sip-xmpp.siphub.ro" && $hdr(Event)== "presence"){
pua_xmpp_req_winfo("$ruri", "$hdr(Expires)");
}
t_release();
}

exit;
}@]++]

Page last modified on May 09, 2013, at 01:48 PM