]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/prefix.c
Merge pull request #5806 from ton31337/fix/remove_break_after_return
[mirror_frr.git] / lib / prefix.c
index cb6e53b30539f1cd7d6cdb8041f8fe0dcdfa561e..2b7727fd0a3353479269903acb917f8adbfaa255 100644 (file)
@@ -56,6 +56,25 @@ int is_zero_mac(const struct ethaddr *mac)
        return 1;
 }
 
+bool is_bcast_mac(const struct ethaddr *mac)
+{
+       int i = 0;
+
+       for (i = 0; i < ETH_ALEN; i++)
+               if (mac->octet[i] != 0xFF)
+                       return false;
+
+       return true;
+}
+
+bool is_mcast_mac(const struct ethaddr *mac)
+{
+       if ((mac->octet[0] & 0x01) == 0x01)
+               return true;
+
+       return false;
+}
+
 unsigned int prefix_bit(const uint8_t *prefix, const uint16_t prefixlen)
 {
        unsigned int offset = prefixlen / 8;
@@ -659,7 +678,7 @@ void apply_mask_ipv4(struct prefix_ipv4 *p)
 /* If prefix is 0.0.0.0/0 then return 1 else return 0. */
 int prefix_ipv4_any(const struct prefix_ipv4 *p)
 {
-       return (p->prefix.s_addr == 0 && p->prefixlen == 0);
+       return (p->prefix.s_addr == INADDR_ANY && p->prefixlen == 0);
 }
 
 /* Allocate a new ip version 6 route */
@@ -839,13 +858,10 @@ int prefix_blen(const struct prefix *p)
        switch (p->family) {
        case AF_INET:
                return IPV4_MAX_BYTELEN;
-               break;
        case AF_INET6:
                return IPV6_MAX_BYTELEN;
-               break;
        case AF_ETHERNET:
                return ETH_ALEN;
-               break;
        }
        return 0;
 }
@@ -1144,7 +1160,7 @@ int netmask_str2prefix_str(const char *net_str, const char *mask_str,
        } else {
                destination = ntohl(network.s_addr);
 
-               if (network.s_addr == 0)
+               if (network.s_addr == INADDR_ANY)
                        prefixlen = 0;
                else if (IN_CLASSC(destination))
                        prefixlen = 24;