]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - include/linux/etherdevice.h
sysfs: add attribute to indicate hw address assignment type
[net-next-2.6.git] / include / linux / etherdevice.h
index 3d7a6687d247c32577cf6bad2f7cb483fd434c51..848480bc2bf93846b14e43c0c94493cb2109f889 100644 (file)
@@ -126,6 +126,20 @@ static inline void random_ether_addr(u8 *addr)
        addr [0] |= 0x02;       /* set local assignment bit (IEEE802) */
 }
 
+/**
+ * dev_hw_addr_random - Create random MAC and set device flag
+ * @dev: pointer to net_device structure
+ * @addr: Pointer to a six-byte array containing the Ethernet address
+ *
+ * Generate random MAC to be used by a device and set addr_assign_type
+ * so the state can be read by sysfs and be used by udev.
+ */
+static inline void dev_hw_addr_random(struct net_device *dev, u8 *hwaddr)
+{
+       dev->addr_assign_type |= NET_ADDR_RANDOM;
+       random_ether_addr(hwaddr);
+}
+
 /**
  * compare_ether_addr - Compare two Ethernet addresses
  * @addr1: Pointer to a six-byte array containing the Ethernet address