/* Determine if an address is a broadcast address on a network interface */
u8_t ip4_addr_isbroadcast(u32_t addr, const struct netif *netif)
/* Determine if an address is a broadcast address on a network interface */
u8_t ip4_addr_isbroadcast(u32_t addr, const struct netif *netif)
{
  ip_addr_t ipaddr;
  ip4_addr_set_u32(&ipaddr, addr);
  if ((~addr == IPADDR_ANY) ||
      (addr == IPADDR_ANY)) {
    return 1;
  } else if ((netif->flags & NETIF_FLAG_BROADCAST) == 0) {
    return 0;
  } else if (addr == ip4_addr_get_u32(&netif->ip_addr)) {
    return 0;
  } else if (ip_addr_netcmp(&ipaddr, &(netif->ip_addr), &(netif->netmask))
          && ((addr & ~ip4_addr_get_u32(&netif->netmask)) ==
           (IPADDR_BROADCAST & ~ip4_addr_get_u32(&netif->netmask)))) {
    return 1;
  } else {
    return 0;
  }
}