Hi.

Thank you for the hint.

I think that search_body will search a string in SDP body. In this case, for 
the first INVITE, SDP doesn't have information about the callee. So, maybe I 
have to use a way of checking the register of the callee (table location) and 
see if the contact and received columns give me some information.


Any idea?


Best regards.


RODRIGO PIMENTA CARVALHO
Inatel Competence Center
Software
Ph: +55 35 3471 9200 RAMAL 979


________________________________
De: [email protected] <[email protected]> em nome 
de Dragomir Haralambiev <[email protected]>
Enviado: sexta-feira, 4 de março de 2016 15:24
Para: OpenSIPS users mailling list
Assunto: Re: [OpenSIPS-Users] How to know whether callee is behind a NAT?

Here is simple way to check NAT devices:
if ( search_body('IN IP4 10.') ) { setflag(NAT); }
if ( search_body("IN IP4 192.168.") ) { setflag(NAT); }
if ( search_body("IN IP4 172.16.") ) { setflag(NAT); }

2016-03-04 19:31 GMT+02:00 Rodrigo Pimenta Carvalho 
<[email protected]<mailto:[email protected]>>:

Hi.


Nowadays I'm having problems to take right control of SIP messages, in a 
situation with user agents present in the LAN and WAN (some of them are behind 
NAT, to the point of view of OpenSIPS).

To control everything, I'm using local domain and public domain registered in 
the Domain table. In addiction I intend to implement the following algorithm:



If message == SIP INVITE

{

    //Tries to guess if client's request originated behind a nat. The parameter 
determines what heuristics is used

    // 2 - the "received" test is used: address in Via is compared against 
source IP address of signaling .

    // 32 - address in Contact is compared against source IP address of 
signaling.

    If ( ! nat_uac_test(2 + 32))

    {

        //caller is in local network


        If callee is behind a NAT from the point of view of opensips

        {

            avp_db_query("select domain from domain where attrs = public", 
"$avp(DOMAIN)");

            set_advertised_address ("$avp(DOMAIN));

        }

        else

        {

            avp_db_query("select domain from domain where attrs = local", 
"$avp(DOMAIN)");
            set_advertised_address ("$avp(DOMAIN));

        }

    }

    else

    {

        avp_db_query("select domain from domain where attrs = public", 
"$avp(DOMAIN)");
        set_advertised_address ("$avp(DOMAIN));

    }

}


However, how can I know whether the callee is not in the same network area as 
the caller, so the callee is behind a NAT?


Any hint will be very helpful!


RODRIGO PIMENTA CARVALHO
Inatel Competence Center
Software
Ph: +55 35 3471 9200<tel:%2B55%2035%203471%209200> RAMAL 979

_______________________________________________
Users mailing list
[email protected]<mailto:[email protected]>
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

Reply via email to