1 #ifndef LINUX_3_4_COMPAT_H
2 #define LINUX_3_4_COMPAT_H
4 #include <linux/version.h>
6 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
8 #include <linux/etherdevice.h>
9 #include <linux/skbuff.h>
11 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28))
12 #define skb_add_rx_frag(skb, i, page, off, size, truesize) \
13 v2_6_28_skb_add_rx_frag(skb, i, page, off, size)
15 #define skb_add_rx_frag(skb, i, page, off, size, truesize) \
16 skb_add_rx_frag(skb, i, page, off, size)
19 #ifdef CONFIG_X86_X32_ABI
20 #define COMPAT_USE_64BIT_TIME \
21 (!!(task_pt_regs(current)->orig_ax & __X32_SYSCALL_BIT))
23 #define COMPAT_USE_64BIT_TIME 0
26 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12))
27 static inline void eth_hw_addr_random(struct net_device *dev)
29 #error eth_hw_addr_random() needs to be implemented for < 2.6.12
31 #else /* kernels >= 2.6.12 */
33 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31))
34 static inline void eth_hw_addr_random(struct net_device *dev)
36 get_random_bytes(dev->dev_addr, ETH_ALEN);
37 dev->dev_addr[0] &= 0xfe; /* clear multicast bit */
38 dev->dev_addr[0] |= 0x02; /* set local assignment bit (IEEE802) */
40 #else /* kernels >= 2.6.31 */
42 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36))
43 /* So this is 2.6.31..2.6.35 */
45 /* Just have the flags present, they won't really mean anything though */
46 #define NET_ADDR_PERM 0 /* address is permanent (default) */
47 #define NET_ADDR_RANDOM 1 /* address is generated randomly */
48 #define NET_ADDR_STOLEN 2 /* address is stolen from other device */
50 static inline void eth_hw_addr_random(struct net_device *dev)
52 random_ether_addr(dev->dev_addr);
55 #else /* 2.6.36 and on */
56 static inline void eth_hw_addr_random(struct net_device *dev)
58 dev_hw_addr_random(dev, dev->dev_addr);
60 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) */
62 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) */
63 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)) */
65 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) */
67 #endif /* LINUX_5_4_COMPAT_H */