nl802154.h 12 KB

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