xref: /openbmc/linux/include/net/nl802154.h (revision f59a3ee6)
1 #ifndef __NL802154_H
2 #define __NL802154_H
3 /*
4  * 802.15.4 netlink interface public header
5  *
6  * Copyright 2014 Alexander Aring <aar@pengutronix.de>
7  *
8  * Permission to use, copy, modify, and/or distribute this software for any
9  * purpose with or without fee is hereby granted, provided that the above
10  * copyright notice and this permission notice appear in all copies.
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19  *
20  */
21 
22 #include <linux/types.h>
23 
24 #define NL802154_GENL_NAME "nl802154"
25 
26 enum nl802154_commands {
27 /* don't change the order or add anything between, this is ABI! */
28 /* currently we don't shipping this file via uapi, ignore the above one */
29 	NL802154_CMD_UNSPEC,
30 
31 	NL802154_CMD_GET_WPAN_PHY,		/* can dump */
32 	NL802154_CMD_SET_WPAN_PHY,
33 	NL802154_CMD_NEW_WPAN_PHY,
34 	NL802154_CMD_DEL_WPAN_PHY,
35 
36 	NL802154_CMD_GET_INTERFACE,		/* can dump */
37 	NL802154_CMD_SET_INTERFACE,
38 	NL802154_CMD_NEW_INTERFACE,
39 	NL802154_CMD_DEL_INTERFACE,
40 
41 	NL802154_CMD_SET_CHANNEL,
42 
43 	NL802154_CMD_SET_PAN_ID,
44 	NL802154_CMD_SET_SHORT_ADDR,
45 
46 	NL802154_CMD_SET_TX_POWER,
47 	NL802154_CMD_SET_CCA_MODE,
48 	NL802154_CMD_SET_CCA_ED_LEVEL,
49 
50 	NL802154_CMD_SET_MAX_FRAME_RETRIES,
51 
52 	NL802154_CMD_SET_BACKOFF_EXPONENT,
53 	NL802154_CMD_SET_MAX_CSMA_BACKOFFS,
54 
55 	NL802154_CMD_SET_LBT_MODE,
56 
57 	NL802154_CMD_SET_ACKREQ_DEFAULT,
58 
59 	NL802154_CMD_SET_WPAN_PHY_NETNS,
60 
61 	NL802154_CMD_SET_SEC_PARAMS,
62 	NL802154_CMD_GET_SEC_KEY,		/* can dump */
63 	NL802154_CMD_NEW_SEC_KEY,
64 	NL802154_CMD_DEL_SEC_KEY,
65 	NL802154_CMD_GET_SEC_DEV,		/* can dump */
66 	NL802154_CMD_NEW_SEC_DEV,
67 	NL802154_CMD_DEL_SEC_DEV,
68 	NL802154_CMD_GET_SEC_DEVKEY,		/* can dump */
69 	NL802154_CMD_NEW_SEC_DEVKEY,
70 	NL802154_CMD_DEL_SEC_DEVKEY,
71 	NL802154_CMD_GET_SEC_LEVEL,		/* can dump */
72 	NL802154_CMD_NEW_SEC_LEVEL,
73 	NL802154_CMD_DEL_SEC_LEVEL,
74 
75 	/* add new commands above here */
76 
77 	/* used to define NL802154_CMD_MAX below */
78 	__NL802154_CMD_AFTER_LAST,
79 	NL802154_CMD_MAX = __NL802154_CMD_AFTER_LAST - 1
80 };
81 
82 enum nl802154_attrs {
83 /* don't change the order or add anything between, this is ABI! */
84 /* currently we don't shipping this file via uapi, ignore the above one */
85 	NL802154_ATTR_UNSPEC,
86 
87 	NL802154_ATTR_WPAN_PHY,
88 	NL802154_ATTR_WPAN_PHY_NAME,
89 
90 	NL802154_ATTR_IFINDEX,
91 	NL802154_ATTR_IFNAME,
92 	NL802154_ATTR_IFTYPE,
93 
94 	NL802154_ATTR_WPAN_DEV,
95 
96 	NL802154_ATTR_PAGE,
97 	NL802154_ATTR_CHANNEL,
98 
99 	NL802154_ATTR_PAN_ID,
100 	NL802154_ATTR_SHORT_ADDR,
101 
102 	NL802154_ATTR_TX_POWER,
103 
104 	NL802154_ATTR_CCA_MODE,
105 	NL802154_ATTR_CCA_OPT,
106 	NL802154_ATTR_CCA_ED_LEVEL,
107 
108 	NL802154_ATTR_MAX_FRAME_RETRIES,
109 
110 	NL802154_ATTR_MAX_BE,
111 	NL802154_ATTR_MIN_BE,
112 	NL802154_ATTR_MAX_CSMA_BACKOFFS,
113 
114 	NL802154_ATTR_LBT_MODE,
115 
116 	NL802154_ATTR_GENERATION,
117 
118 	NL802154_ATTR_CHANNELS_SUPPORTED,
119 	NL802154_ATTR_SUPPORTED_CHANNEL,
120 
121 	NL802154_ATTR_EXTENDED_ADDR,
122 
123 	NL802154_ATTR_WPAN_PHY_CAPS,
124 
125 	NL802154_ATTR_SUPPORTED_COMMANDS,
126 
127 	NL802154_ATTR_ACKREQ_DEFAULT,
128 
129 	NL802154_ATTR_PAD,
130 
131 	NL802154_ATTR_PID,
132 	NL802154_ATTR_NETNS_FD,
133 
134 	/* add attributes here, update the policy in nl802154.c */
135 
136 #ifdef CONFIG_IEEE802154_NL802154_EXPERIMENTAL
137 	NL802154_ATTR_SEC_ENABLED,
138 	NL802154_ATTR_SEC_OUT_LEVEL,
139 	NL802154_ATTR_SEC_OUT_KEY_ID,
140 	NL802154_ATTR_SEC_FRAME_COUNTER,
141 
142 	NL802154_ATTR_SEC_LEVEL,
143 	NL802154_ATTR_SEC_DEVICE,
144 	NL802154_ATTR_SEC_DEVKEY,
145 	NL802154_ATTR_SEC_KEY,
146 #endif /* CONFIG_IEEE802154_NL802154_EXPERIMENTAL */
147 
148 	__NL802154_ATTR_AFTER_LAST,
149 	NL802154_ATTR_MAX = __NL802154_ATTR_AFTER_LAST - 1
150 };
151 
152 enum nl802154_iftype {
153 	NL802154_IFTYPE_UNSPEC = (~(__u32)0),
154 
155 	NL802154_IFTYPE_NODE = 0,
156 	NL802154_IFTYPE_MONITOR,
157 	NL802154_IFTYPE_COORD,
158 
159 	/* keep last */
160 	NUM_NL802154_IFTYPES,
161 	NL802154_IFTYPE_MAX = NUM_NL802154_IFTYPES - 1
162 };
163 
164 /**
165  * enum nl802154_wpan_phy_capability_attr - wpan phy capability attributes
166  *
167  * @__NL802154_CAP_ATTR_INVALID: attribute number 0 is reserved
168  * @NL802154_CAP_ATTR_CHANNELS: a nested attribute for nl802154_channel_attr
169  * @NL802154_CAP_ATTR_TX_POWERS: a nested attribute for
170  *	nl802154_wpan_phy_tx_power
171  * @NL802154_CAP_ATTR_MIN_CCA_ED_LEVEL: minimum value for cca_ed_level
172  * @NL802154_CAP_ATTR_MAX_CCA_ED_LEVEL: maxmimum value for cca_ed_level
173  * @NL802154_CAP_ATTR_CCA_MODES: nl802154_cca_modes flags
174  * @NL802154_CAP_ATTR_CCA_OPTS: nl802154_cca_opts flags
175  * @NL802154_CAP_ATTR_MIN_MINBE: minimum of minbe value
176  * @NL802154_CAP_ATTR_MAX_MINBE: maximum of minbe value
177  * @NL802154_CAP_ATTR_MIN_MAXBE: minimum of maxbe value
178  * @NL802154_CAP_ATTR_MAX_MINBE: maximum of maxbe value
179  * @NL802154_CAP_ATTR_MIN_CSMA_BACKOFFS: minimum of csma backoff value
180  * @NL802154_CAP_ATTR_MAX_CSMA_BACKOFFS: maximum of csma backoffs value
181  * @NL802154_CAP_ATTR_MIN_FRAME_RETRIES: minimum of frame retries value
182  * @NL802154_CAP_ATTR_MAX_FRAME_RETRIES: maximum of frame retries value
183  * @NL802154_CAP_ATTR_IFTYPES: nl802154_iftype flags
184  * @NL802154_CAP_ATTR_LBT: nl802154_supported_bool_states flags
185  * @NL802154_CAP_ATTR_MAX: highest cap attribute currently defined
186  * @__NL802154_CAP_ATTR_AFTER_LAST: internal use
187  */
188 enum nl802154_wpan_phy_capability_attr {
189 	__NL802154_CAP_ATTR_INVALID,
190 
191 	NL802154_CAP_ATTR_IFTYPES,
192 
193 	NL802154_CAP_ATTR_CHANNELS,
194 	NL802154_CAP_ATTR_TX_POWERS,
195 
196 	NL802154_CAP_ATTR_CCA_ED_LEVELS,
197 	NL802154_CAP_ATTR_CCA_MODES,
198 	NL802154_CAP_ATTR_CCA_OPTS,
199 
200 	NL802154_CAP_ATTR_MIN_MINBE,
201 	NL802154_CAP_ATTR_MAX_MINBE,
202 
203 	NL802154_CAP_ATTR_MIN_MAXBE,
204 	NL802154_CAP_ATTR_MAX_MAXBE,
205 
206 	NL802154_CAP_ATTR_MIN_CSMA_BACKOFFS,
207 	NL802154_CAP_ATTR_MAX_CSMA_BACKOFFS,
208 
209 	NL802154_CAP_ATTR_MIN_FRAME_RETRIES,
210 	NL802154_CAP_ATTR_MAX_FRAME_RETRIES,
211 
212 	NL802154_CAP_ATTR_LBT,
213 
214 	/* keep last */
215 	__NL802154_CAP_ATTR_AFTER_LAST,
216 	NL802154_CAP_ATTR_MAX = __NL802154_CAP_ATTR_AFTER_LAST - 1
217 };
218 
219 /**
220  * enum nl802154_cca_modes - cca modes
221  *
222  * @__NL802154_CCA_INVALID: cca mode number 0 is reserved
223  * @NL802154_CCA_ENERGY: Energy above threshold
224  * @NL802154_CCA_CARRIER: Carrier sense only
225  * @NL802154_CCA_ENERGY_CARRIER: Carrier sense with energy above threshold
226  * @NL802154_CCA_ALOHA: CCA shall always report an idle medium
227  * @NL802154_CCA_UWB_SHR: UWB preamble sense based on the SHR of a frame
228  * @NL802154_CCA_UWB_MULTIPLEXED: UWB preamble sense based on the packet with
229  *	the multiplexed preamble
230  * @__NL802154_CCA_ATTR_AFTER_LAST: Internal
231  * @NL802154_CCA_ATTR_MAX: Maximum CCA attribute number
232  */
233 enum nl802154_cca_modes {
234 	__NL802154_CCA_INVALID,
235 	NL802154_CCA_ENERGY,
236 	NL802154_CCA_CARRIER,
237 	NL802154_CCA_ENERGY_CARRIER,
238 	NL802154_CCA_ALOHA,
239 	NL802154_CCA_UWB_SHR,
240 	NL802154_CCA_UWB_MULTIPLEXED,
241 
242 	/* keep last */
243 	__NL802154_CCA_ATTR_AFTER_LAST,
244 	NL802154_CCA_ATTR_MAX = __NL802154_CCA_ATTR_AFTER_LAST - 1
245 };
246 
247 /**
248  * enum nl802154_cca_opts - additional options for cca modes
249  *
250  * @NL802154_CCA_OPT_ENERGY_CARRIER_OR: NL802154_CCA_ENERGY_CARRIER with OR
251  * @NL802154_CCA_OPT_ENERGY_CARRIER_AND: NL802154_CCA_ENERGY_CARRIER with AND
252  */
253 enum nl802154_cca_opts {
254 	NL802154_CCA_OPT_ENERGY_CARRIER_AND,
255 	NL802154_CCA_OPT_ENERGY_CARRIER_OR,
256 
257 	/* keep last */
258 	__NL802154_CCA_OPT_ATTR_AFTER_LAST,
259 	NL802154_CCA_OPT_ATTR_MAX = __NL802154_CCA_OPT_ATTR_AFTER_LAST - 1
260 };
261 
262 /**
263  * enum nl802154_supported_bool_states - bool states for bool capability entry
264  *
265  * @NL802154_SUPPORTED_BOOL_FALSE: indicates to set false
266  * @NL802154_SUPPORTED_BOOL_TRUE: indicates to set true
267  * @__NL802154_SUPPORTED_BOOL_INVALD: reserved
268  * @NL802154_SUPPORTED_BOOL_BOTH: indicates to set true and false
269  * @__NL802154_SUPPORTED_BOOL_AFTER_LAST: Internal
270  * @NL802154_SUPPORTED_BOOL_MAX: highest value for bool states
271  */
272 enum nl802154_supported_bool_states {
273 	NL802154_SUPPORTED_BOOL_FALSE,
274 	NL802154_SUPPORTED_BOOL_TRUE,
275 	/* to handle them in a mask */
276 	__NL802154_SUPPORTED_BOOL_INVALD,
277 	NL802154_SUPPORTED_BOOL_BOTH,
278 
279 	/* keep last */
280 	__NL802154_SUPPORTED_BOOL_AFTER_LAST,
281 	NL802154_SUPPORTED_BOOL_MAX = __NL802154_SUPPORTED_BOOL_AFTER_LAST - 1
282 };
283 
284 #ifdef CONFIG_IEEE802154_NL802154_EXPERIMENTAL
285 
286 enum nl802154_dev_addr_modes {
287 	NL802154_DEV_ADDR_NONE,
288 	__NL802154_DEV_ADDR_INVALID,
289 	NL802154_DEV_ADDR_SHORT,
290 	NL802154_DEV_ADDR_EXTENDED,
291 
292 	/* keep last */
293 	__NL802154_DEV_ADDR_AFTER_LAST,
294 	NL802154_DEV_ADDR_MAX = __NL802154_DEV_ADDR_AFTER_LAST - 1
295 };
296 
297 enum nl802154_dev_addr_attrs {
298 	NL802154_DEV_ADDR_ATTR_UNSPEC,
299 
300 	NL802154_DEV_ADDR_ATTR_PAN_ID,
301 	NL802154_DEV_ADDR_ATTR_MODE,
302 	NL802154_DEV_ADDR_ATTR_SHORT,
303 	NL802154_DEV_ADDR_ATTR_EXTENDED,
304 	NL802154_DEV_ADDR_ATTR_PAD,
305 
306 	/* keep last */
307 	__NL802154_DEV_ADDR_ATTR_AFTER_LAST,
308 	NL802154_DEV_ADDR_ATTR_MAX = __NL802154_DEV_ADDR_ATTR_AFTER_LAST - 1
309 };
310 
311 enum nl802154_key_id_modes {
312 	NL802154_KEY_ID_MODE_IMPLICIT,
313 	NL802154_KEY_ID_MODE_INDEX,
314 	NL802154_KEY_ID_MODE_INDEX_SHORT,
315 	NL802154_KEY_ID_MODE_INDEX_EXTENDED,
316 
317 	/* keep last */
318 	__NL802154_KEY_ID_MODE_AFTER_LAST,
319 	NL802154_KEY_ID_MODE_MAX = __NL802154_KEY_ID_MODE_AFTER_LAST - 1
320 };
321 
322 enum nl802154_key_id_attrs {
323 	NL802154_KEY_ID_ATTR_UNSPEC,
324 
325 	NL802154_KEY_ID_ATTR_MODE,
326 	NL802154_KEY_ID_ATTR_INDEX,
327 	NL802154_KEY_ID_ATTR_IMPLICIT,
328 	NL802154_KEY_ID_ATTR_SOURCE_SHORT,
329 	NL802154_KEY_ID_ATTR_SOURCE_EXTENDED,
330 	NL802154_KEY_ID_ATTR_PAD,
331 
332 	/* keep last */
333 	__NL802154_KEY_ID_ATTR_AFTER_LAST,
334 	NL802154_KEY_ID_ATTR_MAX = __NL802154_KEY_ID_ATTR_AFTER_LAST - 1
335 };
336 
337 enum nl802154_seclevels {
338 	NL802154_SECLEVEL_NONE,
339 	NL802154_SECLEVEL_MIC32,
340 	NL802154_SECLEVEL_MIC64,
341 	NL802154_SECLEVEL_MIC128,
342 	NL802154_SECLEVEL_ENC,
343 	NL802154_SECLEVEL_ENC_MIC32,
344 	NL802154_SECLEVEL_ENC_MIC64,
345 	NL802154_SECLEVEL_ENC_MIC128,
346 
347 	/* keep last */
348 	__NL802154_SECLEVEL_AFTER_LAST,
349 	NL802154_SECLEVEL_MAX = __NL802154_SECLEVEL_AFTER_LAST - 1
350 };
351 
352 enum nl802154_frames {
353 	NL802154_FRAME_BEACON,
354 	NL802154_FRAME_DATA,
355 	NL802154_FRAME_ACK,
356 	NL802154_FRAME_CMD,
357 
358 	/* keep last */
359 	__NL802154_FRAME_AFTER_LAST,
360 	NL802154_FRAME_MAX = __NL802154_FRAME_AFTER_LAST - 1
361 };
362 
363 enum nl802154_cmd_frames {
364 	__NL802154_CMD_FRAME_INVALID,
365 	NL802154_CMD_FRAME_ASSOC_REQUEST,
366 	NL802154_CMD_FRAME_ASSOC_RESPONSE,
367 	NL802154_CMD_FRAME_DISASSOC_NOTIFY,
368 	NL802154_CMD_FRAME_DATA_REQUEST,
369 	NL802154_CMD_FRAME_PAN_ID_CONFLICT_NOTIFY,
370 	NL802154_CMD_FRAME_ORPHAN_NOTIFY,
371 	NL802154_CMD_FRAME_BEACON_REQUEST,
372 	NL802154_CMD_FRAME_COORD_REALIGNMENT,
373 	NL802154_CMD_FRAME_GTS_REQUEST,
374 
375 	/* keep last */
376 	__NL802154_CMD_FRAME_AFTER_LAST,
377 	NL802154_CMD_FRAME_MAX = __NL802154_CMD_FRAME_AFTER_LAST - 1
378 };
379 
380 enum nl802154_seclevel_attrs {
381 	NL802154_SECLEVEL_ATTR_UNSPEC,
382 
383 	NL802154_SECLEVEL_ATTR_LEVELS,
384 	NL802154_SECLEVEL_ATTR_FRAME,
385 	NL802154_SECLEVEL_ATTR_CMD_FRAME,
386 	NL802154_SECLEVEL_ATTR_DEV_OVERRIDE,
387 
388 	/* keep last */
389 	__NL802154_SECLEVEL_ATTR_AFTER_LAST,
390 	NL802154_SECLEVEL_ATTR_MAX = __NL802154_SECLEVEL_ATTR_AFTER_LAST - 1
391 };
392 
393 /* TODO what is this? couldn't find in mib */
394 enum {
395 	NL802154_DEVKEY_IGNORE,
396 	NL802154_DEVKEY_RESTRICT,
397 	NL802154_DEVKEY_RECORD,
398 
399 	/* keep last */
400 	__NL802154_DEVKEY_AFTER_LAST,
401 	NL802154_DEVKEY_MAX = __NL802154_DEVKEY_AFTER_LAST - 1
402 };
403 
404 enum nl802154_dev {
405 	NL802154_DEV_ATTR_UNSPEC,
406 
407 	NL802154_DEV_ATTR_FRAME_COUNTER,
408 	NL802154_DEV_ATTR_PAN_ID,
409 	NL802154_DEV_ATTR_SHORT_ADDR,
410 	NL802154_DEV_ATTR_EXTENDED_ADDR,
411 	NL802154_DEV_ATTR_SECLEVEL_EXEMPT,
412 	NL802154_DEV_ATTR_KEY_MODE,
413 	NL802154_DEV_ATTR_PAD,
414 
415 	/* keep last */
416 	__NL802154_DEV_ATTR_AFTER_LAST,
417 	NL802154_DEV_ATTR_MAX = __NL802154_DEV_ATTR_AFTER_LAST - 1
418 };
419 
420 enum nl802154_devkey {
421 	NL802154_DEVKEY_ATTR_UNSPEC,
422 
423 	NL802154_DEVKEY_ATTR_FRAME_COUNTER,
424 	NL802154_DEVKEY_ATTR_EXTENDED_ADDR,
425 	NL802154_DEVKEY_ATTR_ID,
426 	NL802154_DEVKEY_ATTR_PAD,
427 
428 	/* keep last */
429 	__NL802154_DEVKEY_ATTR_AFTER_LAST,
430 	NL802154_DEVKEY_ATTR_MAX = __NL802154_DEVKEY_ATTR_AFTER_LAST - 1
431 };
432 
433 enum nl802154_key {
434 	NL802154_KEY_ATTR_UNSPEC,
435 
436 	NL802154_KEY_ATTR_ID,
437 	NL802154_KEY_ATTR_USAGE_FRAMES,
438 	NL802154_KEY_ATTR_USAGE_CMDS,
439 	NL802154_KEY_ATTR_BYTES,
440 
441 	/* keep last */
442 	__NL802154_KEY_ATTR_AFTER_LAST,
443 	NL802154_KEY_ATTR_MAX = __NL802154_KEY_ATTR_AFTER_LAST - 1
444 };
445 
446 #define NL802154_KEY_SIZE		16
447 #define NL802154_CMD_FRAME_NR_IDS	256
448 
449 #endif /* CONFIG_IEEE802154_NL802154_EXPERIMENTAL */
450 
451 #endif /* __NL802154_H */
452