blob: cf55cd0586b5cdf96526ba5393eda0cd6432fcd7 [file] [log] [blame]
Sven Eckelmann0046b042016-01-01 00:01:03 +01001/* Copyright (C) 2007-2016 B.A.T.M.A.N. contributors:
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +00002 *
3 * Marek Lindner, Simon Wunderlich
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 2 of the GNU General Public
7 * License as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
Antonio Quartulliebf38fb2013-11-03 20:40:48 +010015 * along with this program; if not, see <http://www.gnu.org/licenses/>.
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +000016 */
17
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +000018#ifndef _NET_BATMAN_ADV_TYPES_H_
19#define _NET_BATMAN_ADV_TYPES_H_
20
Sven Eckelmann1e2c2a42015-04-17 19:40:28 +020021#ifndef _NET_BATMAN_ADV_MAIN_H_
22#error only "main.h" can be included directly
23#endif
24
Linus Luessing162bd642016-01-16 16:40:10 +080025#include <linux/average.h>
Sven Eckelmann1e2c2a42015-04-17 19:40:28 +020026#include <linux/bitops.h>
27#include <linux/compiler.h>
28#include <linux/if_ether.h>
Sven Eckelmann90f564d2016-01-16 10:29:40 +010029#include <linux/kref.h>
Sven Eckelmann1e2c2a42015-04-17 19:40:28 +020030#include <linux/netdevice.h>
31#include <linux/sched.h> /* for linux/wait.h */
32#include <linux/spinlock.h>
33#include <linux/types.h>
34#include <linux/wait.h>
35#include <linux/workqueue.h>
36
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +000037#include "packet.h"
Sven Eckelmann1e2c2a42015-04-17 19:40:28 +020038
39struct seq_file;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +000040
Antonio Quartulli17224472011-11-06 12:23:55 +010041#ifdef CONFIG_BATMAN_ADV_DAT
42
Antonio Quartulli151dcb32014-02-22 17:02:38 +010043/**
44 * batadv_dat_addr_t - it is the type used for all DHT addresses. If it is
45 * changed, BATADV_DAT_ADDR_MAX is changed as well.
Antonio Quartulli785ea112011-11-23 11:35:44 +010046 *
47 * *Please be careful: batadv_dat_addr_t must be UNSIGNED*
48 */
Sven Eckelmann6b5e9712015-05-26 18:34:26 +020049#define batadv_dat_addr_t u16
Antonio Quartulli785ea112011-11-23 11:35:44 +010050
Antonio Quartulli17224472011-11-06 12:23:55 +010051#endif /* CONFIG_BATMAN_ADV_DAT */
52
Marek Lindner14511512012-08-02 17:20:26 +020053/**
Antonio Quartulli6c413b12013-11-05 19:31:08 +010054 * enum batadv_dhcp_recipient - dhcp destination
55 * @BATADV_DHCP_NO: packet is not a dhcp message
56 * @BATADV_DHCP_TO_SERVER: dhcp message is directed to a server
57 * @BATADV_DHCP_TO_CLIENT: dhcp message is directed to a client
58 */
59enum batadv_dhcp_recipient {
60 BATADV_DHCP_NO = 0,
61 BATADV_DHCP_TO_SERVER,
62 BATADV_DHCP_TO_CLIENT,
63};
64
65/**
Antonio Quartulli3c4f7ab2013-10-13 02:50:19 +020066 * BATADV_TT_REMOTE_MASK - bitmask selecting the flags that are sent over the
67 * wire only
68 */
69#define BATADV_TT_REMOTE_MASK 0x00FF
70
71/**
Antonio Quartulli0eb015682013-10-13 02:50:20 +020072 * BATADV_TT_SYNC_MASK - bitmask of the flags that need to be kept in sync
73 * among the nodes. These flags are used to compute the global/local CRC
74 */
75#define BATADV_TT_SYNC_MASK 0x00F0
76
77/**
Marek Lindnerd1f68252015-08-15 18:04:59 +080078 * struct batadv_hard_iface_bat_iv - per hard-interface B.A.T.M.A.N. IV data
Marek Lindner14511512012-08-02 17:20:26 +020079 * @ogm_buff: buffer holding the OGM packet
80 * @ogm_buff_len: length of the OGM packet buffer
81 * @ogm_seqno: OGM sequence number - used to identify each OGM
82 */
83struct batadv_hard_iface_bat_iv {
84 unsigned char *ogm_buff;
85 int ogm_buff_len;
86 atomic_t ogm_seqno;
87};
88
Marek Lindner88a32c92012-12-25 21:45:12 +080089/**
Linus Luessingd6f94d92016-01-16 16:40:09 +080090 * struct batadv_hard_iface_bat_v - per hard-interface B.A.T.M.A.N. V data
91 * @elp_interval: time interval between two ELP transmissions
92 * @elp_seqno: current ELP sequence number
93 * @elp_skb: base skb containing the ELP message to send
94 * @elp_wq: workqueue used to schedule ELP transmissions
95 */
96struct batadv_hard_iface_bat_v {
97 atomic_t elp_interval;
98 atomic_t elp_seqno;
99 struct sk_buff *elp_skb;
100 struct delayed_work elp_wq;
101};
102
103/**
Marek Lindner88a32c92012-12-25 21:45:12 +0800104 * struct batadv_hard_iface - network device known to batman-adv
105 * @list: list node for batadv_hardif_list
106 * @if_num: identificator of the interface
107 * @if_status: status of the interface for batman-adv
108 * @net_dev: pointer to the net_device
Matthias Schiffercaf65bf2013-03-09 23:14:23 +0100109 * @num_bcasts: number of payload re-broadcasts on this interface (ARQ)
Marek Lindner88a32c92012-12-25 21:45:12 +0800110 * @hardif_obj: kobject of the per interface sysfs "mesh" directory
111 * @refcount: number of contexts the object is used
112 * @batman_adv_ptype: packet type describing packets that should be processed by
113 * batman-adv for this interface
114 * @soft_iface: the batman-adv interface which uses this network interface
115 * @rcu: struct used for freeing in an RCU-safe manner
Marek Lindnerd1f68252015-08-15 18:04:59 +0800116 * @bat_iv: per hard-interface B.A.T.M.A.N. IV data
Linus Luessingd6f94d92016-01-16 16:40:09 +0800117 * @bat_v: per hard-interface B.A.T.M.A.N. V data
Marek Lindnerd1f68252015-08-15 18:04:59 +0800118 * @cleanup_work: work queue callback item for hard-interface deinit
Simon Wunderlich5bc7c1e2013-11-21 14:16:12 +0100119 * @debug_dir: dentry for nc subdir in batman-adv directory in debugfs
Marek Lindnercef63412015-08-04 21:09:55 +0800120 * @neigh_list: list of unique single hop neighbors via this interface
121 * @neigh_list_lock: lock protecting neigh_list
Marek Lindner88a32c92012-12-25 21:45:12 +0800122 */
Sven Eckelmann56303d32012-06-05 22:31:31 +0200123struct batadv_hard_iface {
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000124 struct list_head list;
Sven Eckelmann6b5e9712015-05-26 18:34:26 +0200125 s16 if_num;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000126 char if_status;
127 struct net_device *net_dev;
Sven Eckelmann6b5e9712015-05-26 18:34:26 +0200128 u8 num_bcasts;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000129 struct kobject *hardif_obj;
Sven Eckelmann7a659d52016-01-16 10:29:54 +0100130 struct kref refcount;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000131 struct packet_type batman_adv_ptype;
132 struct net_device *soft_iface;
133 struct rcu_head rcu;
Marek Lindner14511512012-08-02 17:20:26 +0200134 struct batadv_hard_iface_bat_iv bat_iv;
Linus Luessingd6f94d92016-01-16 16:40:09 +0800135#ifdef CONFIG_BATMAN_ADV_BATMAN_V
136 struct batadv_hard_iface_bat_v bat_v;
137#endif
Simon Wunderlich5bc44dc2013-01-11 10:19:51 +0100138 struct work_struct cleanup_work;
Simon Wunderlich5bc7c1e2013-11-21 14:16:12 +0100139 struct dentry *debug_dir;
Marek Lindnercef63412015-08-04 21:09:55 +0800140 struct hlist_head neigh_list;
141 /* neigh_list_lock protects: neigh_list */
142 spinlock_t neigh_list_lock;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000143};
144
Ben Hutchings2c530402012-07-10 10:55:09 +0000145/**
Simon Wunderlich7351a4822013-11-13 19:14:47 +0100146 * struct batadv_orig_ifinfo - originator info per outgoing interface
147 * @list: list node for orig_node::ifinfo_list
Marek Lindnerd1f68252015-08-15 18:04:59 +0800148 * @if_outgoing: pointer to outgoing hard-interface
Simon Wunderlich7351a4822013-11-13 19:14:47 +0100149 * @router: router that should be used to reach this originator
150 * @last_real_seqno: last and best known sequence number
151 * @last_ttl: ttl of last received packet
Antonio Quartulli93231582016-01-16 16:40:13 +0800152 * @last_seqno_forwarded: seqno of the OGM which was forwarded last
Simon Wunderlich7351a4822013-11-13 19:14:47 +0100153 * @batman_seqno_reset: time when the batman seqno window was reset
154 * @refcount: number of contexts the object is used
155 * @rcu: struct used for freeing in an RCU-safe manner
156 */
157struct batadv_orig_ifinfo {
158 struct hlist_node list;
159 struct batadv_hard_iface *if_outgoing;
160 struct batadv_neigh_node __rcu *router; /* rcu protected pointer */
Sven Eckelmann6b5e9712015-05-26 18:34:26 +0200161 u32 last_real_seqno;
162 u8 last_ttl;
Antonio Quartulli93231582016-01-16 16:40:13 +0800163 u32 last_seqno_forwarded;
Simon Wunderlich7351a4822013-11-13 19:14:47 +0100164 unsigned long batman_seqno_reset;
Sven Eckelmanna6ba0d32016-01-16 10:29:52 +0100165 struct kref refcount;
Simon Wunderlich7351a4822013-11-13 19:14:47 +0100166 struct rcu_head rcu;
167};
168
169/**
Martin Hundebøll610bfc6bc2013-05-23 16:53:02 +0200170 * struct batadv_frag_table_entry - head in the fragment buffer table
171 * @head: head of list with fragments
172 * @lock: lock to protect the list of fragments
173 * @timestamp: time (jiffie) of last received fragment
174 * @seqno: sequence number of the fragments in the list
175 * @size: accumulated size of packets in list
Sven Eckelmann53e77142014-12-01 10:37:27 +0100176 * @total_size: expected size of the assembled packet
Martin Hundebøll610bfc6bc2013-05-23 16:53:02 +0200177 */
178struct batadv_frag_table_entry {
179 struct hlist_head head;
180 spinlock_t lock; /* protects head */
181 unsigned long timestamp;
Sven Eckelmann6b5e9712015-05-26 18:34:26 +0200182 u16 seqno;
183 u16 size;
184 u16 total_size;
Martin Hundebøll610bfc6bc2013-05-23 16:53:02 +0200185};
186
187/**
188 * struct batadv_frag_list_entry - entry in a list of fragments
189 * @list: list node information
190 * @skb: fragment
191 * @no: fragment number in the set
192 */
193struct batadv_frag_list_entry {
194 struct hlist_node list;
195 struct sk_buff *skb;
Sven Eckelmann6b5e9712015-05-26 18:34:26 +0200196 u8 no;
Martin Hundebøll610bfc6bc2013-05-23 16:53:02 +0200197};
198
199/**
Antonio Quartulli7ea7b4a2013-07-30 22:16:25 +0200200 * struct batadv_vlan_tt - VLAN specific TT attributes
201 * @crc: CRC32 checksum of the entries belonging to this vlan
202 * @num_entries: number of TT entries for this VLAN
203 */
204struct batadv_vlan_tt {
Sven Eckelmann6b5e9712015-05-26 18:34:26 +0200205 u32 crc;
Antonio Quartulli7ea7b4a2013-07-30 22:16:25 +0200206 atomic_t num_entries;
207};
208
209/**
Simon Wunderlich1a321b02014-01-24 22:16:25 +0100210 * struct batadv_orig_node_vlan - VLAN specific data per orig_node
Antonio Quartulli7ea7b4a2013-07-30 22:16:25 +0200211 * @vid: the VLAN identifier
212 * @tt: VLAN specific TT attributes
213 * @list: list node for orig_node::vlan_list
214 * @refcount: number of context where this object is currently in use
215 * @rcu: struct used for freeing in a RCU-safe manner
216 */
217struct batadv_orig_node_vlan {
218 unsigned short vid;
219 struct batadv_vlan_tt tt;
Marek Lindnerd0fa4f32015-06-22 00:30:22 +0800220 struct hlist_node list;
Sven Eckelmann161a3be2016-01-16 10:29:55 +0100221 struct kref refcount;
Antonio Quartulli7ea7b4a2013-07-30 22:16:25 +0200222 struct rcu_head rcu;
223};
224
225/**
Antonio Quartullibbad0a52013-09-02 12:15:02 +0200226 * struct batadv_orig_bat_iv - B.A.T.M.A.N. IV private orig_node members
Marek Lindnerd1f68252015-08-15 18:04:59 +0800227 * @bcast_own: set of bitfields (one per hard-interface) where each one counts
Markus Pargmann21102622014-12-26 12:41:37 +0100228 * the number of our OGMs this orig_node rebroadcasted "back" to us (relative
229 * to last_real_seqno). Every bitfield is BATADV_TQ_LOCAL_WINDOW_SIZE bits long.
230 * @bcast_own_sum: sum of bcast_own
Antonio Quartullibbad0a52013-09-02 12:15:02 +0200231 * @ogm_cnt_lock: lock protecting bcast_own, bcast_own_sum,
232 * neigh_node->bat_iv.real_bits & neigh_node->bat_iv.real_packet_count
233 */
234struct batadv_orig_bat_iv {
235 unsigned long *bcast_own;
Sven Eckelmann6b5e9712015-05-26 18:34:26 +0200236 u8 *bcast_own_sum;
Antonio Quartullibbad0a52013-09-02 12:15:02 +0200237 /* ogm_cnt_lock protects: bcast_own, bcast_own_sum,
238 * neigh_node->bat_iv.real_bits & neigh_node->bat_iv.real_packet_count
239 */
240 spinlock_t ogm_cnt_lock;
241};
242
243/**
Marek Lindnerb6d0ab72012-12-25 17:03:19 +0800244 * struct batadv_orig_node - structure for orig_list maintaining nodes of mesh
Marek Lindner88a32c92012-12-25 21:45:12 +0800245 * @orig: originator ethernet address
Simon Wunderlich7351a4822013-11-13 19:14:47 +0100246 * @ifinfo_list: list for routers per outgoing interface
Simon Wunderlichf3b3d902013-11-13 19:14:50 +0100247 * @last_bonding_candidate: pointer to last ifinfo of last used router
Sven Eckelmann006a1992015-09-06 21:38:46 +0200248 * @dat_addr: address of the orig node in the distributed hash
Marek Lindner88a32c92012-12-25 21:45:12 +0800249 * @last_seen: time when last packet from this node was received
Marek Lindnerb6d0ab72012-12-25 17:03:19 +0800250 * @bcast_seqno_reset: time when the broadcast seqno window was reset
Linus Lüssing8a4023c2015-06-16 17:10:26 +0200251 * @mcast_handler_lock: synchronizes mcast-capability and -flag changes
Linus Lüssing60432d72014-02-15 17:47:51 +0100252 * @mcast_flags: multicast flags announced by the orig node
Sven Eckelmann006a1992015-09-06 21:38:46 +0200253 * @mcast_want_all_unsnoopables_node: a list node for the
Linus Lüssingab498862014-02-15 17:47:53 +0100254 * mcast.want_all_unsnoopables list
Linus Lüssing4c8755d2014-02-15 17:47:54 +0100255 * @mcast_want_all_ipv4_node: a list node for the mcast.want_all_ipv4 list
256 * @mcast_want_all_ipv6_node: a list node for the mcast.want_all_ipv6 list
Marek Lindner17cf0ea2013-04-23 21:39:59 +0800257 * @capabilities: announced capabilities of this originator
Linus Lüssinge17931d2014-02-15 17:47:50 +0100258 * @capa_initialized: bitfield to remember whether a capability was initialized
Marek Lindner88a32c92012-12-25 21:45:12 +0800259 * @last_ttvn: last seen translation table version number
Marek Lindner88a32c92012-12-25 21:45:12 +0800260 * @tt_buff: last tt changeset this node received from the orig node
261 * @tt_buff_len: length of the last tt changeset this node received from the
262 * orig node
263 * @tt_buff_lock: lock that protects tt_buff and tt_buff_len
Antonio Quartullia70a9aa2013-07-30 22:16:24 +0200264 * @tt_lock: prevents from updating the table while reading it. Table update is
265 * made up by two operations (data structure update and metdata -CRC/TTVN-
266 * recalculation) and they have to be executed atomically in order to avoid
267 * another thread to read the table/metadata between those.
Marek Lindner88a32c92012-12-25 21:45:12 +0800268 * @bcast_bits: bitfield containing the info which payload broadcast originated
269 * from this orig node this host already has seen (relative to
270 * last_bcast_seqno)
Marek Lindnerb6d0ab72012-12-25 17:03:19 +0800271 * @last_bcast_seqno: last broadcast sequence number received by this host
Marek Lindner88a32c92012-12-25 21:45:12 +0800272 * @neigh_list: list of potential next hop neighbor towards this orig node
Simon Wunderlichf6c8b712013-11-13 19:14:45 +0100273 * @neigh_list_lock: lock protecting neigh_list and router
Marek Lindner88a32c92012-12-25 21:45:12 +0800274 * @hash_entry: hlist node for batadv_priv::orig_hash
275 * @bat_priv: pointer to soft_iface this orig node belongs to
Marek Lindner88a32c92012-12-25 21:45:12 +0800276 * @bcast_seqno_lock: lock protecting bcast_bits & last_bcast_seqno
Marek Lindner88a32c92012-12-25 21:45:12 +0800277 * @refcount: number of contexts the object is used
278 * @rcu: struct used for freeing in an RCU-safe manner
Martin Hundebølld56b1702013-01-25 11:12:39 +0100279 * @in_coding_list: list of nodes this orig can hear
280 * @out_coding_list: list of nodes that can hear this orig
281 * @in_coding_list_lock: protects in_coding_list
282 * @out_coding_list_lock: protects out_coding_list
Martin Hundebøll610bfc6bc2013-05-23 16:53:02 +0200283 * @fragments: array with heads for fragment chains
Antonio Quartulli7ea7b4a2013-07-30 22:16:25 +0200284 * @vlan_list: a list of orig_node_vlan structs, one per VLAN served by the
285 * originator represented by this object
286 * @vlan_list_lock: lock protecting vlan_list
Antonio Quartullibbad0a52013-09-02 12:15:02 +0200287 * @bat_iv: B.A.T.M.A.N. IV private structure
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000288 */
Sven Eckelmann56303d32012-06-05 22:31:31 +0200289struct batadv_orig_node {
Sven Eckelmann6b5e9712015-05-26 18:34:26 +0200290 u8 orig[ETH_ALEN];
Simon Wunderlich7351a4822013-11-13 19:14:47 +0100291 struct hlist_head ifinfo_list;
Simon Wunderlichf3b3d902013-11-13 19:14:50 +0100292 struct batadv_orig_ifinfo *last_bonding_candidate;
Antonio Quartulli17224472011-11-06 12:23:55 +0100293#ifdef CONFIG_BATMAN_ADV_DAT
Antonio Quartulli785ea112011-11-23 11:35:44 +0100294 batadv_dat_addr_t dat_addr;
Antonio Quartulli17224472011-11-06 12:23:55 +0100295#endif
Marek Lindnerd7b2a972012-03-01 15:35:19 +0800296 unsigned long last_seen;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000297 unsigned long bcast_seqno_reset;
Linus Lüssing60432d72014-02-15 17:47:51 +0100298#ifdef CONFIG_BATMAN_ADV_MCAST
Linus Lüssing8a4023c2015-06-16 17:10:26 +0200299 /* synchronizes mcast tvlv specific orig changes */
300 spinlock_t mcast_handler_lock;
Sven Eckelmann6b5e9712015-05-26 18:34:26 +0200301 u8 mcast_flags;
Linus Lüssingab498862014-02-15 17:47:53 +0100302 struct hlist_node mcast_want_all_unsnoopables_node;
Linus Lüssing4c8755d2014-02-15 17:47:54 +0100303 struct hlist_node mcast_want_all_ipv4_node;
304 struct hlist_node mcast_want_all_ipv6_node;
Linus Lüssing60432d72014-02-15 17:47:51 +0100305#endif
Linus Lüssing65d7d4602015-06-16 17:10:22 +0200306 unsigned long capabilities;
Linus Lüssingac4eebd2015-06-16 17:10:24 +0200307 unsigned long capa_initialized;
Marek Lindner88a32c92012-12-25 21:45:12 +0800308 atomic_t last_ttvn;
Antonio Quartulli2dafb492011-05-05 08:42:45 +0200309 unsigned char *tt_buff;
Sven Eckelmann6b5e9712015-05-26 18:34:26 +0200310 s16 tt_buff_len;
Marek Lindner88a32c92012-12-25 21:45:12 +0800311 spinlock_t tt_buff_lock; /* protects tt_buff & tt_buff_len */
Antonio Quartullia70a9aa2013-07-30 22:16:24 +0200312 /* prevents from changing the table while reading it */
313 spinlock_t tt_lock;
Sven Eckelmann42d0b042012-06-03 22:19:17 +0200314 DECLARE_BITMAP(bcast_bits, BATADV_TQ_LOCAL_WINDOW_SIZE);
Sven Eckelmann6b5e9712015-05-26 18:34:26 +0200315 u32 last_bcast_seqno;
Marek Lindner9591a792010-12-12 21:57:11 +0000316 struct hlist_head neigh_list;
Simon Wunderlichf6c8b712013-11-13 19:14:45 +0100317 /* neigh_list_lock protects: neigh_list and router */
Marek Lindner88a32c92012-12-25 21:45:12 +0800318 spinlock_t neigh_list_lock;
Marek Lindner7aadf882011-02-18 12:28:09 +0000319 struct hlist_node hash_entry;
Sven Eckelmann56303d32012-06-05 22:31:31 +0200320 struct batadv_priv *bat_priv;
Marek Lindner88a32c92012-12-25 21:45:12 +0800321 /* bcast_seqno_lock protects: bcast_bits & last_bcast_seqno */
Sven Eckelmann6e215fd2011-05-08 12:45:45 +0200322 spinlock_t bcast_seqno_lock;
Sven Eckelmann7c124392016-01-16 10:29:56 +0100323 struct kref refcount;
Marek Lindner88a32c92012-12-25 21:45:12 +0800324 struct rcu_head rcu;
Martin Hundebølld56b1702013-01-25 11:12:39 +0100325#ifdef CONFIG_BATMAN_ADV_NC
326 struct list_head in_coding_list;
327 struct list_head out_coding_list;
328 spinlock_t in_coding_list_lock; /* Protects in_coding_list */
329 spinlock_t out_coding_list_lock; /* Protects out_coding_list */
330#endif
Martin Hundebøll610bfc6bc2013-05-23 16:53:02 +0200331 struct batadv_frag_table_entry fragments[BATADV_FRAG_BUFFER_COUNT];
Marek Lindnerd0fa4f32015-06-22 00:30:22 +0800332 struct hlist_head vlan_list;
Antonio Quartulli7ea7b4a2013-07-30 22:16:25 +0200333 spinlock_t vlan_list_lock; /* protects vlan_list */
Antonio Quartullibbad0a52013-09-02 12:15:02 +0200334 struct batadv_orig_bat_iv bat_iv;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000335};
336
Marek Lindner88a32c92012-12-25 21:45:12 +0800337/**
Marek Lindner17cf0ea2013-04-23 21:39:59 +0800338 * enum batadv_orig_capabilities - orig node capabilities
339 * @BATADV_ORIG_CAPA_HAS_DAT: orig node has distributed arp table enabled
Marek Lindner3f4841f2013-04-23 21:40:00 +0800340 * @BATADV_ORIG_CAPA_HAS_NC: orig node has network coding enabled
Linus Lüssinge17931d2014-02-15 17:47:50 +0100341 * @BATADV_ORIG_CAPA_HAS_TT: orig node has tt capability
Linus Lüssing60432d72014-02-15 17:47:51 +0100342 * @BATADV_ORIG_CAPA_HAS_MCAST: orig node has some multicast capability
343 * (= orig node announces a tvlv of type BATADV_TVLV_MCAST)
Marek Lindner17cf0ea2013-04-23 21:39:59 +0800344 */
345enum batadv_orig_capabilities {
Linus Lüssing65d7d4602015-06-16 17:10:22 +0200346 BATADV_ORIG_CAPA_HAS_DAT,
Linus Lüssing46354692015-06-16 17:10:23 +0200347 BATADV_ORIG_CAPA_HAS_NC,
Linus Lüssingac4eebd2015-06-16 17:10:24 +0200348 BATADV_ORIG_CAPA_HAS_TT,
Linus Lüssing9c936e32015-06-16 17:10:25 +0200349 BATADV_ORIG_CAPA_HAS_MCAST,
Marek Lindner17cf0ea2013-04-23 21:39:59 +0800350};
351
352/**
Marek Lindner88a32c92012-12-25 21:45:12 +0800353 * struct batadv_gw_node - structure for orig nodes announcing gw capabilities
354 * @list: list node for batadv_priv_gw::list
355 * @orig_node: pointer to corresponding orig node
Marek Lindner414254e2013-04-23 21:39:58 +0800356 * @bandwidth_down: advertised uplink download bandwidth
357 * @bandwidth_up: advertised uplink upload bandwidth
Marek Lindner88a32c92012-12-25 21:45:12 +0800358 * @refcount: number of contexts the object is used
359 * @rcu: struct used for freeing in an RCU-safe manner
360 */
Sven Eckelmann56303d32012-06-05 22:31:31 +0200361struct batadv_gw_node {
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000362 struct hlist_node list;
Sven Eckelmann56303d32012-06-05 22:31:31 +0200363 struct batadv_orig_node *orig_node;
Sven Eckelmann6b5e9712015-05-26 18:34:26 +0200364 u32 bandwidth_down;
365 u32 bandwidth_up;
Sven Eckelmanne7aed322016-01-16 10:29:41 +0100366 struct kref refcount;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000367 struct rcu_head rcu;
368};
369
Linus Luessing162bd642016-01-16 16:40:10 +0800370DECLARE_EWMA(throughput, 1024, 8)
371
372/**
373 * struct batadv_hardif_neigh_node_bat_v - B.A.T.M.A.N. V private neighbor
374 * information
375 * @throughput: ewma link throughput towards this neighbor
376 * @elp_interval: time interval between two ELP transmissions
377 * @elp_latest_seqno: latest and best known ELP sequence number
378 */
379struct batadv_hardif_neigh_node_bat_v {
380 struct ewma_throughput throughput;
381 u32 elp_interval;
382 u32 elp_latest_seqno;
383};
384
Marek Lindner88a32c92012-12-25 21:45:12 +0800385/**
Marek Lindnerd1f68252015-08-15 18:04:59 +0800386 * struct batadv_hardif_neigh_node - unique neighbor per hard-interface
Marek Lindnercef63412015-08-04 21:09:55 +0800387 * @list: list node for batadv_hard_iface::neigh_list
388 * @addr: the MAC address of the neighboring interface
Marek Lindnerd1f68252015-08-15 18:04:59 +0800389 * @if_incoming: pointer to incoming hard-interface
390 * @last_seen: when last packet via this neighbor was received
Linus Luessing162bd642016-01-16 16:40:10 +0800391 * @bat_v: B.A.T.M.A.N. V private data
Marek Lindnercef63412015-08-04 21:09:55 +0800392 * @refcount: number of contexts the object is used
393 * @rcu: struct used for freeing in a RCU-safe manner
394 */
395struct batadv_hardif_neigh_node {
396 struct hlist_node list;
397 u8 addr[ETH_ALEN];
398 struct batadv_hard_iface *if_incoming;
399 unsigned long last_seen;
Linus Luessing162bd642016-01-16 16:40:10 +0800400#ifdef CONFIG_BATMAN_ADV_BATMAN_V
401 struct batadv_hardif_neigh_node_bat_v bat_v;
402#endif
Sven Eckelmann90f564d2016-01-16 10:29:40 +0100403 struct kref refcount;
Marek Lindnercef63412015-08-04 21:09:55 +0800404 struct rcu_head rcu;
405};
406
407/**
Antonio Quartulli0538f752013-09-02 12:15:01 +0200408 * struct batadv_neigh_node - structure for single hops neighbors
409 * @list: list node for batadv_orig_node::neigh_list
410 * @orig_node: pointer to corresponding orig_node
411 * @addr: the MAC address of the neighboring interface
Simon Wunderlich89652332013-11-13 19:14:46 +0100412 * @ifinfo_list: list for routing metrics per outgoing interface
413 * @ifinfo_lock: lock protecting private ifinfo members and list
Marek Lindnerd1f68252015-08-15 18:04:59 +0800414 * @if_incoming: pointer to incoming hard-interface
Antonio Quartulli0538f752013-09-02 12:15:01 +0200415 * @last_seen: when last packet via this neighbor was received
Sven Eckelmanned21d172015-09-06 21:38:48 +0200416 * @refcount: number of contexts the object is used
Antonio Quartulli0538f752013-09-02 12:15:01 +0200417 * @rcu: struct used for freeing in an RCU-safe manner
Antonio Quartulli0538f752013-09-02 12:15:01 +0200418 */
419struct batadv_neigh_node {
420 struct hlist_node list;
421 struct batadv_orig_node *orig_node;
Sven Eckelmann6b5e9712015-05-26 18:34:26 +0200422 u8 addr[ETH_ALEN];
Simon Wunderlich89652332013-11-13 19:14:46 +0100423 struct hlist_head ifinfo_list;
424 spinlock_t ifinfo_lock; /* protects ifinfo_list and its members */
Antonio Quartulli0538f752013-09-02 12:15:01 +0200425 struct batadv_hard_iface *if_incoming;
426 unsigned long last_seen;
Sven Eckelmann77ae32e2016-01-16 10:29:53 +0100427 struct kref refcount;
Simon Wunderlich89652332013-11-13 19:14:46 +0100428 struct rcu_head rcu;
429};
430
Simon Wunderlich1b371d12014-01-15 21:17:54 +0100431/**
Simon Wunderlich1a321b02014-01-24 22:16:25 +0100432 * struct batadv_neigh_ifinfo_bat_iv - neighbor information per outgoing
Marek Lindnerd1f68252015-08-15 18:04:59 +0800433 * interface for B.A.T.M.A.N. IV
Simon Wunderlich89652332013-11-13 19:14:46 +0100434 * @tq_recv: ring buffer of received TQ values from this neigh node
435 * @tq_index: ring buffer index
436 * @tq_avg: averaged tq of all tq values in the ring buffer (tq_recv)
437 * @real_bits: bitfield containing the number of OGMs received from this neigh
438 * node (relative to orig_node->last_real_seqno)
439 * @real_packet_count: counted result of real_bits
440 */
441struct batadv_neigh_ifinfo_bat_iv {
Sven Eckelmann6b5e9712015-05-26 18:34:26 +0200442 u8 tq_recv[BATADV_TQ_GLOBAL_WINDOW_SIZE];
443 u8 tq_index;
444 u8 tq_avg;
Simon Wunderlich89652332013-11-13 19:14:46 +0100445 DECLARE_BITMAP(real_bits, BATADV_TQ_LOCAL_WINDOW_SIZE);
Sven Eckelmann6b5e9712015-05-26 18:34:26 +0200446 u8 real_packet_count;
Simon Wunderlich89652332013-11-13 19:14:46 +0100447};
448
Simon Wunderlich1b371d12014-01-15 21:17:54 +0100449/**
Linus Luessing162bd642016-01-16 16:40:10 +0800450 * struct batadv_neigh_ifinfo_bat_v - neighbor information per outgoing
451 * interface for B.A.T.M.A.N. V
452 * @throughput: last throughput metric received from originator via this neigh
Antonio Quartulli93231582016-01-16 16:40:13 +0800453 * @last_seqno: last sequence number known for this neighbor
Linus Luessing162bd642016-01-16 16:40:10 +0800454 */
455struct batadv_neigh_ifinfo_bat_v {
456 u32 throughput;
Antonio Quartulli93231582016-01-16 16:40:13 +0800457 u32 last_seqno;
Linus Luessing162bd642016-01-16 16:40:10 +0800458};
459
460/**
Simon Wunderlich1b371d12014-01-15 21:17:54 +0100461 * struct batadv_neigh_ifinfo - neighbor information per outgoing interface
Simon Wunderlich89652332013-11-13 19:14:46 +0100462 * @list: list node for batadv_neigh_node::ifinfo_list
Marek Lindnerd1f68252015-08-15 18:04:59 +0800463 * @if_outgoing: pointer to outgoing hard-interface
Simon Wunderlich89652332013-11-13 19:14:46 +0100464 * @bat_iv: B.A.T.M.A.N. IV private structure
Linus Luessing162bd642016-01-16 16:40:10 +0800465 * @bat_v: B.A.T.M.A.N. V private data
Simon Wunderlich89652332013-11-13 19:14:46 +0100466 * @last_ttl: last received ttl from this neigh node
467 * @refcount: number of contexts the object is used
468 * @rcu: struct used for freeing in a RCU-safe manner
469 */
470struct batadv_neigh_ifinfo {
471 struct hlist_node list;
472 struct batadv_hard_iface *if_outgoing;
473 struct batadv_neigh_ifinfo_bat_iv bat_iv;
Linus Luessing162bd642016-01-16 16:40:10 +0800474#ifdef CONFIG_BATMAN_ADV_BATMAN_V
475 struct batadv_neigh_ifinfo_bat_v bat_v;
476#endif
Sven Eckelmann6b5e9712015-05-26 18:34:26 +0200477 u8 last_ttl;
Sven Eckelmann962c6832016-01-16 10:29:51 +0100478 struct kref refcount;
Marek Lindner88a32c92012-12-25 21:45:12 +0800479 struct rcu_head rcu;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000480};
481
Sven Eckelmann426fc6c2015-09-06 21:38:45 +0200482#ifdef CONFIG_BATMAN_ADV_BLA
483
Marek Lindner88a32c92012-12-25 21:45:12 +0800484/**
485 * struct batadv_bcast_duplist_entry - structure for LAN broadcast suppression
Sven Eckelmann006a1992015-09-06 21:38:46 +0200486 * @orig: mac address of orig node orginating the broadcast
Marek Lindner88a32c92012-12-25 21:45:12 +0800487 * @crc: crc32 checksum of broadcast payload
488 * @entrytime: time when the broadcast packet was received
489 */
Sven Eckelmann56303d32012-06-05 22:31:31 +0200490struct batadv_bcast_duplist_entry {
Sven Eckelmann6b5e9712015-05-26 18:34:26 +0200491 u8 orig[ETH_ALEN];
Simon Wunderlich004e86f2012-10-18 13:47:42 +0200492 __be32 crc;
Simon Wunderlichfe2da6f2012-01-22 20:00:24 +0100493 unsigned long entrytime;
494};
Simon Wunderlich7a5cc242012-01-22 20:00:27 +0100495#endif
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000496
Marek Lindner88a32c92012-12-25 21:45:12 +0800497/**
498 * enum batadv_counters - indices for traffic counters
499 * @BATADV_CNT_TX: transmitted payload traffic packet counter
500 * @BATADV_CNT_TX_BYTES: transmitted payload traffic bytes counter
501 * @BATADV_CNT_TX_DROPPED: dropped transmission payload traffic packet counter
502 * @BATADV_CNT_RX: received payload traffic packet counter
503 * @BATADV_CNT_RX_BYTES: received payload traffic bytes counter
504 * @BATADV_CNT_FORWARD: forwarded payload traffic packet counter
505 * @BATADV_CNT_FORWARD_BYTES: forwarded payload traffic bytes counter
506 * @BATADV_CNT_MGMT_TX: transmitted routing protocol traffic packet counter
507 * @BATADV_CNT_MGMT_TX_BYTES: transmitted routing protocol traffic bytes counter
508 * @BATADV_CNT_MGMT_RX: received routing protocol traffic packet counter
509 * @BATADV_CNT_MGMT_RX_BYTES: received routing protocol traffic bytes counter
Martin Hundebøllee75ed82013-05-23 16:53:03 +0200510 * @BATADV_CNT_FRAG_TX: transmitted fragment traffic packet counter
511 * @BATADV_CNT_FRAG_TX_BYTES: transmitted fragment traffic bytes counter
Martin Hundebøll610bfc6bc2013-05-23 16:53:02 +0200512 * @BATADV_CNT_FRAG_RX: received fragment traffic packet counter
513 * @BATADV_CNT_FRAG_RX_BYTES: received fragment traffic bytes counter
514 * @BATADV_CNT_FRAG_FWD: forwarded fragment traffic packet counter
515 * @BATADV_CNT_FRAG_FWD_BYTES: forwarded fragment traffic bytes counter
Marek Lindner88a32c92012-12-25 21:45:12 +0800516 * @BATADV_CNT_TT_REQUEST_TX: transmitted tt req traffic packet counter
517 * @BATADV_CNT_TT_REQUEST_RX: received tt req traffic packet counter
518 * @BATADV_CNT_TT_RESPONSE_TX: transmitted tt resp traffic packet counter
519 * @BATADV_CNT_TT_RESPONSE_RX: received tt resp traffic packet counter
520 * @BATADV_CNT_TT_ROAM_ADV_TX: transmitted tt roam traffic packet counter
521 * @BATADV_CNT_TT_ROAM_ADV_RX: received tt roam traffic packet counter
522 * @BATADV_CNT_DAT_GET_TX: transmitted dht GET traffic packet counter
523 * @BATADV_CNT_DAT_GET_RX: received dht GET traffic packet counter
524 * @BATADV_CNT_DAT_PUT_TX: transmitted dht PUT traffic packet counter
525 * @BATADV_CNT_DAT_PUT_RX: received dht PUT traffic packet counter
526 * @BATADV_CNT_DAT_CACHED_REPLY_TX: transmitted dat cache reply traffic packet
527 * counter
Martin Hundebøll3c12de92013-01-25 11:12:41 +0100528 * @BATADV_CNT_NC_CODE: transmitted nc-combined traffic packet counter
529 * @BATADV_CNT_NC_CODE_BYTES: transmitted nc-combined traffic bytes counter
530 * @BATADV_CNT_NC_RECODE: transmitted nc-recombined traffic packet counter
531 * @BATADV_CNT_NC_RECODE_BYTES: transmitted nc-recombined traffic bytes counter
Martin Hundebøll612d2b42013-01-25 11:12:42 +0100532 * @BATADV_CNT_NC_BUFFER: counter for packets buffered for later nc decoding
Martin Hundebøll2df52782013-01-25 11:12:43 +0100533 * @BATADV_CNT_NC_DECODE: received and nc-decoded traffic packet counter
534 * @BATADV_CNT_NC_DECODE_BYTES: received and nc-decoded traffic bytes counter
535 * @BATADV_CNT_NC_DECODE_FAILED: received and decode-failed traffic packet
536 * counter
537 * @BATADV_CNT_NC_SNIFFED: counter for nc-decoded packets received in promisc
538 * mode.
Marek Lindner88a32c92012-12-25 21:45:12 +0800539 * @BATADV_CNT_NUM: number of traffic counters
540 */
Sven Eckelmannd69909d2012-06-03 22:19:20 +0200541enum batadv_counters {
Marek Lindner1c9b0552012-06-23 11:47:53 +0200542 BATADV_CNT_TX,
543 BATADV_CNT_TX_BYTES,
544 BATADV_CNT_TX_DROPPED,
545 BATADV_CNT_RX,
546 BATADV_CNT_RX_BYTES,
Sven Eckelmannd69909d2012-06-03 22:19:20 +0200547 BATADV_CNT_FORWARD,
548 BATADV_CNT_FORWARD_BYTES,
549 BATADV_CNT_MGMT_TX,
550 BATADV_CNT_MGMT_TX_BYTES,
551 BATADV_CNT_MGMT_RX,
552 BATADV_CNT_MGMT_RX_BYTES,
Martin Hundebøllee75ed82013-05-23 16:53:03 +0200553 BATADV_CNT_FRAG_TX,
554 BATADV_CNT_FRAG_TX_BYTES,
Martin Hundebøll610bfc6bc2013-05-23 16:53:02 +0200555 BATADV_CNT_FRAG_RX,
556 BATADV_CNT_FRAG_RX_BYTES,
557 BATADV_CNT_FRAG_FWD,
558 BATADV_CNT_FRAG_FWD_BYTES,
Sven Eckelmannd69909d2012-06-03 22:19:20 +0200559 BATADV_CNT_TT_REQUEST_TX,
560 BATADV_CNT_TT_REQUEST_RX,
561 BATADV_CNT_TT_RESPONSE_TX,
562 BATADV_CNT_TT_RESPONSE_RX,
563 BATADV_CNT_TT_ROAM_ADV_TX,
564 BATADV_CNT_TT_ROAM_ADV_RX,
Martin Hundebøll4046b242012-04-20 17:02:45 +0200565#ifdef CONFIG_BATMAN_ADV_DAT
566 BATADV_CNT_DAT_GET_TX,
567 BATADV_CNT_DAT_GET_RX,
568 BATADV_CNT_DAT_PUT_TX,
569 BATADV_CNT_DAT_PUT_RX,
570 BATADV_CNT_DAT_CACHED_REPLY_TX,
571#endif
Martin Hundebøll3c12de92013-01-25 11:12:41 +0100572#ifdef CONFIG_BATMAN_ADV_NC
573 BATADV_CNT_NC_CODE,
574 BATADV_CNT_NC_CODE_BYTES,
575 BATADV_CNT_NC_RECODE,
576 BATADV_CNT_NC_RECODE_BYTES,
Martin Hundebøll612d2b42013-01-25 11:12:42 +0100577 BATADV_CNT_NC_BUFFER,
Martin Hundebøll2df52782013-01-25 11:12:43 +0100578 BATADV_CNT_NC_DECODE,
579 BATADV_CNT_NC_DECODE_BYTES,
580 BATADV_CNT_NC_DECODE_FAILED,
581 BATADV_CNT_NC_SNIFFED,
Martin Hundebøll3c12de92013-01-25 11:12:41 +0100582#endif
Sven Eckelmannd69909d2012-06-03 22:19:20 +0200583 BATADV_CNT_NUM,
Martin Hundebøllf8214862012-04-20 17:02:45 +0200584};
585
Sven Eckelmann807736f2012-07-15 22:26:51 +0200586/**
587 * struct batadv_priv_tt - per mesh interface translation table data
588 * @vn: translation table version number
Marek Lindner88a32c92012-12-25 21:45:12 +0800589 * @ogm_append_cnt: counter of number of OGMs containing the local tt diff
Sven Eckelmann807736f2012-07-15 22:26:51 +0200590 * @local_changes: changes registered in an originator interval
Sven Eckelmann807736f2012-07-15 22:26:51 +0200591 * @changes_list: tracks tt local changes within an originator interval
Marek Lindner88a32c92012-12-25 21:45:12 +0800592 * @local_hash: local translation table hash table
593 * @global_hash: global translation table hash table
594 * @req_list: list of pending & unanswered tt_requests
595 * @roam_list: list of the last roaming events of each client limiting the
596 * number of roaming events to avoid route flapping
597 * @changes_list_lock: lock protecting changes_list
598 * @req_list_lock: lock protecting req_list
599 * @roam_list_lock: lock protecting roam_list
Marek Lindner88a32c92012-12-25 21:45:12 +0800600 * @last_changeset: last tt changeset this host has generated
601 * @last_changeset_len: length of last tt changeset this host has generated
602 * @last_changeset_lock: lock protecting last_changeset & last_changeset_len
Antonio Quartullia70a9aa2013-07-30 22:16:24 +0200603 * @commit_lock: prevents from executing a local TT commit while reading the
604 * local table. The local TT commit is made up by two operations (data
605 * structure update and metdata -CRC/TTVN- recalculation) and they have to be
606 * executed atomically in order to avoid another thread to read the
607 * table/metadata between those.
Marek Lindner88a32c92012-12-25 21:45:12 +0800608 * @work: work queue callback item for translation table purging
Sven Eckelmann807736f2012-07-15 22:26:51 +0200609 */
610struct batadv_priv_tt {
611 atomic_t vn;
612 atomic_t ogm_append_cnt;
613 atomic_t local_changes;
Sven Eckelmann807736f2012-07-15 22:26:51 +0200614 struct list_head changes_list;
615 struct batadv_hashtable *local_hash;
616 struct batadv_hashtable *global_hash;
Marek Lindner7c26a532015-06-28 22:16:06 +0800617 struct hlist_head req_list;
Sven Eckelmann807736f2012-07-15 22:26:51 +0200618 struct list_head roam_list;
619 spinlock_t changes_list_lock; /* protects changes */
620 spinlock_t req_list_lock; /* protects req_list */
621 spinlock_t roam_list_lock; /* protects roam_list */
Sven Eckelmann807736f2012-07-15 22:26:51 +0200622 unsigned char *last_changeset;
Sven Eckelmann6b5e9712015-05-26 18:34:26 +0200623 s16 last_changeset_len;
Marek Lindner88a32c92012-12-25 21:45:12 +0800624 /* protects last_changeset & last_changeset_len */
625 spinlock_t last_changeset_lock;
Antonio Quartullia70a9aa2013-07-30 22:16:24 +0200626 /* prevents from executing a commit while reading the table */
627 spinlock_t commit_lock;
Sven Eckelmann807736f2012-07-15 22:26:51 +0200628 struct delayed_work work;
629};
630
Sven Eckelmann426fc6c2015-09-06 21:38:45 +0200631#ifdef CONFIG_BATMAN_ADV_BLA
632
Marek Lindner88a32c92012-12-25 21:45:12 +0800633/**
634 * struct batadv_priv_bla - per mesh interface bridge loope avoidance data
Sven Eckelmann006a1992015-09-06 21:38:46 +0200635 * @num_requests: number of bla requests in flight
Marek Lindner88a32c92012-12-25 21:45:12 +0800636 * @claim_hash: hash table containing mesh nodes this host has claimed
637 * @backbone_hash: hash table containing all detected backbone gateways
638 * @bcast_duplist: recently received broadcast packets array (for broadcast
639 * duplicate suppression)
640 * @bcast_duplist_curr: index of last broadcast packet added to bcast_duplist
641 * @bcast_duplist_lock: lock protecting bcast_duplist & bcast_duplist_curr
642 * @claim_dest: local claim data (e.g. claim group)
643 * @work: work queue callback item for cleanups & bla announcements
644 */
Sven Eckelmann807736f2012-07-15 22:26:51 +0200645struct batadv_priv_bla {
Marek Lindner88a32c92012-12-25 21:45:12 +0800646 atomic_t num_requests;
Sven Eckelmann807736f2012-07-15 22:26:51 +0200647 struct batadv_hashtable *claim_hash;
648 struct batadv_hashtable *backbone_hash;
649 struct batadv_bcast_duplist_entry bcast_duplist[BATADV_DUPLIST_SIZE];
650 int bcast_duplist_curr;
Marek Lindner88a32c92012-12-25 21:45:12 +0800651 /* protects bcast_duplist & bcast_duplist_curr */
Linus Lüssing7dac7b72012-10-17 14:53:05 +0200652 spinlock_t bcast_duplist_lock;
Sven Eckelmann807736f2012-07-15 22:26:51 +0200653 struct batadv_bla_claim_dst claim_dest;
654 struct delayed_work work;
655};
656#endif
657
Sven Eckelmann426fc6c2015-09-06 21:38:45 +0200658#ifdef CONFIG_BATMAN_ADV_DEBUG
659
Marek Lindner88a32c92012-12-25 21:45:12 +0800660/**
Simon Wunderlich1a321b02014-01-24 22:16:25 +0100661 * struct batadv_priv_debug_log - debug logging data
Marek Lindner88a32c92012-12-25 21:45:12 +0800662 * @log_buff: buffer holding the logs (ring bufer)
663 * @log_start: index of next character to read
664 * @log_end: index of next character to write
665 * @lock: lock protecting log_buff, log_start & log_end
666 * @queue_wait: log reader's wait queue
667 */
Marek Lindner0abf5d82012-12-25 17:03:20 +0800668struct batadv_priv_debug_log {
669 char log_buff[BATADV_LOG_BUF_LEN];
670 unsigned long log_start;
671 unsigned long log_end;
672 spinlock_t lock; /* protects log_buff, log_start and log_end */
673 wait_queue_head_t queue_wait;
674};
675#endif
676
Marek Lindner88a32c92012-12-25 21:45:12 +0800677/**
678 * struct batadv_priv_gw - per mesh interface gateway data
679 * @list: list of available gateway nodes
680 * @list_lock: lock protecting gw_list & curr_gw
681 * @curr_gw: pointer to currently selected gateway node
Marek Lindner414254e2013-04-23 21:39:58 +0800682 * @bandwidth_down: advertised uplink download bandwidth (if gw_mode server)
683 * @bandwidth_up: advertised uplink upload bandwidth (if gw_mode server)
Marek Lindner88a32c92012-12-25 21:45:12 +0800684 * @reselect: bool indicating a gateway re-selection is in progress
685 */
Sven Eckelmann807736f2012-07-15 22:26:51 +0200686struct batadv_priv_gw {
687 struct hlist_head list;
Marek Lindner88a32c92012-12-25 21:45:12 +0800688 spinlock_t list_lock; /* protects gw_list & curr_gw */
Sven Eckelmann807736f2012-07-15 22:26:51 +0200689 struct batadv_gw_node __rcu *curr_gw; /* rcu protected pointer */
Marek Lindner414254e2013-04-23 21:39:58 +0800690 atomic_t bandwidth_down;
691 atomic_t bandwidth_up;
Sven Eckelmann807736f2012-07-15 22:26:51 +0200692 atomic_t reselect;
693};
694
Marek Lindner88a32c92012-12-25 21:45:12 +0800695/**
Marek Lindneref261572013-04-23 21:39:57 +0800696 * struct batadv_priv_tvlv - per mesh interface tvlv data
697 * @container_list: list of registered tvlv containers to be sent with each OGM
698 * @handler_list: list of the various tvlv content handlers
699 * @container_list_lock: protects tvlv container list access
700 * @handler_list_lock: protects handler list access
701 */
702struct batadv_priv_tvlv {
703 struct hlist_head container_list;
704 struct hlist_head handler_list;
705 spinlock_t container_list_lock; /* protects container_list */
706 spinlock_t handler_list_lock; /* protects handler_list */
707};
708
Sven Eckelmann426fc6c2015-09-06 21:38:45 +0200709#ifdef CONFIG_BATMAN_ADV_DAT
710
Marek Lindneref261572013-04-23 21:39:57 +0800711/**
Antonio Quartulli785ea112011-11-23 11:35:44 +0100712 * struct batadv_priv_dat - per mesh interface DAT private data
713 * @addr: node DAT address
Antonio Quartulli2f1dfbe2012-06-30 20:01:19 +0200714 * @hash: hashtable representing the local ARP cache
715 * @work: work queue callback item for cache purging
Antonio Quartulli785ea112011-11-23 11:35:44 +0100716 */
717struct batadv_priv_dat {
718 batadv_dat_addr_t addr;
Antonio Quartulli2f1dfbe2012-06-30 20:01:19 +0200719 struct batadv_hashtable *hash;
720 struct delayed_work work;
Antonio Quartulli785ea112011-11-23 11:35:44 +0100721};
Antonio Quartulli17224472011-11-06 12:23:55 +0100722#endif
Antonio Quartulli785ea112011-11-23 11:35:44 +0100723
Linus Lüssingc5caf4e2014-02-15 17:47:49 +0100724#ifdef CONFIG_BATMAN_ADV_MCAST
725/**
726 * struct batadv_priv_mcast - per mesh interface mcast data
727 * @mla_list: list of multicast addresses we are currently announcing via TT
Linus Lüssingab498862014-02-15 17:47:53 +0100728 * @want_all_unsnoopables_list: a list of orig_nodes wanting all unsnoopable
729 * multicast traffic
Linus Lüssing4c8755d2014-02-15 17:47:54 +0100730 * @want_all_ipv4_list: a list of orig_nodes wanting all IPv4 multicast traffic
731 * @want_all_ipv6_list: a list of orig_nodes wanting all IPv6 multicast traffic
Linus Lüssing60432d72014-02-15 17:47:51 +0100732 * @flags: the flags we have last sent in our mcast tvlv
733 * @enabled: whether the multicast tvlv is currently enabled
734 * @num_disabled: number of nodes that have no mcast tvlv
Linus Lüssingab498862014-02-15 17:47:53 +0100735 * @num_want_all_unsnoopables: number of nodes wanting unsnoopable IP traffic
Linus Lüssing4c8755d2014-02-15 17:47:54 +0100736 * @num_want_all_ipv4: counter for items in want_all_ipv4_list
737 * @num_want_all_ipv6: counter for items in want_all_ipv6_list
Linus Lüssingab498862014-02-15 17:47:53 +0100738 * @want_lists_lock: lock for protecting modifications to mcast want lists
739 * (traversals are rcu-locked)
Linus Lüssingc5caf4e2014-02-15 17:47:49 +0100740 */
741struct batadv_priv_mcast {
742 struct hlist_head mla_list;
Linus Lüssingab498862014-02-15 17:47:53 +0100743 struct hlist_head want_all_unsnoopables_list;
Linus Lüssing4c8755d2014-02-15 17:47:54 +0100744 struct hlist_head want_all_ipv4_list;
745 struct hlist_head want_all_ipv6_list;
Sven Eckelmann6b5e9712015-05-26 18:34:26 +0200746 u8 flags;
Linus Lüssing60432d72014-02-15 17:47:51 +0100747 bool enabled;
748 atomic_t num_disabled;
Linus Lüssingab498862014-02-15 17:47:53 +0100749 atomic_t num_want_all_unsnoopables;
Linus Lüssing4c8755d2014-02-15 17:47:54 +0100750 atomic_t num_want_all_ipv4;
751 atomic_t num_want_all_ipv6;
752 /* protects want_all_{unsnoopables,ipv4,ipv6}_list */
Linus Lüssingab498862014-02-15 17:47:53 +0100753 spinlock_t want_lists_lock;
Linus Lüssingc5caf4e2014-02-15 17:47:49 +0100754};
755#endif
756
Marek Lindner88a32c92012-12-25 21:45:12 +0800757/**
Martin Hundebølld353d8d2013-01-25 11:12:38 +0100758 * struct batadv_priv_nc - per mesh interface network coding private data
759 * @work: work queue callback item for cleanup
Martin Hundebølld56b1702013-01-25 11:12:39 +0100760 * @debug_dir: dentry for nc subdir in batman-adv directory in debugfs
761 * @min_tq: only consider neighbors for encoding if neigh_tq > min_tq
Martin Hundebøll95332472013-01-25 11:12:40 +0100762 * @max_fwd_delay: maximum packet forward delay to allow coding of packets
Martin Hundebøll612d2b42013-01-25 11:12:42 +0100763 * @max_buffer_time: buffer time for sniffed packets used to decoding
Martin Hundebøll95332472013-01-25 11:12:40 +0100764 * @timestamp_fwd_flush: timestamp of last forward packet queue flush
Martin Hundebøll612d2b42013-01-25 11:12:42 +0100765 * @timestamp_sniffed_purge: timestamp of last sniffed packet queue purge
Martin Hundebøll95332472013-01-25 11:12:40 +0100766 * @coding_hash: Hash table used to buffer skbs while waiting for another
767 * incoming skb to code it with. Skbs are added to the buffer just before being
768 * forwarded in routing.c
Martin Hundebøll612d2b42013-01-25 11:12:42 +0100769 * @decoding_hash: Hash table used to buffer skbs that might be needed to decode
770 * a received coded skb. The buffer is used for 1) skbs arriving on the
771 * soft-interface; 2) skbs overheard on the hard-interface; and 3) skbs
772 * forwarded by batman-adv.
Martin Hundebølld353d8d2013-01-25 11:12:38 +0100773 */
774struct batadv_priv_nc {
775 struct delayed_work work;
Martin Hundebølld56b1702013-01-25 11:12:39 +0100776 struct dentry *debug_dir;
777 u8 min_tq;
Martin Hundebøll95332472013-01-25 11:12:40 +0100778 u32 max_fwd_delay;
Martin Hundebøll612d2b42013-01-25 11:12:42 +0100779 u32 max_buffer_time;
Martin Hundebøll95332472013-01-25 11:12:40 +0100780 unsigned long timestamp_fwd_flush;
Martin Hundebøll612d2b42013-01-25 11:12:42 +0100781 unsigned long timestamp_sniffed_purge;
Martin Hundebøll95332472013-01-25 11:12:40 +0100782 struct batadv_hashtable *coding_hash;
Martin Hundebøll612d2b42013-01-25 11:12:42 +0100783 struct batadv_hashtable *decoding_hash;
Martin Hundebølld353d8d2013-01-25 11:12:38 +0100784};
785
786/**
Antonio Quartulli5d2c05b2013-07-02 11:04:34 +0200787 * struct batadv_softif_vlan - per VLAN attributes set
Antonio Quartulli35df3b22014-05-08 17:13:15 +0200788 * @bat_priv: pointer to the mesh object
Antonio Quartulli5d2c05b2013-07-02 11:04:34 +0200789 * @vid: VLAN identifier
790 * @kobj: kobject for sysfs vlan subdirectory
Antonio Quartullib8cbd812013-07-02 11:04:36 +0200791 * @ap_isolation: AP isolation state
Antonio Quartulli7ea7b4a2013-07-30 22:16:25 +0200792 * @tt: TT private attributes (VLAN specific)
Antonio Quartulli5d2c05b2013-07-02 11:04:34 +0200793 * @list: list node for bat_priv::softif_vlan_list
794 * @refcount: number of context where this object is currently in use
795 * @rcu: struct used for freeing in a RCU-safe manner
796 */
797struct batadv_softif_vlan {
Antonio Quartulli35df3b22014-05-08 17:13:15 +0200798 struct batadv_priv *bat_priv;
Antonio Quartulli5d2c05b2013-07-02 11:04:34 +0200799 unsigned short vid;
800 struct kobject *kobj;
Antonio Quartullib8cbd812013-07-02 11:04:36 +0200801 atomic_t ap_isolation; /* boolean */
Antonio Quartulli7ea7b4a2013-07-30 22:16:25 +0200802 struct batadv_vlan_tt tt;
Antonio Quartulli5d2c05b2013-07-02 11:04:34 +0200803 struct hlist_node list;
Sven Eckelmann6be4d302016-01-16 10:29:42 +0100804 struct kref refcount;
Antonio Quartulli5d2c05b2013-07-02 11:04:34 +0200805 struct rcu_head rcu;
806};
807
808/**
Antonio Quartulli0da00352016-01-16 16:40:12 +0800809 * struct batadv_priv_bat_v - B.A.T.M.A.N. V per soft-interface private data
810 * @ogm_buff: buffer holding the OGM packet
811 * @ogm_buff_len: length of the OGM packet buffer
812 * @ogm_seqno: OGM sequence number - used to identify each OGM
813 * @ogm_wq: workqueue used to schedule OGM transmissions
814 */
815struct batadv_priv_bat_v {
816 unsigned char *ogm_buff;
817 int ogm_buff_len;
818 atomic_t ogm_seqno;
819 struct delayed_work ogm_wq;
820};
821
822/**
Marek Lindner88a32c92012-12-25 21:45:12 +0800823 * struct batadv_priv - per mesh interface data
824 * @mesh_state: current status of the mesh (inactive/active/deactivating)
Simon Wunderlich5bc44dc2013-01-11 10:19:51 +0100825 * @soft_iface: net device which holds this struct as private data
Marek Lindner88a32c92012-12-25 21:45:12 +0800826 * @stats: structure holding the data for the ndo_get_stats() call
827 * @bat_counters: mesh internal traffic statistic counters (see batadv_counters)
828 * @aggregated_ogms: bool indicating whether OGM aggregation is enabled
829 * @bonding: bool indicating whether traffic bonding is enabled
830 * @fragmentation: bool indicating whether traffic fragmentation is enabled
Marek Lindnera19d3d82013-05-27 15:33:25 +0800831 * @packet_size_max: max packet size that can be transmitted via
832 * multiple fragmented skbs or a single frame if fragmentation is disabled
Martin Hundebøllee75ed82013-05-23 16:53:03 +0200833 * @frag_seqno: incremental counter to identify chains of egress fragments
Marek Lindner88a32c92012-12-25 21:45:12 +0800834 * @bridge_loop_avoidance: bool indicating whether bridge loop avoidance is
835 * enabled
836 * @distributed_arp_table: bool indicating whether distributed ARP table is
837 * enabled
Linus Lüssing1d8ab8d2014-02-15 17:47:52 +0100838 * @multicast_mode: Enable or disable multicast optimizations on this node's
839 * sender/originating side
Marek Lindner88a32c92012-12-25 21:45:12 +0800840 * @gw_mode: gateway operation: off, client or server (see batadv_gw_modes)
841 * @gw_sel_class: gateway selection class (applies if gw_mode client)
Marek Lindner88a32c92012-12-25 21:45:12 +0800842 * @orig_interval: OGM broadcast interval in milliseconds
843 * @hop_penalty: penalty which will be applied to an OGM's tq-field on every hop
844 * @log_level: configured log level (see batadv_dbg_level)
Antonio Quartullia14c1312015-11-17 16:40:53 +0800845 * @isolation_mark: the skb->mark value used to match packets for AP isolation
846 * @isolation_mark_mask: bitmask identifying the bits in skb->mark to be used
847 * for the isolation mark
Marek Lindner88a32c92012-12-25 21:45:12 +0800848 * @bcast_seqno: last sent broadcast packet sequence number
849 * @bcast_queue_left: number of remaining buffered broadcast packet slots
850 * @batman_queue_left: number of remaining OGM packet slots
851 * @num_ifaces: number of interfaces assigned to this mesh interface
852 * @mesh_obj: kobject for sysfs mesh subdirectory
853 * @debug_dir: dentry for debugfs batman-adv subdirectory
854 * @forw_bat_list: list of aggregated OGMs that will be forwarded
855 * @forw_bcast_list: list of broadcast packets that will be rebroadcasted
856 * @orig_hash: hash table containing mesh participants (orig nodes)
857 * @forw_bat_list_lock: lock protecting forw_bat_list
858 * @forw_bcast_list_lock: lock protecting forw_bcast_list
859 * @orig_work: work queue callback item for orig node purging
Marek Lindnerd1f68252015-08-15 18:04:59 +0800860 * @cleanup_work: work queue callback item for soft-interface deinit
861 * @primary_if: one of the hard-interfaces assigned to this mesh interface
Marek Lindner88a32c92012-12-25 21:45:12 +0800862 * becomes the primary interface
863 * @bat_algo_ops: routing algorithm used by this mesh interface
Antonio Quartulli5d2c05b2013-07-02 11:04:34 +0200864 * @softif_vlan_list: a list of softif_vlan structs, one per VLAN created on top
865 * of the mesh interface represented by this object
866 * @softif_vlan_list_lock: lock protecting softif_vlan_list
Marek Lindner88a32c92012-12-25 21:45:12 +0800867 * @bla: bridge loope avoidance data
868 * @debug_log: holding debug logging relevant data
869 * @gw: gateway data
870 * @tt: translation table data
Marek Lindneref261572013-04-23 21:39:57 +0800871 * @tvlv: type-version-length-value data
Marek Lindner88a32c92012-12-25 21:45:12 +0800872 * @dat: distributed arp table data
Linus Lüssingc5caf4e2014-02-15 17:47:49 +0100873 * @mcast: multicast data
Martin Hundebølld353d8d2013-01-25 11:12:38 +0100874 * @network_coding: bool indicating whether network coding is enabled
Sven Eckelmann006a1992015-09-06 21:38:46 +0200875 * @nc: network coding data
Antonio Quartulli0da00352016-01-16 16:40:12 +0800876 * @bat_v: B.A.T.M.A.N. V per soft-interface private data
Marek Lindner88a32c92012-12-25 21:45:12 +0800877 */
Sven Eckelmann56303d32012-06-05 22:31:31 +0200878struct batadv_priv {
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000879 atomic_t mesh_state;
Simon Wunderlich5bc44dc2013-01-11 10:19:51 +0100880 struct net_device *soft_iface;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000881 struct net_device_stats stats;
Sven Eckelmann6b5e9712015-05-26 18:34:26 +0200882 u64 __percpu *bat_counters; /* Per cpu counters */
Marek Lindner88a32c92012-12-25 21:45:12 +0800883 atomic_t aggregated_ogms;
884 atomic_t bonding;
885 atomic_t fragmentation;
Marek Lindnera19d3d82013-05-27 15:33:25 +0800886 atomic_t packet_size_max;
Martin Hundebøllee75ed82013-05-23 16:53:03 +0200887 atomic_t frag_seqno;
Antonio Quartullifa706552012-11-26 01:27:29 +0100888#ifdef CONFIG_BATMAN_ADV_BLA
Marek Lindner88a32c92012-12-25 21:45:12 +0800889 atomic_t bridge_loop_avoidance;
Antonio Quartullifa706552012-11-26 01:27:29 +0100890#endif
Antonio Quartulli33af49a2012-08-08 18:50:57 +0200891#ifdef CONFIG_BATMAN_ADV_DAT
Marek Lindner88a32c92012-12-25 21:45:12 +0800892 atomic_t distributed_arp_table;
Antonio Quartulli33af49a2012-08-08 18:50:57 +0200893#endif
Linus Lüssing1d8ab8d2014-02-15 17:47:52 +0100894#ifdef CONFIG_BATMAN_ADV_MCAST
895 atomic_t multicast_mode;
896#endif
Marek Lindner88a32c92012-12-25 21:45:12 +0800897 atomic_t gw_mode;
898 atomic_t gw_sel_class;
Marek Lindner88a32c92012-12-25 21:45:12 +0800899 atomic_t orig_interval;
900 atomic_t hop_penalty;
Marek Lindner0c430d02012-12-16 13:53:15 +0800901#ifdef CONFIG_BATMAN_ADV_DEBUG
Marek Lindner88a32c92012-12-25 21:45:12 +0800902 atomic_t log_level;
Marek Lindner0c430d02012-12-16 13:53:15 +0800903#endif
Sven Eckelmann6b5e9712015-05-26 18:34:26 +0200904 u32 isolation_mark;
905 u32 isolation_mark_mask;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000906 atomic_t bcast_seqno;
907 atomic_t bcast_queue_left;
908 atomic_t batman_queue_left;
909 char num_ifaces;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000910 struct kobject *mesh_obj;
911 struct dentry *debug_dir;
912 struct hlist_head forw_bat_list;
913 struct hlist_head forw_bcast_list;
Sven Eckelmann5bf74e92012-06-05 22:31:28 +0200914 struct batadv_hashtable *orig_hash;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000915 spinlock_t forw_bat_list_lock; /* protects forw_bat_list */
Antonio Quartullia7528f82012-09-02 19:00:38 +0200916 spinlock_t forw_bcast_list_lock; /* protects forw_bcast_list */
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000917 struct delayed_work orig_work;
Simon Wunderlich5bc44dc2013-01-11 10:19:51 +0100918 struct work_struct cleanup_work;
Sven Eckelmann56303d32012-06-05 22:31:31 +0200919 struct batadv_hard_iface __rcu *primary_if; /* rcu protected pointer */
Sven Eckelmann56303d32012-06-05 22:31:31 +0200920 struct batadv_algo_ops *bat_algo_ops;
Antonio Quartulli5d2c05b2013-07-02 11:04:34 +0200921 struct hlist_head softif_vlan_list;
922 spinlock_t softif_vlan_list_lock; /* protects softif_vlan_list */
Sven Eckelmann807736f2012-07-15 22:26:51 +0200923#ifdef CONFIG_BATMAN_ADV_BLA
924 struct batadv_priv_bla bla;
925#endif
Marek Lindner0abf5d82012-12-25 17:03:20 +0800926#ifdef CONFIG_BATMAN_ADV_DEBUG
927 struct batadv_priv_debug_log *debug_log;
928#endif
Sven Eckelmann807736f2012-07-15 22:26:51 +0200929 struct batadv_priv_gw gw;
930 struct batadv_priv_tt tt;
Marek Lindneref261572013-04-23 21:39:57 +0800931 struct batadv_priv_tvlv tvlv;
Antonio Quartulli17224472011-11-06 12:23:55 +0100932#ifdef CONFIG_BATMAN_ADV_DAT
Antonio Quartulli785ea112011-11-23 11:35:44 +0100933 struct batadv_priv_dat dat;
Antonio Quartulli17224472011-11-06 12:23:55 +0100934#endif
Linus Lüssingc5caf4e2014-02-15 17:47:49 +0100935#ifdef CONFIG_BATMAN_ADV_MCAST
936 struct batadv_priv_mcast mcast;
937#endif
Martin Hundebølld353d8d2013-01-25 11:12:38 +0100938#ifdef CONFIG_BATMAN_ADV_NC
939 atomic_t network_coding;
940 struct batadv_priv_nc nc;
941#endif /* CONFIG_BATMAN_ADV_NC */
Antonio Quartulli0da00352016-01-16 16:40:12 +0800942#ifdef CONFIG_BATMAN_ADV_BATMAN_V
943 struct batadv_priv_bat_v bat_v;
944#endif
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000945};
946
Marek Lindner88a32c92012-12-25 21:45:12 +0800947/**
948 * struct batadv_socket_client - layer2 icmp socket client data
949 * @queue_list: packet queue for packets destined for this socket client
950 * @queue_len: number of packets in the packet queue (queue_list)
951 * @index: socket client's index in the batadv_socket_client_hash
952 * @lock: lock protecting queue_list, queue_len & index
953 * @queue_wait: socket client's wait queue
954 * @bat_priv: pointer to soft_iface this client belongs to
955 */
Sven Eckelmann56303d32012-06-05 22:31:31 +0200956struct batadv_socket_client {
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000957 struct list_head queue_list;
958 unsigned int queue_len;
959 unsigned char index;
Marek Lindner88a32c92012-12-25 21:45:12 +0800960 spinlock_t lock; /* protects queue_list, queue_len & index */
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000961 wait_queue_head_t queue_wait;
Sven Eckelmann56303d32012-06-05 22:31:31 +0200962 struct batadv_priv *bat_priv;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000963};
964
Marek Lindner88a32c92012-12-25 21:45:12 +0800965/**
966 * struct batadv_socket_packet - layer2 icmp packet for socket client
967 * @list: list node for batadv_socket_client::queue_list
968 * @icmp_len: size of the layer2 icmp packet
969 * @icmp_packet: layer2 icmp packet
970 */
Sven Eckelmann56303d32012-06-05 22:31:31 +0200971struct batadv_socket_packet {
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000972 struct list_head list;
973 size_t icmp_len;
Sven Eckelmann6b5e9712015-05-26 18:34:26 +0200974 u8 icmp_packet[BATADV_ICMP_MAX_PACKET_SIZE];
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000975};
976
Sven Eckelmann426fc6c2015-09-06 21:38:45 +0200977#ifdef CONFIG_BATMAN_ADV_BLA
978
Marek Lindner88a32c92012-12-25 21:45:12 +0800979/**
980 * struct batadv_bla_backbone_gw - batman-adv gateway bridged into the LAN
981 * @orig: originator address of backbone node (mac address of primary iface)
982 * @vid: vlan id this gateway was detected on
983 * @hash_entry: hlist node for batadv_priv_bla::backbone_hash
984 * @bat_priv: pointer to soft_iface this backbone gateway belongs to
985 * @lasttime: last time we heard of this backbone gw
986 * @wait_periods: grace time for bridge forward delays and bla group forming at
987 * bootup phase - no bcast traffic is formwared until it has elapsed
988 * @request_sent: if this bool is set to true we are out of sync with this
989 * backbone gateway - no bcast traffic is formwared until the situation was
990 * resolved
991 * @crc: crc16 checksum over all claims
Simon Wunderlich5a1dd8a2015-09-11 18:04:13 +0200992 * @crc_lock: lock protecting crc
Marek Lindner88a32c92012-12-25 21:45:12 +0800993 * @refcount: number of contexts the object is used
994 * @rcu: struct used for freeing in an RCU-safe manner
995 */
Marek Lindnerbae98772012-12-25 17:03:24 +0800996struct batadv_bla_backbone_gw {
Sven Eckelmann6b5e9712015-05-26 18:34:26 +0200997 u8 orig[ETH_ALEN];
Antonio Quartullieb2deb62013-04-19 18:07:00 +0200998 unsigned short vid;
Marek Lindner2006fea2012-12-25 17:03:21 +0800999 struct hlist_node hash_entry;
1000 struct batadv_priv *bat_priv;
Marek Lindner88a32c92012-12-25 21:45:12 +08001001 unsigned long lasttime;
Marek Lindner2006fea2012-12-25 17:03:21 +08001002 atomic_t wait_periods;
1003 atomic_t request_sent;
Sven Eckelmann6b5e9712015-05-26 18:34:26 +02001004 u16 crc;
Simon Wunderlich5a1dd8a2015-09-11 18:04:13 +02001005 spinlock_t crc_lock; /* protects crc */
Sven Eckelmann06e56de2016-01-16 10:29:43 +01001006 struct kref refcount;
Marek Lindner2006fea2012-12-25 17:03:21 +08001007 struct rcu_head rcu;
Marek Lindner2006fea2012-12-25 17:03:21 +08001008};
1009
Marek Lindner88a32c92012-12-25 21:45:12 +08001010/**
1011 * struct batadv_bla_claim - claimed non-mesh client structure
1012 * @addr: mac address of claimed non-mesh client
1013 * @vid: vlan id this client was detected on
Sven Eckelmann006a1992015-09-06 21:38:46 +02001014 * @backbone_gw: pointer to backbone gw claiming this client
Marek Lindner88a32c92012-12-25 21:45:12 +08001015 * @lasttime: last time we heard of claim (locals only)
1016 * @hash_entry: hlist node for batadv_priv_bla::claim_hash
1017 * @refcount: number of contexts the object is used
1018 * @rcu: struct used for freeing in an RCU-safe manner
1019 */
Marek Lindner712bbfe42012-12-25 17:03:25 +08001020struct batadv_bla_claim {
Sven Eckelmann6b5e9712015-05-26 18:34:26 +02001021 u8 addr[ETH_ALEN];
Antonio Quartullieb2deb62013-04-19 18:07:00 +02001022 unsigned short vid;
Marek Lindnerbae98772012-12-25 17:03:24 +08001023 struct batadv_bla_backbone_gw *backbone_gw;
Marek Lindner88a32c92012-12-25 21:45:12 +08001024 unsigned long lasttime;
1025 struct hlist_node hash_entry;
Marek Lindner2006fea2012-12-25 17:03:21 +08001026 struct rcu_head rcu;
Sven Eckelmann71b7e3d2016-01-16 10:29:44 +01001027 struct kref refcount;
Marek Lindner2006fea2012-12-25 17:03:21 +08001028};
1029#endif
1030
Marek Lindner88a32c92012-12-25 21:45:12 +08001031/**
1032 * struct batadv_tt_common_entry - tt local & tt global common data
1033 * @addr: mac address of non-mesh client
Antonio Quartullic018ad32013-06-04 12:11:39 +02001034 * @vid: VLAN identifier
Marek Lindner88a32c92012-12-25 21:45:12 +08001035 * @hash_entry: hlist node for batadv_priv_tt::local_hash or for
1036 * batadv_priv_tt::global_hash
1037 * @flags: various state handling flags (see batadv_tt_client_flags)
1038 * @added_at: timestamp used for purging stale tt common entries
1039 * @refcount: number of contexts the object is used
1040 * @rcu: struct used for freeing in an RCU-safe manner
1041 */
Sven Eckelmann56303d32012-06-05 22:31:31 +02001042struct batadv_tt_common_entry {
Sven Eckelmann6b5e9712015-05-26 18:34:26 +02001043 u8 addr[ETH_ALEN];
Antonio Quartullic018ad32013-06-04 12:11:39 +02001044 unsigned short vid;
Antonio Quartulli93840ac2011-10-22 00:55:39 +02001045 struct hlist_node hash_entry;
Sven Eckelmann6b5e9712015-05-26 18:34:26 +02001046 u16 flags;
Antonio Quartulli30cfd022012-07-05 23:38:29 +02001047 unsigned long added_at;
Sven Eckelmann92dcdf02016-01-16 10:29:57 +01001048 struct kref refcount;
Antonio Quartulli7683fdc2011-04-27 14:28:07 +02001049 struct rcu_head rcu;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +00001050};
1051
Marek Lindner88a32c92012-12-25 21:45:12 +08001052/**
1053 * struct batadv_tt_local_entry - translation table local entry data
1054 * @common: general translation table data
1055 * @last_seen: timestamp used for purging stale tt local entries
1056 */
Sven Eckelmann56303d32012-06-05 22:31:31 +02001057struct batadv_tt_local_entry {
1058 struct batadv_tt_common_entry common;
Antonio Quartulli48100ba2011-10-30 12:17:33 +01001059 unsigned long last_seen;
1060};
1061
Marek Lindner88a32c92012-12-25 21:45:12 +08001062/**
1063 * struct batadv_tt_global_entry - translation table global entry data
1064 * @common: general translation table data
1065 * @orig_list: list of orig nodes announcing this non-mesh client
Linus Lüssing1d8ab8d2014-02-15 17:47:52 +01001066 * @orig_list_count: number of items in the orig_list
Marek Lindner88a32c92012-12-25 21:45:12 +08001067 * @list_lock: lock protecting orig_list
1068 * @roam_at: time at which TT_GLOBAL_ROAM was set
1069 */
Sven Eckelmann56303d32012-06-05 22:31:31 +02001070struct batadv_tt_global_entry {
1071 struct batadv_tt_common_entry common;
Simon Wunderlichdb08e6e2011-10-22 20:12:51 +02001072 struct hlist_head orig_list;
Linus Lüssing1d8ab8d2014-02-15 17:47:52 +01001073 atomic_t orig_list_count;
Marek Lindner88a32c92012-12-25 21:45:12 +08001074 spinlock_t list_lock; /* protects orig_list */
1075 unsigned long roam_at;
Simon Wunderlichdb08e6e2011-10-22 20:12:51 +02001076};
1077
Marek Lindner88a32c92012-12-25 21:45:12 +08001078/**
1079 * struct batadv_tt_orig_list_entry - orig node announcing a non-mesh client
1080 * @orig_node: pointer to orig node announcing this non-mesh client
1081 * @ttvn: translation table version number which added the non-mesh client
1082 * @list: list node for batadv_tt_global_entry::orig_list
1083 * @refcount: number of contexts the object is used
1084 * @rcu: struct used for freeing in an RCU-safe manner
1085 */
Sven Eckelmann56303d32012-06-05 22:31:31 +02001086struct batadv_tt_orig_list_entry {
1087 struct batadv_orig_node *orig_node;
Sven Eckelmann6b5e9712015-05-26 18:34:26 +02001088 u8 ttvn;
Marek Lindner88a32c92012-12-25 21:45:12 +08001089 struct hlist_node list;
Sven Eckelmann6e8ef692016-01-16 10:29:50 +01001090 struct kref refcount;
Simon Wunderlichdb08e6e2011-10-22 20:12:51 +02001091 struct rcu_head rcu;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +00001092};
1093
Marek Lindner88a32c92012-12-25 21:45:12 +08001094/**
Antonio Quartulli3f687852014-11-02 11:29:56 +01001095 * struct batadv_tt_change_node - structure for tt changes occurred
Marek Lindner88a32c92012-12-25 21:45:12 +08001096 * @list: list node for batadv_priv_tt::changes_list
1097 * @change: holds the actual translation table diff data
1098 */
Sven Eckelmann56303d32012-06-05 22:31:31 +02001099struct batadv_tt_change_node {
Antonio Quartullia73105b2011-04-27 14:27:44 +02001100 struct list_head list;
Marek Lindnere1bf0c12013-04-23 21:40:01 +08001101 struct batadv_tvlv_tt_change change;
Antonio Quartullia73105b2011-04-27 14:27:44 +02001102};
1103
Marek Lindner88a32c92012-12-25 21:45:12 +08001104/**
1105 * struct batadv_tt_req_node - data to keep track of the tt requests in flight
1106 * @addr: mac address address of the originator this request was sent to
1107 * @issued_at: timestamp used for purging stale tt requests
1108 * @list: list node for batadv_priv_tt::req_list
1109 */
Sven Eckelmann56303d32012-06-05 22:31:31 +02001110struct batadv_tt_req_node {
Sven Eckelmann6b5e9712015-05-26 18:34:26 +02001111 u8 addr[ETH_ALEN];
Antonio Quartullia73105b2011-04-27 14:27:44 +02001112 unsigned long issued_at;
Marek Lindner7c26a532015-06-28 22:16:06 +08001113 struct hlist_node list;
Antonio Quartullia73105b2011-04-27 14:27:44 +02001114};
1115
Marek Lindner88a32c92012-12-25 21:45:12 +08001116/**
1117 * struct batadv_tt_roam_node - roaming client data
1118 * @addr: mac address of the client in the roaming phase
1119 * @counter: number of allowed roaming events per client within a single
1120 * OGM interval (changes are committed with each OGM)
1121 * @first_time: timestamp used for purging stale roaming node entries
1122 * @list: list node for batadv_priv_tt::roam_list
1123 */
Sven Eckelmann56303d32012-06-05 22:31:31 +02001124struct batadv_tt_roam_node {
Sven Eckelmann6b5e9712015-05-26 18:34:26 +02001125 u8 addr[ETH_ALEN];
Antonio Quartullicc47f662011-04-27 14:27:57 +02001126 atomic_t counter;
1127 unsigned long first_time;
1128 struct list_head list;
1129};
1130
Marek Lindner88a32c92012-12-25 21:45:12 +08001131/**
Martin Hundebølld56b1702013-01-25 11:12:39 +01001132 * struct batadv_nc_node - network coding node
1133 * @list: next and prev pointer for the list handling
1134 * @addr: the node's mac address
1135 * @refcount: number of contexts the object is used by
1136 * @rcu: struct used for freeing in an RCU-safe manner
1137 * @orig_node: pointer to corresponding orig node struct
1138 * @last_seen: timestamp of last ogm received from this node
1139 */
1140struct batadv_nc_node {
1141 struct list_head list;
Sven Eckelmann6b5e9712015-05-26 18:34:26 +02001142 u8 addr[ETH_ALEN];
Sven Eckelmanndaf99b42016-01-16 10:29:45 +01001143 struct kref refcount;
Martin Hundebølld56b1702013-01-25 11:12:39 +01001144 struct rcu_head rcu;
1145 struct batadv_orig_node *orig_node;
1146 unsigned long last_seen;
1147};
1148
1149/**
Martin Hundebøll95332472013-01-25 11:12:40 +01001150 * struct batadv_nc_path - network coding path
1151 * @hash_entry: next and prev pointer for the list handling
1152 * @rcu: struct used for freeing in an RCU-safe manner
1153 * @refcount: number of contexts the object is used by
1154 * @packet_list: list of buffered packets for this path
1155 * @packet_list_lock: access lock for packet list
1156 * @next_hop: next hop (destination) of path
1157 * @prev_hop: previous hop (source) of path
1158 * @last_valid: timestamp for last validation of path
1159 */
1160struct batadv_nc_path {
1161 struct hlist_node hash_entry;
1162 struct rcu_head rcu;
Sven Eckelmann727e0cd2016-01-16 10:29:46 +01001163 struct kref refcount;
Martin Hundebøll95332472013-01-25 11:12:40 +01001164 struct list_head packet_list;
1165 spinlock_t packet_list_lock; /* Protects packet_list */
Sven Eckelmann6b5e9712015-05-26 18:34:26 +02001166 u8 next_hop[ETH_ALEN];
1167 u8 prev_hop[ETH_ALEN];
Martin Hundebøll95332472013-01-25 11:12:40 +01001168 unsigned long last_valid;
1169};
1170
1171/**
1172 * struct batadv_nc_packet - network coding packet used when coding and
1173 * decoding packets
1174 * @list: next and prev pointer for the list handling
1175 * @packet_id: crc32 checksum of skb data
1176 * @timestamp: field containing the info when the packet was added to path
1177 * @neigh_node: pointer to original next hop neighbor of skb
1178 * @skb: skb which can be encoded or used for decoding
1179 * @nc_path: pointer to path this nc packet is attached to
1180 */
1181struct batadv_nc_packet {
1182 struct list_head list;
1183 __be32 packet_id;
1184 unsigned long timestamp;
1185 struct batadv_neigh_node *neigh_node;
1186 struct sk_buff *skb;
1187 struct batadv_nc_path *nc_path;
1188};
1189
1190/**
Simon Wunderlich1a321b02014-01-24 22:16:25 +01001191 * struct batadv_skb_cb - control buffer structure used to store private data
1192 * relevant to batman-adv in the skb->cb buffer in skbs.
Martin Hundebøll3c12de92013-01-25 11:12:41 +01001193 * @decoded: Marks a skb as decoded, which is checked when searching for coding
1194 * opportunities in network-coding.c
1195 */
1196struct batadv_skb_cb {
1197 bool decoded;
1198};
1199
1200/**
Marek Lindner88a32c92012-12-25 21:45:12 +08001201 * struct batadv_forw_packet - structure for bcast packets to be sent/forwarded
1202 * @list: list node for batadv_socket_client::queue_list
1203 * @send_time: execution time for delayed_work (packet sending)
1204 * @own: bool for locally generated packets (local OGMs are re-scheduled after
1205 * sending)
1206 * @skb: bcast packet's skb buffer
1207 * @packet_len: size of aggregated OGM packet inside the skb buffer
1208 * @direct_link_flags: direct link flags for aggregated OGM packets
1209 * @num_packets: counter for bcast packet retransmission
1210 * @delayed_work: work queue callback item for packet sending
Simon Wunderlichef0a9372013-11-13 19:14:49 +01001211 * @if_incoming: pointer to incoming hard-iface or primary iface if
1212 * locally generated packet
1213 * @if_outgoing: packet where the packet should be sent to, or NULL if
1214 * unspecified
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +00001215 */
Sven Eckelmann56303d32012-06-05 22:31:31 +02001216struct batadv_forw_packet {
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +00001217 struct hlist_node list;
1218 unsigned long send_time;
Sven Eckelmann6b5e9712015-05-26 18:34:26 +02001219 u8 own;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +00001220 struct sk_buff *skb;
Sven Eckelmann6b5e9712015-05-26 18:34:26 +02001221 u16 packet_len;
1222 u32 direct_link_flags;
1223 u8 num_packets;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +00001224 struct delayed_work delayed_work;
Sven Eckelmann56303d32012-06-05 22:31:31 +02001225 struct batadv_hard_iface *if_incoming;
Simon Wunderlichef0a9372013-11-13 19:14:49 +01001226 struct batadv_hard_iface *if_outgoing;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +00001227};
1228
Marek Lindner88a32c92012-12-25 21:45:12 +08001229/**
Marek Lindner88a32c92012-12-25 21:45:12 +08001230 * struct batadv_algo_ops - mesh algorithm callbacks
1231 * @list: list node for the batadv_algo_list
1232 * @name: name of the algorithm
1233 * @bat_iface_enable: init routing info when hard-interface is enabled
1234 * @bat_iface_disable: de-init routing info when hard-interface is disabled
1235 * @bat_iface_update_mac: (re-)init mac addresses of the protocol information
1236 * belonging to this hard-interface
1237 * @bat_primary_iface_set: called when primary interface is selected / changed
1238 * @bat_ogm_schedule: prepare a new outgoing OGM for the send queue
1239 * @bat_ogm_emit: send scheduled OGM
Marek Lindner8248a4c2015-08-04 21:09:56 +08001240 * @bat_hardif_neigh_init: called on creation of single hop entry
Simon Wunderlich89652332013-11-13 19:14:46 +01001241 * @bat_neigh_cmp: compare the metrics of two neighbors for their respective
1242 * outgoing interfaces
Simon Wunderlich18165f62015-08-08 02:01:50 +02001243 * @bat_neigh_is_similar_or_better: check if neigh1 is equally similar or
1244 * better than neigh2 for their respective outgoing interface from the metric
Simon Wunderlich89652332013-11-13 19:14:46 +01001245 * prospective
Marek Lindner75874052015-08-04 21:09:57 +08001246 * @bat_neigh_print: print the single hop neighbor list (optional)
Antonio Quartullibcef1f32015-03-01 00:50:17 +08001247 * @bat_neigh_free: free the resources allocated by the routing algorithm for a
1248 * neigh_node object
Antonio Quartulli737a2a222013-09-02 12:15:03 +02001249 * @bat_orig_print: print the originator table (optional)
Antonio Quartullid0015fd2013-09-03 11:10:23 +02001250 * @bat_orig_free: free the resources allocated by the routing algorithm for an
1251 * orig_node object
1252 * @bat_orig_add_if: ask the routing algorithm to apply the needed changes to
1253 * the orig_node due to a new hard-interface being added into the mesh
1254 * @bat_orig_del_if: ask the routing algorithm to apply the needed changes to
1255 * the orig_node due to an hard-interface being removed from the mesh
Marek Lindner88a32c92012-12-25 21:45:12 +08001256 */
Sven Eckelmann56303d32012-06-05 22:31:31 +02001257struct batadv_algo_ops {
Marek Lindner1c280472011-11-28 17:40:17 +08001258 struct hlist_node list;
1259 char *name;
Sven Eckelmann56303d32012-06-05 22:31:31 +02001260 int (*bat_iface_enable)(struct batadv_hard_iface *hard_iface);
Sven Eckelmann56303d32012-06-05 22:31:31 +02001261 void (*bat_iface_disable)(struct batadv_hard_iface *hard_iface);
Sven Eckelmann56303d32012-06-05 22:31:31 +02001262 void (*bat_iface_update_mac)(struct batadv_hard_iface *hard_iface);
Sven Eckelmann56303d32012-06-05 22:31:31 +02001263 void (*bat_primary_iface_set)(struct batadv_hard_iface *hard_iface);
Sven Eckelmann56303d32012-06-05 22:31:31 +02001264 void (*bat_ogm_schedule)(struct batadv_hard_iface *hard_iface);
Sven Eckelmann56303d32012-06-05 22:31:31 +02001265 void (*bat_ogm_emit)(struct batadv_forw_packet *forw_packet);
Antonio Quartullibcef1f32015-03-01 00:50:17 +08001266 /* neigh_node handling API */
Marek Lindner8248a4c2015-08-04 21:09:56 +08001267 void (*bat_hardif_neigh_init)(struct batadv_hardif_neigh_node *neigh);
Antonio Quartullia3285a82013-09-02 12:15:04 +02001268 int (*bat_neigh_cmp)(struct batadv_neigh_node *neigh1,
Simon Wunderlich89652332013-11-13 19:14:46 +01001269 struct batadv_hard_iface *if_outgoing1,
1270 struct batadv_neigh_node *neigh2,
1271 struct batadv_hard_iface *if_outgoing2);
Simon Wunderlich18165f62015-08-08 02:01:50 +02001272 bool (*bat_neigh_is_similar_or_better)
Simon Wunderlich89652332013-11-13 19:14:46 +01001273 (struct batadv_neigh_node *neigh1,
1274 struct batadv_hard_iface *if_outgoing1,
1275 struct batadv_neigh_node *neigh2,
1276 struct batadv_hard_iface *if_outgoing2);
Marek Lindner75874052015-08-04 21:09:57 +08001277 void (*bat_neigh_print)(struct batadv_priv *priv, struct seq_file *seq);
Antonio Quartullibcef1f32015-03-01 00:50:17 +08001278 void (*bat_neigh_free)(struct batadv_neigh_node *neigh);
Antonio Quartulli737a2a222013-09-02 12:15:03 +02001279 /* orig_node handling API */
Simon Wunderlichcb1c92e2013-11-21 11:52:16 +01001280 void (*bat_orig_print)(struct batadv_priv *priv, struct seq_file *seq,
1281 struct batadv_hard_iface *hard_iface);
Antonio Quartullid0015fd2013-09-03 11:10:23 +02001282 void (*bat_orig_free)(struct batadv_orig_node *orig_node);
1283 int (*bat_orig_add_if)(struct batadv_orig_node *orig_node,
1284 int max_if_num);
1285 int (*bat_orig_del_if)(struct batadv_orig_node *orig_node,
1286 int max_if_num, int del_if_num);
Marek Lindner1c280472011-11-28 17:40:17 +08001287};
1288
Antonio Quartulli785ea112011-11-23 11:35:44 +01001289/**
Antonio Quartulli2f1dfbe2012-06-30 20:01:19 +02001290 * struct batadv_dat_entry - it is a single entry of batman-adv ARP backend. It
1291 * is used to stored ARP entries needed for the global DAT cache
1292 * @ip: the IPv4 corresponding to this DAT/ARP entry
1293 * @mac_addr: the MAC address associated to the stored IPv4
Antonio Quartullibe1db4f2013-06-04 12:11:43 +02001294 * @vid: the vlan ID associated to this entry
Antonio Quartulli2f1dfbe2012-06-30 20:01:19 +02001295 * @last_update: time in jiffies when this entry was refreshed last time
1296 * @hash_entry: hlist node for batadv_priv_dat::hash
1297 * @refcount: number of contexts the object is used
1298 * @rcu: struct used for freeing in an RCU-safe manner
1299 */
1300struct batadv_dat_entry {
1301 __be32 ip;
Sven Eckelmann6b5e9712015-05-26 18:34:26 +02001302 u8 mac_addr[ETH_ALEN];
Antonio Quartullibe1db4f2013-06-04 12:11:43 +02001303 unsigned short vid;
Antonio Quartulli2f1dfbe2012-06-30 20:01:19 +02001304 unsigned long last_update;
1305 struct hlist_node hash_entry;
Sven Eckelmann68a67222016-01-16 10:29:47 +01001306 struct kref refcount;
Antonio Quartulli2f1dfbe2012-06-30 20:01:19 +02001307 struct rcu_head rcu;
1308};
1309
1310/**
Linus Lüssingc5caf4e2014-02-15 17:47:49 +01001311 * struct batadv_hw_addr - a list entry for a MAC address
1312 * @list: list node for the linking of entries
1313 * @addr: the MAC address of this list entry
1314 */
1315struct batadv_hw_addr {
1316 struct hlist_node list;
1317 unsigned char addr[ETH_ALEN];
1318};
1319
1320/**
Antonio Quartulli785ea112011-11-23 11:35:44 +01001321 * struct batadv_dat_candidate - candidate destination for DAT operations
1322 * @type: the type of the selected candidate. It can one of the following:
1323 * - BATADV_DAT_CANDIDATE_NOT_FOUND
1324 * - BATADV_DAT_CANDIDATE_ORIG
1325 * @orig_node: if type is BATADV_DAT_CANDIDATE_ORIG this field points to the
1326 * corresponding originator node structure
1327 */
1328struct batadv_dat_candidate {
1329 int type;
1330 struct batadv_orig_node *orig_node;
1331};
1332
Marek Lindneref261572013-04-23 21:39:57 +08001333/**
1334 * struct batadv_tvlv_container - container for tvlv appended to OGMs
1335 * @list: hlist node for batadv_priv_tvlv::container_list
1336 * @tvlv_hdr: tvlv header information needed to construct the tvlv
Marek Lindneref261572013-04-23 21:39:57 +08001337 * @refcount: number of contexts the object is used
1338 */
1339struct batadv_tvlv_container {
1340 struct hlist_node list;
1341 struct batadv_tvlv_hdr tvlv_hdr;
Sven Eckelmannf7157dd2016-01-16 10:29:48 +01001342 struct kref refcount;
Marek Lindneref261572013-04-23 21:39:57 +08001343};
1344
1345/**
1346 * struct batadv_tvlv_handler - handler for specific tvlv type and version
1347 * @list: hlist node for batadv_priv_tvlv::handler_list
1348 * @ogm_handler: handler callback which is given the tvlv payload to process on
1349 * incoming OGM packets
1350 * @unicast_handler: handler callback which is given the tvlv payload to process
1351 * on incoming unicast tvlv packets
1352 * @type: tvlv type this handler feels responsible for
1353 * @version: tvlv version this handler feels responsible for
1354 * @flags: tvlv handler flags
1355 * @refcount: number of contexts the object is used
1356 * @rcu: struct used for freeing in an RCU-safe manner
1357 */
1358struct batadv_tvlv_handler {
1359 struct hlist_node list;
1360 void (*ogm_handler)(struct batadv_priv *bat_priv,
1361 struct batadv_orig_node *orig,
Sven Eckelmann6b5e9712015-05-26 18:34:26 +02001362 u8 flags, void *tvlv_value, u16 tvlv_value_len);
Marek Lindneref261572013-04-23 21:39:57 +08001363 int (*unicast_handler)(struct batadv_priv *bat_priv,
Sven Eckelmann6b5e9712015-05-26 18:34:26 +02001364 u8 *src, u8 *dst,
1365 void *tvlv_value, u16 tvlv_value_len);
1366 u8 type;
1367 u8 version;
1368 u8 flags;
Sven Eckelmann32836f52016-01-16 10:29:49 +01001369 struct kref refcount;
Marek Lindneref261572013-04-23 21:39:57 +08001370 struct rcu_head rcu;
1371};
1372
1373/**
1374 * enum batadv_tvlv_handler_flags - tvlv handler flags definitions
1375 * @BATADV_TVLV_HANDLER_OGM_CIFNOTFND: tvlv ogm processing function will call
1376 * this handler even if its type was not found (with no data)
1377 * @BATADV_TVLV_HANDLER_OGM_CALLED: interval tvlv handling flag - the API marks
1378 * a handler as being called, so it won't be called if the
1379 * BATADV_TVLV_HANDLER_OGM_CIFNOTFND flag was set
1380 */
1381enum batadv_tvlv_handler_flags {
1382 BATADV_TVLV_HANDLER_OGM_CIFNOTFND = BIT(1),
1383 BATADV_TVLV_HANDLER_OGM_CALLED = BIT(2),
1384};
1385
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +00001386#endif /* _NET_BATMAN_ADV_TYPES_H_ */