[OpenSIPS-Users] check if ip address belongs to ip and subnet subscriber

Stefano Pisani stefano.pisani at omnianet.it
Sat Feb 1 17:50:40 CET 2014


why you are using "[]"? use "()" instead.

Il 01/02/2014 17.44, Edwin ha scritto:
> This helped a bit, so I came up with:
>
> $var(sourceip_net) = $(avp(sourceip_mask){ip.pton}) &
> $(avp(sourceip){ip.pton});
> $var(si_net) = $(avp(sourceip_mask){ip.pton}) & $(si{ip.pton});
>
> if($var(sourceip_net) == $var(si_net))
> {
>      xlog("L_INFO", " ip $si belongs to $au\n");
> }
> else
> {
>      xlog("L_INFO", " ip $si does not belong to $au\n");
>      sl_send_reply("403", "Forbidden");
>      exit;
> }
>
> But I like to write i like this:
>
> if( [ $(avp(sourceip_mask){ip.pton}) & $(avp(sourceip){ip.pton}) ] == [
> $(avp(sourceip_mask){ip.pton}) & $(si{ip.pton}) ] )
> {
>      xlog("L_INFO", " ip $si belongs to $au\n");
> }
> else
> {
>      xlog("L_INFO", " ip $si does not belong to $au\n");
>      sl_send_reply("403", "Forbidden");
>      exit;
> }
>
> But this gives an error (column 121-123: syntax error, column 121-123: bad
> command!)
>
>
>
> --
> View this message in context: http://opensips-open-sip-server.1449251.n2.nabble.com/check-if-ip-address-belongs-to-ip-and-subnet-subscriber-tp7589375p7589398.html
> Sent from the OpenSIPS - Users mailing list archive at Nabble.com.
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users




More information about the Users mailing list