unsigned int modulus = mask_bits % 8; /* Number of whole bytes in the mask */
unsigned int divisor = mask_bits / 8; /* Remaining bits in the mask after whole bytes are dealt with */
+ /* We shouldnt match anything, /0 is always valid */
+ if (!mask_bits)
+ return true;
+
/* First compare the whole bytes, if they dont match, return false */
if (memcmp(address, mask, divisor))
return false;
{
memcpy(&addr_raw, &address_in6.s6_addr, 16);
memcpy(&mask_raw, &mask_in6.s6_addr, 16);
+
+ if (bits > 128)
+ bits = 128;
}
else
{
{
memcpy(&addr_raw, &address_in4.s_addr, 4);
memcpy(&mask_raw, &mask_in4.s_addr, 4);
+
+ if (bits > 32)
+ bits = 32;
}
else
{