]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - include/linux/etherdevice.h
[ETHERNET]: Optimize is_broadcast_ether_addr
[linux-2.6-omap-h63xx.git] / include / linux / etherdevice.h
index ce8518e658b6a0c2219071ed0fbfb0e462fb9115..17460c85df7b843e5b83fe3811bef33cbb45e5cc 100644 (file)
@@ -69,6 +69,11 @@ static inline int is_multicast_ether_addr(const u8 *addr)
        return ((addr[0] != 0xff) && (0x01 & addr[0]));
 }
 
+static inline int is_broadcast_ether_addr(const u8 *addr)
+{
+       return (addr[0] & addr[1] & addr[2] & addr[3] & addr[4] & addr[5]) == 0xff;
+}
+
 /**
  * is_valid_ether_addr - Determine if the given Ethernet address is valid
  * @addr: Pointer to a six-byte array containing the Ethernet address
@@ -98,6 +103,22 @@ static inline void random_ether_addr(u8 *addr)
        addr [0] &= 0xfe;       /* clear multicast bit */
        addr [0] |= 0x02;       /* set local assignment bit (IEEE802) */
 }
+
+/**
+ * compare_ether_addr - Compare two Ethernet addresses
+ * @addr1: Pointer to a six-byte array containing the Ethernet address
+ * @addr2 Pointer other six-byte array containing the Ethernet address
+ *
+ * Compare two ethernet addresses, returns 0 if equal
+ */
+static inline unsigned compare_ether_addr(const u8 *_a, const u8 *_b)
+{
+       const u16 *a = (const u16 *) _a;
+       const u16 *b = (const u16 *) _b;
+
+       BUILD_BUG_ON(ETH_ALEN != 6);
+       return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2])) != 0;
+}
 #endif /* __KERNEL__ */
 
 #endif /* _LINUX_ETHERDEVICE_H */