<div dir="ltr"><p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;">Greetings,</span></p><p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;"><br>
</span></p>

<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;">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:&quot;Verdana&quot;,&quot;sans-serif&quot;"><br></span></p>

<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;">I understand that forwarding calls to a certain gateway
can be achieved using the </span><span lang="EN-US" style="font-family:&quot;Courier New&quot;">rewritehostport(…)</span><span lang="EN-US" style="font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;"> function; and
that prefix-/caller-/group-/time-/priority-based dynamic routing can be
addressed using the </span><span lang="EN-US" style="font-family:&quot;Courier New&quot;">DROUTING</span><span lang="EN-US" style="font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;"> 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:&quot;Courier New&quot;">dr_gateways</span><span lang="EN-US" style="font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;"> 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:&quot;Verdana&quot;,&quot;sans-serif&quot;"><br></span></p>

<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;">Solving this problem, I assume, requires either
writing a whole new </span><span lang="EN-US" style="font-family:&quot;Courier New&quot;">DROUTING</span><span lang="EN-US" style="font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;"> 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:&quot;Courier New&quot;">opensips.cfg</span><span lang="EN-US" style="font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;">).
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:&quot;Verdana&quot;,&quot;sans-serif&quot;"><br></span></p>

<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;">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:&quot;Verdana&quot;,&quot;sans-serif&quot;"><br></span></p>

<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;">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:&quot;Courier New&quot;">DROUTING</span><span lang="EN-US" style="font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;">
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:&quot;Courier New&quot;">DROUTING</span><span lang="EN-US" style="font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;"> module for
prefix-/time-/priority-based routing, or probing, purposes?</span></p><p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;"><br></span></p>

<p class="MsoNormal"><span lang="EN-US" style="font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;">Regards,</span></p>

<p class="MsoNormal"><font face="Verdana, sans-serif">Shaahin Madani</font></p></div>