[OpenSIPS-Users] check VIA Header / regexp + variables?

Max Mühlbronner mm at 42com.com
Thu Mar 3 14:36:28 CET 2011


Hi,


Awesome, this works great! You made my day.
Thanks again for the help, it is highly appreciated.

Best Regards

Max M.


Am 03.03.2011 13:43, schrieb Bogdan-Andrei Iancu:
> 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
>>
>
>




More information about the Users mailing list