/* Checks if a netmask is valid (starting with ones, then only zeros) */
u8_t ip4_addr_netmask_valid(u32_t netmask)
/* Checks if a netmask is valid (starting with ones, then only zeros) */
u8_t ip4_addr_netmask_valid(u32_t netmask)
{
  u32_t mask;
  u32_t nm_hostorder = lwip_htonl(netmask);
  for (mask = 1U << 31 ; mask != 0; mask >>= 1) {
    if ((nm_hostorder & mask) == 0) {
      break;
    }
  }
  for (; mask != 0; mask >>= 1) {
    if ((nm_hostorder & mask) != 0) {
      return 0;
    }
  }
  return 1;
}