[Kamailio-Users] help understanding kamailio.cfg and processing call flow
Fabian Borot
fborot at hotmail.com
Thu Nov 13 15:47:13 CET 2008
thank you fro you help klaus, I did not know about sipwise.com.
> Date: Thu, 13 Nov 2008 10:06:11 +0100
> From: klaus.mailinglists at pernau.at
> To: fborot at hotmail.com
> CC: users at lists.kamailio.org
> Subject: Re: [Kamailio-Users] help understanding kamailio.cfg and processing call flow
>
> 1. read the confige file from sipwise.com - IMO it is very self explanatory.
>
> some comments below:
>
> Fabian Borot schrieb:
> > hello
> >
> > 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?
>
> Yes, it sends 401 and exits immediately. Thus the exit after 401 would
> not be needed, but it is good to have it there as it eases reading the
> config script.
>
> > 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"?
>
> save stores the record and send back 200 OK. But it does not stop
> processing. Thus, you MUST have an exit after save().
>
> >
> > ++ 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?
>
> t_relay() sends automatically 100 trying to the caller (except you call
> it with some special flags (see README of tm module)) and forwards the
> request to the next destination.
>
> > ex2: a "200 OK" is received as a response to an INVITE, does t_relay
> > knows that it has to send an "ACK"?
>
> No. The proxy does not send ACK. The proxy forwards the response to the
> caller. Then the caller will send the ACK which will be forwarded by the
> proxy to the callee. For successful call setups the proxy wont send
> ACKs. The proxy will send ACK to the callee by itself only if a call
> gets cancelled.
>
> >
> > ++++++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?
>
> };
> is the same as
> }
>
> choose the syntax you like
>
> > 5- is "exit" the same as "exit()"?
>
> I don't know - I always use exit;
> Probably exit() is just an alias.
>
>
> regards
> klaus
>
>
>
> >
> >
> > 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. Sign up today.
> > <http://windowslive.com/Explore/Hotmail?ocid=TXT_TAGLM_WL_hotmail_acq_safety_112008>
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Users mailing list
> > Users at lists.kamailio.org
> > http://lists.kamailio.org/cgi-bin/mailman/listinfo/users
_________________________________________________________________
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/20081113/94ed2720/attachment.htm
More information about the Users
mailing list