[SR-Users] Use AVP as regex in avp_subst

Alex Balashov abalashov at evaristesys.com
Thu Jul 8 17:35:18 CEST 2010


There may be an easier and more elegant and more performant way to  
accomplish what you are trying to accomplish, but we cannot know  
without seeing the pattern and the regex.  :)

--
Alex Balashov - Principal
Evariste Systems LLC
1170 Peachtree Street
12th Floor, Suite 1200
Atlanta, GA 30309
Tel: +1-678-954-0670
Fax: +1-404-961-1892
Web: http://www.evaristesys.com/

On Jul 8, 2010, at 10:30 AM, Uriel Rozenbaum  
<uriel.rozenbaum at gmail.com> wrote:

> Hi Daniel,
>
> Actually I'm going to partially take your advice, implementing the  
> following:
>
> exec_avp("echo '$avp(s:ANI)' | sed '$avp(s:carrierAniRegex)'",
> "$avp(s:ANIegress)");
>
> I'll check for performance issues later but surely this simplifies a
> lot the config.
>
> Thanks!
> Uriel
>
> On Thu, Jul 8, 2010 at 5:55 AM, Daniel-Constantin Mierla
> <miconda at gmail.com> wrote:
>> Hello,
>>
>> On 7/7/10 11:06 PM, Uriel Rozenbaum wrote:
>>>
>>> Hey guys,
>>>
>>> I'm using Kamailio 1.5.3-notls and need to apply some re operation  
>>> to an
>>> AVP.
>>>
>>> The problem I have is that my re expression is held in an AVP, so  
>>> the
>>> parser is not recognizing it :(
>>>
>>> Would it be very hard to change that behavior? Any ideas/tips to
>>> implement?
>>>
>>> This code
>>>   route[16]
>>>   {
>>>     ...
>>>   avp_subst("$avp(s:ANI)/$avp(s:ANIegress)", "$avp 
>>> (s:carrierAniRegex)");
>>>     ...
>>>   }
>>>
>>> returns this error
>>>   ERROR:avpops:fixup_subst: avpops: bad subst re $avp 
>>> (s:carrierAniRegex)
>>>
>>> This code
>>> route[16]
>>>   {
>>>     ...
>>>   avp_subst("$avp(s:ANI)/$avp(s:ANIegress)", $avp 
>>> (s:carrierAniRegex));
>>>     ...
>>>   }
>>>
>>> returns this error
>>>   CRITICAL:core:yyerror: parse error in config file, line 751,  
>>> column
>>> 51-74: syntax error
>>>   CRITICAL:core:yyerror: parse error in config file, line 751,  
>>> column
>>> 74-75: bad arguments
>>>
>>> Do you think some other way I can achieve this? Be aware I'm using
>>> SQLops to get realtime the value of the expression...
>>>
>>
>> avp_subst() cannot help here, there is no support for taking the
>> substitution expression from a variable.
>>
>> What you can do in 1.5 is either look at dialplan to see if it fits  
>> your
>> needs (it can do such substitution with expressions taken from db at
>> startup, which can be reloaded at runtime), otherwise try using  
>> perl module
>> (or exec in 1.5+ and lua/python in devel).
>>
>> Cheers,
>> Daniel
>>
>> --
>> Daniel-Constantin Mierla
>> http://www.asipto.com/
>>
>>
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing  
> list
> sr-users at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users



More information about the sr-users mailing list