[Kamailio-Users] question about register

Fabian Borot fborot at hotmail.com
Mon Nov 10 18:06:10 CET 2008


Hello

I am having an issue handling UN-REGISTERs.


This is my config file:

route{
        xlog("L_INFO", "mylog: starting_main_logic.\n");
        if (!mf_process_maxfwd_header("10")) {
                sl_send_reply("483","Too Many Hops");
                xlog("L_INFO","mylog: Too Many Hops.\n");
                exit;
        };

        if (msg:len >= 2048 ) {
                sl_send_reply("513", "Message too big");
                xlog("L_INFO","mylog: Message too big.\n");
                exit;
        };
        
        if (!method=="REGISTER") {
                xlog("L_INFO","mylog: Recording Route. Method: [$rm].\n");
                record_route();
        }
      
        if (loose_route()) {
                # mark routing logic in request
                xlog("L_INFO","mylog: Loose Route section. Method: [$rm].\n");
                append_hf("P-hint: rr-enforced\r\n");
                route(1);
        };



         if (uri==myself) {
                if (method=="REGISTER" && (!search("expires=0"))) {
                        xlog("L_INFO","mylog: starting to process REGISTER.Info: [$au].\n");
                        if (!www_authorize("", "subscriber")) {
                                xlog("L_INFO","mylog: REGISTER came without auth, sending challenge.\n");
                                www_challenge("", "0");
                                exit;
                        };
                        save("location");
                        xlog("L_INFO","mylog: save-location successful.\n");
                        exit;
                } else if (method=="INVITE") {
                        xlog("L_INFO","mylog: Processing INVITE.\n");
                        if (!proxy_authorize("","subscriber")) {
                                xlog("L_INFO","mylog: INVITE came without auth, sending challenge.\n");
                                proxy_challenge("","0");
                                exit;
                };
                consume_credentials();
        };


        # native SIP destinations are handled using our USRLOC DB
        if (!lookup("location")) {
                sl_send_reply("404", "Not Found");
                xlog("L_INFO","mylog: lookup-location failed, sending 404 Not Found. Method: [$rm].\n");
                exit;
        };
        append_hf("P-hint: usrloc applied\r\n");
        };
        route(1);
}

route[1] {
        # send it out now; use stateful forwarding as it works reliably
        # even for UDP2TCP
        if (t_relay()) {
                xlog("L_INFO","mylog: Route 1 section. Method [$rm].");
        } else {
                sl_reply_error();
                xlog("L_INFO","mylog: Route 1 section. T_Relay failed. Method [$rm].");
        };
        exit;
}

I added the "&& (!search("expires=0"))" to make sure that only the REGISTER requests will be processed by the next lines and the AOR will be saved in those cases.
The X-lite sends "expires=0" in the Contact HF when it is unregistering. 
This is how the processing of a REGISTER looks like as per my code:

Nov 10 12:33:08 sp1094a ../../sbin/kamailio[26069]: mylog: starting_main_logic. 
Nov 10 12:33:08 sp1094a ../../sbin/kamailio[26069]: mylog: starting to process REGISTER.Info: [<null>]. 
Nov 10 12:33:08 sp1094a ../../sbin/kamailio[26069]: mylog: REGISTER came without auth, sending challenge. 
Nov 10 12:33:08 sp1094a ../../sbin/kamailio[26069]: mylog: starting_main_logic. 
Nov 10 12:33:08 sp1094a ../../sbin/kamailio[26069]: mylog: starting to process REGISTER.Info: [101]. 
Nov 10 12:33:08 sp1094a ../../sbin/kamailio[26069]: mylog: save-location successful. 

and when the phone UN-REGISTERs this is what I see:


Nov 10 12:33:17 sp1094a ../../sbin/kamailio[26069]: mylog: starting_main_logic. 
Nov 10 12:33:17 sp1094a ../../sbin/kamailio[26069]: mylog: lookup-location failed, sending 404 Not Found. Method: [REGISTER]. 


My question is, do I need to use the lookup section for REGISTERs and UN-REGISTERs?
If I comment out that part this is how the log looks like:

        #if (!lookup("location")) {
        #       sl_send_reply("404", "Not Found");
        #       xlog("L_INFO","mylog: lookup-location failed, sending 404 Not Found. Method: [$rm].\n");
        #       exit;
        #};



log:

the 1st part [REGISTER] looks the same

[root at sp1094a kamailio]# tail -f /var/log/kamailio_logs | grep mylog
Nov 10 12:36:35 sp1094a ../../sbin/kamailio[26203]: mylog: starting_main_logic. 
Nov 10 12:36:35 sp1094a ../../sbin/kamailio[26203]: mylog: starting to process REGISTER.Info: [<null>]. 
Nov 10 12:36:35 sp1094a ../../sbin/kamailio[26203]: mylog: REGISTER came without auth, sending challenge. 
Nov 10 12:36:35 sp1094a ../../sbin/kamailio[26203]: mylog: starting_main_logic. 
Nov 10 12:36:35 sp1094a ../../sbin/kamailio[26203]: mylog: starting to process REGISTER.Info: [101]. 
Nov 10 12:36:35 sp1094a ../../sbin/kamailio[26203]: mylog: save-location successful. 


and this is what the log shows when the phone is UN-REGISTERING


Nov 10 12:36:42 sp1094a ../../sbin/kamailio[26203]: mylog: starting_main_logic. 
Nov 10 12:36:42 sp1094a ../../sbin/kamailio[26203]: mylog: Route 1 section. Method [REGISTER].
Nov 10 12:36:42 sp1094a ../../sbin/kamailio[26203]: mylog: starting_main_logic. 
Nov 10 12:36:42 sp1094a ../../sbin/kamailio[26203]: mylog: Route 1 section. Method [REGISTER].
Nov 10 12:36:42 sp1094a ../../sbin/kamailio[26203]: mylog: starting_main_logic. 
Nov 10 12:36:42 sp1094a ../../sbin/kamailio[26203]: mylog: Route 1 section. Method [REGISTER].
Nov 10 12:36:42 sp1094a ../../sbin/kamailio[26203]: mylog: starting_main_logic. 
Nov 10 12:36:42 sp1094a ../../sbin/kamailio[26203]: mylog: Route 1 section. Method [REGISTER].
Nov 10 12:36:42 sp1094a ../../sbin/kamailio[26203]: mylog: starting_main_logic. 
Nov 10 12:36:42 sp1094a ../../sbin/kamailio[26203]: mylog: Route 1 section. Method [REGISTER].
Nov 10 12:36:42 sp1094a ../../sbin/kamailio[26203]: mylog: starting_main_logic. 
Nov 10 12:36:42 sp1094a ../../sbin/kamailio[26203]: mylog: Route 1 section. Method [REGISTER].
Nov 10 12:36:42 sp1094a ../../sbin/kamailio[26203]: mylog: starting_main_logic. 
Nov 10 12:36:42 sp1094a ../../sbin/kamailio[26203]: mylog: Route 1 section. Method [REGISTER].
Nov 10 12:36:42 sp1094a ../../sbin/kamailio[26203]: mylog: starting_main_logic. 
Nov 10 12:36:42 sp1094a ../../sbin/kamailio[26203]: mylog: Route 1 section. Method [REGISTER].
Nov 10 12:36:42 sp1094a ../../sbin/kamailio[26203]: mylog: starting_main_logic. 
Nov 10 12:36:42 sp1094a ../../sbin/kamailio[26203]: mylog: Route 1 section. Method [REGISTER].
Nov 10 12:36:42 sp1094a ../../sbin/kamailio[26203]: mylog: starting_main_logic. 
Nov 10 12:36:42 sp1094a ../../sbin/kamailio[26203]: mylog: Route 1 section. Method [REGISTER].
Nov 10 12:36:42 sp1094a ../../sbin/kamailio[26203]: mylog: starting_main_logic. 
Nov 10 12:36:42 sp1094a ../../sbin/kamailio[26203]: mylog: Route 1 section. Method [REGISTER].
Nov 10 12:36:42 sp1094a ../../sbin/kamailio[26203]: mylog: starting_main_logic. 
Nov 10 12:36:42 sp1094a ../../sbin/kamailio[26203]: mylog: Route 1 section. Method [REGISTER].
Nov 10 12:36:42 sp1094a ../../sbin/kamailio[26203]: mylog: starting_main_logic. 
Nov 10 12:36:42 sp1094a ../../sbin/kamailio[26203]: mylog: Route 1 section. Method [REGISTER].
Nov 10 12:36:43 sp1094a ../../sbin/kamailio[26203]: mylog: starting_main_logic. 
Nov 10 12:36:43 sp1094a ../../sbin/kamailio[26203]: mylog: Route 1 section. Method [REGISTER].
Nov 10 12:36:43 sp1094a ../../sbin/kamailio[26203]: mylog: starting_main_logic. 
Nov 10 12:36:43 sp1094a ../../sbin/kamailio[26203]: mylog: Route 1 section. Method [REGISTER].
Nov 10 12:36:43 sp1094a ../../sbin/kamailio[26203]: mylog: starting_main_logic. 
Nov 10 12:36:43 sp1094a ../../sbin/kamailio[26203]: mylog: Message too big. 

[root at sp1094a kamailio]# 

Regards


Fabian





_________________________________________________________________
Stay up to date on your PC, the Web, and your mobile phone with Windows Live
http://clk.atdmt.com/MRT/go/119462413/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kamailio.org/pipermail/users/attachments/20081110/51bb732b/attachment.htm 


More information about the Users mailing list