[OpenSIPS-Users] check if ip address belongs to ip and subnet subscriber
Edwin
eahaselhoff at gmail.com
Sat Feb 1 17:44:26 CET 2014
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.
More information about the Users
mailing list