Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Jan 2016 14:36:17 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r294832 - head/sys/compat/linuxkpi/common/include/linux
Message-ID:  <201601261436.u0QEaHfF048341@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Tue Jan 26 14:36:16 2016
New Revision: 294832
URL: https://svnweb.freebsd.org/changeset/base/294832

Log:
  Implement ether_addr_equal(), ether_addr_equal_64bits() and
  random_ether_addr() for the LinuxKPI.
  
  MFC after:	1 week
  Sponsored by:	Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/include/linux/etherdevice.h

Modified: head/sys/compat/linuxkpi/common/include/linux/etherdevice.h
==============================================================================
--- head/sys/compat/linuxkpi/common/include/linux/etherdevice.h	Tue Jan 26 14:34:40 2016	(r294831)
+++ head/sys/compat/linuxkpi/common/include/linux/etherdevice.h	Tue Jan 26 14:36:16 2016	(r294832)
@@ -29,6 +29,9 @@
 
 #include <linux/types.h>
 
+#include <sys/random.h>
+#include <sys/libkern.h>
+
 #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 */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201601261436.u0QEaHfF048341>