Hello,

do you want to check if caller (origin) is registered or if callee (destination) is registered? Like one can call to pstn only if has a phone registered for itself?

Or you want to say that you want to forward to gateway only for registered users. But maybe you want for local subscribers.

Cheers,
Daniel

On 3/12/13 3:04 PM, Victor V. Kustov wrote:
Hi.

I try to use Kamailio 4.1 git version as registrar and PSTN gw.

Need accept register from users. Its OK, I made it and use save()
function - from keep registrations in case of kamailio restart.

Need forward calls to gw, but only for registered users.
If I understand correctly in INVITE enough check
registered("location"), isnt it? but it's not work, i need verify auth
again.



Routing part of my config:


route {
         # initial sanity checks - skip in letter
# We are registrar!

         if (is_method("REGISTER"))
         {
                 sl_send_reply("100", "Trying"); # send "Trying, dont threat on 
me
                 if(isflagset(FLT_NATS))
                 {
                       setbflag(FLB_NATB);
                         # uncomment next line to do SIP NAT pinging
                         ## setbflag(FLB_NATSIPPING);
                 }

                 # we must check auth right now
                 # WORK: if (!www_authorize("$fd", "subscriber"))
                 if (!auth_check("$fd", "subscriber", "1"))
                 {
                     # WORK: www_challenge("$fd", "0");
                     auth_challenge("$fd", "0");
                     # send me requisites plz
                     exit;
                 } else
                 {
                     # ok. auth accepted, save in location
                     if (save("location"))
                     #if (save("location","0x04","$fd"))
                            {
                         xlog("L_WARN", "Save OK in location sip:$au@$fd");
                            } else
                            {
                         xlog("L_WARN", "Save FAIL in location sip:$au@$fd");
                            }
                 }

                 xlog("L_WARN", "REGISTERED method done");
                 exit;
         }

         if (is_method("INVITE"))
         {
            if ($si == $sel(cfg_get.pstn.gw_ip))
            {
              # incoming calls
              xlog("L_WARN", "Incoming call");
            } else
            {
                 # outgoing calls

                 xlog("L_WARN", "Outgoing call");
                 # check auth
                 # we must check auth right now

                 if (!proxy_authorize("$fd", "subscriber"))
                 {
                     proxy_challenge("$fd", "0");
                     exit;
                 }
consume_credentials();

### THAT FUNCTIONS ALWAYS WRITE IN LOGS
# "!registered" "!lookup" for both registered and unregged users

#                if (!registered("location")) xlog("L_WARN","!registered");
#                if (!lookup("location")) xlog("L_WARN", "!lookup");

                 # number change - FIX late
                 # check may be used dialplan automatically?

                 # route
                 $ru = "sip:" + $rU + "@" + $sel(cfg_get.pstn.gw_ip);
                 xlog("L_WARN", "Rewrite to $ru, send to PSTN.");
                
                 if (!t_relay()) { sl_reply_error(); }
            }

        } else
        {
        # reply 2 keepalive and drop all
         # if (!t_relay()) { sl_reply_error(); }
         }      

}







--
Daniel-Constantin Mierla - http://www.asipto.com
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Kamailio World Conference, April 16-17, 2013, Berlin
 - http://conference.kamailio.com -


_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

Reply via email to