diff options
Diffstat (limited to 'include/linux/etherdevice.h')
| -rw-r--r-- | include/linux/etherdevice.h | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h index 220748b7abea..a1478258d002 100644 --- a/include/linux/etherdevice.h +++ b/include/linux/etherdevice.h | |||
| @@ -56,18 +56,32 @@ static inline int is_zero_ether_addr(const u8 *addr) | |||
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | /** | 58 | /** |
| 59 | * is_multicast_ether_addr - Determine if the given Ethernet address is a | ||
| 60 | * multicast address. | ||
| 61 | * | ||
| 62 | * @addr: Pointer to a six-byte array containing the Ethernet address | ||
| 63 | * | ||
| 64 | * Return true if the address is a multicast address. | ||
| 65 | */ | ||
| 66 | static inline int is_multicast_ether_addr(const u8 *addr) | ||
| 67 | { | ||
| 68 | return addr[0] & 0x01; | ||
| 69 | } | ||
| 70 | |||
| 71 | /** | ||
| 59 | * is_valid_ether_addr - Determine if the given Ethernet address is valid | 72 | * is_valid_ether_addr - Determine if the given Ethernet address is valid |
| 60 | * @addr: Pointer to a six-byte array containing the Ethernet address | 73 | * @addr: Pointer to a six-byte array containing the Ethernet address |
| 61 | * | 74 | * |
| 62 | * Check that the Ethernet address (MAC) is not 00:00:00:00:00:00, is not | 75 | * Check that the Ethernet address (MAC) is not 00:00:00:00:00:00, is not |
| 63 | * a multicast address, and is not FF:FF:FF:FF:FF:FF. The multicast | 76 | * a multicast address, and is not FF:FF:FF:FF:FF:FF. |
| 64 | * and FF:FF:... tests are combined into the single test "!(addr[0]&1)". | ||
| 65 | * | 77 | * |
| 66 | * Return true if the address is valid. | 78 | * Return true if the address is valid. |
| 67 | */ | 79 | */ |
| 68 | static inline int is_valid_ether_addr(const u8 *addr) | 80 | static inline int is_valid_ether_addr(const u8 *addr) |
| 69 | { | 81 | { |
| 70 | return !(addr[0]&1) && !is_zero_ether_addr(addr); | 82 | /* FF:FF:FF:FF:FF:FF is a multicast address so we don't need to |
| 83 | * explicitly check for it here. */ | ||
| 84 | return !is_multicast_ether_addr(addr) && !is_zero_ether_addr(addr); | ||
| 71 | } | 85 | } |
| 72 | 86 | ||
| 73 | /** | 87 | /** |
| @@ -83,6 +97,6 @@ static inline void random_ether_addr(u8 *addr) | |||
| 83 | addr [0] &= 0xfe; /* clear multicast bit */ | 97 | addr [0] &= 0xfe; /* clear multicast bit */ |
| 84 | addr [0] |= 0x02; /* set local assignment bit (IEEE802) */ | 98 | addr [0] |= 0x02; /* set local assignment bit (IEEE802) */ |
| 85 | } | 99 | } |
| 86 | #endif | 100 | #endif /* __KERNEL__ */ |
| 87 | 101 | ||
| 88 | #endif /* _LINUX_ETHERDEVICE_H */ | 102 | #endif /* _LINUX_ETHERDEVICE_H */ |
