[Users] query on openser

Norman Brandinger norm at goes.com
Thu Jul 20 04:44:12 CEST 2006


Hi Vivek,

Below is an example that appears to solve your problem.

Note that the regular expression in the avp_subst() statement was made 
specifically for this example.    Based on your example, the "needle" 
that is being matched is preceded by an underscore.  If this can ALWAYS 
be guaranteed then you shouldn't have a problem using this regular 
expression.  If the haystack has some other known pattern that a regular 
expression can be used to match, then all you have to do is create 
another regular expression and drop it into the example below.

  avp_write("7267261000", "$avp(s:needle)");
  avp_write("<sip:termdoneatscsf_7267261000 at test.com;lr>", 
"$avp(s:haystack)");
  avp_subst("$avp(s:haystack)/$avp(s:match)","/<sip:.*_(.*)@(.*)>/\1/");
 
  xlog("L_NOTICE", "needle=($avp(s:needle)) haystack=($avp(s:haystack)) 
match=($avp(s:match))\n");

  if (avp_check("$avp(s:needle)","eq/$avp(s:match)/g")) {
    xlog("L_NOTICE", "Match found\n");
  } else {
    xlog("L_NOTICE", "Match not found\n");
  }

Regards,
Norm


Vivek Bhat wrote:
> Hi,
>
> I have installed openser v1.1.0 on Linux system.
>
>
> I have problem checking if "Route" header contains the
> "username" of Req-URI as below:
>
> Req-URI will be like "sip:7267261000@<domain>"
> and Route header will be like
> "<sip:termdoneatscsf_7267261000@<domain>;lr>
>
> # To get the RURI I did like this
> avp_write("$ru/username", "$avp(UNAMEOFRURI)"); 
> avp_print();
>
> # To get the Route Header, I did like this
> avp_write("$hdr(Route)", "$avp(ROUTEUSERNAME)");
> avp_print();
>
> Now, what is the best way to check if
> $avp(ROUTEUSERNAME) contains $avp(UNAMEOFRURI)?
>
> I tried as below, and it gives error "regexp requires
> string value"
>
> if(avp_check("$avp(UNAMEOFRURI)","re/$avp(ROUTEUSERNAME)/gi"))
> {
>
> 	log(1, "Usernames of RURI is found inside Route
> header."); 
> } else
>                                         {
> 	log(1, "Usernames of RURI is NOT found inside Route
> header."); 
>
> }
>
> Instead of avp_check, I tried to use search as below:
> if(search("^(Route):.*$ru/username.*"))
> {
>          log(1, "Usernames of RURI is found inside
> Route header."); 
> }
>
> But, it didn't work either. 
>
> Please suggest what is the best method to do this?
>
> Thanks,
> Vivek
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
>
> _______________________________________________
> Users mailing list
> Users at openser.org
> http://openser.org/cgi-bin/mailman/listinfo/users
>
>
>
>   





More information about the Users mailing list