[Kamailio-Users] help understanding kamailio.cfg and processing call flow

Fabian Borot fborot at hotmail.com
Thu Nov 13 04:54:56 CET 2008


hello

I have been struggling to get the grasp on kamailio for weeks now. My prob is not understanding the call flow but how to translate it using the functions provided by the modules and the core. I do not have clear the scope or reach of several functions,provided by either the core or the modules.
Example:


Register with Auth:

1- user sends REGISTER request w/o the encripted credentials
2- kamailio answers with 401 and sends the challenge
3- the uac sends the REGISTER again, this time with the right credentials and after verifying kamailio sends 200 OK
4- if the user is behind a NAT we can fix the contact info before saving it to the location db.


With the help of the forum and the tutorials I have found in the internet I have been able to accomplish it with these
 commands:

route{
    if (uri==myself) {
        if (method=="REGISTER") {
                xlog("L_INFO","mylog: starting to process REGISTER.Info.\n");
                    if (!www_authorize("", "subscriber")) {
                        xlog("L_INFO","mylog: REGISTER came without auth, sending challenge.\n");
                            www_challenge("", "0");
                            exit;
                    };
                    if (nat_uac_test("1")){
                        xlog("L_INFO","mylog: REGISTER-Device behind NAT.\n");
                            fix_nated_register();
            }
                    force_rport();
                    save("location");
                    xlog("L_INFO","mylog: save-location successful.\n");
                    exit;
    }
    route(1);
}
route[1] {
        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;
}

but here come the first questions:
1- when the uac sends the first REGISTER, the function www_challenge() is the one that actually sends the "401" message?
or the "exit" just exit out the "if" block and the script will continue with route(1) which in turns executes "t_relay()?

++from the doc, www_challenge() function++++
The function challenges a user agent. It will generate a WWW-Authorize header field containing a digest challenge, it 
will put the header field into a response generated from the request the server is processing and send the reply.
+++++++++++++++++++++++++++++++++


2- the "exit" after the save("location") function I assume would stop the execution of the script and at that point kamailio
responds with "200 ok"? or just exit out the "if" block, the script then reaches the "route(1)" section and the "t_relay()" 
sends the "200 ok"?

++ from the doc, core-cookbook, exit() function+++++++
Stop the execution of the configuration script – it has the same behaviour as return(0). It does not affect the 
implicit action to be taken after script execution.
++++++++++++++++++++++++++++

3- the "t_relay" function: does that function creates and sends the approriate response for each request? 
ex1: an INVITE is received, does t_relay() "know" that it can send "100 trying" automatically?
ex2: a "200 OK" is received as a response to an INVITE, does t_relay knows that it has to send an "ACK"?

++++++from the doc, t_relay() funcion ++++++++++
>From user's perspective, the major function is t_relay(). It setup transaction state, absorb retransmissions from upstream,
 generate downstream retransmissions and correlate replies to requests. 
+++++++++++++++++++++++++++++


4- why do I see ";" even after a "}", is it needed sometimes?
5- is "exit" the same as "exit()"?


These may sound like dumb questions for some of the experienced users, but for a newbie they are not. Also, if this sounds like "
hey, code my config file for me" I assure you that that is not the intended purpose.
I would appreciate any help and thank everybody in advance.


Fabian


 


_________________________________________________________________
Color coding for safety: Windows Live Hotmail alerts you to suspicious email.
http://windowslive.com/Explore/Hotmail?ocid=TXT_TAGLM_WL_hotmail_acq_safety_112008
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kamailio.org/pipermail/users/attachments/20081112/73734ad3/attachment.htm 


More information about the Users mailing list