<div>Nice.</div>
<div> </div>
<div>Thanks for the help<br><br></div>
<div class="gmail_quote">On Wed, Aug 26, 2009 at 10:55 AM, Bogdan-Andrei Iancu (via Nabble) <span dir="ltr">&lt;<a href="http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3517646&i=0" target="_top" rel="nofollow">[hidden email]</a>&gt;</span> wrote:<br>

<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">Hi Duane, <br><br>You can replace the complicated: <br><br>    subst_uri(&#39;/^sip:([0-9]+)@(.*)$/sip:$avp(s:areacode)\1@\2/i&#39;); <br>
<br>with more nicer: <br><br>    $rU =  $avp(s:areacode)  + $rU; <br><br>Regards, <br>Bogdan <br><br><br>osiris123d wrote: 
<div><br>&gt; Got it working!  Man OpenSIPS sure can do anything with SIP <br>&gt; <br>&gt; So here is what I did for future searchers <br>&gt; <br>&gt; So the users account is a 7 digit DID number XXXXXXX at <a href="http://blah.com/" target="_blank" rel="nofollow">blah.com</a> <br>
&gt; <br>&gt; I set up an AVP called areacode for the whole domain <a href="http://blah.com/" target="_blank" rel="nofollow">blah.com</a> (this assumes <br>&gt; that the whole domain <a href="http://blah.com/" target="_blank" rel="nofollow">blah.com</a> is only in one areacode) <br>
&gt; <br>&gt; opensipsctl avp add -T usr_preferences 0 at <a href="http://blah.com/" target="_blank" rel="nofollow">blah.com</a> areacode 1 201 <br>&gt; opensipsctl avp add -T usr_preferences 0 at <a href="http://foo.com/" target="_blank" rel="nofollow">foo.com</a> areacode 1 339 <br>
&gt; <br>&gt; <br>&gt; In the opensips.cfg file I do the following (it depends on your config as to <br>&gt; where you want to put this) <br>&gt; if (uri=~&quot;^sip:[2-9][0-9]{6}@&quot;) { <br>&gt; avp_db_load(&quot;$ru/domain&quot;,&quot;$avp(s:areacode)&quot;); <br>
&gt; subst_uri(&#39;/^sip:([0-9]+)@(.*)$/sip:$avp(s:areacode)\1@\2/i&#39;); <br>&gt; }; <br>&gt; <br>&gt; So when someone calls a 7 digit number the avp_db_load() loads the variable <br>&gt; for areacode and the subst_uri adds the areacode at the beginning of the <br>
&gt; Request-URI. <div class='shrinkable-quote'><br>&gt; <br>&gt; <br>&gt; <br>&gt; <br>&gt; <br>&gt; <br>&gt; Bogdan-Andrei Iancu wrote: <br>&gt;   <br>&gt;&gt; Hi Duane, <br>&gt;&gt; <br>&gt;&gt; You can correlate AVPs you a USER, a DOAMAIN, etc - it is up to you, </div>
&gt;&gt; from the script, when loading the AVP - is a pure logical mapping. <br>&gt;&gt; <br>&gt;&gt; Regards, <br>&gt;&gt; Bogdan <br>&gt;&gt; <br>&gt;&gt; osiris123d wrote: <br>&gt;&gt;     <br>&gt;&gt;&gt; I was reading Flavio&#39;s &quot;Building Telephony Systems with OpenSER&quot; chapter <br>
&gt;&gt;&gt; about AVPOPs and he mentions that AVP&#39;s can be used for a whole domain. <br>&gt;&gt;&gt; I <br>&gt;&gt;&gt; was thinking that I might be able to configure a area code for Company <br>&gt;&gt;&gt; A&#39;s <br>
&gt;&gt;&gt; domain and then route calls that way.  If not that then I can set the AVP <br>&gt;&gt;&gt; on <br>&gt;&gt;&gt; the fly within the transaction by looking at the callers Request URI&#39;s <br>&gt;&gt;&gt; first <br>
&gt;&gt;&gt; 3 digits and route it appropriately. <br>&gt;&gt;&gt; <br>&gt;&gt;&gt; <br>&gt;&gt;&gt; Bogdan-Andrei Iancu wrote: <br>&gt;&gt;&gt;   <br>&gt;&gt;&gt;       <br>&gt;&gt;&gt;&gt; Hi, <br>&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt; Requirements on the format of  CONTACT and TO headers are nonsense as <br>
&gt;&gt;&gt;&gt; they are not used for routing at all. Only FROM (which provides info on <br>&gt;&gt;&gt;&gt; the caller) and RURI (request URI) (which provide info on callee). <br>&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt; So, bottom line, only the normalization of the RURI should be required <br>
&gt;&gt;&gt;&gt; on the system. <br>&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt; Regards, <br>&gt;&gt;&gt;&gt; Bogdan <br>&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt; osiris123d wrote: <br>&gt;&gt;&gt;&gt;     <br>&gt;&gt;&gt;&gt;         <br>
&gt;&gt;&gt;&gt;&gt; Thanks for the info. <br>&gt;&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt;&gt; I will look into this and work up a config. <br>&gt;&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt;&gt; I also got this direct email about my post from someone else who lives <br>
&gt;&gt;&gt;&gt;&gt; in <br>&gt;&gt;&gt;&gt;&gt; the US.  I figured I would go ahead and post below what he sent just so <br>&gt;&gt;&gt;&gt;&gt; its <br>&gt;&gt;&gt;&gt;&gt; out there. <br>&gt;&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt;&gt; <br>
&gt;&gt;&gt;&gt;&gt; Hello Duane --   <br>&gt;&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt;&gt; You have hit on one of the more difficult areas in SIP and telephony in <br>&gt;&gt;&gt;&gt;&gt; general -- especially here in the North American Numbering Plan.  Below <br>
&gt;&gt;&gt;&gt;&gt; I <br>&gt;&gt;&gt;&gt;&gt; will address the problem in general, and not particularly related to <br>&gt;&gt;&gt;&gt;&gt; the <br>&gt;&gt;&gt;&gt;&gt; OpenSIPs question, because IMO you need a solution that will work in <br>
&gt;&gt;&gt;&gt;&gt; any <br>&gt;&gt;&gt;&gt;&gt; architecture, not just OpenSIPs. <br>&gt;&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt;&gt; In a nutshell, I recommend that for your USA users you: <br>&gt;&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt;&gt; 1.) Require From: and Contact: headers to be in NANPA National (10 <br>
&gt;&gt;&gt;&gt;&gt; digit) <br>&gt;&gt;&gt;&gt;&gt; format.  This is method is standard in the telephone industry, and will <br>&gt;&gt;&gt;&gt;&gt; allow easy integration with North American ANI or Caller ID format, <br>
&gt;&gt;&gt;&gt;&gt; especially when a call may eventually be handed off to the PSTN.   <br>&gt;&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt;&gt; 2.)  Require incoming To: headers to be in e.164 International format, <br>&gt;&gt;&gt;&gt;&gt; i.e. <br>
&gt;&gt;&gt;&gt;&gt; NANPA-destination numbers all begin with the 1 digit, followed by the <br>&gt;&gt;&gt;&gt;&gt; 10 <br>&gt;&gt;&gt;&gt;&gt; digit National number.   Any incoming call to 612xxxxxxx goes to <br>&gt;&gt;&gt;&gt;&gt; Sydney, <br>
&gt;&gt;&gt;&gt;&gt; Austrailia, and not Minneapolis, MN.  This requirement should be <br>&gt;&gt;&gt;&gt;&gt; enforced <br>&gt;&gt;&gt;&gt;&gt; at <br>&gt;&gt;&gt;&gt;&gt; the perimeter of your network, where Customer Equipment can enforce the <br>
&gt;&gt;&gt;&gt;&gt; &quot;local&quot; digit normalization policy.   <br>&gt;&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt;&gt; 3.)  If you can&#39;t enforce #2 above, you will need to &quot;Normalize&quot; <br>&gt;&gt;&gt;&gt;&gt; incoming <br>
&gt;&gt;&gt;&gt;&gt; calls to the e.164 International format prior to routing.  The <br>&gt;&gt;&gt;&gt;&gt; unfortunate <br>&gt;&gt;&gt;&gt;&gt; reality here in the USA is that the requirements for how many digits to <br>
&gt;&gt;&gt;&gt;&gt; dial <br>&gt;&gt;&gt;&gt;&gt; for a given destination (the &quot;dialing plan&quot;) depends on where the call <br>&gt;&gt;&gt;&gt;&gt; comes <br>&gt;&gt;&gt;&gt;&gt; from.   Here in the Chicago area, residents of the 847 area code must <br>
&gt;&gt;&gt;&gt;&gt; today <br>&gt;&gt;&gt;&gt;&gt; dial all calls as 11 digits.  Calls within the 312 or 773 area code may <br>&gt;&gt;&gt;&gt;&gt; today be dialed as 7 digits, however beginning on 07 November, all <br>&gt;&gt;&gt;&gt;&gt; calls <br>
&gt;&gt;&gt;&gt;&gt; originating in 312 and 773 must be dialed as 1+10 digits, due to the <br>&gt;&gt;&gt;&gt;&gt; new <br>&gt;&gt;&gt;&gt;&gt; 872 <br>&gt;&gt;&gt;&gt;&gt; overlay area code.    For more information, see <br>
&gt;&gt;&gt;&gt;&gt; <a href="http://www.nanpa.com/reports/NPA_Dialing_Plans_05_09.pdf" rel="nofollow" target="_blank">http://www.nanpa.com/reports/NPA_Dialing_Plans_05_09.pdf</a><br>&gt;&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt;&gt; 4.)  Finally, if you have any termination carriers who need special <br>
&gt;&gt;&gt;&gt;&gt; &quot;prefixes,&quot;  append them after you have made your route selection.   <br>&gt;&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt;&gt; If you would like further information or discussion, please feel free <br>
&gt;&gt;&gt;&gt;&gt; to <br>&gt;&gt;&gt;&gt;&gt; contact me. <br>&gt;&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt;&gt; John S. RobiXXXX <br>&gt;&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt;&gt; <a href="http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=3516196&amp;i=0" rel="nofollow" target="_blank">[hidden email]</a> <br>
&gt;&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt;&gt; Bogdan-Andrei Iancu wrote: <br>&gt;&gt;&gt;&gt;&gt;   <br>&gt;&gt;&gt;&gt;&gt;       <br>&gt;&gt;&gt;&gt;&gt;           <br>&gt;&gt;&gt;&gt;&gt;&gt; Hi there, <br>
&gt;&gt;&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt;&gt;&gt; When you have to deal with local dialling you need consider the amount <br>&gt;&gt;&gt;&gt;&gt;&gt; of information yon need to keep in order to translate to national <br>
&gt;&gt;&gt;&gt;&gt;&gt; format <br>&gt;&gt;&gt;&gt;&gt;&gt; and the complexity of the processing you have to do. <br>&gt;&gt;&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt;&gt;&gt; A compromise solution will be to keep in user profile some information <br>
&gt;&gt;&gt;&gt;&gt;&gt; about the location (like for US, the 2 digits Id of the state) - this <br>&gt;&gt;&gt;&gt;&gt;&gt; will reduce the amount of data you need to keep per user. Also, this <br>&gt;&gt;&gt;&gt;&gt;&gt; info can be loaded at auth time, using &quot;load_credentials&quot; parameter <br>
&gt;&gt;&gt;&gt;&gt;&gt; (just an example). <br>&gt;&gt;&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt;&gt;&gt; Now, using the location information, you can use dialplan to do the <br>&gt;&gt;&gt;&gt;&gt;&gt; actual transformation. Like, if location is NJ (use a separate plan): <br>
&gt;&gt;&gt;&gt;&gt;&gt;     if 7 digits -&gt; put 011-201 prefix <br>&gt;&gt;&gt;&gt;&gt;&gt;     if  10 digits -&gt; put 011 prefix <br>&gt;&gt;&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt;&gt;&gt; And so on... <br>&gt;&gt;&gt;&gt;&gt;&gt; <br>
&gt;&gt;&gt;&gt;&gt;&gt; This works pretty fine and scale (not for local dialling but for <br>&gt;&gt;&gt;&gt;&gt;&gt; national dialling in international platforms). <br>&gt;&gt;&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt;&gt;&gt; Regards, <br>
&gt;&gt;&gt;&gt;&gt;&gt; Bogdan <br>&gt;&gt;&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt;&gt;&gt; osiris123d wrote: <br>&gt;&gt;&gt;&gt;&gt;&gt;     <br>&gt;&gt;&gt;&gt;&gt;&gt;         <br>&gt;&gt;&gt;&gt;&gt;&gt;             <br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; I was curious to see how people configure OpenSIPS when their <br>&gt;&gt;&gt;&gt;&gt;&gt;&gt; customers <br>&gt;&gt;&gt;&gt;&gt;&gt;&gt; could <br>&gt;&gt;&gt;&gt;&gt;&gt;&gt; potentially be in different area codes.  I am located in the US.  Say <br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; I <br>&gt;&gt;&gt;&gt;&gt;&gt;&gt; have <br>&gt;&gt;&gt;&gt;&gt;&gt;&gt; customers that are in the following area codes <br>&gt;&gt;&gt;&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt;&gt;&gt;&gt; 201-XXX-XXXX    &lt;- New Jersey <br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; 339-XXX-XXXX    &lt;- Boston <br>&gt;&gt;&gt;&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt;&gt;&gt;&gt; Initially when I was setting up users I configured the username to be <br>&gt;&gt;&gt;&gt;&gt;&gt;&gt; just <br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; like the persons email address (ex. <a href="http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=3516196&amp;i=1" rel="nofollow" target="_blank">[hidden email]</a>), and configured <br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; an <br>&gt;&gt;&gt;&gt;&gt;&gt;&gt; alias that included the DID for that person (ex. <a href="http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=3516196&amp;i=2" rel="nofollow" target="_blank">[hidden email]</a>). <br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt;&gt;&gt;&gt; So when bobsmith in New Jersey calls someone and just types 7 digits <br>&gt;&gt;&gt;&gt;&gt;&gt;&gt; then <br>&gt;&gt;&gt;&gt;&gt;&gt;&gt; obviously its local.  How do people out there using OpenSIPS usually <br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; determine if the call is local or not?  I was thinking that I need to <br>&gt;&gt;&gt;&gt;&gt;&gt;&gt; swap <br>&gt;&gt;&gt;&gt;&gt;&gt;&gt; my username and alias around so that the username is the 10 digit DID <br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; and <br>&gt;&gt;&gt;&gt;&gt;&gt;&gt; then I can look at the first 3 digits to see what the area code is. <br>&gt;&gt;&gt;&gt;&gt;&gt;&gt; My <br>&gt;&gt;&gt;&gt;&gt;&gt;&gt; other idea was to set up Groups for each area code and add the users <br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; to <br>&gt;&gt;&gt;&gt;&gt;&gt;&gt; their Area Code group and determine it that way. <br>&gt;&gt;&gt;&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt;&gt;&gt;&gt; Am I looking at this the right way or am I making this more <br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; complicated? <br>&gt;&gt;&gt;&gt;&gt;&gt;&gt; I <br>&gt;&gt;&gt;&gt;&gt;&gt;&gt; would like to get my setup right the first time so that this config <br>&gt;&gt;&gt;&gt;&gt;&gt;&gt; scales <br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; well. <br>&gt;&gt;&gt;&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt;&gt;&gt;&gt; Thanks for any input. <br>&gt;&gt;&gt;&gt;&gt;&gt;&gt;   <br>&gt;&gt;&gt;&gt;&gt;&gt;&gt;       <br>&gt;&gt;&gt;&gt;&gt;&gt;&gt;           <br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;               <br>&gt;&gt;&gt;&gt;&gt;&gt; _______________________________________________ <br>&gt;&gt;&gt;&gt;&gt;&gt; Users mailing list <br>&gt;&gt;&gt;&gt;&gt;&gt; <a href="http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=3516196&amp;i=3" rel="nofollow" target="_blank">[hidden email]</a> <br>
&gt;&gt;&gt;&gt;&gt;&gt; <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="nofollow" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>&gt;&gt;&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt;&gt;&gt; <br>
&gt;&gt;&gt;&gt;&gt;&gt;     <br>&gt;&gt;&gt;&gt;&gt;&gt;         <br>&gt;&gt;&gt;&gt;&gt;&gt;             <br>&gt;&gt;&gt;&gt;&gt;   <br>&gt;&gt;&gt;&gt;&gt;       <br>&gt;&gt;&gt;&gt;&gt;           <br>&gt;&gt;&gt;&gt; _______________________________________________ <br>
&gt;&gt;&gt;&gt; Users mailing list <br>&gt;&gt;&gt;&gt; <a href="http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=3516196&amp;i=4" rel="nofollow" target="_blank">[hidden email]</a> <br>&gt;&gt;&gt;&gt; <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="nofollow" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt;     <br>&gt;&gt;&gt;&gt;         <br>&gt;&gt;&gt;   <br>&gt;&gt;&gt;       <br>&gt;&gt; _______________________________________________ <br>&gt;&gt; Users mailing list <br>
&gt;&gt; <a href="http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=3516196&amp;i=5" rel="nofollow" target="_blank">[hidden email]</a> <br>&gt;&gt; <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="nofollow" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
&gt;&gt; <br>&gt;&gt; <br>&gt;&gt;     <br>&gt; <br>&gt;   </div><br><br>_______________________________________________ <br>Users mailing list <br><a href="http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=3516196&amp;i=6" rel="nofollow" target="_blank">[hidden email]</a> <br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="nofollow" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br></blockquote></div><br><br clear="all">
<div></div><br>-- <br>--<br>*--*--*--*--*--*<br>Duane<br>*--*--*--*--*--*<br>--<br>

<br><hr align="left" width="300">
View this message in context: <a href="http://n2.nabble.com/Multiple-Area-Codes-in-Customer-Area-tp3419932p3517646.html">Re: [OpenSIPS-Users] Multiple Area Codes in Customer Area</a><br>
Sent from the <a href="http://n2.nabble.com/OpenSIPS-Users-f1449235.html">OpenSIPS - Users mailing list archive</a> at Nabble.com.<br>