<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">You must not rely on STUN for NAT traversal. Read the RFC for details.<div><div><br></div><div><a href="http://tools.ietf.org/html/rfc5389">http://tools.ietf.org/html/rfc5389</a></div></div><div><span class="Apple-style-span" style="font-family: 'Lucida Grande', 'Lucida Sans Unicode', Arial, Verdana, sans-serif; font-size: 12px; line-height: 18px; "><br></span></div><div><span class="Apple-style-span" style="font-family: 'Lucida Grande', 'Lucida Sans Unicode', Arial, Verdana, sans-serif; font-size: 12px; line-height: 18px; ">Quote from the standard:</span></div><div><span class="Apple-style-span" style="font-family: 'Lucida Grande', 'Lucida Sans Unicode', Arial, Verdana, sans-serif; font-size: 12px; line-height: 18px; "><br></span></div><div><span class="Apple-style-span" style="font-family: 'Lucida Grande', 'Lucida Sans Unicode', Arial, Verdana, sans-serif; font-size: 12px; line-height: 18px; "><div class="round_border" style="border-top-left-radius: 5px 5px; border-top-right-radius: 5px 5px; border-bottom-right-radius: 5px 5px; border-bottom-left-radius: 5px 5px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-color: rgb(169, 169, 169); border-right-color: rgb(169, 169, 169); border-bottom-color: rgb(169, 169, 169); border-left-color: rgb(169, 169, 169); position: static; z-index: auto; ">Experience since the publication of RFC 3489 has found that classic STUN simply does not work sufficiently well to be a deployable solution.</div></span><div><br></div><div>To traverse NAT reliably you need media relays and optionally ICE support in the end-points. STUN is not enough to traverse NAT is just a helper tool,</div><div><br></div><div>Regards,</div><div>Adrian</div><div><br></div><div><div><div><div>On Oct 20, 2011, at 1:19 PM, archiveacephale wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><br>hello everyone,<br><br>my name is Lyu from Japan, working on a iOS app integration of OpenSIPS for<br>synchronized rich contents communication between clients.<br>What I want to achieve is letting 2 clients communicate touch drawing + voice + eventually video streaming in realtime to each other.<br><br>Synching touch drawing is going well, but I have problem with audio calls.<br><br>For NAT Traversal I've tried STUN server, which work fine for 3G-3G, 3G-WiFi and WiFi-WiFi w/ 2 different LANs,<br>but does not work for WiFi-WiFi on same LAN which is not tolerable for our project.<br>STUN server seems to work fine (which I'm not sure) as there's no difference in the log<br>for WiFi-WiFi (2 LANs) and WiFi-WiFi (same LAN).<br><br>As I'm a total newb in this field and not quite sure if my configuration is right, <br>I'd greatly appreciate if someone can tell me if my config set up isn't doing anything wrong.<br><br>My OpenSIPS server is running on a EC2 CentOS6 instance with OpenSIPS 1.7.0. and <br>using iDoubs v2 clients on iOS4 machines (iPhone and iPad).<br><br>Please let me know if I should share other logs than below.<br>Here's my STUN log (2 clients on same LAN):<br><br>received on A1:P1<br>Got a request (len=64) from LAN_GLOBAL_IP:64958<br>Received stun message: 64 bytes <br>ServerName = IM-client/OMA1.0 doubango/v0.0.0<br>Unknown attribute: 32808<br>Request parsed ok<br>BindRequest does not contain MessageIntegrity<br>Request is valid:<br> flags=0<br> changeIp=0<br> changePort=0<br> from = LAN_GLOBAL_IP:64958<br> respond to = LAN_GLOBAL_IP:64958<br> mapped = LAN_GLOBAL_IP:64958<br>Encoding stun message:<br>Encoding MappedAddress: LAN_GLOBAL_IP:64958<br>Encoding SourceAddress: SERVER_INTERNAL_IP_1:3478<br>Encoding ChangedAddress: SERVER_INTERNAL_IP_2:3479<br>Encoding XorMappedAddress: 250.174.7.15:56492<br>Encoding ServerName: <a href="http://Vovida.org">Vovida.org</a> 0.96<br><br>received on A1:P1<br>Got a request (len=64) from LAN_GLOBAL_IP:55792<br>Received stun message: 64 bytes<br>ServerName = IM-client/OMA1.0 doubango/v0.0.0<br>Unknown attribute: 32808<br>Request parsed ok<br>BindRequest does not contain MessageIntegrity<br>Request is valid:<br> flags=0<br> changeIp=0<br> changePort=0<br> from = LAN_GLOBAL_IP:55792<br> respond to = LAN_GLOBAL_IP:55792 <br> mapped = LAN_GLOBAL_IP:55792<br>Encoding stun message:<br>Encoding MappedAddress: LAN_GLOBAL_IP:55792<br>Encoding SourceAddress: SERVER_INTERNAL_IP_1:3478<br>Encoding ChangedAddress: SERVER_INTERNAL_IP_2:3479<br>Encoding XorMappedAddress: 250.174.7.15:63714<br>Encoding ServerName: <a href="http://Vovida.org">Vovida.org</a> 0.96<br><br><br>Here is my opensips.cfg:<br><br>#<br># $Id: opensips.cfg 8141 2011-07-08 12:17:13Z vladut-paiu $<br>#<br># OpenSIPS basic configuration script<br># by Anca Vamanu <<a href="mailto:anca@voice-system.ro">anca@voice-system.ro</a>><br>#<br># Please refer to the Core CookBook at:<br># <a href="http://www.opensips.org/Resources/DocsCookbooks">http://www.opensips.org/Resources/DocsCookbooks</a><br># for a explanation of possible statements, functions and parameters.<br>#<br><br><br>####### Global Parameters #########<br><br>#debug=3<br>#log_stderror=no<br>#log_facility=LOG_LOCAL0<br><br>fork=yes<br>children=4<br><br>/* uncomment the following lines to enable debugging */<br>debug=6<br>#fork=no<br>log_stderror=no<br><br>/* uncomment the next line to disable TCP (default on) */<br>#disable_tcp=yes<br><br>/* uncomment the next line to enable the auto temporary blacklisting of <br> not available destinations (default disabled) */<br>#disable_dns_blacklist=no<br><br>/* uncomment the next line to enable IPv6 lookup after IPv4 dns <br> lookup failures (default disabled) */<br>#dns_try_ipv6=yes<br><br>/* uncomment the next line to disable the auto discovery of local aliases<br> based on revers DNS on IPs (default on) */<br>#auto_aliases=no<br><br>/* uncomment the following lines to enable TLS support (default off) */<br>#disable_tls = no<br>#listen = tls:your_IP:5061<br>#tls_verify_server = 1<br>#tls_verify_client = 1<br>#tls_require_client_certificate = 0<br>#tls_method = TLSv1<br>#tls_certificate = "/usr/local/etc/opensips/tls/user/user-cert.pem"<br>#tls_private_key = "/usr/local/etc/opensips/tls/user/user-privkey.pem"<br>#tls_ca_list = "/usr/local/etc/opensips/tls/user/user-calist.pem"<br><br># default db_url to be used by modules requiring DB connection<br>db_default_url="<a href="mysql://opensips:opensips@localhost/opensips">mysql://opensips:opensips@localhost/opensips</a>"<br><br><br>port=5060<br><br>/* uncomment and configure the following line if you want opensips to <br> bind on a specific interface/port/proto (default bind on all available) */<br>#listen=udp:192.168.1.2:5060<br><br><br>####### Modules Section ########<br><br>#set module path<br>mpath="/usr/local/lib64/opensips/modules/"<br><br>/* uncomment next line for MySQL DB support */<br>loadmodule "db_mysql.so"<br>loadmodule "signaling.so"<br>loadmodule "sl.so"<br>loadmodule "tm.so"<br>loadmodule "rr.so"<br>loadmodule "maxfwd.so"<br>loadmodule "usrloc.so"<br>loadmodule "registrar.so"<br>loadmodule "textops.so"<br>loadmodule "mi_fifo.so"<br>loadmodule "uri.so"<br>loadmodule "acc.so"<br>/* uncomment next lines for MySQL based authentication support <br> NOTE: a DB (like db_mysql) module must be also loaded */<br>loadmodule "auth.so"<br>loadmodule "auth_db.so"<br>/* uncomment next line for aliases support<br> NOTE: a DB (like db_mysql) module must be also loaded */<br>loadmodule "alias_db.so"<br>/* uncomment next line for multi-domain support<br> NOTE: a DB (like db_mysql) module must be also loaded<br> NOTE: be sure and enable multi-domain support in all used modules<br> (see "multi-module params" section ) */<br>#loadmodule "domain.so"<br>/* uncomment the next two lines for presence server support<br> NOTE: a DB (like db_mysql) module must be also loaded */<br>loadmodule "presence.so"<br>loadmodule "presence_xml.so"<br><br><br># ----------------- setting module-specific parameters ---------------<br><br><br># ----- mi_fifo params -----<br>modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")<br><br><br># ----- rr params -----<br># do not append from tag to the RR (no need for this script)<br>modparam("rr", "append_fromtag", 0)<br><br><br># ----- registrar params -----<br>/* uncomment the next line not to allow more than 10 contacts per AOR */<br>modparam("registrar", "max_contacts", 10)<br><br><br># ----- usrloc params -----<br># modparam("usrloc", "db_mode", 0)<br>/* uncomment the following lines if you want to enable DB persistency<br> for location entries */<br>modparam("usrloc", "db_mode", 2)<br>modparam("usrloc", "db_url",<br><span class="Apple-tab-span" style="white-space:pre">        </span>"<a href="mysql://opensips:opensips@localhost/opensips">mysql://opensips:opensips@localhost/opensips</a>")<br><br><br># ----- uri params -----<br>modparam("uri", "use_uri_table", 0)<br><br><br># ----- acc params -----<br>/* what sepcial events should be accounted ? */<br>modparam("acc", "early_media", 1)<br>modparam("acc", "report_cancels", 1)<br>/* by default ww do not adjust the direct of the sequential requests.<br> if you enable this parameter, be sure the enable "append_fromtag"<br> in "rr" module */<br>modparam("acc", "detect_direction", 0)<br>/* account triggers (flags) */<br>modparam("acc", "failed_transaction_flag", 3)<br>modparam("acc", "log_flag", 1)<br>modparam("acc", "log_missed_flag", 2)<br>/* uncomment the following lines to enable DB accounting also */<br>modparam("acc", "db_flag", 1)<br>modparam("acc", "db_missed_flag", 2)<br><br><br># ----- auth_db params -----<br>/* uncomment the following lines if you want to enable the DB based<br> authentication */<br>modparam("auth_db", "calculate_ha1", yes)<br>modparam("auth_db", "password_column", "password")<br>modparam("auth_db", "db_url",<br><span class="Apple-tab-span" style="white-space:pre">        </span>"<a href="mysql://opensips:opensips@localhost/opensips">mysql://opensips:opensips@localhost/opensips</a>")<br>modparam("auth_db", "load_credentials", "")<br><br><br># ----- alias_db params -----<br>/* uncomment the following lines if you want to enable the DB based<br> aliases */<br>modparam("alias_db", "db_url",<br><span class="Apple-tab-span" style="white-space:pre">        </span>"<a href="mysql://opensips:opensips@localhost/opensips">mysql://opensips:opensips@localhost/opensips</a>")<br><br><br># ----- domain params -----<br>/* uncomment the following lines to enable multi-domain detection<br> support */<br>#modparam("domain", "db_url",<br>#<span class="Apple-tab-span" style="white-space:pre">        </span>"<a href="mysql://opensips:opensips@localhost/opensips">mysql://opensips:opensips@localhost/opensips</a>")<br>#modparam("domain", "db_mode", 1) # Use caching<br><br><br># ----- multi-module params -----<br>/* uncomment the following line if you want to enable multi-domain support<br> in the modules (dafault off) */<br>#modparam("auth_db|usrloc|uri", "use_domain", 1)<br><br><br># ----- presence params -----<br>/* uncomment the following lines if you want to enable presence */<br>modparam("presence|presence_xml", "db_url",<br><span class="Apple-tab-span" style="white-space:pre">        </span>"<a href="mysql://opensips:opensips@localhost/opensips">mysql://opensips:opensips@localhost/opensips</a>")<br>modparam("presence_xml", "force_active", 1)<br>modparam("presence", "server_address", "<a href="sip:127.0.0.1:5060">sip:127.0.0.1:5060</a>")<br><br><br>####### Routing Logic ########<br><br><br># main request routing logic<br><br>route{<br><br><span class="Apple-tab-span" style="white-space:pre">        </span>if (!mf_process_maxfwd_header("10")) {<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>sl_send_reply("483","Too Many Hops");<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>exit;<br><span class="Apple-tab-span" style="white-space:pre">        </span>}<br><br><span class="Apple-tab-span" style="white-space:pre">        </span>if (has_totag()) {<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span># sequential request withing a dialog should<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span># take the path determined by record-routing<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>if (loose_route()) {<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>if (is_method("BYE")) {<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>setflag(1); # do accounting ...<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>setflag(3); # ... even if the transaction fails<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>} else if (is_method("INVITE")) {<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span># even if in most of the cases is useless, do RR for<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span># re-INVITEs alos, as some buggy clients do change route set<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span># during the dialog.<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>record_route();<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>}<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span># route it out to whatever destination was set by loose_route()<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span># in $du (destination URI).<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>route(1);<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>} else {<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>/* uncomment the following lines if you want to enable presence */<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>if (is_method("SUBSCRIBE") && $rd == "your.server.ip.address") {<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span># in-dialog subscribe requests<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>route(2);<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>exit;<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>}<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>if ( is_method("ACK") ) {<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>if ( t_check_trans() ) {<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span># non loose-route, but stateful ACK; must be an ACK after <br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span># a 487 or e.g. 404 from upstream server<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>t_relay();<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>exit;<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>} else {<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span># ACK without matching transaction -><br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span># ignore and discard<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>exit;<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>}<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>}<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>sl_send_reply("404","Not here");<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>}<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>exit;<br><span class="Apple-tab-span" style="white-space:pre">        </span>}<br><br><span class="Apple-tab-span" style="white-space:pre">        </span>#initial requests<br><br><span class="Apple-tab-span" style="white-space:pre">        </span># CANCEL processing<br><span class="Apple-tab-span" style="white-space:pre">        </span>if (is_method("CANCEL"))<br><span class="Apple-tab-span" style="white-space:pre">        </span>{<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>if (t_check_trans())<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>t_relay();<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>exit;<br><span class="Apple-tab-span" style="white-space:pre">        </span>}<br><br><span class="Apple-tab-span" style="white-space:pre">        </span>t_check_trans();<br><br><span class="Apple-tab-span" style="white-space:pre">        </span># authenticate if from local subscriber (uncomment to enable auth)<br><span class="Apple-tab-span" style="white-space:pre">        </span># authenticate all initial non-REGISTER request that pretend to be<br><span class="Apple-tab-span" style="white-space:pre">        </span># generated by local subscriber (domain from FROM URI is local)<br><span class="Apple-tab-span" style="white-space:pre">        </span>if (!(method=="REGISTER") && from_uri==myself) /*no multidomain version*/<br><span class="Apple-tab-span" style="white-space:pre">        </span>##if (!(method=="REGISTER") && is_from_local()) /*multidomain version*/<br><span class="Apple-tab-span" style="white-space:pre">        </span>{<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>if (!proxy_authorize("", "subscriber")) {<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>proxy_challenge("", "0");<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>exit;<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>}<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>if (!db_check_from()) {<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>sl_send_reply("403","Forbidden auth ID");<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>exit;<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>}<br><span class="Apple-tab-span" style="white-space:pre">        </span><br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>consume_credentials();<br><span class="Apple-tab-span" style="white-space:pre">        </span>##<span class="Apple-tab-span" style="white-space:pre">        </span># caller authenticated<br><span class="Apple-tab-span" style="white-space:pre">        </span>}<br><br><span class="Apple-tab-span" style="white-space:pre">        </span># preloaded route checking<br><span class="Apple-tab-span" style="white-space:pre">        </span>if (loose_route()) {<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>xlog("L_ERR",<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>"Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]");<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>if (!is_method("ACK"))<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>sl_send_reply("403","Preload Route denied");<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>exit;<br><span class="Apple-tab-span" style="white-space:pre">        </span>}<br><br><span class="Apple-tab-span" style="white-space:pre">        </span># record routing<br><span class="Apple-tab-span" style="white-space:pre">        </span>if (!is_method("REGISTER|MESSAGE"))<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>record_route();<br><br><span class="Apple-tab-span" style="white-space:pre">        </span># account only INVITEs<br><span class="Apple-tab-span" style="white-space:pre">        </span>if (is_method("INVITE")) {<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>setflag(1); # do accounting<br><span class="Apple-tab-span" style="white-space:pre">        </span>}<br><span class="Apple-tab-span" style="white-space:pre">        </span>if (!uri==myself)<br><span class="Apple-tab-span" style="white-space:pre">        </span>## replace with following line if multi-domain support is used<br><span class="Apple-tab-span" style="white-space:pre">        </span>##if (!is_uri_host_local())<br><span class="Apple-tab-span" style="white-space:pre">        </span>{<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>append_hf("P-hint: outbound¥r¥n"); <br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span># if you have some interdomain connections via TLS<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>##if($rd=="tls_domain1.net") {<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>##<span class="Apple-tab-span" style="white-space:pre">        </span>t_relay("tls:domain1.net");<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>##<span class="Apple-tab-span" style="white-space:pre">        </span>exit;<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>##} else if($rd=="tls_domain2.net") {<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>##<span class="Apple-tab-span" style="white-space:pre">        </span>t_relay("tls:domain2.net");<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>##<span class="Apple-tab-span" style="white-space:pre">        </span>exit;<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>##}<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>route(1);<br><span class="Apple-tab-span" style="white-space:pre">        </span>}<br><br><span class="Apple-tab-span" style="white-space:pre">        </span># requests for my domain<br><br><span class="Apple-tab-span" style="white-space:pre">        </span>## uncomment this if you want to enable presence server <br><span class="Apple-tab-span" style="white-space:pre">        </span>## and comment the next 'if' block<br><span class="Apple-tab-span" style="white-space:pre">        </span>## NOTE: uncomment also the definition of route[2] from below<br><span class="Apple-tab-span" style="white-space:pre">        </span>if( is_method("PUBLISH|SUBSCRIBE"))<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>route(2);<br><br><span class="Apple-tab-span" style="white-space:pre">        </span>#if (is_method("PUBLISH"))<br><span class="Apple-tab-span" style="white-space:pre">        </span>#{<br><span class="Apple-tab-span" style="white-space:pre">        </span>#<span class="Apple-tab-span" style="white-space:pre">        </span>sl_send_reply("503", "Service Unavailable");<br><span class="Apple-tab-span" style="white-space:pre">        </span>#<span class="Apple-tab-span" style="white-space:pre">        </span>exit;<br><span class="Apple-tab-span" style="white-space:pre">        </span>#}<br><span class="Apple-tab-span" style="white-space:pre">        </span><br><br><span class="Apple-tab-span" style="white-space:pre">        </span>if (is_method("REGISTER"))<br><span class="Apple-tab-span" style="white-space:pre">        </span>{<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span># authenticate the REGISTER requests (uncomment to enable auth)<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>if (!www_authorize("", "subscriber"))<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>{<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>www_challenge("", "0");<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>exit;<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>}<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>if (!db_check_to()) <br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>{<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>sl_send_reply("403","Forbidden auth ID");<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>exit;<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>}<br><br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>if (!save("location"))<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>sl_reply_error();<br><br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>exit;<br><span class="Apple-tab-span" style="white-space:pre">        </span>}<br><br><span class="Apple-tab-span" style="white-space:pre">        </span>if ($rU==NULL) {<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span># request with no Username in RURI<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>sl_send_reply("484","Address Incomplete");<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>exit;<br><span class="Apple-tab-span" style="white-space:pre">        </span>}<br><br><span class="Apple-tab-span" style="white-space:pre">        </span># apply DB based aliases (uncomment to enable)<br><span class="Apple-tab-span" style="white-space:pre">        </span>alias_db_lookup("dbaliases");<br><br><span class="Apple-tab-span" style="white-space:pre">        </span># do lookup with method filtering<br><span class="Apple-tab-span" style="white-space:pre">        </span>if (!lookup("location","m")) {<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>switch ($retcode) {<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>case -1:<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>case -3:<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>t_newtran();<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>t_reply("404", "Not Found");<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>exit;<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>case -2:<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>sl_send_reply("405", "Method Not Allowed");<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>exit;<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>}<br><span class="Apple-tab-span" style="white-space:pre">        </span>}<br><br><span class="Apple-tab-span" style="white-space:pre">        </span># when routing via usrloc, log the missed calls also<br><span class="Apple-tab-span" style="white-space:pre">        </span>setflag(2);<br><br><span class="Apple-tab-span" style="white-space:pre">        </span>route(1);<br>}<br><br><br>route[1] {<br><span class="Apple-tab-span" style="white-space:pre">        </span># for INVITEs enable some additional helper routes<br><span class="Apple-tab-span" style="white-space:pre">        </span>if (is_method("INVITE")) {<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>t_on_branch("2");<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>t_on_reply("2");<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>t_on_failure("1");<br><span class="Apple-tab-span" style="white-space:pre">        </span>}<br><br><span class="Apple-tab-span" style="white-space:pre">        </span>if (!t_relay()) {<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>sl_reply_error();<br><span class="Apple-tab-span" style="white-space:pre">        </span>};<br><span class="Apple-tab-span" style="white-space:pre">        </span>exit;<br>}<br><br><br># Presence route<br>/* uncomment the whole following route for enabling presence<br> NOTE: do not forget to enable the call of this route from the main<br> route */<br>route[2]<br>{<br><span class="Apple-tab-span" style="white-space:pre">        </span>if (!t_newtran())<br><span class="Apple-tab-span" style="white-space:pre">        </span>{<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>sl_reply_error();<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>exit;<br><span class="Apple-tab-span" style="white-space:pre">        </span>};<br><br><span class="Apple-tab-span" style="white-space:pre">        </span>if(is_method("PUBLISH"))<br><span class="Apple-tab-span" style="white-space:pre">        </span>{<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>handle_publish();<br><span class="Apple-tab-span" style="white-space:pre">        </span>}<br><span class="Apple-tab-span" style="white-space:pre">        </span>else<br><span class="Apple-tab-span" style="white-space:pre">        </span>if( is_method("SUBSCRIBE"))<br><span class="Apple-tab-span" style="white-space:pre">        </span>{<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>handle_subscribe();<br><span class="Apple-tab-span" style="white-space:pre">        </span>}<br><br><span class="Apple-tab-span" style="white-space:pre">        </span>exit;<br>}<br><br><br>branch_route[2] {<br><span class="Apple-tab-span" style="white-space:pre">        </span>xlog("new branch at $ru¥n");<br>}<br><br><br>onreply_route[2] {<br><span class="Apple-tab-span" style="white-space:pre">        </span>xlog("incoming reply¥n");<br>}<br><br><br>failure_route[1] {<br><span class="Apple-tab-span" style="white-space:pre">        </span>if (t_was_cancelled()) {<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>exit;<br><span class="Apple-tab-span" style="white-space:pre">        </span>}<br><br><span class="Apple-tab-span" style="white-space:pre">        </span># uncomment the following lines if you want to block client <br><span class="Apple-tab-span" style="white-space:pre">        </span># redirect based on 3xx replies.<br><span class="Apple-tab-span" style="white-space:pre">        </span>##if (t_check_status("3[0-9][0-9]")) {<br><span class="Apple-tab-span" style="white-space:pre">        </span>##t_reply("404","Not found");<br><span class="Apple-tab-span" style="white-space:pre">        </span>##<span class="Apple-tab-span" style="white-space:pre">        </span>exit;<br><span class="Apple-tab-span" style="white-space:pre">        </span>##}<br><br><span class="Apple-tab-span" style="white-space:pre">        </span># uncomment the following lines if you want to redirect the failed <br><span class="Apple-tab-span" style="white-space:pre">        </span># calls to a different new destination<br><span class="Apple-tab-span" style="white-space:pre">        </span>##if (t_check_status("486|408")) {<br><span class="Apple-tab-span" style="white-space:pre">        </span>##<span class="Apple-tab-span" style="white-space:pre">        </span>sethostport("192.168.2.100:5060");<br><span class="Apple-tab-span" style="white-space:pre">        </span>##<span class="Apple-tab-span" style="white-space:pre">        </span># do not set the missed call flag again<br><span class="Apple-tab-span" style="white-space:pre">        </span>##<span class="Apple-tab-span" style="white-space:pre">        </span>t_relay();<br><span class="Apple-tab-span" style="white-space:pre">        </span>##}<br>}<br><br><br><br><br><br><br>_______________________________________________<br>Users mailing list<br><a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>http://lists.opensips.org/cgi-bin/mailman/listinfo/users<br><br></div></blockquote></div><br></div></div></div></body></html>