<div dir="ltr">Hi list! :-)<br>I'm a total newbie in Kamailio. Trying to study)<br>Sorry for lots of text, I'm simply don't know how to explain my questions shorter :-D<br><br>I want to configure Kamailio as dispatcher, registrar and NAT traversal in front of FS farm.<br>I've managed to set up Kamailio and Fswitches.<br>Now I need to handle "special cases" with confs, REFER transfers etc<br><br>Giovanni Maruzzelli once presented solution for this, with following logic:<br>-------------------------------------------------------------------------------------------------------<br>1) Kamailio by default distribute calls to various FSs - dispatch or load_balance<br>2) Each time Kamailio sends a call to a FS, it writes down which destination "number" is going to which FS<br>server and from which UserID<br>3) if another call comes for the same (or related) destination, or is originated from the same UserID<br>then Kamailio sends the call to that same FS server, bypassing default distribution algorithm<br>-------------------------------------------------------------------------------------------------------<br>Sounds good and helpful, but I'm stuck :-(<br><b>Can someone please share an example or point me how and in what form should I write down call info,<br>and how can I control it (delete on BYE or CANCEL)?</b><br><br>Actually there are 2 questions<br>It seems to me that recordings can be made using HTABLEs but here's a problem:<br>=====================================================================================<br>=============================================================================================<br>1) PROBLEM WITH WRITING TO HTABLE ON ATT TRANSFER<br><br>After the dispatcher sets $du - I write an htable entry $sht(fsdest=>$fU:$rU) = $du;<br>Existing entries are removed on catching 'BYE' for normal clearing, and with failure_route for all failures.<br>BYE logic is:<br>IN WITHINNDLG route<br><br><br><div style="color:rgb(248,248,242);background-color:rgb(39,40,34);font-family:Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre"><div>  <span style="color:rgb(249,38,114)">if</span> (has_totag()) {</div><div>    <span style="color:rgb(249,38,114)">if</span> (loose_route()) {</div><div>      <span style="color:rgb(249,38,114)">if</span> (is_method(<span style="color:rgb(230,219,116)">"BYE"</span>)) {</div><div>          <span style="color:rgb(249,38,114)">if</span> (sht_match_name(<span style="color:rgb(230,219,116)">"fsdest"</span>, <span style="color:rgb(230,219,116)">"eq"</span>, <span style="color:rgb(230,219,116)">"$fU:$rU"</span>)) {<br></div><div>            $sht(fsdest<span style="color:rgb(249,38,114)">=></span>$fU:$rU) <span style="color:rgb(249,38,114)">=</span> <span style="color:rgb(174,129,255)">$null</span>; //BYE A->B</div><div>          } <span style="color:rgb(249,38,114)">else</span> {</div><div>            $sht(fsdest<span style="color:rgb(249,38,114)">=></span>$rU:$fU) <span style="color:rgb(249,38,114)">=</span> <span style="color:rgb(174,129,255)">$null</span>; //BYE A<-B</div><div>          }</div><div>      }<br></div><div>      handle_ruri_alias();</div><div>      <span style="color:rgb(166,226,46)">route</span><span style="color:rgb(102,217,239)">(</span><span style="color:rgb(174,129,255)">RELAY</span><span style="color:rgb(102,217,239)">)</span>;</div><div>    }</div><div>  }</div></div><div><br></div>Another entry is setting up if blind transfer is made.<br>If INVITE is coming from one of FSs, and have 'Referred-By' field.<div>IN DIALOG route:  <br><div style="color:rgb(248,248,242);background-color:rgb(39,40,34);font-family:Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre"><div>    <span style="color:rgb(249,38,114)">if</span> (is_present_hf(<span style="color:rgb(230,219,116)">"Referred-By"</span>)) {</div><div>      $sht(fsdest<span style="color:rgb(249,38,114)">=></span>$fU:$rU) <span style="color:rgb(249,38,114)">=</span> $si;</div><div>    }</div></div>For now it's working. Entries are written and deleted properly.<br><br><b>Problem with Attended transfer.</b><br>1) A --> B = htable entry A:B=xxxx<br>2) A --> C = htable entry A:C=xxxx(checked and set same FS addr because $fU is present (If only it's worked as it should))<br>3) Att transfer (Refer $rU B, referred-by - A. Refer-To - C) B --> C = all related entries deleted from table over BYE logic.<br>4) No entry B --> C (no INVITE was sent, bridged by REFER)<br>So, logic for check active calls in htable is broken now, because we don't have entry B-->C<div><br></div><div><div><b>How can I handle writing to htable in Attended transfer case?</b></div>If another Invite will come FROM or TO B or C = there will be no htable entry.<br>I'm not sure this is even a correct way. Surely missing something.<div><div>=============================================================================================<br>=============================================================================================<br><br>2) PROBLEM WITH IDENTIFYING TABLE ENTRIES<br><br>Anyway, the main problem is with identifying those htables to set proper $du.<br>If INVITE is coming TO FSs I need to check if caller ID ($fU) or dest ($rU) is present in htables.<br><br>Form I need to write to hash must be like $fU:$rU<br>Entry must be unique or it will be:<br>1) rewrited anytime a new invite is going to the same dest.<br>2) deleted anytime BYE or failure will come <br><br>eg:<br>If $sht(fsdest=>$rU) = $dd <br>1) 1000 --> 3200 = htable entry 3200 = xxxx<br>2) 1005 --> 3200 = htable entry rewriten to the same 3200 = xxxx<br>When 1000 or 1005 leaving conf, it sends BYE and removes entry.<br>So, next call to 3200 may be sent to the wrong FS.<br><br>Ok, we have a unique entry ($fU:$rU). Checking for active destination:<br>if (sht_match_name("fsdest", "re", ":$rU")) {}<br>If there's an htable with $rU in key - we got a match.<br>Now we need to assign a value from htable to $du. </div><div>But, I don't know how to get the name of this entry.<br>There's always different $fU: (or $rU if we check for the same caller ID ($fU)).<br><br></div><div>eg:<br>1000 --> 3200 = htbale 1000 --> 3200<br>New call 1005 --> 3200<br>Check sht_match name ":3200" - got match<br>We need to set: $du = $sht(fsdest=>$fU:$rU)<br>But it will be $sht(fsdest=>1005:3200) and we don't have this entry. <br>We need (fsdest=>1003:3200) But i don't see any way to get needed $fU.<br><br><b>Is there any way to search or identify these tables?</b><br>=============================================================================================<br>=============================================================================================<br><br>Can someone help me with this, please? :-)<br>Or maybe there is a better way to do this? <br><br><b>My kamailio.cfg routing block in pastebin, if needed<br><a href="https://pastebin.com/1PZ0QSDW">https://pastebin.com/1PZ0QSDW</a></b><br><br></div><div>Thank you!<br></div><div>Regards, Tim<br></div></div></div></div></div>