b2c33535874cde4980f27705aa3f737866dfabd2
[sliver-openvswitch.git] / datapath / linux / compat / include / linux / etherdevice.h
1 #ifndef __LINUX_ETHERDEVICE_WRAPPER_H
2 #define __LINUX_ETHERDEVICE_WRAPPER_H 1
3
4 #include <linux/version.h>
5 #include_next <linux/etherdevice.h>
6
7 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
8 static inline void eth_hw_addr_random(struct net_device *dev)
9 {
10         random_ether_addr(dev->dev_addr);
11 }
12 #elif LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)
13 static inline void eth_hw_addr_random(struct net_device *dev)
14 {
15         dev_hw_addr_random(dev, dev->dev_addr);
16 }
17 #endif
18
19 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
20 #define eth_mac_addr rpl_eth_mac_addr
21 static inline int eth_mac_addr(struct net_device *dev, void *p)
22 {
23         struct sockaddr *addr = p;
24
25         if (!is_valid_ether_addr(addr->sa_data))
26                 return -EADDRNOTAVAIL;
27 #ifdef NET_ADDR_RANDOM
28         dev->addr_assign_type &= ~NET_ADDR_RANDOM;
29 #endif
30         memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
31         return 0;
32 }
33 #endif
34
35 #endif