I have an IP like this: 12.12.12.12 I\'m looping through different IP ranges (in 12.12.12.0/24 (example)) format, and trying to see if the IP is in the range. I have t
Just test whether:
(ip & netmask) == (range & netmask)
You can determine the netmask from the CIDR parameters range/netbits as follows:
range/netbits
uint32_t netmask = ~(~uint32_t(0) >> netbits);