[OpenSIPS-Users] check VIA Header / regexp + variables?
Bogdan-Andrei Iancu
bogdan at opensips.org
Thu Mar 3 13:43:09 CET 2011
Hi Max,
What you can do is:
1) get the via body:
$avp(i:1) = $(hdr(via)[0]) ;
2) make subst over the body to get the IP
avp_subst("$avp(i:1)/$avp(i:2)" , "/.*UDP
([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}).*/\1/");
3) make the test
if ($avp(i:2)==$si) {}
Regards,
Bogdan
PS: I haven't tested the subst regexp, so doublecheck it ;)
Max Mühlbronner wrote:
> Hello,
>
>
> i want to perform a check on the VIA Headers, basically to compare if
> the source ip ($si) is included in one of the VIA Headers. Already
> tried several things, but it seems like there is no way to check for a
> variable in a regexpression, maybe someone got a solution or tried
> something similar before?
>
>
> for example:
>
> if (search ("Via:.*$si.")) {
> ...
> }
>
> or
>
> $var(viacheck) = $si;
> if (search ("Via:.*$var(viacheck).")) {
> ...
> }
>
>
> or different approach:
>
> $var(viacheck) = $si;
> if($(hdr(Via)[*])=~ ".*$var(viacheck).") {
> ...
> }
>
>
> But nothing seems to work, is there any way to check for a variable /
> non static values in a regexp? Or does anyone know a way to check if
> the source ip is contained in VIA Header?
>
>
>
> Best Regards
>
> Max M.
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
--
Bogdan-Andrei Iancu
OpenSIPS eBootcamp - 28th February 2011
OpenSIPS solutions and "know-how"
More information about the Users
mailing list