[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sr-users
Subject:    [SR-Users] Iterating Through Multiple IP Peers for DID Call Termination in Kamailio
From:       Shah Hussain Khattak via sr-users <sr-users () lists ! kamailio ! org>
Date:       2023-09-26 0:09:43
Message-ID: KL1PR06MB6448E6887039C1A0AC3DD1BCCFFCA () KL1PR06MB6448 ! apcprd06 ! prod ! outlook ! com
[Download RAW message or body]

Hello Team,

I hope you're all doing well. I'm reaching out to request your insights on the \
following scenario.

Overview:
I have successfully configured Kamailio to authenticate IP addresses, primarily for \
PBXs and customers unable to register. With this setup, I can flawlessly receive \
incoming traffic and forward it to our internal FreeSwitch servers.

Current issue:
Now, I'm focusing on managing traffic in the opposite direction—specifically for \
DIDs. I have a DID table set up in Kamailio that associates DID numbers with their \
respective IP peers. Upon receiving a call, a database lookup is performed to find \
the destination number, after which the call is terminated at the customer's IP.

I'm facing difficulty in handling situations where a customer has multiple IP peers \
(for redundancy). My aim is to try each of these IPs sequentially when terminating a \
specific DID call towards them. The current logic I'm employing for the INVITE lookup \
looks like this:

# Database lookup for INVITEs

if (is_method("INVITE")) {
  sql_query("didrouting_db", "SELECT route_to FROM did_routing WHERE \
did_number='$rU'", "result");  if ($dbr(result=>rows) > 0) {
     $var(route_to) = $dbr(result=>[0,0]);
     xlog("L_INFO", "Routing DID $rU to $var(route_to)\n");
     $du = "sip:" + $var(route_to) + ":5060";
  } else {
     $du = "sip:" + FS_IP + ":5060";
  }
}

The above logic works fine for a single IP.

I intend to use a comma-separated list of IPs in my route_to column (for example \
192.168.1.2,192.168.1.3, ...) and then iterate through these IPs one by one. I'm \
having trouble coming up with a workable logic or loop to achieve this. Would you be \
able to offer any guidance or suggestions?

Please also recommend if there is a better approach available to handle this \
scenario.

Thank you in advance for your valuable input.


Regards,
Shah Hussain


[Attachment #3 (text/html)]

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} \
</style> </head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);" class="elementToProof"> </div>
<span style="font-family: Calibri, Helvetica, sans-serif;">Hello Team,</span>
<div class="elementToProof"><br>
</div>
<div class="elementToProof"><span style="font-family: Calibri, Helvetica, \
sans-serif;">I hope you're all doing well. I'm reaching out to request your insights \
on the following scenario.</span></div> <div><br>
</div>
<div><span style="font-family: Calibri, Helvetica, \
sans-serif;"><b><u>Overview:</u></b></span></div> <div><span style="font-family: \
Calibri, Helvetica, sans-serif;">I have successfully configured Kamailio to \
authenticate IP addresses, primarily for PBXs and customers unable to register. With \
this setup, I can flawlessly receive incoming traffic and forward  it to our internal \
FreeSwitch servers.</span></div> <div><br>
</div>
<div class="elementToProof"><span style="font-family: Calibri, Helvetica, \
sans-serif;"><b><u>Current issue:</u></b></span></div> <div><span style="font-family: \
Calibri, Helvetica, sans-serif;">Now, I'm focusing on managing traffic in the \
opposite direction—specifically for DIDs. I have a DID table set up in Kamailio that \
associates DID numbers with their respective IP peers. Upon receiving  a call, a \
database lookup is performed to find the destination number, after which the call is \
terminated at the customer's IP.</span></div> <div class="elementToProof"><br>
</div>
<div class="elementToProof"><span style="font-family: Calibri, Helvetica, \
sans-serif;">I'm facing difficulty in handling situations where a customer has \
multiple IP peers (for redundancy). My aim is to try each of these IPs sequentially \
when terminating a specific  DID call towards them. The current logic I'm employing \
for the INVITE lookup looks like this:</span><br> </div>
<div class="elementToProof"><br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);" class="elementToProof ContentPasted0"> <span style="font-family: \
&quot;Courier New&quot;, monospace;"># Database lookup for INVITEs</span></div> <div \
style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, \
0);" class="elementToProof ContentPasted0"> <span style="font-family: &quot;Courier \
New&quot;, monospace;"><br> </span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);" class="elementToProof ContentPasted0"> <div><span style="font-family: \
&quot;Courier New&quot;, monospace;">if (is_method(&quot;INVITE&quot;)) \
{</span></div> <div><span style="font-family: &quot;Courier New&quot;, \
monospace;">&nbsp; sql_query(&quot;didrouting_db&quot;, &quot;SELECT route_to FROM \
did_routing WHERE did_number='$rU'&quot;, &quot;result&quot;);</span></div> <div \
class="elementToProof"><span style="font-family: &quot;Courier New&quot;, \
monospace;">&nbsp; if ($dbr(result=&gt;rows) &gt; 0) {</span></div> <div><span \
style="font-family: &quot;Courier New&quot;, monospace;">&nbsp; &nbsp; \
&nbsp;$var(route_to) = $dbr(result=&gt;[0,0]);</span></div> <div><span \
style="font-family: &quot;Courier New&quot;, monospace;">&nbsp; &nbsp; \
&nbsp;xlog(&quot;L_INFO&quot;, &quot;Routing DID $rU to \
$var(route_to)\n&quot;);</span></div> <div><span style="font-family: &quot;Courier \
New&quot;, monospace;">&nbsp; &nbsp; &nbsp;$du = &quot;sip:&quot; + $var(route_to) + \
&quot;:5060&quot;;</span></div> <div class="elementToProof"><span style="font-family: \
&quot;Courier New&quot;, monospace;">&nbsp; } else {</span></div> <div><span \
style="font-family: &quot;Courier New&quot;, monospace;">&nbsp; &nbsp; &nbsp;$du = \
&quot;sip:&quot; + FS_IP + &quot;:5060&quot;;</span></div> <div><span \
style="font-family: &quot;Courier New&quot;, monospace;">&nbsp; }</span></div> </div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);" class="elementToProof ContentPasted0"> <span style="font-family: \
&quot;Courier New&quot;, monospace;">}</span><br> </div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);" class="elementToProof ContentPasted0"> <br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);" class="elementToProof ContentPasted0"> <div \
class="elementToProof"><span style="font-family: Calibri, Helvetica, sans-serif;">The \
above logic works fine for a single IP.&nbsp;</span></div> <div \
class="elementToProof"><span style="font-family: Calibri, Helvetica, \
sans-serif;"><br> </span></div>
<div class="elementToProof"><span style="font-family: Calibri, Helvetica, \
sans-serif;">I intend to use a comma-separated list of IPs in my <b>route_to</b> \
column (for example 192.168.1.2,192.168.1.3, ...) and then iterate through these IPs \
one by one. I'm having trouble coming up with a workable logic or loop to achieve \
this. Would you be able to offer any guidance or suggestions?&nbsp;</span></div> \
<div><br> </div>
<div>Please also recommend if there is a better approach available to handle this \
scenario.&nbsp;</div> <div><br>
</div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);" class="elementToProof ContentPasted0"> <span style="font-family: \
Calibri, Helvetica, sans-serif;">Thank you in advance for your valuable \
input.</span><br> </div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);" class="elementToProof ContentPasted0"> <span style="font-family: \
Calibri, Helvetica, sans-serif;"><br> </span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);" class="elementToProof ContentPasted0"> <span style="font-family: \
Calibri, Helvetica, sans-serif;"><br> </span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);" class="elementToProof ContentPasted0"> <span style="font-family: \
Calibri, Helvetica, sans-serif;">Regards,&nbsp;</span></div> <div style="font-family: \
Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" \
class="elementToProof ContentPasted0"> <span style="font-family: Calibri, Helvetica, \
sans-serif;">Shah Hussain&nbsp;</span></div> </body>
</html>



__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
To unsubscribe send an email to sr-users-leave@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the sender!
Edit mailing list options or unsubscribe:

--===============0557369711==--

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic