From 75edebe3011c963a7cd84be0f4a987477f2aaf89 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 27 Jan 2009 16:53:39 -0500 Subject: Move is_valid_ether_addr() to include/net.h Import the is_valid_ether_addr() function from the Linux kernel. Signed-off-by: Mike Frysinger Signed-off-by: Ben Warren --- include/net.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'include/net.h') diff --git a/include/net.h b/include/net.h index d2d394f..bbe0d4b 100644 --- a/include/net.h +++ b/include/net.h @@ -474,6 +474,22 @@ static inline int is_multicast_ether_addr(const u8 *addr) return (0x01 & addr[0]); } +/** + * is_valid_ether_addr - Determine if the given Ethernet address is valid + * @addr: Pointer to a six-byte array containing the Ethernet address + * + * Check that the Ethernet address (MAC) is not 00:00:00:00:00:00, is not + * a multicast address, and is not FF:FF:FF:FF:FF:FF. + * + * Return true if the address is valid. + */ +static inline int is_valid_ether_addr(const u8 * addr) +{ + /* FF:FF:FF:FF:FF:FF is a multicast address so we don't need to + * explicitly check for it here. */ + return !is_multicast_ether_addr(addr) && !is_zero_ether_addr(addr); +} + /* Convert an IP address to a string */ extern void ip_to_string (IPaddr_t x, char *s); -- cgit v1.1