From e6ef991e5eda83debca8363ac5dca58df4d795c4 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Tue, 26 Jan 2016 14:36:16 +0000 Subject: [PATCH] Implement ether_addr_equal(), ether_addr_equal_64bits() and random_ether_addr() for the LinuxKPI. MFC after: 1 week Sponsored by: Mellanox Technologies --- .../common/include/linux/etherdevice.h | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/etherdevice.h b/sys/compat/linuxkpi/common/include/linux/etherdevice.h index c7a6ebead34..70e5f64581b 100644 --- a/sys/compat/linuxkpi/common/include/linux/etherdevice.h +++ b/sys/compat/linuxkpi/common/include/linux/etherdevice.h @@ -29,6 +29,9 @@ #include +#include +#include + #define ETH_MODULE_SFF_8079 1 #define ETH_MODULE_SFF_8079_LEN 256 #define ETH_MODULE_SFF_8472 2 @@ -78,4 +81,25 @@ ether_addr_copy(u8 * dst, const u8 * src) memcpy(dst, src, 6); } +static inline bool +ether_addr_equal(const u8 *pa, const u8 *pb) +{ + return (memcmp(pa, pb, 6) == 0); +} + +static inline bool +ether_addr_equal_64bits(const u8 *pa, const u8 *pb) +{ + return (memcmp(pa, pb, 6) == 0); +} + +static inline void +random_ether_addr(u8 * dst) +{ + read_random(dst, 6); + + dst[0] &= 0xfe; + dst[0] |= 0x02; +} + #endif /* _LINUX_ETHERDEVICE */ -- 2.45.2