Dear Bogdan,<br><br>Thanks very much for your time.<br><br>Regards,<br>-LN<br><br><div class="gmail_quote">On Tue, Mar 31, 2009 at 8:53 PM, Bogdan-Andrei Iancu <span dir="ltr">&lt;<a href="mailto:bogdan@voice-system.ro">bogdan@voice-system.ro</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Please use fix_nated_register() for REGISTER requests - this will set the appropriate info to be saved in usrloc.<br>

<br>
fix_nated_register() is not changing the contact (so the usrloc will save the real contact), but is just setting some additional info to be saved in usrloc (the received field)<br>
<br>
fix_nated_contact() is actually changing the contact from the request - this is to be used for non-REGISTER requests.<div class="im"><br>
<br>
Regards,<br>
Bogdan<br>
<br>
oso che bol wrote:<br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="h5">
<br>
Dear Bogdan<br>
<br>
I change the config of NATed REGISTER request to:<br>
<br>
/    if (nat_uac_test(&quot;19&quot;)) {<br>
        if (is_method(&quot;REGISTER&quot;) || !search(&quot;^Record-Route&quot;)) {<br>
            log(&quot;LOG: HTK Someone trying to register from private IP, rewriting\n&quot;);<br>
            fix_nated_contact(); # Rewrite contact with source IP of signalling<br>
            force_rport(); # Add rport parameter to topmost Via<br>
            setbflag(6);    # Mark as NATed<br>
        if (method==&quot;INVITE&quot;) {<br>
            fix_nated_sdp(&quot;1&quot;); # Add direction=active to SDP<br>
            force_rport(); # Add rport parameter to topmost Via<br>
            setbflag(6); # Mark as NATed<br>
         };<br>
        };/<br>
<br>
Output of &quot;opensipsctl ul show&quot;:<br>
<br>
/[root@LN]# opensipsctl ul show<br>
database engine &#39;MYSQL&#39; loaded<br>
Control engine &#39;FIFO&#39; loaded<br>
entering fifo_cmd ul_dump<br>
Mar 31 07:17:27 [6412] DBG:mi_fifo:mi_parse_node: end of input tree<br>
Mar 31 07:17:27 [6412] DBG:mi_fifo:mi_fifo_server: done parsing the mi tree<br>
Domain:: aliases table=512 records=0 max_slot=0<br>
Domain:: location table=512 records=2 max_slot=1<br>
    AOR:: 5000<br>
        Contact:: sip:5000@77.69.220.94:5060;transport=UDP Q=<br>
            Expires:: 1038<br>
            Callid:: A9AOj5F5oIeDS04U53IMr4_65zZvf5<br>
            Cseq:: 6049<br>
            User-agent:: E66-1 RM-343 102.07.81<br>
            State:: CS_SYNC<br>
            Flags:: 0<br>
            Cflag:: 64<br>
            Socket:: udp:174.132.X.Y:5060<br>
            Methods:: 4294967295<br>
    AOR:: 6000<br>
        Contact:: sip:6000@58.186.156.135:11370;rinstance=dbe921dccef4bee4 Q=<br>
            Expires:: 1060<br>
            Callid:: MDdmOTVkNzAzODAxN2JiMjk0MTk1NTEwNThjOWE2ZTM.<br>
            Cseq:: 6<br>
            User-agent:: X-Lite release 1100l stamp 47546<br>
            State:: CS_SYNC<br>
            Flags:: 0<br>
            Cflag:: 64<br>
            Socket:: udp:174.132.X.Y:5060<br>
            Methods:: 5951<br>
FIFO command was:<br>
:ul_dump:opensips_receiver_6568/<br>
<br>
Could you please explain why with mobile user 5000, the contact /sip:5000@77.69.220.94:5060;transport=UDP /and with X-Lite User 6000 the contact is /6000@58.186.156.135:11370;rinstance=dbe921dccef4bee4/<br>
<br>
How fix_nated_register() differ with fix_nated_register(), do we need to call fix_nated_register() at REGISTER processing?<br>
<br>
Thanks and Regards,<br>
<br>
-LN<br>
<br></div></div><div class="im">
On Tue, Mar 31, 2009 at 6:19 PM, Bogdan-Andrei Iancu &lt;<a href="mailto:bogdan@voice-system.ro" target="_blank">bogdan@voice-system.ro</a> &lt;mailto:<a href="mailto:bogdan@voice-system.ro" target="_blank">bogdan@voice-system.ro</a>&gt;&gt; wrote:<br>

<br>
    Hi,<br>
<br>
    if the online-user info is correct, it looks like the<br>
    fix_nated_register() is not done.<br>
<br>
    Please post the output of &quot;opensipsctl ul show&quot;, for that specific<br>
    user.<br>
<br>
    Also test by using xlog if the at register time your processing<br>
    gets inside the &quot;if (!search(&quot;^Contact:[ ]*\*&quot;) &amp;&amp;<br>
    nat_uac_test(&quot;19&quot;)) {&quot;.<br>
<br>
    Regards,<br>
    Bogdan<br>
<br>
    oso che bol wrote:<br>
<br>
        Dear All,<br>
<br>
        I use Opensips 1.4.1 with rtpproxy 1.2 for NAT support.<br>
<br>
        I use X-Lite which is Behind NAT, register to OpenSIPs proxy,<br>
        Opensips store right contact address. But, when i use Nokia<br>
        E66 to register to Opensips, the contact address is bellow:<br>
        Online SIP Users<br>
        Username Domain Contact Expires User Agent<br>
        5000 *<a href="mailto:sip%3A5000@192.168.1.100" target="_blank">sip:5000@192.168.1.100</a> &lt;mailto:<a href="mailto:sip%253A5000@192.168.1.100" target="_blank">sip%3A5000@192.168.1.100</a>&gt;<br>
        &lt;mailto:<a href="mailto:sip%253A5000@192.168.1.100" target="_blank">sip%3A5000@192.168.1.100</a><br></div>
        &lt;mailto:<a href="mailto:sip%25253A5000@192.168.1.100" target="_blank">sip%253A5000@192.168.1.100</a>&gt;&gt;;transport=UDP* 2009-03-30<div><div></div><div class="h5"><br>
        07:20:24.0 E66-1 RM-343 102.07.81<br>
<br>
<br>
        User 5000 do not store with external IP address of its<br>
        (external address not 192.168.1.100). Do you have any ideas<br>
        about this?<br>
<br>
        Bellow is my Opensips.conf<br>
<br>
        Thanks and Regards,<br>
<br>
        -LN<br>
<br>
        Opensips.conf<br>
<br>
        ==================<br>
<br>
        ####### Global Parameters #########<br>
<br>
        debug=4<br>
        log_stderror=yes<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=yes<br>
<br>
        #disable_tcp=yes<br>
        #disable_dns_blacklist=no<br>
        #dns_try_ipv6=yes<br>
        #auto_aliases=no<br>
<br>
        /* uncomment the following lines to enable TLS support<br>
         (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 = &quot;//etc/opensips/tls/user/user-cert.pem&quot;<br>
        #tls_private_key = &quot;//etc/opensips/tls/user/user-privkey.pem&quot;<br>
        #tls_ca_list = &quot;//etc/opensips/tls/user/user-calist.pem&quot;<br>
<br>
<br>
        port=5060<br>
        listen=udp:MY_OPENSIP_IP:5060<br>
<br>
<br>
        ####### Modules Section ########<br>
<br>
        #set module path<br>
        mpath=&quot;//lib/opensips/modules/&quot;<br>
<br>
        /* uncomment next line for MySQL DB support */<br>
        loadmodule &quot;db_mysql.so&quot;<br>
        loadmodule &quot;sl.so&quot;<br>
        loadmodule &quot;tm.so&quot;<br>
        loadmodule &quot;rr.so&quot;<br>
        loadmodule &quot;maxfwd.so&quot;<br>
        loadmodule &quot;usrloc.so&quot;<br>
        loadmodule &quot;registrar.so&quot;<br>
        loadmodule &quot;textops.so&quot;<br>
        loadmodule &quot;mi_fifo.so&quot;<br>
        loadmodule &quot;uri_db.so&quot;<br>
        loadmodule &quot;uri.so&quot;<br>
        loadmodule &quot;xlog.so&quot;<br>
        loadmodule &quot;acc.so&quot;<br>
        loadmodule &quot;auth.so&quot;<br>
        loadmodule &quot;auth_db.so&quot;<br>
<br>
        #loadmodule &quot;presence.so&quot;<br>
        #loadmodule &quot;presence_xml.so&quot;<br>
<br>
        loadmodule &quot;nathelper.so&quot;<br>
        loadmodule &quot;avpops.so&quot;<br>
        ######################<br>
<br>
<br>
        modparam(&quot;mi_fifo&quot;, &quot;fifo_name&quot;, &quot;/tmp/opensips_fifo&quot;)<br>
        modparam(&quot;rr&quot;, &quot;enable_full_lr&quot;, 1)<br>
        modparam(&quot;rr&quot;, &quot;append_fromtag&quot;, 0)<br>
        modparam(&quot;registrar&quot;, &quot;method_filtering&quot;, 1)<br>
<br>
        /* uncomment the next line to disable parallel forking via<br>
        location */<br>
        # modparam(&quot;registrar&quot;, &quot;append_branches&quot;, 0)<br>
        /* uncomment the next line not to allow more than 10 contacts<br>
        per AOR */<br>
        #modparam(&quot;registrar&quot;, &quot;max_contacts&quot;, 10)<br>
        modparam(&quot;uri_db&quot;, &quot;use_uri_table&quot;, 1)<br>
        modparam(&quot;uri_db&quot;, &quot;db_url&quot;,<br>
        &quot;mysql://sermyadmin:secret@MY_DATABASE_IP/sermyadmin&quot;)<br>
        #them for bug9, like guide in bug9<br>
        modparam(&quot;uri_db&quot;, &quot;db_table&quot;, &quot;uri&quot;)<br>
<br>
<br>
        # ----- acc params -----<br>
        /* what sepcial events should be accounted ? */<br>
        modparam(&quot;acc&quot;, &quot;early_media&quot;, 1)<br>
        modparam(&quot;acc&quot;, &quot;report_ack&quot;, 1)<br>
        modparam(&quot;acc&quot;, &quot;report_cancels&quot;, 1)<br>
        modparam(&quot;acc&quot;, &quot;detect_direction&quot;, 0)<br>
        modparam(&quot;acc&quot;, &quot;failed_transaction_flag&quot;, 3)<br>
        modparam(&quot;acc&quot;, &quot;log_flag&quot;, 1)<br>
        modparam(&quot;acc&quot;, &quot;log_missed_flag&quot;, 2)<br>
        modparam(&quot;acc&quot;, &quot;db_flag&quot;, 1)<br>
        modparam(&quot;acc&quot;, &quot;db_missed_flag&quot;, 2)<br>
<br>
        modparam(&quot;usrloc&quot;, &quot;db_mode&quot;,   2)<br>
        modparam(&quot;usrloc&quot;, &quot;db_url&quot;,<br>
           &quot;mysql://sermyadmin:secret@MY_DATABASE_IP/sermyadmin&quot;)<br>
<br>
        modparam(&quot;auth_db&quot;, &quot;calculate_ha1&quot;, yes)<br>
        modparam(&quot;auth_db&quot;, &quot;password_column&quot;, &quot;password&quot;)<br>
        modparam(&quot;auth_db|permission&quot;, &quot;db_url&quot;,<br>
           &quot;mysql://sermyadmin:secret@MY_DATABASE_IP/sermyadmin&quot;)<br>
<br>
        modparam(&quot;avpops&quot;, &quot;avp_url&quot;,<br>
        &quot;mysql://sermyadmin:secret@MY_DATABASE_IP/sermyadmin&quot;)<br>
        modparam(&quot;avpops&quot;, &quot;avp_table&quot;, &quot;usr_preferences&quot;)<br>
<br>
        #try for fix error of Mobile Address<br>
        modparam(&quot;registrar&quot;, &quot;received_avp&quot;, &quot;$avp(s:rcv)&quot;)<br>
        modparam(&quot;nathelper&quot;, &quot;received_avp&quot;, &quot;$avp(s:rcv)&quot;)<br>
<br>
        #Theo guide<br>
        <a href="http://www.opensips.org/html/docs/modules/1.4.x/registrar.html" target="_blank">http://www.opensips.org/html/docs/modules/1.4.x/registrar.html</a><br>
        modparam(&quot;usrloc&quot;, &quot;nat_bflag&quot;, 6)<br>
        modparam(&quot;nathelper&quot;, &quot;ping_nated_only&quot;, 1)<br>
        modparam(&quot;nathelper&quot;, &quot;sipping_bflag&quot;, 8)<br>
<br>
        #modparam(&quot;nathelper&quot;, &quot;rtpproxy_sock&quot;, &quot;udp:MY_RTPPROXY_IP:7890&quot;)<br>
        modparam(&quot;nathelper&quot;, &quot;force_socket&quot;, &quot;udp:MY_RTPPROXY_IP:7890&quot;)<br>
        modparam(&quot;nathelper&quot;, &quot;natping_interval&quot;, 89)<br>
        modparam(&quot;nathelper&quot;, &quot;sipping_from&quot;, &quot;sip:1000@MY_OPENSIP_IP&quot;)<br>
<br>
<br>
        # main request routing logic<br>
<br>
        route {<br>
<br>
           #<br>
        -----------------------------------------------------------------<br>
           # Sanity Check Section<br>
           #<br>
        -----------------------------------------------------------------<br>
           if (!mf_process_maxfwd_header(&quot;10&quot;)) {<br>
               sl_send_reply(&quot;483&quot;, &quot;Too Many Hops&quot;);<br>
               exit;<br>
           }<br>
<br>
           if (msg:len &gt; max_len) {<br>
               sl_send_reply(&quot;513&quot;, &quot;Message Overflow&quot;);<br>
               exit;<br>
           }<br>
<br>
           #<br>
        -----------------------------------------------------------------<br>
           # Record Route Section<br>
           #<br>
        -----------------------------------------------------------------<br>
           if (method!=&quot;REGISTER&quot;) {<br>
               record_route();<br>
           }<br>
<br>
           if (method==&quot;BYE&quot; || method==&quot;CANCEL&quot;) {<br>
               unforce_rtp_proxy();<br>
           }<br>
<br>
           #<br>
        -----------------------------------------------------------------<br>
           # Loose Route Section<br>
           #<br>
        -----------------------------------------------------------------<br>
           if (loose_route()) {<br>
<br>
               if ((method==&quot;INVITE&quot; || method==&quot;REFER&quot;) &amp;&amp;<br>
        !has_totag()) {<br>
                   sl_send_reply(&quot;403&quot;, &quot;Forbidden&quot;);<br>
                   exit;<br>
               }<br>
<br>
               if (method==&quot;INVITE&quot;) {<br>
<br>
                   if (!proxy_authorize(&quot;MY_OPENSIPS_IP&quot;,&quot;subscriber&quot;)) {<br>
                       proxy_challenge(&quot;MY_OPENSIPS_IP&quot;,&quot;0&quot;);<br>
                       exit;<br>
                   } else if (!check_from()) {<br>
                       sl_send_reply(&quot;403&quot;, &quot;Use From=ID&quot;);<br>
                       exit;<br>
                   }<br>
                   consume_credentials();<br>
<br>
                   if (nat_uac_test(&quot;19&quot;)) {<br>
                       setflag(6);<br>
                       force_rport();<br>
                       fix_nated_contact();<br>
                   }<br>
                   force_rtp_proxy(&quot;l&quot;);<br>
               }<br>
               route(1);<br>
               exit;<br>
           }<br>
<br>
           #<br>
        -----------------------------------------------------------------<br>
           # Call Type Processing Section<br>
           #<br>
        -----------------------------------------------------------------<br>
           if (uri!=myself) {<br>
               route(4);<br>
               route(1);<br>
               exit;<br>
           }<br>
<br>
           if (method==&quot;ACK&quot;) {<br>
               route(1);<br>
               exit;<br>
           } else if (method==&quot;CANCEL&quot;) {<br>
               route(1);<br>
               exit;<br>
           } else if (method==&quot;INVITE&quot;) {<br>
               route(3);<br>
               exit;<br>
           } else  if (method==&quot;REGISTER&quot;) {<br>
               route(2);<br>
               exit;<br>
           }<br>
<br>
           lookup(&quot;aliases&quot;);<br>
           if (uri!=myself) {<br>
               route(4);<br>
               route(1);<br>
               exit;<br>
           }<br>
<br>
           if (!lookup(&quot;location&quot;)) {<br>
               sl_send_reply(&quot;404&quot;, &quot;User Not Found&quot;);<br>
               exit;<br>
           }<br>
<br>
           route(1);<br>
        }<br>
<br>
        route[1] {<br>
<br>
           #<br>
        -----------------------------------------------------------------<br>
           # Default Message Handler<br>
           #<br>
        -----------------------------------------------------------------<br>
<br>
           t_on_reply(&quot;1&quot;);<br>
<br>
           if (!t_relay()) {<br>
               if (method==&quot;INVITE&quot; &amp;&amp; isflagset(6)) {<br>
                   unforce_rtp_proxy();<br>
               };<br>
               sl_reply_error();<br>
           }<br>
        }<br>
<br>
        route[2] {<br>
<br>
           #<br>
        -----------------------------------------------------------------<br>
           # REGISTER Message Handler<br>
           #<br>
        ----------------------------------------------------------------<br>
<br>
           if (!search(&quot;^Contact:[ ]*\*&quot;) &amp;&amp; nat_uac_test(&quot;19&quot;)) {<br>
               setflag(6);<br>
               fix_nated_register();<br>
               force_rport();<br>
           }<br>
<br>
           sl_send_reply(&quot;100&quot;, &quot;Trying&quot;);<br>
<br>
           if (!www_authorize(&quot;MY_OPENSIPS_IP&quot;,&quot;subscriber&quot;)) {<br>
               www_challenge(&quot;MY_OPENSIPS_IP&quot;,&quot;0&quot;);<br>
               exit;<br>
           }<br>
<br>
           #if (!check_to()) {<br>
           #    sl_send_reply(&quot;401&quot;, &quot;Unauthorized Loi Ngo&quot;);<br>
           #    exit;<br>
           #}<br>
<br>
           consume_credentials();<br>
<br>
           if (!save(&quot;location&quot;)) {<br>
               sl_reply_error();<br>
           };<br>
        }<br>
<br>
        route[3] {<br>
<br>
           #<br>
        -----------------------------------------------------------------<br>
           # INVITE Message Handler<br>
           #<br>
        -----------------------------------------------------------------<br>
             #Drop because error Use From=ID when call. Open<br>
           #if (!proxy_authorize(&quot;&quot;,&quot;subscriber&quot;)) {<br>
           #    proxy_challenge(&quot;&quot;,&quot;0&quot;);<br>
           #    exit;<br>
           #} else if (!check_from()) {<br>
           #    sl_send_reply(&quot;403&quot;, &quot;Use From=ID&quot;);<br>
           #    exit;<br>
           #}<br>
<br>
           #consume_credentials();<br>
<br>
           if (nat_uac_test(&quot;19&quot;)) {<br>
               setflag(6);<br>
           }<br>
<br>
           lookup(&quot;aliases&quot;);<br>
           if (uri!=myself) {<br>
               route(4);<br>
               route(1);<br>
               exit;<br>
           }<br>
<br>
           if (!lookup(&quot;location&quot;)) {<br>
               sl_send_reply(&quot;404&quot;, &quot;User Not Found&quot;);<br>
               exit;<br>
           }<br>
<br>
           route(4);<br>
           route(1);<br>
        }<br>
<br>
        route[4] {<br>
<br>
           #<br>
        -----------------------------------------------------------------<br>
           # NAT Traversal Section<br>
           #<br>
        -----------------------------------------------------------------<br>
<br>
           if (isflagset(6)) {<br>
               force_rport();<br>
               fix_nated_contact();<br>
               force_rtp_proxy();<br>
           }<br>
        }<br>
<br>
        onreply_route[1] {<br>
<br>
           if (isflagset(6) &amp;&amp; status=~&quot;(180)|(183)|2[0-9][0-9]&quot;) {<br>
               if (!search(&quot;^Content-Length:[ ]*0&quot;)) {<br>
                   force_rtp_proxy();<br>
               }<br>
           }<br>
<br>
           if (nat_uac_test(&quot;1&quot;)) {<br>
               fix_nated_contact();<br>
           }<br>
        }<br>
<br>
        ------------------------------------------------------------------------<br>
<br>
        _______________________________________________<br>
        Users mailing list<br></div></div>
        <a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a> &lt;mailto:<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a>&gt;<div class="im"><br>
        <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
         <br>
<br>
<br>
</div></blockquote>
<br>
</blockquote></div><br>