[Serusers] setting prefix according to $SIP_HF_FROM?

Steve Blair blairs at isc.upenn.edu
Tue Nov 8 14:08:10 CET 2005


  I'd like to ask a slightly different but related question. What if 
you'd like to
check the value of the username in the From field and replace this value
with something else. For example:

  I am using the CC-Diversion header to forward unanswered calls to a
voicemail system reachable via a gateway and a PRI. The "redirected"
call has an original called number in the ISDN setup message that matches
the username in the original R-URI. So far so good.

  But I need to present to the voicemail system a 10 digit original called
number and my users only register with their 5 digit extension. Rather than
change all of my users to a 10 digit username I'd prefer to prefix the 
username
in the From field with the appropriate area code and exchange based on the
leading number in the 5 digit extension. So 81234 would become 2158981234
and so on.

    xlog("L_INFO", "\n[SER]: Failure block #3 OCTEL user: Time: [%Tf] 
Method: <%rm>
    From uri <%fu> To < %tu> IP source address <%is> R-uri: <%ru> 
Contact Header: <%ct> \n\n");

    if(search("^From: 8*@*")
   {
       prefix("something");
    }
    else if (search("^From: sip:[3678][0-9]{4}@u.edu"))
   {
       prefix("something else");
   };

   If I follow this example I don't see how to prefix the From field? Is 
there a
way to retain the initial value in the from field then prepend a string 
to it?

Thanks,Steve

Gerd Feiner wrote:

> yeah,
>
> this is what i do now, with about 7 different prefixes this is not a  
> problem.  but i am thinking when we have more than 200 or so  prefixes 
> ... then a single search would be much better, wouldn't it?
>
>
> Am 07.11.2005 um 20:27 schrieb sip:
>
>> As a workaround, could you not do a search on a regexp of the From  
>> header and
>> just do a couple of if-then cases...  i.e.
>>
>> If(search("^From: 999*@*")
>> {
>>   prefix("something");
>> }
>> else if(search("^From: 998*@*")
>> {
>>   prefix("something else");
>> };
>>
>> ?
>>
>>
>>
>>
>> On Mon, 7 Nov 2005 19:37:55 +0100, Gerd Feiner wrote
>>
>>> hi,
>>>
>>> is there some way, to prefix a given uri (=~[1-9]\d*, for example)
>>> based on the From-header field?  suppose i want to extract a
>>> specific  part (the area-code) from the From-header (like in
>>> bla at 04711.sip...),  i want to add
>>>
>>> prefix(echo $SIP_HF_FROM | sed 's/.*\@\([^.]*\)\..*/\1/')
>>>
>>> or something like that in my SER config, but (even with the exec-
>>> module, which isn't at all that flexible in my opinion) there seems
>>> to be no way to accomplish this.  background is my previous mail
>>> regarding aliases based on SIP_DOMAIN.  if i could just extract that
>>>  area-code from the From-header, then i could easily prefix it to
>>> the  To-header, so i would have no problems with aliases at all.
>>>
>>> any clues?
>>>
>>> brgds,
>>> g. feiner
>>>
>>> _______________________________________________
>>> 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