[OpenSIPS-Users] Runtime avp substitution

Bogdan-Andrei Iancu bogdan at voice-system.ro
Wed Sep 22 14:26:52 CEST 2010


Hi Paul,

have you looked at dialplan module ? 
       http://www.opensips.org/html/docs/modules/1.6.x/dialplan.html

The subst-like funcs in script do not support dynamic patterns..

Regards,
Bogdan

Paul Smith wrote:
> How can I do a regular expression substitution on an avp where the 
> pattern is loaded from the user subsrciption or usr_preference table?
>
> For example I need to limit callerid presented to a pre-determined range 
> owned by my customer, and perform substitution eg add a prefix.  If a 
> UAC sets P-Preferred-identify to 1234 and I have a usr_preference to 
> match any 4 digit caller starting with 1, and prefix with 789 then 
> callerid should be set to 7891234
>
> I have in mind something like:
>
> In my database I set the expression for  $avp(s:expcallerid) for this 
> user to "/1.{3}/789\1/i"
> then in my dialplan I want to match and substitute the 
> Preferred-Identity to form the $avp(s:callerid) and then set 
> P-Asserted-Identity
>
> xlog("dialled number = $rU");
> xlog("callerid barring requested by device = $avp(s:clir)");
> xlog("callerid preferred set by device = $pU");
> xlog("callerid expression for this user = $avp(s:expcallerid)");
> xlog("default callerid for this user = $avp(s:defcallerid)");
>
> $avp(s:callerid)=$avp(s:defcallerid);
> if($avp(s:clir)){
>        # user has restricted callerid
>         $avp(s:callerid)="Anonymous";
> } else if($pU) {
>       # UAC device has set preferred callerid
>       $avp(s:callerid)=pU;
>       if(avp_subst("$avp(s:callerid)",$avp(s:expcallerid)) ){
>             xlog("preferred callerid matched callerid expression");
>       } else {
>            xlog("preferred callerid rejected, using default");
>            $avp(s:callerid)=$avp(s:defcallerid);
>       }
> } else {
>       #use default callerid
>       $avp(s:callerid)=$avp(s:defcallerid);
> }
>
> I get the error
> Sep 22 12:30:21 [6253] CRITICAL:core:yyerror: parse error in config 
> file, line 518, column 44-45: bad arguments for command <avp_subst>
>
> which I think means that avp_subst is expecting a static regular 
> expression in the script, whereas  I want a user variable as the regular 
> expression.
>
> Is there another way to look at the problem? Have I missed something 
> obvious (again)?
>
> Thanks
> Paul
>
> _______________________________________________
> 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




More information about the Users mailing list