<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Segoe UI";
        panose-1:2 11 5 2 4 2 4 2 2 3;}
@font-face
        {font-family:"Segoe UI Semilight";
        panose-1:2 11 4 2 4 2 4 2 2 3;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">Rodrigo,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">Thank you for this! This helps out a lot in relation to pulling the info from a database.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">I think I may be able to do something with variable $fu<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">Select PBX<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">From table<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">Where CustomerContext like &#8216;%$fu%&#8217;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">That way If I have multiple customercontext it can dynamically select the correct PBX<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"> users-bounces@lists.opensips.org [mailto:users-bounces@lists.opensips.org]
<b>On Behalf Of </b>Rodrigo Pimenta Carvalho<br>
<b>Sent:</b> Tuesday, September 29, 2015 10:17 AM<br>
<b>To:</b> OpenSIPS users mailling list &lt;Users@lists.opensips.org&gt;<br>
<b>Subject:</b> Re: [OpenSIPS-Users] Questions in opensips<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<div id="divtagdefaultwrapper">
<p class="MsoNormal" style="margin-bottom:12.0pt;background:white"><span style="font-family:&quot;Calibri&quot;,sans-serif;color:black">Hi.<br>
I'm new to OpenSIPS too and I have received good help from experts that access this forum.<br>
But, one point that you have to do is access a database to get the information about the PBX, haven't you? For this, you can use the module AVPOP:<br>
<br>
modparam(&quot;avpops&quot;,&quot;db_url&quot;,&quot;sqlite:///usr/local/opensips_proxy/sqlite&quot;) # CUSTOMIZE ME<br>
<br>
That is, you can use a module that allows you to access the database. In this example, I use SQLite.<br>
<br>
Are you familiar with the database handling actions via such module?<br>
<br>
To get data from database, you can do something like this:<br>
<br>
avp_db_query(put sql query here, &quot;$avp(myAvp)&quot;);&nbsp; # the avp will contain the query result.<br>
<br>
About the others details, like forwarding calls, someone expert might reply to you.<br>
<br>
You SQL will be similar to: select PBX from table where Exten = 'extension' and CustomerContext = 'the customer context';<br>
<br>
{exten} &amp; {CustomerContext}, the query returns a value&nbsp;&nbsp; of which PBX&nbsp; <br>
<br>
Tell me if this information is useful for you, please.<br>
<br>
Regards.<o:p></o:p></span></p>
<p style="background:white"><span style="font-family:&quot;Calibri&quot;,sans-serif;color:black"><o:p>&nbsp;</o:p></span></p>
<p style="background:white"><span style="font-family:&quot;Calibri&quot;,sans-serif;color:black"><o:p>&nbsp;</o:p></span></p>
<div id="Signature">
<div name="divtagdefaultwrapper">
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">RODRIGO PIMENTA CARVALHO<br>
Inatel Competence Center<br>
Software<br>
Ph: &#43;55 35 3471 9200 RAMAL 979<o:p></o:p></span></p>
</div>
</div>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt;background:white"><span style="font-family:&quot;Calibri&quot;,sans-serif;color:black"><o:p>&nbsp;</o:p></span></p>
<div>
<div class="MsoNormal" align="center" style="text-align:center;background:white">
<span style="font-family:&quot;Calibri&quot;,sans-serif;color:black">
<hr size="2" width="98%" align="center">
</span></div>
<div id="divRplyFwdMsg">
<p class="MsoNormal" style="background:white"><b><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">De:</span></b><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">
</span><a href="mailto:users-bounces@lists.opensips.org"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">users-bounces@lists.opensips.org</span></a><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black"> &lt;</span><a href="mailto:users-bounces@lists.opensips.org"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">users-bounces@lists.opensips.org</span></a><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">&gt;
 em nome de Travis Manson-Drake &lt;</span><a href="mailto:travism@simplybits.com"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">travism@simplybits.com</span></a><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">&gt;<br>
<b>Enviado:</b> terça-feira, 29 de setembro de 2015 13:54<br>
<b>Para:</b> </span><a href="mailto:Users@lists.opensips.org"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">Users@lists.opensips.org</span></a><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black"><br>
<b>Assunto:</b> [OpenSIPS-Users] Questions in opensips</span><span style="font-family:&quot;Calibri&quot;,sans-serif;color:black">
<o:p></o:p></span></p>
<div>
<p class="MsoNormal" style="background:white"><span style="font-family:&quot;Calibri&quot;,sans-serif;color:black">&nbsp;<o:p></o:p></span></p>
</div>
</div>
<div>
<div>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">Hello everyone,
<o:p></o:p></span></p>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">&nbsp;<o:p></o:p></span></p>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">I wanted to pick your brains and see if any of you have done something like this before, or might eb able to send me in the right direction.<o:p></o:p></span></p>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">&nbsp;<o:p></o:p></span></p>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">Here&#8217;s what I&#8217;m trying to accomplish.<o:p></o:p></span></p>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">&nbsp;<o:p></o:p></span></p>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">Thought process<o:p></o:p></span></p>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">&nbsp;<o:p></o:p></span></p>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">Sip packet comes into proxy<o:p></o:p></span></p>
<p style="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:8.0pt;margin-left:.5in;text-indent:-.25in;line-height:105%;background:white">
<span style="font-size:11.0pt;line-height:105%;font-family:&quot;Calibri&quot;,sans-serif;color:black">-</span><span style="font-size:7.0pt;line-height:105%;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:11.0pt;line-height:105%;font-family:&quot;Calibri&quot;,sans-serif;color:black">Proxy parses sip message, and checks from_uri (for example {exten}{CustomerConetxt}@proxyIPaddr)<o:p></o:p></span></p>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">-&nbsp; once the proxy parses the data, we query a database.<o:p></o:p></span></p>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">- based on the value of {exten} &amp; {CustomerContext}, the query returns a value&nbsp;&nbsp; of which PBX this {exten}&amp;{CustomerContext} belongs to.<o:p></o:p></span></p>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">- once this info has been returned to the proxy it then manipulates the dest_uri to something like {exten}&amp;{CustomerContext}@PBX DNS<o:p></o:p></span></p>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">&nbsp;<o:p></o:p></span></p>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">At this point the sip message is forwarded onto the appropriate PBX, and we simply Record_Route for future communications.<o:p></o:p></span></p>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">&nbsp;<o:p></o:p></span></p>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">I know I can hard code the PBX&#8217;s value in the sip server of the UAC, and just have the proxy do what it does.<o:p></o:p></span></p>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">But what I&#8217;m really trying to go for is to simply hardcode the info for a sip proxy, have the UAC send its request to it, then it forwards on traffic to
 the appropriate PBX based upon the value of the from_uri<o:p></o:p></span></p>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">&nbsp;<o:p></o:p></span></p>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">With that being said:<o:p></o:p></span></p>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">&nbsp;<o:p></o:p></span></p>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">How would I do this?<o:p></o:p></span></p>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">&nbsp;<o:p></o:p></span></p>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">I had looked at sipmsgops and some of its functions however I can&#8217;t seem to find one that will enable me to pull just the dest uri, &amp; extract info from it<o:p></o:p></span></p>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">&nbsp;<o:p></o:p></span></p>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">Is there also a function in sipmsgops for manipulating the dest_uri?
<o:p></o:p></span></p>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">&nbsp;<o:p></o:p></span></p>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">Any input is greatly appreciated!
<o:p></o:p></span></p>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">&nbsp;<o:p></o:p></span></p>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">Thank you for your time,<o:p></o:p></span></p>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">&nbsp;<o:p></o:p></span></p>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">&nbsp;<o:p></o:p></span></p>
<p style="line-height:115%;background:white"><b><span style="font-size:10.0pt;line-height:115%;font-family:&quot;Arial&quot;,sans-serif;color:navy">Travis Manson-Drake</span></b><span style="font-size:11.0pt;line-height:115%;font-family:&quot;Calibri&quot;,sans-serif;color:black"><o:p></o:p></span></p>
<p style="line-height:115%;background:white"><b><span style="font-size:10.0pt;line-height:115%;font-family:&quot;Arial&quot;,sans-serif;color:navy">Voice Systems Analyst L1</span></b><span style="font-size:11.0pt;line-height:115%;font-family:&quot;Calibri&quot;,sans-serif;color:black"><o:p></o:p></span></p>
<p style="background:white"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif;color:navy">Simply Bits, LLC</span></b><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black"><o:p></o:p></span></p>
<p style="background:white"><b><i><span style="font-size:8.0pt;font-family:&quot;Arial&quot;,sans-serif;color:#FFC000">Now You&#8217;re Thinkin&#8217; Smart!</span></i></b><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black"><o:p></o:p></span></p>
<p style="line-height:115%;background:white"><span style="font-size:8.0pt;line-height:115%;font-family:&quot;Arial&quot;,sans-serif;color:navy">5225 N. Sabino Canyon Road
<br>
Tucson, AZ 85750</span><span style="font-size:11.0pt;line-height:115%;font-family:&quot;Calibri&quot;,sans-serif;color:black"><o:p></o:p></span></p>
<p style="line-height:115%;background:white"><b><span style="font-size:8.0pt;line-height:115%;font-family:&quot;Arial&quot;,sans-serif;color:navy">Phone:</span></b><span style="font-size:8.0pt;line-height:115%;font-family:&quot;Arial&quot;,sans-serif;color:navy">
</span><span style="font-size:8.0pt;line-height:115%;font-family:&quot;Arial&quot;,sans-serif;color:#002060">520-545-0311</span><span style="font-size:11.0pt;line-height:115%;font-family:&quot;Calibri&quot;,sans-serif;color:black"><o:p></o:p></span></p>
<p style="line-height:115%;background:white"><b><span style="font-size:8.0pt;line-height:115%;font-family:&quot;Arial&quot;,sans-serif;color:navy">Fax:</span></b><span style="font-size:8.0pt;line-height:115%;font-family:&quot;Arial&quot;,sans-serif;color:navy">
</span><span style="font-size:8.0pt;line-height:115%;font-family:&quot;Arial&quot;,sans-serif;color:#002060">520-545-7252</span><span style="font-size:11.0pt;line-height:115%;font-family:&quot;Calibri&quot;,sans-serif;color:black"><o:p></o:p></span></p>
<p style="line-height:115%;background:white"><b><span style="font-size:8.0pt;line-height:115%;font-family:&quot;Arial&quot;,sans-serif;color:navy">Support Hotline</span></b><span style="font-size:8.0pt;line-height:115%;font-family:&quot;Arial&quot;,sans-serif;color:navy">:
</span><span style="font-size:8.0pt;line-height:115%;font-family:&quot;Arial&quot;,sans-serif;color:#002060">5205450333</span><span style="font-size:11.0pt;line-height:115%;font-family:&quot;Calibri&quot;,sans-serif;color:black"><o:p></o:p></span></p>
<p style="background:white"><a href="http://www.simplybits.com/" title="http://www.simplybits.com/" id="LPlnk267778"><span style="font-size:8.0pt;color:#0563C1">www.simplybits.com</span></a><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black"><o:p></o:p></span></p>
<div style="margin-top:15.0pt;margin-bottom:15.0pt;overflow:auto" id="LPBorder_GT_14435463875780.5056159045648994">
<table class="MsoNormalTable" border="1" cellpadding="0" width="80%" style="width:80.0%;background:white;border-top:solid #CCCCCC 1.0pt;border-left:none;border-bottom:solid #CCCCCC 1.0pt;border-right:none">
<tbody>
<tr>
<td valign="top" style="border:none;padding:.75pt .75pt .75pt .75pt">
<div style="margin-left:10.5pt;margin-top:6.0pt;margin-right:10.5pt" id="LPTitle_14435463875770.15876367962107085">
<p class="MsoNormal"><span style="font-size:16.0pt;font-family:&quot;Segoe UI Semilight&quot;,sans-serif;color:#333333">Internet - Phone - Business Technology Solutions | Simply Bits<o:p></o:p></span></p>
</div>
<div style="margin-left:10.5pt;margin-top:6.0pt;margin-right:10.5pt" id="LPDescription_14435463875770.5587309017927775">
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Segoe UI&quot;,sans-serif;color:#666666">Providing buisnesses with qualtiy solutions for Internet Service, VoIP Phone Service, Fax to email, Website Design, Internet Marketing and much more.<o:p></o:p></span></p>
</div>
<div style="margin-left:10.5pt;margin-top:6.0pt;margin-right:10.5pt;margin-bottom:7.5pt;text-overflow: ellipsis;overflow:hidden" id="LPUrlContainer_14435463875770.039874300339964086">
<p class="MsoNormal"><a href="http://www.simplybits.com/" target="_blank"><span style="font-size:8.5pt;font-family:&quot;Segoe UI&quot;,sans-serif;text-decoration:none">Leia mais...</span></a><o:p></o:p></p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<p style="background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">&nbsp;<o:p></o:p></span></p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>