<div dir="ltr"><p class="MsoNormal"><span lang="EN-US" style="font-family:"Verdana","sans-serif"">Greetings,</span></p><p class="MsoNormal"><span lang="EN-US" style="font-family:"Verdana","sans-serif""><br>
</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Verdana","sans-serif"">In my OpenSIPS server, when I receive an INVITE
requests, I need to (1) consult an external database to get a list of gateways,
and (2) send the request to those gateways, in order, starting from the first
and trying the next only if the current one fails (e.g. irresponsive, offline,
busy, etc).</span></p><p class="MsoNormal"><span lang="EN-US" style="font-family:"Verdana","sans-serif""><br></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Verdana","sans-serif"">I understand that forwarding calls to a certain gateway
can be achieved using the </span><span lang="EN-US" style="font-family:"Courier New"">rewritehostport(…)</span><span lang="EN-US" style="font-family:"Verdana","sans-serif""> function; and
that prefix-/caller-/group-/time-/priority-based dynamic routing can be
addressed using the </span><span lang="EN-US" style="font-family:"Courier New"">DROUTING</span><span lang="EN-US" style="font-family:"Verdana","sans-serif""> module. However, in my system
what actually is “dynamic” is the gateway list itself, which is therefore not a
subset of the </span><span lang="EN-US" style="font-family:"Courier New"">dr_gateways</span><span lang="EN-US" style="font-family:"Verdana","sans-serif""> table. In fact, OpenSIPS has
no idea about the list of gateways due to the complex business-logic involved.
The dynamic gateway list, nevertheless, needs to be treated identical to an
ordinary one, i.e. prefix, time and priority of gateways must be considered.</span></p><p class="MsoNormal"><span lang="EN-US" style="font-family:"Verdana","sans-serif""><br></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Verdana","sans-serif"">Solving this problem, I assume, requires either
writing a whole new </span><span lang="EN-US" style="font-family:"Courier New"">DROUTING</span><span lang="EN-US" style="font-family:"Verdana","sans-serif""> module, which wraps the
necessary business-logic and consults the external database; or wrapping the
business-logic in a Perl script that is called from the routing script (</span><span lang="EN-US" style="font-family:"Courier New"">opensips.cfg</span><span lang="EN-US" style="font-family:"Verdana","sans-serif"">).
Now, there are two issues that I would like to know your expert opinion about:</span></p><p class="MsoNormal"><span lang="EN-US" style="font-family:"Verdana","sans-serif""><br></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Verdana","sans-serif"">1. Is my solution, i.e. using the Perl script to wrap the business logic and queries to the external database, the best possible way to do this?</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Verdana","sans-serif""><br></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Verdana","sans-serif"">2. As the list of gateways is dynamic, is there any
way to leverage the facilities offered by the </span><span lang="EN-US" style="font-family:"Courier New"">DROUTING</span><span lang="EN-US" style="font-family:"Verdana","sans-serif"">
module? Specifically, can I somehow get the list of gateways from the Perl
script and pass it to the </span><span lang="EN-US" style="font-family:"Courier New"">DROUTING</span><span lang="EN-US" style="font-family:"Verdana","sans-serif""> module for
prefix-/time-/priority-based routing, or probing, purposes?</span></p><p class="MsoNormal"><span lang="EN-US" style="font-family:"Verdana","sans-serif""><br></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Verdana","sans-serif"">Regards,</span></p>
<p class="MsoNormal"><font face="Verdana, sans-serif">Shaahin Madani</font></p></div>