[OpenSIPS-Users] Get IP/Port of registered user (or from Location table?)

bluerain frank21118 at yahoo.com
Mon Nov 18 02:14:41 CET 2013

Hello Liviu,

thanks for your help again!  Ok, so I tried that and is weird, is kinda
working but is working weirdly.  Not sure, maybe I don't truely understand
how opensips works?  But here is my code:

	if (is_method("INVITE")) {


			if (!lookup("location","m")){
					case -1: 
						$var(aor)="sip:FRANK101 at";
						if(!lookup("location","","$var(aor)")) {
							t_reply("404","Not Found new $rc");
					case -3:
						#$var(aor)="sip:FRANK101 at";
						#if(!lookup("location","","$var(aor)")) {
							t_reply("404","Not Found");
					case -2:
						#$var(aor)="sip:FRANK101 at";
						#if(!lookup("location","","$var(aor)")) {
							sl_send_reply("405", "Method Not Allowed");


So if I use the code above, it would reply "404","Not Found" which means the
lookup() function returned "-3"

And then if I unquote the all the "#" in "-3" section", since that is where
the error happend, now when I sent the INVITE, it would return "405 Method
Not Allowed", which means now lookup() function returned "-2"

So lastly if I unquote the "#"in "-2", the call actually worked!  But it
seems the code must got iterated 3 times before it reach the "method not
found" section and thus finally sent the call out?

So what I mean is that if I sent an "unknown" user in the INVITE, from the
code above, it will jump to "-1" section (because it return error code -1)
and then when it execute again the lookup() in the "-1" section, it jump to
-3 and then execute lookup() again in "-3" and then finally it jump to "-2"
to execute the finally lookup.  Why?

Shouldn't it simply jump to "-1" and then do the lookup("frank101") which IS
IN THE LOCATION table and then proceed with jumping to the route(relay) and
FRANK101 phone should ring, no?

but instead it seems it looped back into the "invite" and then do the lookup
again with blah errors, until it finally reach the finally possibility of
"-2", then call works... weird, why?

Thank you!

View this message in context: http://opensips-open-sip-server.1449251.n2.nabble.com/Get-IP-Port-of-registered-user-or-from-Location-table-tp7588494p7588550.html
Sent from the OpenSIPS - Users mailing list archive at Nabble.com.

More information about the Users mailing list