I need to "AND" a IP address with its subnet mask. IP address is a hexadecimal number and the subnet mask is a number between 0 - 32 (not 0).
4a21bd6e/25
Can I use the bellow code to "AND" these two variables to obtain most significant 25 bits of the IP address?
uint32_t IP = 4a21bd6e;
uint8_t netmask = 25;
int mask = 0x80000000;
uint32_t results = IP & (mask >> (netmask - 1));