Rather than using your own delimiter (i.e. comma) and doing tedious string-splitting, you may wish to consider XAVPs for nonscalar/list-style data:
https://www.kamailio.org/wikidocs/cookbooks/5.7.x/pseudovariables/#xavpid-xavps -- Alex > On Sep 25, 2023, at 8:09 PM, Shah Hussain Khattak via sr-users > <[email protected]> wrote: > > 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 > __________________________________________________________ > Kamailio - Users Mailing List - Non Commercial Discussions > To unsubscribe send an email to [email protected] > Important: keep the mailing list in the recipients, do not reply only to the > sender! > Edit mailing list options or unsubscribe: -- Alex Balashov Principal Consultant Evariste Systems LLC Web: https://evaristesys.com Tel: +1-706-510-6800 __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions To unsubscribe send an email to [email protected] Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe:
