[OpenSIPS-Devel] 2.4 new IP and Subnet comparison.

Nick Altmann nick at altmann.pro
Tue Aug 7 17:27:47 EDT 2018


Hi Adam,

I didn't test in 2.4, but in 2.3 we usually do this way:

    $var(mask) = "255.255.255.0";
    $var(src_net) = $(var(mask){ip.pton}) & $(si{ip.pton});
    if ($(var(src_net){ip.ntop}) == "10.10.10.0") {
        // $si is from 10.10.10.0/24
    }

--
Nick

2018-08-07 23:53 GMT+03:00 Adam Overbeeke <Adam.Overbeeke at genesys.com>:

> Hello,
>
>
>
> We are trying to use the new functionality in 2.4:
>
>
>
>    - any script variable now supports comparison via the '==' and '!='
>    logical operators with IP addresses and netmasks (eg. *$var(ip) ==
>    10.10.0.0/24 <http://10.10.0.0/24>*). This tests whether the IP
>    address in the variable matches the subnet given in the expression.
>
>
>
> Can you provide a better example for the IP address within a netmask
> comparison? The example given does not compile with the given cidr and we
> have no way to know what value was set to the variable. A simple example
> with variables set for IP and CIDR and the comparison would be appreciated.
> If you offer another way to determine IP within a subnet, that would work
> too.
>
>
>
> Thanks,
>
>
>
> Adam
>
>
>
> Adam Overbeeke
>
> Lead Voice Network Engineer, PureCloud
>
> [image: cid:image001.png at 01D2DB78.7C3D8250]
>
>
>
> _______________________________________________
> Devel mailing list
> Devel at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/devel/attachments/20180808/bee0a793/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 1242 bytes
Desc: not available
URL: <http://lists.opensips.org/pipermail/devel/attachments/20180808/bee0a793/attachment-0001.png>


More information about the Devel mailing list