[OpenSIPS-Users] lookup() questions

OCEANET - Cédric BASSAGET cedric at oceanet.com
Wed Oct 29 14:04:27 CET 2014


Hi Bogdan,
thanks for your reply.

nat_bflag is set before save(location), so I have a "received" field in 
my usrloc table.

Here's what I see with debug :

route[1][BEFORE LOOKUP] ru=sip:0970559986@<IP of UAC> , du=<null>
route[1][LOOKUP] lookup with aor=sip:2015@<domain>
route[1][AFTER LOOKUP] ru=sip:2015@<IP of UAC> , du=sip:<IP of UAC>:1024

so $du seems to be good too.

Now I have to play with $rU as Răzvan said, tu replace 2015 with the 
real phone number I'm trying to reach.

Thanks for your help again.
Regards,
Cédric


OCEANET
---------------------------------------------------------------
[AGENCE DU MANS]
7, rue des Frênes
ZAC de la Pointe
72190 SARGE LES LE MANS
[t] +33 (0)2.43.50.26.50
[f] +33 (0)2.43.72.21.14

[AGENCE D'ANGERS]
5, rue Fleming
Angers Technopole
49066 ANGERS
[t] +33 (0)2.41.19.28.65
[f] +33 (0)2.52.19.22.00

http://www.oceanet.com
http://www.oceanet-telecom.com

On 28/10/2014 13:37, Bogdan-Andrei Iancu wrote:
> Hello Cedric,
>
> First of all, do not forget about the nat flag (see nat_bflag in 
> usrloc module):
> http://www.opensips.org/html/docs/modules/1.11.x/usrloc.html#id293683
>
> You should set it before save(location), if REGISTER comes from behind 
> a NAT.
>
> Now, if the usrloc records has a "received" field, when doing 
> lookup(location), you will get:
>     contact URI in $ru
>     received URI in $du
>
> And when doing t_relay(), $du (outbound proxy) has priority over $ru, 
> so the call should be sent to 1014 port.
>
> Regards,
>
> Bogdan-Andrei Iancu
> OpenSIPS Founder and Developer
> http://www.opensips-solutions.com
>
> On 27.10.2014 12:37, OCEANET - Cédric BASSAGET wrote:
>> Hello Răzvan,
>>
>> Thanks for your reply.
>> Yes, I'm sure i'm tracking udp trafic, I can see SIP options for 
>> example.
>> I've found my error, and it's a big one : I was doing "exit" in my 
>> switch() statement, instead of "break". So t_relay was never 
>> called... No comment...
>>
>> So the lookup function seems to work correctly, but it does not do 
>> what I expect.
>>
>> What I want is just to send SIP requests to UAC behind NAT on the 
>> good udp port (ex : 1025, corresponding to the "received" field in 
>> usrloc). Actually (when not using lookup() ), requests are sent to 
>> port 5060, whatever the value of "received" field is. But I don't 
>> want to change user and domain part of RURI, just adjust the port.
>>
>> With lookup() function :
>> incoming INVITE RURI : sip:0970559986@<the IP of my SBC>:5060
>> INVITE RURI after lookup (to my UAC) : sip:2015@<the IP of my UAC>
>>
>> invite is relayed to udp port 1025, which is a good thing. But 
>> username has been changed, and I don't want that.
>>
>> Without lookup() function, invite is relayed to port 5060, so my 
>> router/nat doesn't route it correctly -> nothing works.
>>
>> Don't hesitate to ask if this is not clear. I don't know where to 
>> look for, usrloc seems to be good, but is not used well...
>>
>> Should I do a mysql query to extract the port of the "received" in 
>> usrloc, and then play qith $dp and $rp ? I think there is something 
>> simpler than that, but I can't find it.
>>
>> I hope somebody can help me ...!
>> Regards,
>> Cédric
>>
>>
>>
>>
>>
>>
>> OCEANET
>> ---------------------------------------------------------------
>> [AGENCE DU MANS]
>> 7, rue des Frênes
>> ZAC de la Pointe
>> 72190 SARGE LES LE MANS
>> [t] +33 (0)2.43.50.26.50
>> [f] +33 (0)2.43.72.21.14
>>
>> [AGENCE D'ANGERS]
>> 5, rue Fleming
>> Angers Technopole
>> 49066 ANGERS
>> [t] +33 (0)2.41.19.28.65
>> [f] +33 (0)2.52.19.22.00
>>
>> http://www.oceanet.com
>> http://www.oceanet-telecom.com
>>
>> On 24/10/2014 20:15, Răzvan Crainea wrote:
>>> Hi, Cedric!
>>>
>>> The third version is the correct version you should use, if the 
>>> R-URI is different than the AOR you are looking for.
>>> Are you sure that your tcpdump trace is tracking the UDP traffic? 
>>> Are you sure there are no errors generated by t_relay()? Do you see 
>>> t_relay DBG lines in the logs?
>>>
>>> Best regards,
>>>
>>> Răzvan Crainea
>>> OpenSIPS Core Developer
>>> http://www.opensips-solutions.com
>>>
>>> On 10/24/2014 02:31 AM, OCEANET - Cédric BASSAGET wrote:
>>>> Hello,
>>>>
>>>> I'm actually trying to resolve NAT issues with opensips, and I have a
>>>> problem using lookup() function.
>>>>
>>>> UAC register to my opensips server. When UAC is behind nat (detected
>>>> with nat_uac_test()), I do a "fix_nated_register()" and 
>>>> save("location").
>>>> My usrloc table looks correct, I have a line with (important fields):
>>>> - a username = 2015 (sip trunk identifier)
>>>> - a domain = the domain my UAC is registering to (= the domain my
>>>> opensips is listening on)
>>>> - a contact = sip:2015@<the IP of my UAC>
>>>> - a received = sip:<the IP of my UAC>:<port> (in my tests, port=1024)
>>>> - and many other fields (...)
>>>>
>>>> When trying to relay an incoming INVITE to this UAC, if I understood
>>>> well, I have to do a "lookup()" before t_relay, to tell opensips to 
>>>> send
>>>> the request to the "usrloc.received" <address:port>.
>>>>
>>>> I've tried couple things, like :
>>>> - lookup("location") -> $ru is totally different from what we are
>>>> looking for, so it does not work, that's normal
>>>> - lookup("location","","2015@<domain>") -> got an error :
>>>> ERROR:core:parse_uri: bad uri,  state 0 parsed: <2015> (4) /
>>>> <2015 at domain> (37)
>>>> - lookup("location","","sip:2015@<domain>") -> $retcode=1, and debug
>>>> shows me this :
>>>>
>>>> DBG:registrar:lookup: found a complete match
>>>> DBG:registrar:lookup: setting as ruri <sip:2015@<the IP of my UAC>>
>>>> but nothing goes out to ip address of my UAC... (tcpdump).
>>>>
>>>> Can somebody tell me if I've correctly understood how lookup() 
>>>> function
>>>> works ? Or if I'm doing totally aberrant things ?
>>>>
>>>> Regards,
>>>> Cédric
>>>>
>>>> _______________________________________________
>>>> Users mailing list
>>>> Users at lists.opensips.org
>>>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at lists.opensips.org
>>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.opensips.org
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>




More information about the Users mailing list