nl802154.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  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. #define NL802154_GENL_NAME "nl802154"
  22. enum nl802154_commands {
  23. /* don't change the order or add anything between, this is ABI! */
  24. /* currently we don't shipping this file via uapi, ignore the above one */
  25. NL802154_CMD_UNSPEC,
  26. NL802154_CMD_GET_WPAN_PHY, /* can dump */
  27. NL802154_CMD_SET_WPAN_PHY,
  28. NL802154_CMD_NEW_WPAN_PHY,
  29. NL802154_CMD_DEL_WPAN_PHY,
  30. NL802154_CMD_GET_INTERFACE, /* can dump */
  31. NL802154_CMD_SET_INTERFACE,
  32. NL802154_CMD_NEW_INTERFACE,
  33. NL802154_CMD_DEL_INTERFACE,
  34. NL802154_CMD_SET_CHANNEL,
  35. NL802154_CMD_SET_PAN_ID,
  36. NL802154_CMD_SET_SHORT_ADDR,
  37. NL802154_CMD_SET_TX_POWER,
  38. NL802154_CMD_SET_CCA_MODE,
  39. NL802154_CMD_SET_CCA_ED_LEVEL,
  40. NL802154_CMD_SET_MAX_FRAME_RETRIES,
  41. NL802154_CMD_SET_BACKOFF_EXPONENT,
  42. NL802154_CMD_SET_MAX_CSMA_BACKOFFS,
  43. NL802154_CMD_SET_LBT_MODE,
  44. NL802154_CMD_SET_ACKREQ_DEFAULT,
  45. NL802154_CMD_SET_WPAN_PHY_NETNS,
  46. /* add new commands above here */
  47. #ifdef CONFIG_IEEE802154_NL802154_EXPERIMENTAL
  48. NL802154_CMD_SET_SEC_PARAMS,
  49. NL802154_CMD_GET_SEC_KEY, /* can dump */
  50. NL802154_CMD_NEW_SEC_KEY,
  51. NL802154_CMD_DEL_SEC_KEY,
  52. NL802154_CMD_GET_SEC_DEV, /* can dump */
  53. NL802154_CMD_NEW_SEC_DEV,
  54. NL802154_CMD_DEL_SEC_DEV,
  55. NL802154_CMD_GET_SEC_DEVKEY, /* can dump */
  56. NL802154_CMD_NEW_SEC_DEVKEY,
  57. NL802154_CMD_DEL_SEC_DEVKEY,
  58. NL802154_CMD_GET_SEC_LEVEL, /* can dump */
  59. NL802154_CMD_NEW_SEC_LEVEL,
  60. NL802154_CMD_DEL_SEC_LEVEL,
  61. #endif /* CONFIG_IEEE802154_NL802154_EXPERIMENTAL */
  62. /* used to define NL802154_CMD_MAX below */
  63. __NL802154_CMD_AFTER_LAST,
  64. NL802154_CMD_MAX = __NL802154_CMD_AFTER_LAST - 1
  65. };
  66. enum nl802154_attrs {
  67. /* don't change the order or add anything between, this is ABI! */
  68. /* currently we don't shipping this file via uapi, ignore the above one */
  69. NL802154_ATTR_UNSPEC,
  70. NL802154_ATTR_WPAN_PHY,
  71. NL802154_ATTR_WPAN_PHY_NAME,
  72. NL802154_ATTR_IFINDEX,
  73. NL802154_ATTR_IFNAME,
  74. NL802154_ATTR_IFTYPE,
  75. NL802154_ATTR_WPAN_DEV,
  76. NL802154_ATTR_PAGE,
  77. NL802154_ATTR_CHANNEL,
  78. NL802154_ATTR_PAN_ID,
  79. NL802154_ATTR_SHORT_ADDR,
  80. NL802154_ATTR_TX_POWER,
  81. NL802154_ATTR_CCA_MODE,
  82. NL802154_ATTR_CCA_OPT,
  83. NL802154_ATTR_CCA_ED_LEVEL,
  84. NL802154_ATTR_MAX_FRAME_RETRIES,
  85. NL802154_ATTR_MAX_BE,
  86. NL802154_ATTR_MIN_BE,
  87. NL802154_ATTR_MAX_CSMA_BACKOFFS,
  88. NL802154_ATTR_LBT_MODE,
  89. NL802154_ATTR_GENERATION,
  90. NL802154_ATTR_CHANNELS_SUPPORTED,
  91. NL802154_ATTR_SUPPORTED_CHANNEL,
  92. NL802154_ATTR_EXTENDED_ADDR,
  93. NL802154_ATTR_WPAN_PHY_CAPS,
  94. NL802154_ATTR_SUPPORTED_COMMANDS,
  95. NL802154_ATTR_ACKREQ_DEFAULT,
  96. NL802154_ATTR_PAD,
  97. NL802154_ATTR_PID,
  98. NL802154_ATTR_NETNS_FD,
  99. /* add attributes here, update the policy in nl802154.c */
  100. #ifdef CONFIG_IEEE802154_NL802154_EXPERIMENTAL
  101. NL802154_ATTR_SEC_ENABLED,
  102. NL802154_ATTR_SEC_OUT_LEVEL,
  103. NL802154_ATTR_SEC_OUT_KEY_ID,
  104. NL802154_ATTR_SEC_FRAME_COUNTER,
  105. NL802154_ATTR_SEC_LEVEL,
  106. NL802154_ATTR_SEC_DEVICE,
  107. NL802154_ATTR_SEC_DEVKEY,
  108. NL802154_ATTR_SEC_KEY,
  109. #endif /* CONFIG_IEEE802154_NL802154_EXPERIMENTAL */
  110. __NL802154_ATTR_AFTER_LAST,
  111. NL802154_ATTR_MAX = __NL802154_ATTR_AFTER_LAST - 1
  112. };
  113. enum nl802154_iftype {
  114. /* for backwards compatibility TODO */
  115. NL802154_IFTYPE_UNSPEC = -1,
  116. NL802154_IFTYPE_NODE,
  117. NL802154_IFTYPE_MONITOR,
  118. NL802154_IFTYPE_COORD,
  119. /* keep last */
  120. NUM_NL802154_IFTYPES,
  121. NL802154_IFTYPE_MAX = NUM_NL802154_IFTYPES - 1
  122. };
  123. /**
  124. * enum nl802154_wpan_phy_capability_attr - wpan phy capability attributes
  125. *
  126. * @__NL802154_CAP_ATTR_INVALID: attribute number 0 is reserved
  127. * @NL802154_CAP_ATTR_CHANNELS: a nested attribute for nl802154_channel_attr
  128. * @NL802154_CAP_ATTR_TX_POWERS: a nested attribute for
  129. * nl802154_wpan_phy_tx_power
  130. * @NL802154_CAP_ATTR_MIN_CCA_ED_LEVEL: minimum value for cca_ed_level
  131. * @NL802154_CAP_ATTR_MAX_CCA_ED_LEVEL: maxmimum value for cca_ed_level
  132. * @NL802154_CAP_ATTR_CCA_MODES: nl802154_cca_modes flags
  133. * @NL802154_CAP_ATTR_CCA_OPTS: nl802154_cca_opts flags
  134. * @NL802154_CAP_ATTR_MIN_MINBE: minimum of minbe value
  135. * @NL802154_CAP_ATTR_MAX_MINBE: maximum of minbe value
  136. * @NL802154_CAP_ATTR_MIN_MAXBE: minimum of maxbe value
  137. * @NL802154_CAP_ATTR_MAX_MINBE: maximum of maxbe value
  138. * @NL802154_CAP_ATTR_MIN_CSMA_BACKOFFS: minimum of csma backoff value
  139. * @NL802154_CAP_ATTR_MAX_CSMA_BACKOFFS: maximum of csma backoffs value
  140. * @NL802154_CAP_ATTR_MIN_FRAME_RETRIES: minimum of frame retries value
  141. * @NL802154_CAP_ATTR_MAX_FRAME_RETRIES: maximum of frame retries value
  142. * @NL802154_CAP_ATTR_IFTYPES: nl802154_iftype flags
  143. * @NL802154_CAP_ATTR_LBT: nl802154_supported_bool_states flags
  144. * @NL802154_CAP_ATTR_MAX: highest cap attribute currently defined
  145. * @__NL802154_CAP_ATTR_AFTER_LAST: internal use
  146. */
  147. enum nl802154_wpan_phy_capability_attr {
  148. __NL802154_CAP_ATTR_INVALID,
  149. NL802154_CAP_ATTR_IFTYPES,
  150. NL802154_CAP_ATTR_CHANNELS,
  151. NL802154_CAP_ATTR_TX_POWERS,
  152. NL802154_CAP_ATTR_CCA_ED_LEVELS,
  153. NL802154_CAP_ATTR_CCA_MODES,
  154. NL802154_CAP_ATTR_CCA_OPTS,
  155. NL802154_CAP_ATTR_MIN_MINBE,
  156. NL802154_CAP_ATTR_MAX_MINBE,
  157. NL802154_CAP_ATTR_MIN_MAXBE,
  158. NL802154_CAP_ATTR_MAX_MAXBE,
  159. NL802154_CAP_ATTR_MIN_CSMA_BACKOFFS,
  160. NL802154_CAP_ATTR_MAX_CSMA_BACKOFFS,
  161. NL802154_CAP_ATTR_MIN_FRAME_RETRIES,
  162. NL802154_CAP_ATTR_MAX_FRAME_RETRIES,
  163. NL802154_CAP_ATTR_LBT,
  164. /* keep last */
  165. __NL802154_CAP_ATTR_AFTER_LAST,
  166. NL802154_CAP_ATTR_MAX = __NL802154_CAP_ATTR_AFTER_LAST - 1
  167. };
  168. /**
  169. * enum nl802154_cca_modes - cca modes
  170. *
  171. * @__NL802154_CCA_INVALID: cca mode number 0 is reserved
  172. * @NL802154_CCA_ENERGY: Energy above threshold
  173. * @NL802154_CCA_CARRIER: Carrier sense only
  174. * @NL802154_CCA_ENERGY_CARRIER: Carrier sense with energy above threshold
  175. * @NL802154_CCA_ALOHA: CCA shall always report an idle medium
  176. * @NL802154_CCA_UWB_SHR: UWB preamble sense based on the SHR of a frame
  177. * @NL802154_CCA_UWB_MULTIPLEXED: UWB preamble sense based on the packet with
  178. * the multiplexed preamble
  179. * @__NL802154_CCA_ATTR_AFTER_LAST: Internal
  180. * @NL802154_CCA_ATTR_MAX: Maximum CCA attribute number
  181. */
  182. enum nl802154_cca_modes {
  183. __NL802154_CCA_INVALID,
  184. NL802154_CCA_ENERGY,
  185. NL802154_CCA_CARRIER,
  186. NL802154_CCA_ENERGY_CARRIER,
  187. NL802154_CCA_ALOHA,
  188. NL802154_CCA_UWB_SHR,
  189. NL802154_CCA_UWB_MULTIPLEXED,
  190. /* keep last */
  191. __NL802154_CCA_ATTR_AFTER_LAST,
  192. NL802154_CCA_ATTR_MAX = __NL802154_CCA_ATTR_AFTER_LAST - 1
  193. };
  194. /**
  195. * enum nl802154_cca_opts - additional options for cca modes
  196. *
  197. * @NL802154_CCA_OPT_ENERGY_CARRIER_OR: NL802154_CCA_ENERGY_CARRIER with OR
  198. * @NL802154_CCA_OPT_ENERGY_CARRIER_AND: NL802154_CCA_ENERGY_CARRIER with AND
  199. */
  200. enum nl802154_cca_opts {
  201. NL802154_CCA_OPT_ENERGY_CARRIER_AND,
  202. NL802154_CCA_OPT_ENERGY_CARRIER_OR,
  203. /* keep last */
  204. __NL802154_CCA_OPT_ATTR_AFTER_LAST,
  205. NL802154_CCA_OPT_ATTR_MAX = __NL802154_CCA_OPT_ATTR_AFTER_LAST - 1
  206. };
  207. /**
  208. * enum nl802154_supported_bool_states - bool states for bool capability entry
  209. *
  210. * @NL802154_SUPPORTED_BOOL_FALSE: indicates to set false
  211. * @NL802154_SUPPORTED_BOOL_TRUE: indicates to set true
  212. * @__NL802154_SUPPORTED_BOOL_INVALD: reserved
  213. * @NL802154_SUPPORTED_BOOL_BOTH: indicates to set true and false
  214. * @__NL802154_SUPPORTED_BOOL_AFTER_LAST: Internal
  215. * @NL802154_SUPPORTED_BOOL_MAX: highest value for bool states
  216. */
  217. enum nl802154_supported_bool_states {
  218. NL802154_SUPPORTED_BOOL_FALSE,
  219. NL802154_SUPPORTED_BOOL_TRUE,
  220. /* to handle them in a mask */
  221. __NL802154_SUPPORTED_BOOL_INVALD,
  222. NL802154_SUPPORTED_BOOL_BOTH,
  223. /* keep last */
  224. __NL802154_SUPPORTED_BOOL_AFTER_LAST,
  225. NL802154_SUPPORTED_BOOL_MAX = __NL802154_SUPPORTED_BOOL_AFTER_LAST - 1
  226. };
  227. #ifdef CONFIG_IEEE802154_NL802154_EXPERIMENTAL
  228. enum nl802154_dev_addr_modes {
  229. NL802154_DEV_ADDR_NONE,
  230. __NL802154_DEV_ADDR_INVALID,
  231. NL802154_DEV_ADDR_SHORT,
  232. NL802154_DEV_ADDR_EXTENDED,
  233. /* keep last */
  234. __NL802154_DEV_ADDR_AFTER_LAST,
  235. NL802154_DEV_ADDR_MAX = __NL802154_DEV_ADDR_AFTER_LAST - 1
  236. };
  237. enum nl802154_dev_addr_attrs {
  238. NL802154_DEV_ADDR_ATTR_UNSPEC,
  239. NL802154_DEV_ADDR_ATTR_PAN_ID,
  240. NL802154_DEV_ADDR_ATTR_MODE,
  241. NL802154_DEV_ADDR_ATTR_SHORT,
  242. NL802154_DEV_ADDR_ATTR_EXTENDED,
  243. NL802154_DEV_ADDR_ATTR_PAD,
  244. /* keep last */
  245. __NL802154_DEV_ADDR_ATTR_AFTER_LAST,
  246. NL802154_DEV_ADDR_ATTR_MAX = __NL802154_DEV_ADDR_ATTR_AFTER_LAST - 1
  247. };
  248. enum nl802154_key_id_modes {
  249. NL802154_KEY_ID_MODE_IMPLICIT,
  250. NL802154_KEY_ID_MODE_INDEX,
  251. NL802154_KEY_ID_MODE_INDEX_SHORT,
  252. NL802154_KEY_ID_MODE_INDEX_EXTENDED,
  253. /* keep last */
  254. __NL802154_KEY_ID_MODE_AFTER_LAST,
  255. NL802154_KEY_ID_MODE_MAX = __NL802154_KEY_ID_MODE_AFTER_LAST - 1
  256. };
  257. enum nl802154_key_id_attrs {
  258. NL802154_KEY_ID_ATTR_UNSPEC,
  259. NL802154_KEY_ID_ATTR_MODE,
  260. NL802154_KEY_ID_ATTR_INDEX,
  261. NL802154_KEY_ID_ATTR_IMPLICIT,
  262. NL802154_KEY_ID_ATTR_SOURCE_SHORT,
  263. NL802154_KEY_ID_ATTR_SOURCE_EXTENDED,
  264. NL802154_KEY_ID_ATTR_PAD,
  265. /* keep last */
  266. __NL802154_KEY_ID_ATTR_AFTER_LAST,
  267. NL802154_KEY_ID_ATTR_MAX = __NL802154_KEY_ID_ATTR_AFTER_LAST - 1
  268. };
  269. enum nl802154_seclevels {
  270. NL802154_SECLEVEL_NONE,
  271. NL802154_SECLEVEL_MIC32,
  272. NL802154_SECLEVEL_MIC64,
  273. NL802154_SECLEVEL_MIC128,
  274. NL802154_SECLEVEL_ENC,
  275. NL802154_SECLEVEL_ENC_MIC32,
  276. NL802154_SECLEVEL_ENC_MIC64,
  277. NL802154_SECLEVEL_ENC_MIC128,
  278. /* keep last */
  279. __NL802154_SECLEVEL_AFTER_LAST,
  280. NL802154_SECLEVEL_MAX = __NL802154_SECLEVEL_AFTER_LAST - 1
  281. };
  282. enum nl802154_frames {
  283. NL802154_FRAME_BEACON,
  284. NL802154_FRAME_DATA,
  285. NL802154_FRAME_ACK,
  286. NL802154_FRAME_CMD,
  287. /* keep last */
  288. __NL802154_FRAME_AFTER_LAST,
  289. NL802154_FRAME_MAX = __NL802154_FRAME_AFTER_LAST - 1
  290. };
  291. enum nl802154_cmd_frames {
  292. __NL802154_CMD_FRAME_INVALID,
  293. NL802154_CMD_FRAME_ASSOC_REQUEST,
  294. NL802154_CMD_FRAME_ASSOC_RESPONSE,
  295. NL802154_CMD_FRAME_DISASSOC_NOTIFY,
  296. NL802154_CMD_FRAME_DATA_REQUEST,
  297. NL802154_CMD_FRAME_PAN_ID_CONFLICT_NOTIFY,
  298. NL802154_CMD_FRAME_ORPHAN_NOTIFY,
  299. NL802154_CMD_FRAME_BEACON_REQUEST,
  300. NL802154_CMD_FRAME_COORD_REALIGNMENT,
  301. NL802154_CMD_FRAME_GTS_REQUEST,
  302. /* keep last */
  303. __NL802154_CMD_FRAME_AFTER_LAST,
  304. NL802154_CMD_FRAME_MAX = __NL802154_CMD_FRAME_AFTER_LAST - 1
  305. };
  306. enum nl802154_seclevel_attrs {
  307. NL802154_SECLEVEL_ATTR_UNSPEC,
  308. NL802154_SECLEVEL_ATTR_LEVELS,
  309. NL802154_SECLEVEL_ATTR_FRAME,
  310. NL802154_SECLEVEL_ATTR_CMD_FRAME,
  311. NL802154_SECLEVEL_ATTR_DEV_OVERRIDE,
  312. /* keep last */
  313. __NL802154_SECLEVEL_ATTR_AFTER_LAST,
  314. NL802154_SECLEVEL_ATTR_MAX = __NL802154_SECLEVEL_ATTR_AFTER_LAST - 1
  315. };
  316. /* TODO what is this? couldn't find in mib */
  317. enum {
  318. NL802154_DEVKEY_IGNORE,
  319. NL802154_DEVKEY_RESTRICT,
  320. NL802154_DEVKEY_RECORD,
  321. /* keep last */
  322. __NL802154_DEVKEY_AFTER_LAST,
  323. NL802154_DEVKEY_MAX = __NL802154_DEVKEY_AFTER_LAST - 1
  324. };
  325. enum nl802154_dev {
  326. NL802154_DEV_ATTR_UNSPEC,
  327. NL802154_DEV_ATTR_FRAME_COUNTER,
  328. NL802154_DEV_ATTR_PAN_ID,
  329. NL802154_DEV_ATTR_SHORT_ADDR,
  330. NL802154_DEV_ATTR_EXTENDED_ADDR,
  331. NL802154_DEV_ATTR_SECLEVEL_EXEMPT,
  332. NL802154_DEV_ATTR_KEY_MODE,
  333. NL802154_DEV_ATTR_PAD,
  334. /* keep last */
  335. __NL802154_DEV_ATTR_AFTER_LAST,
  336. NL802154_DEV_ATTR_MAX = __NL802154_DEV_ATTR_AFTER_LAST - 1
  337. };
  338. enum nl802154_devkey {
  339. NL802154_DEVKEY_ATTR_UNSPEC,
  340. NL802154_DEVKEY_ATTR_FRAME_COUNTER,
  341. NL802154_DEVKEY_ATTR_EXTENDED_ADDR,
  342. NL802154_DEVKEY_ATTR_ID,
  343. NL802154_DEVKEY_ATTR_PAD,
  344. /* keep last */
  345. __NL802154_DEVKEY_ATTR_AFTER_LAST,
  346. NL802154_DEVKEY_ATTR_MAX = __NL802154_DEVKEY_ATTR_AFTER_LAST - 1
  347. };
  348. enum nl802154_key {
  349. NL802154_KEY_ATTR_UNSPEC,
  350. NL802154_KEY_ATTR_ID,
  351. NL802154_KEY_ATTR_USAGE_FRAMES,
  352. NL802154_KEY_ATTR_USAGE_CMDS,
  353. NL802154_KEY_ATTR_BYTES,
  354. /* keep last */
  355. __NL802154_KEY_ATTR_AFTER_LAST,
  356. NL802154_KEY_ATTR_MAX = __NL802154_KEY_ATTR_AFTER_LAST - 1
  357. };
  358. #define NL802154_KEY_SIZE 16
  359. #define NL802154_CMD_FRAME_NR_IDS 256
  360. #endif /* CONFIG_IEEE802154_NL802154_EXPERIMENTAL */
  361. #endif /* __NL802154_H */