[OpenSIPS-Users] regular expression matching

Gabriel Bermudez elgabo81 at gmail.com
Mon Oct 11 19:34:07 CEST 2010


hi bodgan

true, the problem is my voip provider, all calls must be delivered
with a "pri prefix" at the begining, but local calls must be delivered
without the E.164 prefix and I receive all my calls in E.164 so I must
replace this prefix with another on, so for a local call.

local call (593 E.164 prefix)
00593899999999 -> 7424899999999
international call
0015678942356 -> 74240015678942356

I have managed to check for the special prefix with this expression

do_routing();
$avp(s:pri_local) = $(avp(s:dr_attrs){param.value,pri_local});
$avp(s:pri_local_re) = "sip:"+$avp(s:pri_local)+"*";
xlog("check if $ru matches $avp(s:pri_local_re)");
if(avp_check("$ruri", "fm/$avp(s:pri_local_re)")) {
   $avp(s:pri_replace) = $(avp(s:dr_attrs){param.value,pri_replace});
   xlog("$avp(s:pri_local) must be replaced by $avp(s:pri_replace)");
   $avp(s:new_uri) = $rU;
   $avp(s:local_len) = $(avp(s:pri_local){s.len});
   $avp(s:new_uri) = $avp(s:pri_replace) +
$(avp(s:new_uri){s.substr,$avp(s:local_len),0});
   xlog("new uri $avp(s:new_uri)");
   $rU = $avp(s:new_uri);
}

works, but I would like to do the replacement less verbose, for
performace reasons mainly.  Can it be done?

Regards,

2010/10/11 Bogdan-Andrei Iancu <bogdan at voice-system.ro>:
> Hi Gabriel,
>
> when using regexp ops, you cannot use variables in the regexp definition.
>
> But your I miss your logic here - if you do routing based on prefixes
> (do_routing() ), why do you need an extra regexp checking for that rule
> ? if the Rule matches, you already know that RURI looks like
> "sip:74240059389999999 at a.b.c.d"
>
> Regards,
> Bogdan
>
> Gabriel Bermudez wrote:
>> Hi everyone,
>>
>> I'm having trouble creating a regex in the opensips.cfg file.  This is
>> the snipplet
>>
>> modparam("drouting", "attrs_avp", '$avp(s:dr_attrs)')
>> ...
>> do_routing();
>> $avp(s:special) = $(avp(s:dr_attrs){param.value,special});
>> xlog("attrs/$avp(s:dr_attrs) special/$avp(s:special) rU/$ru
>> ^sip:$avp(s:special)[0-9]*@");
>> if (uri =~ "^sip:$avp(s:special)[0-9]*@") {
>>     xlog("do something to the R-URI");
>> }
>>
>> the $avp(s:dr_attrs) gets loaded with "special=742400593", so the
>> avp(s:special) has the value "742400593" and the the $ru variable
>> which I presume must have the same value of the uri variable has
>> "sip:74240059389999999 at a.b.c.d", but for some reason the expression is
>> not returning true.  What I'm doing wrong.
>>
>> Regards,
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.opensips.org
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>
>>
>
>
> --
> Bogdan-Andrei Iancu
> OpenSIPS Bootcamp
> 15 - 19 November 2010, Edison, New Jersey, USA
> www.voice-system.ro
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>



More information about the Users mailing list