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