<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
</style>
</head>
<body class='hmmessage'>
<meta http-equiv="Content-Type" content="text/html; charset=unicode">
<meta name="Generator" content="Microsoft SafeHTML">
<style>
.hmmessage P
{margin:0px;padding:0px;}
body.hmmessage
{font-size:10pt;font-family:Verdana;}
</style>
thank you fro you help klaus, I did not know about sipwise.com.<br><br><br><br><br>> Date: Thu, 13 Nov 2008 10:06:11 +0100<br>> From: klaus.mailinglists@pernau.at<br>> To: fborot@hotmail.com<br>> CC: users@lists.kamailio.org<br>> Subject: Re: [Kamailio-Users] help understanding kamailio.cfg and processing call flow<br>> <br>> 1. read the confige file from sipwise.com - IMO it is very self explanatory.<br>> <br>> some comments below:<br>> <br>> Fabian Borot schrieb:<br>> > hello<br>> > <br>> > Register with Auth:<br>> > <br>> > 1- user sends REGISTER request w/o the encripted credentials<br>> > 2- kamailio answers with 401 and sends the challenge<br>> > 3- the uac sends the REGISTER again, this time with the right <br>> > credentials and after verifying kamailio sends 200 OK<br>> > 4- if the user is behind a NAT we can fix the contact info before saving <br>> > it to the location db.<br>> > <br>> > <br>> > With the help of the forum and the tutorials I have found in the <br>> > internet I have been able to accomplish it with these<br>> > commands:<br>> > <br>> > route{<br>> > if (uri==myself) {<br>> > if (method=="REGISTER") {<br>> > xlog("L_INFO","mylog: starting to process <br>> > REGISTER.Info.\n");<br>> > if (!www_authorize("", "subscriber")) {<br>> > xlog("L_INFO","mylog: REGISTER came without <br>> > auth, sending challenge.\n");<br>> > www_challenge("", "0");<br>> > exit;<br>> > };<br>> > if (nat_uac_test("1")){<br>> > xlog("L_INFO","mylog: REGISTER-Device behind <br>> > NAT.\n");<br>> > fix_nated_register();<br>> > }<br>> > force_rport();<br>> > save("location");<br>> > xlog("L_INFO","mylog: save-location successful.\n");<br>> > exit;<br>> > }<br>> > route(1);<br>> > }<br>> > route[1] {<br>> > if (t_relay()) {<br>> > xlog("L_INFO","mylog: Route 1 section. Method [$rm].");<br>> > } else {<br>> > sl_reply_error();<br>> > xlog("L_INFO","mylog: Route 1 section. T_Relay failed. <br>> > Method [$rm].");<br>> > };<br>> > exit;<br>> > }<br>> > <br>> > but here come the first questions:<br>> > 1- when the uac sends the first REGISTER, the function www_challenge() <br>> > is the one that actually sends the "401" message?<br>> <br>> Yes, it sends 401 and exits immediately. Thus the exit after 401 would <br>> not be needed, but it is good to have it there as it eases reading the <br>> config script.<br>> <br>> > or the "exit" just exit out the "if" block and the script will continue <br>> > with route(1) which in turns executes "t_relay()?<br>> > <br>> > ++from the doc, www_challenge() function++++<br>> > The function challenges a user agent. It will generate a WWW-Authorize <br>> > header field containing a digest challenge, it<br>> > will put the header field into a response generated from the request the <br>> > server is processing and send the reply.<br>> > +++++++++++++++++++++++++++++++++<br>> > <br>> > <br>> > 2- the "exit" after the save("location") function I assume would stop <br>> > the execution of the script and at that point kamailio<br>> > responds with "200 ok"? or just exit out the "if" block, the script then <br>> > reaches the "route(1)" section and the "t_relay()"<br>> > sends the "200 ok"?<br>> <br>> save stores the record and send back 200 OK. But it does not stop <br>> processing. Thus, you MUST have an exit after save().<br>> <br>> > <br>> > ++ from the doc, core-cookbook, exit() function+++++++<br>> > Stop the execution of the configuration script – it has the same <br>> > behaviour as return(0). It does not affect the<br>> > implicit action to be taken after script execution.<br>> > ++++++++++++++++++++++++++++<br>> > <br>> > 3- the "t_relay" function: does that function creates and sends the <br>> > approriate response for each request?<br>> > ex1: an INVITE is received, does t_relay() "know" that it can send "100 <br>> > trying" automatically?<br>> <br>> t_relay() sends automatically 100 trying to the caller (except you call <br>> it with some special flags (see README of tm module)) and forwards the <br>> request to the next destination.<br>> <br>> > ex2: a "200 OK" is received as a response to an INVITE, does t_relay <br>> > knows that it has to send an "ACK"?<br>> <br>> No. The proxy does not send ACK. The proxy forwards the response to the <br>> caller. Then the caller will send the ACK which will be forwarded by the <br>> proxy to the callee. For successful call setups the proxy wont send <br>> ACKs. The proxy will send ACK to the callee by itself only if a call <br>> gets cancelled.<br>> <br>> > <br>> > ++++++from the doc, t_relay() funcion ++++++++++<br>> > From user's perspective, the major function is t_relay(). It setup <br>> > transaction state, absorb retransmissions from upstream,<br>> > generate downstream retransmissions and correlate replies to requests.<br>> > +++++++++++++++++++++++++++++<br>> > <br>> > <br>> > 4- why do I see ";" even after a "}", is it needed sometimes?<br>> <br>> };<br>> is the same as<br>> }<br>> <br>> choose the syntax you like<br>> <br>> > 5- is "exit" the same as "exit()"?<br>> <br>> I don't know - I always use exit;<br>> Probably exit() is just an alias.<br>> <br>> <br>> regards<br>> klaus<br>> <br>> <br>> <br>> > <br>> > <br>> > These may sound like dumb questions for some of the experienced users, <br>> > but for a newbie they are not. Also, if this sounds like "<br>> > hey, code my config file for me" I assure you that that is not the <br>> > intended purpose.<br>> > I would appreciate any help and thank everybody in advance.<br>> > <br>> > <br>> > Fabian<br>> > <br>> > <br>> > <br>> > <br>> > <br>> > ------------------------------------------------------------------------<br>> > Color coding for safety: Windows Live Hotmail alerts you to suspicious <br>> > email. Sign up today. <br>> > <http://windowslive.com/Explore/Hotmail?ocid=TXT_TAGLM_WL_hotmail_acq_safety_112008><br>> > <br>> > <br>> > ------------------------------------------------------------------------<br>> > <br>> > _______________________________________________<br>> > Users mailing list<br>> > Users@lists.kamailio.org<br>> > http://lists.kamailio.org/cgi-bin/mailman/listinfo/users<br><br /><hr />Color coding for safety: Windows Live Hotmail alerts you to suspicious email. <a href='http://windowslive.com/Explore/Hotmail?ocid=TXT_TAGLM_WL_hotmail_acq_safety_112008' target='_new'>Sign up today.</a></body>
</html>