[Serusers] Questions about strip() and altering ANI/From: numbers

Miklos Tirpak miklos at iptel.org
Fri Mar 13 10:23:05 CET 2009



On 03/13/2009 10:05 AM, Miklos Tirpak wrote:
> Hello,
> 
> On 03/11/2009 05:25 PM, Frank Durda IV wrote:
>> When using strip() on a E.164 format number (eg +17895551212),
>> does strip(2) delete the +1, or is it going to delete "17"
>> in the shown example?  I seem to be getting the latter
>> behavior.  If the latter is what is intended, how does one
>> get rid of the plus?
> 
> strip(2) should strip the first two characters of the user name, no 
> matter what it is, so "+1" in your case.
> 
>>
>> Second, is there something equivalent to strip() for editing
>> the ANI/From: number?   As I am doing PSTN gateway conversions,
>> I have to strip the +1 from a E.164 ANI/From: (if sent) at some
>> point so that the destination PSTN switch can correctly do
>> the Calling Name database lookup.  The North American
>> Calling Name databases will only match if exactly ten digits
>> are provided, so the ANI/From: has to be scrubbed down
>> to ten digits if the country code in the ANI/From:
>> begins with +1.
> 
> If you want to remain compatible with the old SIP RFC, 2543, then you 
> should not modify the From header. Check which standards/drafts the 
> gateway supports, you might want to add a Remote-Party-ID, or a 
> P-Asserted-Identity header instead, these solutions are cleaner in my 
> opinion. Have a look at etc/ser-oob.cfg.
> 
> if (!@from.user =~ "^\+1") {

sorry,
   if (@from.user =~ "^\+1") {
       ....

Miklos

>     # move the user name to an AVP
>     $new_user = @from.user;
>     # strip the +1
>     subst_attr("$new_user", "/\+1(.*)$/\1/");
>     # delete existing RPID header
>     remove_hf_value("Remote-Party-ID");
>     # add a new RPID
>     append_hf_value("Remote-Party-ID", 
> "<sip:%$new_user@%@from.host>;screen=yes");
>     del_attr("$new_user");
> }
> 
> (not tested)
> 
> Miklos
> 
> 
>>
>> Thanks!
>>
>>
>>
>> _______________________________________________
>> Serusers mailing list
>> Serusers at lists.iptel.org
>> http://lists.iptel.org/mailman/listinfo/serusers
> _______________________________________________
> Serusers mailing list
> Serusers at lists.iptel.org
> http://lists.iptel.org/mailman/listinfo/serusers



More information about the sr-users mailing list