<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:10pt"><div><span>Basically your inbouind and outbound calls should go through the same sequence of checkups, and look for a local user number. Then outbound calls should resort in your PSTN trunk, and inbound calls resort in a 404 Not Found. Also I guess you want to charge your users the same rate regardless if it's on-net or off-net calls, so CDR need to be taken care of too.<br></span></div><div style="color: rgb(0, 0, 0); font-size: 10.65px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><span><br></span></div><div><br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; margin-top: 5px; padding-left: 5px;">  <div style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div
 dir="ltr"> <font face="Arial" size="2"> <hr size="1">  <b><span style="font-weight:bold;">From:</span></b> Stanislav Sinyagin &lt;ssinyagin@yahoo.com&gt;<br> <b><span style="font-weight: bold;">To:</span></b> FreeSWITCH Users Help &lt;freeswitch-users@lists.freeswitch.org&gt; <br> <b><span style="font-weight: bold;">Sent:</span></b> Sunday, September 23, 2012 10:31 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [Freeswitch-users] Keeping local calls local<br> </font> </div> <br>
<meta http-equiv="x-dns-prefetch-control" content="off"><div id="yiv250824882"><div><div style="color:#000;background-color:#fff;font-family:arial, helvetica, sans-serif;font-size:10pt;"><div><span>well, that was only a hint, but not the whole solution :)</span></div><div style="color:rgb(0, 0, 0);font-size:13.3333px;font-family:arial, helvetica, sans-serif;background-color:transparent;font-style:normal;"><span>In your case, it would require some database lookup, or maybe the dialplan should go through the customer numbers before sending the call to PSTN.&nbsp;</span></div><div style="color:rgb(0, 0, 0);font-size:13.3333px;font-family:arial, helvetica, sans-serif;background-color:transparent;font-style:normal;"><span><br></span></div><div style="color:rgb(0, 0, 0);font-size:13.3333px;font-family:arial, helvetica, sans-serif;background-color:transparent;font-style:normal;"><span>enum would be a good option instead of database lookup, as was already
 proposed on the list.</span></div><div style="
color:rgb(0, 0, 0);font-size:13.3333px;font-family:arial, helvetica, sans-serif;background-color:transparent;font-style:normal;"><br><span></span></div><div style="color:rgb(0, 0, 0);font-size:13.3333px;font-family:arial, helvetica, sans-serif;background-color:transparent;font-style:normal;"><span>In any case, this all requires a bit of engineering and design effort. <br></span></div><div style="color:rgb(0, 0, 0);font-size:13.3333px;font-family:arial, helvetica, sans-serif;background-color:transparent;font-style:normal;"><br><span></span></div><div style="color:rgb(0, 0, 0);font-size:13.3333px;font-family:arial, helvetica, sans-serif;background-color:transparent;font-style:normal;"><span><br></span></div><div><br><blockquote style="border-left:2px solid rgb(16, 16, 255);margin-left:5px;margin-top:5px;padding-left:5px;">  <div style="font-family:arial, helvetica, sans-serif;font-size:10pt;"> <div style="font-family:times new roman, new york, times,
 serif;font-size:12pt;"> <div dir="ltr"> <font face="Arial" size="2"> <hr size="1">  <b><span style="font-weight:bold;">From:</span></b> D'Arcy Cain &lt;darcy@Vex.Net&gt;<br> <b><span style="font-weight:bold;">To:</span></b> FreeSWITCH Users Help &lt;freeswitch-users@lists.freeswitch.org&gt; <br><b><span style="font-weight:bold;">Cc:</span></b> Stanislav Sinyagin &lt;ssinyagin@yahoo.com&gt; <br> <b><span style="font-weight:bold;">Sent:</span></b> Sunday, September 23, 2012 10:04 PM<br> <b><span style="font-weight:bold;">Subject:</span></b> Re: [Freeswitch-users] Keeping local calls local<br> </font> </div> <br>
On Sun, 23 Sep 2012 11:17:37 -0700 (PDT)<br>Stanislav Sinyagin &lt;<a rel="nofollow" ymailto="mailto:ssinyagin@yahoo.com" target="_blank" href="mailto:ssinyagin@yahoo.com">ssinyagin@yahoo.com</a>&gt; wrote:<br><br>&gt; here's a piece of my dialplan in "default" context. It simply catches<br>&gt; such calls and transfers them directly to the public context. The<br>&gt; public context matches local DID numbers and transfers them to<br>&gt; corresponding extensions in default context:<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &lt;extension name="internal_did"&gt;<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;condition field="destination_number" expression="^($${default_did_prefix}\d+)$"&gt;<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;action application="transfer" data="$1 XML public"/&gt;<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/condition&gt;<br>&gt; &nbsp;&nbsp;&nbsp; &lt;/extension&gt;<br>&gt; <br>&gt; The "default_did_prefix" variable holds my DID
 number block. <br><br>Looks good
 but my problem is that I do not have a DID block.&nbsp; Clients<br>are porting their numbers so they are all over the place.&nbsp; My first<br>three numbers in the system are from three different area codes.&nbsp; I<br>would need to include all of my numbers in the expression somehow.&nbsp; Wit<br>just three I can use '|' but that won't be practical when I have<br>hundreds or thousands.<br><br>-- <br>D'Arcy J.M. Cain<br>System Administrator, Vex.Net<br>http://www.Vex.Net/ IM:<a rel="nofollow" ymailto="mailto:darcy@Vex.Net" target="_blank" href="mailto:darcy@Vex.Net">darcy@Vex.Net</a><br><br><br> </div> </div> </blockquote></div>   </div></div></div><meta http-equiv="x-dns-prefetch-control" content="on"><br>_________________________________________________________________________<br>Professional FreeSWITCH Consulting Services:<br><a ymailto="mailto:consulting@freeswitch.org" href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br><a
 href="http://www.freeswitchsolutions.com/" target="_blank">http://www.freeswitchsolutions.com</a><br><br>FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br><a href="http://www.cudatel.com/" target="_blank">http://www.cudatel.com</a><br><br>Official FreeSWITCH Sites<br><a href="http://www.freeswitch.org/" target="_blank">http://www.freeswitch.org</a><br><a href="http://wiki.freeswitch.org/" target="_blank">http://wiki.freeswitch.org</a><br><a href="http://www.cluecon.com/" target="_blank">http://www.cluecon.com</a><br><br>FreeSWITCH-users mailing list<br><a ymailto="mailto:FreeSWITCH-users@lists.freeswitch.org" href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br><a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users"
 target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br><a href="http://www.freeswitch.org/" target="_blank">http://www.freeswitch.org</a><br><br><br> </div> </div> </blockquote></div>   </div></body></html>