[Users] avp_subst re problem
Klaus Darilion
klaus.mailinglists at pernau.at
Mon Nov 27 10:34:21 CET 2006
Hi Andreas!
I have not take a look at your regexp, but maybe my code for parsing
P-Asserted-Identity helps.
regards
klaus
route[7] {
xlog("L_INFO","======================================================================='\n");
xlog("L_INFO","body of P-Asserted-Identity: header is
'$hdr(P-Asserted-Identity)'\n");
# fetch and parse P-Asserted-Identity
avp_write("$hdr(P-Asserted-Identity)","$avp(s:pai)");
xlog("L_INFO","$$avp(s:pai) = '$avp(s:pai)'\n");
# check if addr-spec or name-addr and convert to addr-spec
if (avp_check("$avp(s:pai)","re/.*<.*>.*")) {
xlog("L_INFO","P-Asserted-Identity header is in name-addr format,
fetch addr-spec\n");
if
(!avp_subst("$avp(s:pai)/$avp(s:paias)","/<[[:blank:]]*tel:([^[[:blank:]]]+)[[:blank:]]*>/\1/"))
{
xlog("L_INFO","ERROR: failed to fetch name-addr 1\n");
}
} else {
avp_copy("$avp(s:pai)","$avp(s:paias)");
}
xlog("L_INFO","P-Asserted-Identity addr-spec = '$avp(s:paias)', fetch
tel URI\n");
if
(avp_subst("$avp(s:paias)/$avp(s:cli)","/^tel:(\+[0-9\-\.\/]+)(.*)$/\1/")) {
xlog("L_INFO","tel URI with E.164 number found, CLI =
'$avp(s:cli)'\n");
avp_subst("$avp(s:clitemp)/$avp(s:cli)","/\+/00/");
} else if
(avp_subst("$avp(s:paias)/$avp(s:cli)","/^tel:(\[0-9\-\.\/]+)(.*)$/\1/")) {
xlog("L_INFO","tel URI with local number found, CLI =
'$avp(s:cli)'\n");
avp_subst("$avp(s:paias)/$avp(s:params)","/^tel:(\[0-9\-\.\/]+)(.*)$/\2/");
xlog("L_INFO","tel URI with local number found, params =
'$avp(s:params)'\n");
if
(avp_subst("$avp(s:params)/$avp(s:context)","/^.+;phone-context=(^;).*/\1/"))
{
xlog("L_INFO","tel URI with local number found, phone-context =
'$avp(s:context)'\n");
} else {
xlog("L_INFO","ERROR: local number without context\n");
}
} else {
xlog("L_INFO","'$avp(s:paias)' is not a valid tel URI \n");
}
# evaluate privacy header (CLIR)
avp_write("$hdr(Privacy)","$avp(s:privacy)");
if ( avp_check("$avp(s:privacy)","re/id/i") ) {
uac_replace_from("Anonymous","sip:anonymous at invalid");
remove_hf("P-Asserted-Identity");
} else {
uac_replace_from("$avp(s:cli)","sip:$avp(s:cli)@mydomain.com");
remove_hf("P-Asserted-Identity");
}
avp_print();
}
Andreas Heise wrote:
>
> Hello,
> I tried to use avp_subst to extract the part <......> of a Remote-Party-ID
>
> $avp(s:merker)= Remote-Party-ID:
> "test"<sip:12345 at localhost>;party=calling;id-type=subscriber;screen=yes;privacy=full
>
> avp_subst("$avp(s:merker)/$avp(s:merker1)", "/(.*)>(.*)/\1>/");
>
> the result for merker1 is Remote-Party-ID: "test"<sip:12345 at localhost>
>
> what must I change in the re to get this result? <sip:12345 at localhost>
>
>
> thanks in advance,
> Andreas
>
>
>
> _______________________________________________
> Users mailing list
> Users at openser.org
> http://openser.org/cgi-bin/mailman/listinfo/users
--
Klaus Darilion
nic.at
More information about the sr-users
mailing list