1 #ifndef __LINUX_ETHERDEVICE_WRAPPER_H
2 #define __LINUX_ETHERDEVICE_WRAPPER_H 1
4 #include <linux/version.h>
5 #include_next <linux/etherdevice.h>
7 #ifndef HAVE_ETH_HW_ADDR_RANDOM
8 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
9 static inline void eth_hw_addr_random(struct net_device *dev)
11 random_ether_addr(dev->dev_addr);
13 #elif LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)
14 static inline void eth_hw_addr_random(struct net_device *dev)
16 dev_hw_addr_random(dev, dev->dev_addr);
21 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
22 #define eth_mac_addr rpl_eth_mac_addr
23 static inline int eth_mac_addr(struct net_device *dev, void *p)
25 struct sockaddr *addr = p;
27 if (!is_valid_ether_addr(addr->sa_data))
28 return -EADDRNOTAVAIL;
29 #ifdef NET_ADDR_RANDOM
30 dev->addr_assign_type &= ~NET_ADDR_RANDOM;
32 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
37 static inline void ether_addr_copy(u8 *dst, const u8 *src)
39 #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
40 *(u32 *)dst = *(const u32 *)src;
41 *(u16 *)(dst + 4) = *(const u16 *)(src + 4);
44 const u16 *b = (const u16 *)src;