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 NL802154_CMD_SCAN_EVENT, 76 77 /* add new commands above here */ 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 NL802154_ATTR_COORDINATOR, 137 138 /* add attributes here, update the policy in nl802154.c */ 139 140 #ifdef CONFIG_IEEE802154_NL802154_EXPERIMENTAL 141 NL802154_ATTR_SEC_ENABLED, 142 NL802154_ATTR_SEC_OUT_LEVEL, 143 NL802154_ATTR_SEC_OUT_KEY_ID, 144 NL802154_ATTR_SEC_FRAME_COUNTER, 145 146 NL802154_ATTR_SEC_LEVEL, 147 NL802154_ATTR_SEC_DEVICE, 148 NL802154_ATTR_SEC_DEVKEY, 149 NL802154_ATTR_SEC_KEY, 150 #endif /* CONFIG_IEEE802154_NL802154_EXPERIMENTAL */ 151 152 __NL802154_ATTR_AFTER_LAST, 153 NL802154_ATTR_MAX = __NL802154_ATTR_AFTER_LAST - 1 154 }; 155 156 enum nl802154_iftype { 157 NL802154_IFTYPE_UNSPEC = (~(__u32)0), 158 159 NL802154_IFTYPE_NODE = 0, 160 NL802154_IFTYPE_MONITOR, 161 NL802154_IFTYPE_COORD, 162 163 /* keep last */ 164 NUM_NL802154_IFTYPES, 165 NL802154_IFTYPE_MAX = NUM_NL802154_IFTYPES - 1 166 }; 167 168 /** 169 * enum nl802154_wpan_phy_capability_attr - wpan phy capability attributes 170 * 171 * @__NL802154_CAP_ATTR_INVALID: attribute number 0 is reserved 172 * @NL802154_CAP_ATTR_CHANNELS: a nested attribute for nl802154_channel_attr 173 * @NL802154_CAP_ATTR_TX_POWERS: a nested attribute for 174 * nl802154_wpan_phy_tx_power 175 * @NL802154_CAP_ATTR_MIN_CCA_ED_LEVEL: minimum value for cca_ed_level 176 * @NL802154_CAP_ATTR_MAX_CCA_ED_LEVEL: maxmimum value for cca_ed_level 177 * @NL802154_CAP_ATTR_CCA_MODES: nl802154_cca_modes flags 178 * @NL802154_CAP_ATTR_CCA_OPTS: nl802154_cca_opts flags 179 * @NL802154_CAP_ATTR_MIN_MINBE: minimum of minbe value 180 * @NL802154_CAP_ATTR_MAX_MINBE: maximum of minbe value 181 * @NL802154_CAP_ATTR_MIN_MAXBE: minimum of maxbe value 182 * @NL802154_CAP_ATTR_MAX_MINBE: maximum of maxbe value 183 * @NL802154_CAP_ATTR_MIN_CSMA_BACKOFFS: minimum of csma backoff value 184 * @NL802154_CAP_ATTR_MAX_CSMA_BACKOFFS: maximum of csma backoffs value 185 * @NL802154_CAP_ATTR_MIN_FRAME_RETRIES: minimum of frame retries value 186 * @NL802154_CAP_ATTR_MAX_FRAME_RETRIES: maximum of frame retries value 187 * @NL802154_CAP_ATTR_IFTYPES: nl802154_iftype flags 188 * @NL802154_CAP_ATTR_LBT: nl802154_supported_bool_states flags 189 * @NL802154_CAP_ATTR_MAX: highest cap attribute currently defined 190 * @__NL802154_CAP_ATTR_AFTER_LAST: internal use 191 */ 192 enum nl802154_wpan_phy_capability_attr { 193 __NL802154_CAP_ATTR_INVALID, 194 195 NL802154_CAP_ATTR_IFTYPES, 196 197 NL802154_CAP_ATTR_CHANNELS, 198 NL802154_CAP_ATTR_TX_POWERS, 199 200 NL802154_CAP_ATTR_CCA_ED_LEVELS, 201 NL802154_CAP_ATTR_CCA_MODES, 202 NL802154_CAP_ATTR_CCA_OPTS, 203 204 NL802154_CAP_ATTR_MIN_MINBE, 205 NL802154_CAP_ATTR_MAX_MINBE, 206 207 NL802154_CAP_ATTR_MIN_MAXBE, 208 NL802154_CAP_ATTR_MAX_MAXBE, 209 210 NL802154_CAP_ATTR_MIN_CSMA_BACKOFFS, 211 NL802154_CAP_ATTR_MAX_CSMA_BACKOFFS, 212 213 NL802154_CAP_ATTR_MIN_FRAME_RETRIES, 214 NL802154_CAP_ATTR_MAX_FRAME_RETRIES, 215 216 NL802154_CAP_ATTR_LBT, 217 218 /* keep last */ 219 __NL802154_CAP_ATTR_AFTER_LAST, 220 NL802154_CAP_ATTR_MAX = __NL802154_CAP_ATTR_AFTER_LAST - 1 221 }; 222 223 /** 224 * enum nl802154_coord - Netlink attributes for a coord 225 * 226 * @__NL802154_COORD_INVALID: invalid 227 * @NL802154_COORD_PANID: PANID of the coordinator (2 bytes) 228 * @NL802154_COORD_ADDR: coordinator address, (8 bytes or 2 bytes) 229 * @NL802154_COORD_CHANNEL: channel number, related to @NL802154_COORD_PAGE (u8) 230 * @NL802154_COORD_PAGE: channel page, related to @NL802154_COORD_CHANNEL (u8) 231 * @NL802154_COORD_PREAMBLE_CODE: Preamble code used when the beacon was received, 232 * this is PHY dependent and optional (u8) 233 * @NL802154_COORD_MEAN_PRF: Mean PRF used when the beacon was received, 234 * this is PHY dependent and optional (u8) 235 * @NL802154_COORD_SUPERFRAME_SPEC: superframe specification of the PAN (u16) 236 * @NL802154_COORD_LINK_QUALITY: signal quality of beacon in unspecified units, 237 * scaled to 0..255 (u8) 238 * @NL802154_COORD_GTS_PERMIT: set to true if GTS is permitted on this PAN 239 * @NL802154_COORD_PAYLOAD_DATA: binary data containing the raw data from the 240 * frame payload, (only if beacon or probe response had data) 241 * @NL802154_COORD_PAD: attribute used for padding for 64-bit alignment 242 * @NL802154_COORD_MAX: highest coordinator attribute 243 */ 244 enum nl802154_coord { 245 __NL802154_COORD_INVALID, 246 NL802154_COORD_PANID, 247 NL802154_COORD_ADDR, 248 NL802154_COORD_CHANNEL, 249 NL802154_COORD_PAGE, 250 NL802154_COORD_PREAMBLE_CODE, 251 NL802154_COORD_MEAN_PRF, 252 NL802154_COORD_SUPERFRAME_SPEC, 253 NL802154_COORD_LINK_QUALITY, 254 NL802154_COORD_GTS_PERMIT, 255 NL802154_COORD_PAYLOAD_DATA, 256 NL802154_COORD_PAD, 257 258 /* keep last */ 259 NL802154_COORD_MAX, 260 }; 261 262 /** 263 * enum nl802154_cca_modes - cca modes 264 * 265 * @__NL802154_CCA_INVALID: cca mode number 0 is reserved 266 * @NL802154_CCA_ENERGY: Energy above threshold 267 * @NL802154_CCA_CARRIER: Carrier sense only 268 * @NL802154_CCA_ENERGY_CARRIER: Carrier sense with energy above threshold 269 * @NL802154_CCA_ALOHA: CCA shall always report an idle medium 270 * @NL802154_CCA_UWB_SHR: UWB preamble sense based on the SHR of a frame 271 * @NL802154_CCA_UWB_MULTIPLEXED: UWB preamble sense based on the packet with 272 * the multiplexed preamble 273 * @__NL802154_CCA_ATTR_AFTER_LAST: Internal 274 * @NL802154_CCA_ATTR_MAX: Maximum CCA attribute number 275 */ 276 enum nl802154_cca_modes { 277 __NL802154_CCA_INVALID, 278 NL802154_CCA_ENERGY, 279 NL802154_CCA_CARRIER, 280 NL802154_CCA_ENERGY_CARRIER, 281 NL802154_CCA_ALOHA, 282 NL802154_CCA_UWB_SHR, 283 NL802154_CCA_UWB_MULTIPLEXED, 284 285 /* keep last */ 286 __NL802154_CCA_ATTR_AFTER_LAST, 287 NL802154_CCA_ATTR_MAX = __NL802154_CCA_ATTR_AFTER_LAST - 1 288 }; 289 290 /** 291 * enum nl802154_cca_opts - additional options for cca modes 292 * 293 * @NL802154_CCA_OPT_ENERGY_CARRIER_OR: NL802154_CCA_ENERGY_CARRIER with OR 294 * @NL802154_CCA_OPT_ENERGY_CARRIER_AND: NL802154_CCA_ENERGY_CARRIER with AND 295 */ 296 enum nl802154_cca_opts { 297 NL802154_CCA_OPT_ENERGY_CARRIER_AND, 298 NL802154_CCA_OPT_ENERGY_CARRIER_OR, 299 300 /* keep last */ 301 __NL802154_CCA_OPT_ATTR_AFTER_LAST, 302 NL802154_CCA_OPT_ATTR_MAX = __NL802154_CCA_OPT_ATTR_AFTER_LAST - 1 303 }; 304 305 /** 306 * enum nl802154_supported_bool_states - bool states for bool capability entry 307 * 308 * @NL802154_SUPPORTED_BOOL_FALSE: indicates to set false 309 * @NL802154_SUPPORTED_BOOL_TRUE: indicates to set true 310 * @__NL802154_SUPPORTED_BOOL_INVALD: reserved 311 * @NL802154_SUPPORTED_BOOL_BOTH: indicates to set true and false 312 * @__NL802154_SUPPORTED_BOOL_AFTER_LAST: Internal 313 * @NL802154_SUPPORTED_BOOL_MAX: highest value for bool states 314 */ 315 enum nl802154_supported_bool_states { 316 NL802154_SUPPORTED_BOOL_FALSE, 317 NL802154_SUPPORTED_BOOL_TRUE, 318 /* to handle them in a mask */ 319 __NL802154_SUPPORTED_BOOL_INVALD, 320 NL802154_SUPPORTED_BOOL_BOTH, 321 322 /* keep last */ 323 __NL802154_SUPPORTED_BOOL_AFTER_LAST, 324 NL802154_SUPPORTED_BOOL_MAX = __NL802154_SUPPORTED_BOOL_AFTER_LAST - 1 325 }; 326 327 #ifdef CONFIG_IEEE802154_NL802154_EXPERIMENTAL 328 329 enum nl802154_dev_addr_modes { 330 NL802154_DEV_ADDR_NONE, 331 __NL802154_DEV_ADDR_INVALID, 332 NL802154_DEV_ADDR_SHORT, 333 NL802154_DEV_ADDR_EXTENDED, 334 335 /* keep last */ 336 __NL802154_DEV_ADDR_AFTER_LAST, 337 NL802154_DEV_ADDR_MAX = __NL802154_DEV_ADDR_AFTER_LAST - 1 338 }; 339 340 enum nl802154_dev_addr_attrs { 341 NL802154_DEV_ADDR_ATTR_UNSPEC, 342 343 NL802154_DEV_ADDR_ATTR_PAN_ID, 344 NL802154_DEV_ADDR_ATTR_MODE, 345 NL802154_DEV_ADDR_ATTR_SHORT, 346 NL802154_DEV_ADDR_ATTR_EXTENDED, 347 NL802154_DEV_ADDR_ATTR_PAD, 348 349 /* keep last */ 350 __NL802154_DEV_ADDR_ATTR_AFTER_LAST, 351 NL802154_DEV_ADDR_ATTR_MAX = __NL802154_DEV_ADDR_ATTR_AFTER_LAST - 1 352 }; 353 354 enum nl802154_key_id_modes { 355 NL802154_KEY_ID_MODE_IMPLICIT, 356 NL802154_KEY_ID_MODE_INDEX, 357 NL802154_KEY_ID_MODE_INDEX_SHORT, 358 NL802154_KEY_ID_MODE_INDEX_EXTENDED, 359 360 /* keep last */ 361 __NL802154_KEY_ID_MODE_AFTER_LAST, 362 NL802154_KEY_ID_MODE_MAX = __NL802154_KEY_ID_MODE_AFTER_LAST - 1 363 }; 364 365 enum nl802154_key_id_attrs { 366 NL802154_KEY_ID_ATTR_UNSPEC, 367 368 NL802154_KEY_ID_ATTR_MODE, 369 NL802154_KEY_ID_ATTR_INDEX, 370 NL802154_KEY_ID_ATTR_IMPLICIT, 371 NL802154_KEY_ID_ATTR_SOURCE_SHORT, 372 NL802154_KEY_ID_ATTR_SOURCE_EXTENDED, 373 NL802154_KEY_ID_ATTR_PAD, 374 375 /* keep last */ 376 __NL802154_KEY_ID_ATTR_AFTER_LAST, 377 NL802154_KEY_ID_ATTR_MAX = __NL802154_KEY_ID_ATTR_AFTER_LAST - 1 378 }; 379 380 enum nl802154_seclevels { 381 NL802154_SECLEVEL_NONE, 382 NL802154_SECLEVEL_MIC32, 383 NL802154_SECLEVEL_MIC64, 384 NL802154_SECLEVEL_MIC128, 385 NL802154_SECLEVEL_ENC, 386 NL802154_SECLEVEL_ENC_MIC32, 387 NL802154_SECLEVEL_ENC_MIC64, 388 NL802154_SECLEVEL_ENC_MIC128, 389 390 /* keep last */ 391 __NL802154_SECLEVEL_AFTER_LAST, 392 NL802154_SECLEVEL_MAX = __NL802154_SECLEVEL_AFTER_LAST - 1 393 }; 394 395 enum nl802154_frames { 396 NL802154_FRAME_BEACON, 397 NL802154_FRAME_DATA, 398 NL802154_FRAME_ACK, 399 NL802154_FRAME_CMD, 400 401 /* keep last */ 402 __NL802154_FRAME_AFTER_LAST, 403 NL802154_FRAME_MAX = __NL802154_FRAME_AFTER_LAST - 1 404 }; 405 406 enum nl802154_cmd_frames { 407 __NL802154_CMD_FRAME_INVALID, 408 NL802154_CMD_FRAME_ASSOC_REQUEST, 409 NL802154_CMD_FRAME_ASSOC_RESPONSE, 410 NL802154_CMD_FRAME_DISASSOC_NOTIFY, 411 NL802154_CMD_FRAME_DATA_REQUEST, 412 NL802154_CMD_FRAME_PAN_ID_CONFLICT_NOTIFY, 413 NL802154_CMD_FRAME_ORPHAN_NOTIFY, 414 NL802154_CMD_FRAME_BEACON_REQUEST, 415 NL802154_CMD_FRAME_COORD_REALIGNMENT, 416 NL802154_CMD_FRAME_GTS_REQUEST, 417 418 /* keep last */ 419 __NL802154_CMD_FRAME_AFTER_LAST, 420 NL802154_CMD_FRAME_MAX = __NL802154_CMD_FRAME_AFTER_LAST - 1 421 }; 422 423 enum nl802154_seclevel_attrs { 424 NL802154_SECLEVEL_ATTR_UNSPEC, 425 426 NL802154_SECLEVEL_ATTR_LEVELS, 427 NL802154_SECLEVEL_ATTR_FRAME, 428 NL802154_SECLEVEL_ATTR_CMD_FRAME, 429 NL802154_SECLEVEL_ATTR_DEV_OVERRIDE, 430 431 /* keep last */ 432 __NL802154_SECLEVEL_ATTR_AFTER_LAST, 433 NL802154_SECLEVEL_ATTR_MAX = __NL802154_SECLEVEL_ATTR_AFTER_LAST - 1 434 }; 435 436 /* TODO what is this? couldn't find in mib */ 437 enum { 438 NL802154_DEVKEY_IGNORE, 439 NL802154_DEVKEY_RESTRICT, 440 NL802154_DEVKEY_RECORD, 441 442 /* keep last */ 443 __NL802154_DEVKEY_AFTER_LAST, 444 NL802154_DEVKEY_MAX = __NL802154_DEVKEY_AFTER_LAST - 1 445 }; 446 447 enum nl802154_dev { 448 NL802154_DEV_ATTR_UNSPEC, 449 450 NL802154_DEV_ATTR_FRAME_COUNTER, 451 NL802154_DEV_ATTR_PAN_ID, 452 NL802154_DEV_ATTR_SHORT_ADDR, 453 NL802154_DEV_ATTR_EXTENDED_ADDR, 454 NL802154_DEV_ATTR_SECLEVEL_EXEMPT, 455 NL802154_DEV_ATTR_KEY_MODE, 456 NL802154_DEV_ATTR_PAD, 457 458 /* keep last */ 459 __NL802154_DEV_ATTR_AFTER_LAST, 460 NL802154_DEV_ATTR_MAX = __NL802154_DEV_ATTR_AFTER_LAST - 1 461 }; 462 463 enum nl802154_devkey { 464 NL802154_DEVKEY_ATTR_UNSPEC, 465 466 NL802154_DEVKEY_ATTR_FRAME_COUNTER, 467 NL802154_DEVKEY_ATTR_EXTENDED_ADDR, 468 NL802154_DEVKEY_ATTR_ID, 469 NL802154_DEVKEY_ATTR_PAD, 470 471 /* keep last */ 472 __NL802154_DEVKEY_ATTR_AFTER_LAST, 473 NL802154_DEVKEY_ATTR_MAX = __NL802154_DEVKEY_ATTR_AFTER_LAST - 1 474 }; 475 476 enum nl802154_key { 477 NL802154_KEY_ATTR_UNSPEC, 478 479 NL802154_KEY_ATTR_ID, 480 NL802154_KEY_ATTR_USAGE_FRAMES, 481 NL802154_KEY_ATTR_USAGE_CMDS, 482 NL802154_KEY_ATTR_BYTES, 483 484 /* keep last */ 485 __NL802154_KEY_ATTR_AFTER_LAST, 486 NL802154_KEY_ATTR_MAX = __NL802154_KEY_ATTR_AFTER_LAST - 1 487 }; 488 489 #define NL802154_KEY_SIZE 16 490 #define NL802154_CMD_FRAME_NR_IDS 256 491 492 #endif /* CONFIG_IEEE802154_NL802154_EXPERIMENTAL */ 493 494 #endif /* __NL802154_H */ 495