xref: /linux-6.15/include/uapi/linux/batman_adv.h (revision 66dfdff0)
1 /* SPDX-License-Identifier: MIT */
2 /* Copyright (C) 2016-2017  B.A.T.M.A.N. contributors:
3  *
4  * Matthias Schiffer
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 
25 #ifndef _UAPI_LINUX_BATMAN_ADV_H_
26 #define _UAPI_LINUX_BATMAN_ADV_H_
27 
28 #define BATADV_NL_NAME "batadv"
29 
30 #define BATADV_NL_MCAST_GROUP_TPMETER	"tpmeter"
31 
32 /**
33  * enum batadv_tt_client_flags - TT client specific flags
34  *
35  * Bits from 0 to 7 are called _remote flags_ because they are sent on the wire.
36  * Bits from 8 to 15 are called _local flags_ because they are used for local
37  * computations only.
38  *
39  * Bits from 4 to 7 - a subset of remote flags - are ensured to be in sync with
40  * the other nodes in the network. To achieve this goal these flags are included
41  * in the TT CRC computation.
42  */
43 enum batadv_tt_client_flags {
44 	/**
45 	 * @BATADV_TT_CLIENT_DEL: the client has to be deleted from the table
46 	 */
47 	BATADV_TT_CLIENT_DEL     = (1 << 0),
48 
49 	/**
50 	 * @BATADV_TT_CLIENT_ROAM: the client roamed to/from another node and
51 	 * the new update telling its new real location has not been
52 	 * received/sent yet
53 	 */
54 	BATADV_TT_CLIENT_ROAM    = (1 << 1),
55 
56 	/**
57 	 * @BATADV_TT_CLIENT_WIFI: this client is connected through a wifi
58 	 * interface. This information is used by the "AP Isolation" feature
59 	 */
60 	BATADV_TT_CLIENT_WIFI    = (1 << 4),
61 
62 	/**
63 	 * @BATADV_TT_CLIENT_ISOLA: this client is considered "isolated". This
64 	 * information is used by the Extended Isolation feature
65 	 */
66 	BATADV_TT_CLIENT_ISOLA	 = (1 << 5),
67 
68 	/**
69 	 * @BATADV_TT_CLIENT_NOPURGE: this client should never be removed from
70 	 * the table
71 	 */
72 	BATADV_TT_CLIENT_NOPURGE = (1 << 8),
73 
74 	/**
75 	 * @BATADV_TT_CLIENT_NEW: this client has been added to the local table
76 	 * but has not been announced yet
77 	 */
78 	BATADV_TT_CLIENT_NEW     = (1 << 9),
79 
80 	/**
81 	 * @BATADV_TT_CLIENT_PENDING: this client is marked for removal but it
82 	 * is kept in the table for one more originator interval for consistency
83 	 * purposes
84 	 */
85 	BATADV_TT_CLIENT_PENDING = (1 << 10),
86 
87 	/**
88 	 * @BATADV_TT_CLIENT_TEMP: this global client has been detected to be
89 	 * part of the network but no nnode has already announced it
90 	 */
91 	BATADV_TT_CLIENT_TEMP	 = (1 << 11),
92 };
93 
94 /**
95  * enum batadv_nl_attrs - batman-adv netlink attributes
96  */
97 enum batadv_nl_attrs {
98 	/**
99 	 * @BATADV_ATTR_UNSPEC: unspecified attribute to catch errors
100 	 */
101 	BATADV_ATTR_UNSPEC,
102 
103 	/**
104 	 * @BATADV_ATTR_VERSION: batman-adv version string
105 	 */
106 	BATADV_ATTR_VERSION,
107 
108 	/**
109 	 * @BATADV_ATTR_ALGO_NAME: name of routing algorithm
110 	 */
111 	BATADV_ATTR_ALGO_NAME,
112 
113 	/**
114 	 * @BATADV_ATTR_MESH_IFINDEX: index of the batman-adv interface
115 	 */
116 	BATADV_ATTR_MESH_IFINDEX,
117 
118 	/**
119 	 * @BATADV_ATTR_MESH_IFNAME: name of the batman-adv interface
120 	 */
121 	BATADV_ATTR_MESH_IFNAME,
122 
123 	/**
124 	 * @BATADV_ATTR_MESH_ADDRESS: mac address of the batman-adv interface
125 	 */
126 	BATADV_ATTR_MESH_ADDRESS,
127 
128 	/**
129 	 * @BATADV_ATTR_HARD_IFINDEX: index of the non-batman-adv interface
130 	 */
131 	BATADV_ATTR_HARD_IFINDEX,
132 
133 	/**
134 	 * @BATADV_ATTR_HARD_IFNAME: name of the non-batman-adv interface
135 	 */
136 	BATADV_ATTR_HARD_IFNAME,
137 
138 	/**
139 	 * @BATADV_ATTR_HARD_ADDRESS: mac address of the non-batman-adv
140 	 * interface
141 	 */
142 	BATADV_ATTR_HARD_ADDRESS,
143 
144 	/**
145 	 * @BATADV_ATTR_ORIG_ADDRESS: originator mac address
146 	 */
147 	BATADV_ATTR_ORIG_ADDRESS,
148 
149 	/**
150 	 * @BATADV_ATTR_TPMETER_RESULT: result of run (see
151 	 * batadv_tp_meter_status)
152 	 */
153 	BATADV_ATTR_TPMETER_RESULT,
154 
155 	/**
156 	 * @BATADV_ATTR_TPMETER_TEST_TIME: time (msec) the run took
157 	 */
158 	BATADV_ATTR_TPMETER_TEST_TIME,
159 
160 	/**
161 	 * @BATADV_ATTR_TPMETER_BYTES: amount of acked bytes during run
162 	 */
163 	BATADV_ATTR_TPMETER_BYTES,
164 
165 	/**
166 	 * @BATADV_ATTR_TPMETER_COOKIE: session cookie to match tp_meter session
167 	 */
168 	BATADV_ATTR_TPMETER_COOKIE,
169 
170 	/**
171 	 * @BATADV_ATTR_PAD: attribute used for padding for 64-bit alignment
172 	 */
173 	BATADV_ATTR_PAD,
174 
175 	/**
176 	 * @BATADV_ATTR_ACTIVE: Flag indicating if the hard interface is active
177 	 */
178 	BATADV_ATTR_ACTIVE,
179 
180 	/**
181 	 * @BATADV_ATTR_TT_ADDRESS: Client MAC address
182 	 */
183 	BATADV_ATTR_TT_ADDRESS,
184 
185 	/**
186 	 * @BATADV_ATTR_TT_TTVN: Translation table version
187 	 */
188 	BATADV_ATTR_TT_TTVN,
189 
190 	/**
191 	 * @BATADV_ATTR_TT_LAST_TTVN: Previous translation table version
192 	 */
193 	BATADV_ATTR_TT_LAST_TTVN,
194 
195 	/**
196 	 * @BATADV_ATTR_TT_CRC32: CRC32 over translation table
197 	 */
198 	BATADV_ATTR_TT_CRC32,
199 
200 	/**
201 	 * @BATADV_ATTR_TT_VID: VLAN ID
202 	 */
203 	BATADV_ATTR_TT_VID,
204 
205 	/**
206 	 * @BATADV_ATTR_TT_FLAGS: Translation table client flags
207 	 */
208 	BATADV_ATTR_TT_FLAGS,
209 
210 	/**
211 	 * @BATADV_ATTR_FLAG_BEST: Flags indicating entry is the best
212 	 */
213 	BATADV_ATTR_FLAG_BEST,
214 
215 	/**
216 	 * @BATADV_ATTR_LAST_SEEN_MSECS: Time in milliseconds since last seen
217 	 */
218 	BATADV_ATTR_LAST_SEEN_MSECS,
219 
220 	/**
221 	 * @BATADV_ATTR_NEIGH_ADDRESS: Neighbour MAC address
222 	 */
223 	BATADV_ATTR_NEIGH_ADDRESS,
224 
225 	/**
226 	 * @BATADV_ATTR_TQ: TQ to neighbour
227 	 */
228 	BATADV_ATTR_TQ,
229 
230 	/**
231 	 * @BATADV_ATTR_THROUGHPUT: Estimated throughput to Neighbour
232 	 */
233 	BATADV_ATTR_THROUGHPUT,
234 
235 	/**
236 	 * @BATADV_ATTR_BANDWIDTH_UP: Reported uplink bandwidth
237 	 */
238 	BATADV_ATTR_BANDWIDTH_UP,
239 
240 	/**
241 	 * @BATADV_ATTR_BANDWIDTH_DOWN: Reported downlink bandwidth
242 	 */
243 	BATADV_ATTR_BANDWIDTH_DOWN,
244 
245 	/**
246 	 * @BATADV_ATTR_ROUTER: Gateway router MAC address
247 	 */
248 	BATADV_ATTR_ROUTER,
249 
250 	/**
251 	 * @BATADV_ATTR_BLA_OWN: Flag indicating own originator
252 	 */
253 	BATADV_ATTR_BLA_OWN,
254 
255 	/**
256 	 * @BATADV_ATTR_BLA_ADDRESS: Bridge loop avoidance claim MAC address
257 	 */
258 	BATADV_ATTR_BLA_ADDRESS,
259 
260 	/**
261 	 * @BATADV_ATTR_BLA_VID: BLA VLAN ID
262 	 */
263 	BATADV_ATTR_BLA_VID,
264 
265 	/**
266 	 * @BATADV_ATTR_BLA_BACKBONE: BLA gateway originator MAC address
267 	 */
268 	BATADV_ATTR_BLA_BACKBONE,
269 
270 	/**
271 	 * @BATADV_ATTR_BLA_CRC: BLA CRC
272 	 */
273 	BATADV_ATTR_BLA_CRC,
274 
275 	/* add attributes above here, update the policy in netlink.c */
276 
277 	/**
278 	 * @__BATADV_ATTR_AFTER_LAST: internal use
279 	 */
280 	__BATADV_ATTR_AFTER_LAST,
281 
282 	/**
283 	 * @NUM_BATADV_ATTR: total number of batadv_nl_attrs available
284 	 */
285 	NUM_BATADV_ATTR = __BATADV_ATTR_AFTER_LAST,
286 
287 	/**
288 	 * @BATADV_ATTR_MAX: highest attribute number currently defined
289 	 */
290 	BATADV_ATTR_MAX = __BATADV_ATTR_AFTER_LAST - 1
291 };
292 
293 /**
294  * enum batadv_nl_commands - supported batman-adv netlink commands
295  */
296 enum batadv_nl_commands {
297 	/**
298 	 * @BATADV_CMD_UNSPEC: unspecified command to catch errors
299 	 */
300 	BATADV_CMD_UNSPEC,
301 
302 	/**
303 	 * @BATADV_CMD_GET_MESH_INFO: Query basic information about batman-adv
304 	 * device
305 	 */
306 	BATADV_CMD_GET_MESH_INFO,
307 
308 	/**
309 	 * @BATADV_CMD_TP_METER: Start a tp meter session
310 	 */
311 	BATADV_CMD_TP_METER,
312 
313 	/**
314 	 * @BATADV_CMD_TP_METER_CANCEL: Cancel a tp meter session
315 	 */
316 	BATADV_CMD_TP_METER_CANCEL,
317 
318 	/**
319 	 * @BATADV_CMD_GET_ROUTING_ALGOS: Query the list of routing algorithms.
320 	 */
321 	BATADV_CMD_GET_ROUTING_ALGOS,
322 
323 	/**
324 	 * @BATADV_CMD_GET_HARDIFS: Query list of hard interfaces
325 	 */
326 	BATADV_CMD_GET_HARDIFS,
327 
328 	/**
329 	 * @BATADV_CMD_GET_TRANSTABLE_LOCAL: Query list of local translations
330 	 */
331 	BATADV_CMD_GET_TRANSTABLE_LOCAL,
332 
333 	/**
334 	 * @BATADV_CMD_GET_TRANSTABLE_GLOBAL: Query list of global translations
335 	 */
336 	BATADV_CMD_GET_TRANSTABLE_GLOBAL,
337 
338 	/**
339 	 * @BATADV_CMD_GET_ORIGINATORS: Query list of originators
340 	 */
341 	BATADV_CMD_GET_ORIGINATORS,
342 
343 	/**
344 	 * @BATADV_CMD_GET_NEIGHBORS: Query list of neighbours
345 	 */
346 	BATADV_CMD_GET_NEIGHBORS,
347 
348 	/**
349 	 * @BATADV_CMD_GET_GATEWAYS: Query list of gateways
350 	 */
351 	BATADV_CMD_GET_GATEWAYS,
352 
353 	/**
354 	 * @BATADV_CMD_GET_BLA_CLAIM: Query list of bridge loop avoidance claims
355 	 */
356 	BATADV_CMD_GET_BLA_CLAIM,
357 
358 	/**
359 	 * @BATADV_CMD_GET_BLA_BACKBONE: Query list of bridge loop avoidance
360 	 * backbones
361 	 */
362 	BATADV_CMD_GET_BLA_BACKBONE,
363 
364 	/* add new commands above here */
365 
366 	/**
367 	 * @__BATADV_CMD_AFTER_LAST: internal use
368 	 */
369 	__BATADV_CMD_AFTER_LAST,
370 
371 	/**
372 	 * @BATADV_CMD_MAX: highest used command number
373 	 */
374 	BATADV_CMD_MAX = __BATADV_CMD_AFTER_LAST - 1
375 };
376 
377 /**
378  * enum batadv_tp_meter_reason - reason of a tp meter test run stop
379  */
380 enum batadv_tp_meter_reason {
381 	/**
382 	 * @BATADV_TP_REASON_COMPLETE: sender finished tp run
383 	 */
384 	BATADV_TP_REASON_COMPLETE		= 3,
385 
386 	/**
387 	 * @BATADV_TP_REASON_CANCEL: sender was stopped during run
388 	 */
389 	BATADV_TP_REASON_CANCEL			= 4,
390 
391 	/* error status >= 128 */
392 
393 	/**
394 	 * @BATADV_TP_REASON_DST_UNREACHABLE: receiver could not be reached or
395 	 * didn't answer
396 	 */
397 	BATADV_TP_REASON_DST_UNREACHABLE	= 128,
398 
399 	/**
400 	 * @BATADV_TP_REASON_RESEND_LIMIT: (unused) sender retry reached limit
401 	 */
402 	BATADV_TP_REASON_RESEND_LIMIT		= 129,
403 
404 	/**
405 	 * @BATADV_TP_REASON_ALREADY_ONGOING: test to or from the same node
406 	 * already ongoing
407 	 */
408 	BATADV_TP_REASON_ALREADY_ONGOING	= 130,
409 
410 	/**
411 	 * @BATADV_TP_REASON_MEMORY_ERROR: test was stopped due to low memory
412 	 */
413 	BATADV_TP_REASON_MEMORY_ERROR		= 131,
414 
415 	/**
416 	 * @BATADV_TP_REASON_CANT_SEND: failed to send via outgoing interface
417 	 */
418 	BATADV_TP_REASON_CANT_SEND		= 132,
419 
420 	/**
421 	 * @BATADV_TP_REASON_TOO_MANY: too many ongoing sessions
422 	 */
423 	BATADV_TP_REASON_TOO_MANY		= 133,
424 };
425 
426 #endif /* _UAPI_LINUX_BATMAN_ADV_H_ */
427