-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompat.h
167 lines (127 loc) · 5.29 KB
/
compat.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (C) 2007-2018 B.A.T.M.A.N. contributors:
*
* Marek Lindner, Simon Wunderlich
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
* This file contains macros for maintaining compatibility with older versions
* of the Linux kernel.
*/
#ifndef _NET_BATMAN_ADV_COMPAT_H_
#define _NET_BATMAN_ADV_COMPAT_H_
#ifdef __KERNEL__
#include <linux/version.h> /* LINUX_VERSION_CODE */
#include <linux/kconfig.h>
#include <generated/autoconf.h>
#include "compat-autoconf.h"
/* test for dependency CONFIG_BATMAN_ADV_DEBUG -> CONFIG_BATMAN_ADV_DEBUGFS */
#if defined(CONFIG_BATMAN_ADV_DEBUG) && !defined(CONFIG_BATMAN_ADV_DEBUGFS)
#error CONFIG_BATMAN_ADV_DEBUG=y requires CONFIG_BATMAN_ADV_DEBUGFS=y
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0)
#include <linux/netdevice.h>
#define netdev_master_upper_dev_get_rcu(dev) \
(dev->priv_flags & IFF_BRIDGE_PORT ? dev : NULL); \
break;
#endif /* < KERNEL_VERSION(3, 9, 0) */
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
#define batadv_interface_add_vid(x, y, z) \
__batadv_interface_add_vid(struct net_device *dev, __be16 proto,\
unsigned short vid);\
static void batadv_interface_add_vid(struct net_device *dev, unsigned short vid)\
{\
__batadv_interface_add_vid(dev, htons(ETH_P_8021Q), vid);\
}\
static int __batadv_interface_add_vid(struct net_device *dev, __be16 proto,\
unsigned short vid)
#define batadv_interface_kill_vid(x, y, z) \
__batadv_interface_kill_vid(struct net_device *dev, __be16 proto,\
unsigned short vid);\
static void batadv_interface_kill_vid(struct net_device *dev,\
unsigned short vid)\
{\
__batadv_interface_kill_vid(dev, htons(ETH_P_8021Q), vid);\
}\
static int __batadv_interface_kill_vid(struct net_device *dev, __be16 proto,\
unsigned short vid)
#endif /* < KERNEL_VERSION(3, 3, 0) */
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)
#define snd_portid snd_pid
#endif /* < KERNEL_VERSION(3, 7, 0) */
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0)
#define batadv_interface_set_mac_addr(x, y) \
__batadv_interface_set_mac_addr(struct net_device *dev, void *p);\
static int batadv_interface_set_mac_addr(struct net_device *dev, void *p) \
{\
int ret;\
\
ret = __batadv_interface_set_mac_addr(dev, p);\
if (!ret) \
dev->addr_assign_type &= ~NET_ADDR_RANDOM;\
return ret;\
}\
static int __batadv_interface_set_mac_addr(x, y)
#define batadv_interface_tx(x, y) \
__batadv_interface_tx(struct sk_buff *skb, struct net_device *soft_iface); \
static int batadv_interface_tx(struct sk_buff *skb, \
struct net_device *soft_iface) \
{ \
skb_reset_mac_header(skb); \
return __batadv_interface_tx(skb, soft_iface); \
} \
static int __batadv_interface_tx(struct sk_buff *skb, \
struct net_device *soft_iface)
#endif /* < KERNEL_VERSION(3, 9, 0) */
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0)
#define batadv_interface_add_vid(x, y, z) \
__batadv_interface_add_vid(struct net_device *dev, __be16 proto,\
unsigned short vid);\
static int batadv_interface_add_vid(struct net_device *dev, unsigned short vid)\
{\
return __batadv_interface_add_vid(dev, htons(ETH_P_8021Q), vid);\
}\
static int __batadv_interface_add_vid(struct net_device *dev, __be16 proto,\
unsigned short vid)
#define batadv_interface_kill_vid(x, y, z) \
__batadv_interface_kill_vid(struct net_device *dev, __be16 proto,\
unsigned short vid);\
static int batadv_interface_kill_vid(struct net_device *dev,\
unsigned short vid)\
{\
return __batadv_interface_kill_vid(dev, htons(ETH_P_8021Q), vid);\
}\
static int __batadv_interface_kill_vid(struct net_device *dev, __be16 proto,\
unsigned short vid)
#endif /* >= KERNEL_VERSION(3, 3, 0) */
#endif /* < KERNEL_VERSION(3, 10, 0) */
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)
/* wild hack for batadv_getlink_net only */
#define get_link_net get_xstats_size || 1 ? fallback_net : (struct net*)netdev->rtnl_link_ops->get_xstats_size
#endif /* < KERNEL_VERSION(4, 0, 0) */
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0)
#define IFF_NO_QUEUE 0; dev->tx_queue_len = 0
#endif /* < KERNEL_VERSION(4, 3, 0) */
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)
/* workaround for current issues with Debian's make-kpkg */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
#include <uapi/linux/pkt_cls.h>
#endif
#endif /* < KERNEL_VERSION(4, 6, 0) */
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
#define batadv_softif_slave_add(__dev, __slave_dev, __extack) \
batadv_softif_slave_add(__dev, __slave_dev)
#endif /* < KERNEL_VERSION(4, 15, 0) */
#endif /* __KERNEL__ */
#endif /* _NET_BATMAN_ADV_COMPAT_H_ */