Maybe the database can apply the regex and give you the transformed
result? Databases are quite capable these days. I do this in
PostgreSQL all the time.
On 07/08/2010 01:53 PM, Uriel Rozenbaum wrote:
Hi Alex, :)
I was just trying to keep it simple, but let me explain a little bit.
I'm using a Proxy+RTPProxy in mhomed mode. I have a public and a
private IP on that Proxy and route calls in and out of a network.
As I have many carriers that want different ANI and DNIS patterns I
have to deal with some flexible configuration. So I created a table
where I hold a special regex rule for each of them and then I get the
regex in realtime (with SQLOps) into an AVP ($avp(s:carrierAniRegex)).
Then I get the ANI for the incoming leg and store it on an AVP ($avp(s:ANI)).
When I execute this regex I get the new ANI to replace in FROM, RPID and PAI.
To be honest it's actually more complex because in a per carrier
basis, I configure if I'll use a fix ANI, a REGEX edited one or I'll
leave it transparently. :)
If someone would like to do something similar, I'll be glad to share
scripts and configs.
Best regards,
Uriel
On Thu, Jul 8, 2010 at 12:35 PM, Alex Balashov
<abalashov(a)evaristesys.com> wrote:
> 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(a)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(a)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(a)lists.sip-router.org
>>
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>
--
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: