[Serusers] What exactly does "lookup" lookup?

Klaus Darilion klaus.mailinglists at pernau.at
Thu Apr 14 23:29:25 CEST 2005


Hi Brian!

Brian McCrary wrote:
> Hello,
> 
> My routing plans are pretty simple, when a number comes into SER,
> see if it it's a registered SIP phone, if so send the call to it, and
> if not, then authenticate the user, and send it to the PSTN gateway.  

You should authenticate all calls from local users (user which REGISTERs 
with your SIP proxy). And only these users are allowed to access the PSTN.

> I thought this could easily be solved by having a lookup("location") as
> the first part of my routing.  However, I'm not really sure what lookup
> looks up.  I assume it's the user being dialed, such as if a call comes
> in wanting sip:1234567890 at x.x.x.x, lookup would look into the database
> and see user "1234567890" matches a registered user, and go from there.

Yes, that is the it goes. Of course lookup("location") can only find 
something, if there are registered users - you have to save the location 
using save("location") for REGISTER requests.

Note: depeding on the use_domain setting, lookup also compares the 
domain part of the SIP URI.

> However, using lookup never returns a match, thus the call goes into a
> loop since it's next stop is the PSTN gateway.  I can see the phone has
> registered by running serctl ul show.
> 
> Here's part of my routing I tried using, I may be incorrect in using
> t_relay, but right now lookup is never true

It looks fine. Probably you have problems with matching domains. Verfiy 
the domain of the registered user with serctl and compare it to the 
domain in the INVITE request.

regards,
klaus


> 
> if (method=="INVITE") {
>                         if (lookup("location")) {
> 			log("LOG: SIP Phone found\n");
>                         t_relay();
>                         break; 
>                        } else if (uri=~"sip:[0-9]+ at .*") { 
>                        if (!is_user_in("credentials", "local")) {
>                        sl_send_reply("403", "Forbidden");
>                        break;
>                        };
> 
> rewritehostport("10.0.0.4:5060");  # PSTN GW
> 
> Brian
> 
> _______________________________________________
> Serusers mailing list
> serusers at lists.iptel.org
> http://lists.iptel.org/mailman/listinfo/serusers
> 
> 




More information about the sr-users mailing list