<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Hi,<br>
use module permission.<br>
<br>
s<br>
<br>
Il 30/01/2014 12.21, Edwin Haselhoff ha scritto:<br>
</div>
<blockquote cite="mid:52EA35C0.8010406@gmail.com" type="cite">
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
Hi all,<br>
<br>
For security reasons I want to check if the $si ip is part of ip
and subnet of a subscriber so added '$(avp(sourceip)' and
'$(avp(sourceip_mask)' to the subscriber table.<br>
<small>(I know I can use permissions module, but this is in cache
and we like to make changes real time without haveing to reload
the table in cache)</small><br>
<br>
I tried something like this where sourceip_net and sourceip_mask
is the ip subnet belonging to the subscriber:<br>
<br>
$si = 10.100.5.42
(00001010000101000001111000101010)<br>
$avp(sourceip_net) = 10.20.30.40;
(00001010000101000001111000101000)<br>
$avp(sourceip_mask) = 29;<br>
<br>
if($si{ip.isip} &&
$(si{ip.pton}{s.substr,0,$avp(sourceip_mask)}) ==
$(avp(sourceip_net){ip.pton}{s.substr,0,$avp(sourceip_mask)}))<br>
{<br>
xlog("L_INFO", " ip $si belongs to $au\n");<br>
}<br>
else<br>
{<br>
xlog("L_INFO", " ip $si does not belong to $au\n");<br>
sl_send_reply("403", "Forbidden");<br>
exit;<br>
}<br>
<br>
<br>
So I expect the ip is valid and the comparison is true
(00001010000101000001111000101 = 00001010000101000001111000101)
but it doesn't seem to work like I expect.<br>
<br>
It's difficult to output ip.pton to xlog (unreadable). Does it
output a binary format like I expect?<br>
<br>
Any ideas how to accomplish this?<br>
<br>
Thanks,<br>
<br>
Edwin<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
<a class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
</blockquote>
<br>
</body>
</html>