Jay A. Kreibich wrote:
>
>   It breaks for everything except network_size == 16.
>   
Why do you say that?
>   You want something closer to (ip_addr & (~(~0 << network_size)))
>   
In SQLite ~0 is -1.

    sqlite> select ~0;
    -1

So your inner expression is only a more complicated way of saying the 
same thing.

By complementing the result of the inner expression you have generated 
an invalid netmask pattern with zeros in the high bits and ones in the 
low bit positions. This can' t be used to mask off the network portion 
of an IP adresss. It would return the host address within the network 
which can't be used to test if the original IP address is within a 
particular network.
 
>   Again, that only works for v4.  
>   
It was only intended to work for IPv4 as shown in the OP.

Dennis Cote
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to