1 #ifndef __LINUX_NETDEVICE_WRAPPER_H
2 #define __LINUX_NETDEVICE_WRAPPER_H 1
4 #include_next <linux/netdevice.h>
8 /* Before 2.6.21, struct net_device has a "struct class_device" member named
9 * class_dev. Beginning with 2.6.21, struct net_device instead has a "struct
10 * device" member named dev. Otherwise the usage of these members is pretty
12 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)
13 #define NETDEV_DEV_MEMBER class_dev
15 #define NETDEV_DEV_MEMBER dev
19 #define to_net_dev(class) \
20 container_of(class, struct net_device, NETDEV_DEV_MEMBER)
23 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
25 struct net *dev_net(const struct net_device *dev)
29 #endif /* linux kernel < 2.6.26 */
31 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
32 #define proc_net init_net.proc_net
35 #ifndef for_each_netdev
36 /* Linux before 2.6.22 didn't have for_each_netdev at all. */
37 #define for_each_netdev(net, d) for (d = dev_base; d; d = d->next)
38 #elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
39 /* Linux 2.6.24 added a network namespace pointer to the macro. */
40 #undef for_each_netdev
41 #define for_each_netdev(net,d) list_for_each_entry(d, &dev_base_head, dev_list)