Change Via-port based on Destination-port

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Change Via-port based on Destination-port

joel.oliveira
This post was updated on .
Hello all,

I am having problems with a D-Link Horstbox Professional DVA-G3342SB which is behind a router and is not receiving any calls when registered in OpenSIPs; when I register him on a Asterisk it does receive calls.

My 2 different configurations are:
a) Asterisk 1.4.26.2
b) Opensips 1.6.4 + Cisco Media GW

As you can see in the pastebin - http://pastebin.com/LXPf3mXe , in both Request of Register by the client (Asterisk and OpenSIPs) the source-port is different then the Request-port ( e.g. in Asterisk source-port=1024 and via-port=1026 ), which by itself is very strange but Asterisk handles well the situation. When placing a call to the client ( first Invite in the pastebin ) it uses the same IP:port for both placing the SIP-message ( U 2011/06/08 11:57:54.237976 Asterisk-IP:5060 -> Client-IP:1024 ) and the Request Invite ( INVITE sip:Client-number@Client-IP:1024 SIP/2.0. ) delivering correctly the call.

In OpenSIPs: since the ports are different between the source and the via-header in the Register, OpenSIPs identifies the user as behind NAT ( which is true ). When placing a call to the client (the Last Invite on the Pastebin ) the Request-Invite-port and the destination-port are different because it uses both contact and the received information from DB to generate the SIP Request and the call never gets to the client.

U 2011/06/08 16:01:33.494159 OpenSIPs-IP:5060 -> Client-IP:1031
INVITE sip:Client-number@Client-IP:1026 SIP/2.0.

So for the question to maybe solve my problem: Is it possible to clone the Asterisk-behaviour, i.e. compare both via-IP and destination-IP and if they are equal just change the via-port with the destination-port? Or by any reason I am thinking this all wrong and should rethink this?

Thanks for your time - Best Regards,
Joel Oliveira
Reply | Threaded
Open this post in threaded view
|

Re: Change Via-port based on Destination-port

Bogdan-Andrei Iancu-2
Hi Joel,

Have you tried to add in the very beginning of your script a
"force_rport();" ?

Regards,
Bogdam

On 06/08/2011 07:00 PM, joel.oliveira wrote:

> Hello all,
>
> I am having problems with a D-Link Horstbox Professional DVA-G3342SB which
> is behind a router and is not receiving any calls when registered in
> OpenSIPs; when I register him on a Asterisk it does receive calls.
>
> My 2 different configurations are:
> a) Asterisk 1.4.26.2
> b) Opensips 1.6.4 + Cisco Media GW
>
> As you can see in the pastebin - http://pastebin.com/LXPf3mXe , in both
> Request of Register by the client (Asterisk and OpenSIPs) the source-port is
> different then the Via-port ( e.g. in Asterisk source-port=1024 and
> via-port=1026 ), which by itself is very strange but Asterisk handles well
> the situation. When placing a call to the client ( first Invite in the
> pastebin ) it uses the same IP:port for both placing the SIP-message and the
> Via-header delivering correctly the call.
>
> In OpenSIPs: since the ports are different between the source and the
> via-header, OpenSIPs identifies the user as behind NAT ( which is true ).
> When placing a call to the client (the Last Invite on the Pastebin ) the via
> and the destination-port are different because it uses both contact and the
> received information from DB to generate the SIP Request and the call never
> gets to the client.
>
> So for the question to maybe solve my problem: Is it possible to clone the
> Asterisk-behaviour, i.e. compare both via-IP and destination-IP and if they
> are equal just change the via-port with the destination-port? Or by any
> reason I am thinking this all wrong and should rethink this?
>
> Thanks for your time - Best Regards,
> Joel Oliveira

--
Bogdan-Andrei Iancu
OpenSIPS solutions and "know-how"


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Change Via-port based on Destination-port

joel.oliveira
Hello Bogdan,

Thanks for your reply. Yes, I had already the force_rport in the beginning of the script.

After some more analisys I found out that my problem wasn't with the first Invite but with the one that is branched to the client, the one that is generated by OpenSIPs and that is the one that has differences between the ports in the request and the destination part of the message.

After some time I figured out a way on doing this by changing the branch_route to:

branch_route[2] {

        xlog("New branch at $ru\n");
       
        if(is_method("INVITE") && $du != NULL)
        {
                # if RURI-domain is equal to the destination-domain and their ports are different substitute RURI-port with the destination-port
                if( $(du{uri.host}) == $rd && $(du{uri.port}) != $rp )
                        $rp = $(du{uri.port});
        }
       
}

By this I managed to imitate the Asterisk's behaviour :)

Best Regards,
Joel Oliveira