ieee802154_mac.h 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903
  1. /*****************************************************************************
  2. * include/nuttx/wireless/ieee802154/ieee802154_mac.h
  3. *
  4. * Copyright (C) 2016 Sebastien Lorquet. All rights reserved.
  5. * Copyright (C) 2017 Verge Inc. All rights reserved.
  6. *
  7. * Author: Sebastien Lorquet <sebastien@lorquet.fr>
  8. * Author: Anthony Merlino <anthony@vergeaero.com>
  9. *
  10. * The naming and comments for various fields are taken directly
  11. * from the IEEE 802.15.4 2011 standard.
  12. *
  13. * Redistribution and use in source and binary forms, with or without
  14. * modification, are permitted provided that the following conditions
  15. * are met:
  16. *
  17. * 1. Redistributions of source code must retain the above copyright
  18. * notice, this list of conditions and the following disclaimer.
  19. * 2. Redistributions in binary form must reproduce the above copyright
  20. * notice, this list of conditions and the following disclaimer in
  21. * the documentation and/or other materials provided with the
  22. * distribution.
  23. * 3. Neither the name NuttX nor the names of its contributors may be
  24. * used to endorse or promote products derived from this software
  25. * without specific prior written permission.
  26. *
  27. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  28. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  29. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  30. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  31. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  32. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  33. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  34. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  35. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  36. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  37. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  38. * POSSIBILITY OF SUCH DAMAGE.
  39. *
  40. *****************************************************************************/
  41. #ifndef __INCLUDE_NUTTX_WIRELESS_IEEE802154_IEEE802154_MAC_H
  42. #define __INCLUDE_NUTTX_WIRELESS_IEEE802154_IEEE802154_MAC_H
  43. /*****************************************************************************
  44. * Included Files
  45. *****************************************************************************/
  46. #include <nuttx/config.h>
  47. #include <signal.h>
  48. #include <stdint.h>
  49. #include <stdbool.h>
  50. #include <string.h>
  51. #if defined(CONFIG_NET_6LOWPAN) || defined(CONFIG_NET_IEEE802154)
  52. # include <net/if.h>
  53. #endif
  54. #include <nuttx/fs/ioctl.h>
  55. /*****************************************************************************
  56. * Pre-Processor Definitions
  57. *****************************************************************************/
  58. /* Configuration *************************************************************/
  59. #if !defined(CONFIG_MAC802154_NPANDESC) || CONFIG_MAC802154_NPANDESC <= 0
  60. # undef CONFIG_MAC802154_NPANDESC
  61. # define CONFIG_MAC802154_NPANDESC 5
  62. #endif
  63. #define MAC802154_NPANDESC CONFIG_MAC802154_NPANDESC
  64. /* IEEE 802.15.4 address macros */
  65. /* Copy a an IEEE 802.15.4 address */
  66. #define IEEE802154_ANYADDRCOPY(dest,src,len) \
  67. memcpy(dest, src, len)
  68. #define IEEE802154_PANIDCOPY(dest,src) \
  69. IEEE802154_ANYADDRCOPY(dest,src,IEEE802154_PANIDSIZE)
  70. #define IEEE802154_SADDRCOPY(dest,src) \
  71. IEEE802154_ANYADDRCOPY(dest,src,IEEE802154_SADDRSIZE)
  72. #define IEEE802154_EADDRCOPY(dest,src) \
  73. IEEE802154_ANYADDRCOPY(dest,src,IEEE802154_EADDRSIZE)
  74. /* Compare two IEEE 802.15.4 addresses */
  75. #define IEEE802154_ANYADDRCMP(addr1,addr2,len) \
  76. (memcmp(addr1, addr2, len) == 0)
  77. #define IEEE802154_PANIDCMP(addr1,addr2) \
  78. IEEE802154_ANYADDRCMP(addr1,addr2,IEEE802154_PANIDSIZE)
  79. #define IEEE802154_SADDRCMP(addr1,addr2) \
  80. IEEE802154_ANYADDRCMP(addr1,addr2,IEEE802154_SADDRSIZE)
  81. #define IEEE802154_EADDRCMP(addr1,addr2) \
  82. IEEE802154_ANYADDRCMP(addr1,addr2,IEEE802154_EADDRSIZE)
  83. /* Some addresses */
  84. #define IEEE802154_PANID_UNSPEC ((uint8_t[]){0xff,0xff})
  85. #define IEEE802154_SADDR_UNSPEC ((uint8_t[]){0xff,0xff})
  86. #define IEEE802154_SADDR_BCAST ((uint8_t[]){0xfe,0xff})
  87. #define IEEE802154_EADDR_UNSPEC ((uint8_t[]){0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff})
  88. /* IEEE 802.15.4 MAC Character Driver IOCTL Commands *************************/
  89. /* The IEEE 802.15.4 standard specifies a MLME Service Access Point (SAP)
  90. * including a series of primitives that are used as an interface between
  91. * the MLME and the next highest layer. There are 4 types of primitives:
  92. *
  93. * - Request
  94. * - Indication
  95. * - Response
  96. * - Confirm
  97. *
  98. * Of these, Request and Response primitives are sent from the next highest
  99. * layer to the MLME. Indication and Confirm primitives are used to notify the
  100. * next highest layer of changes or actions that have taken place.
  101. *
  102. * The MAC802154 character driver exposed here provides IOCTL hooks for all
  103. * Request and Response primitives.
  104. */
  105. #define MAC802154IOC_MLME_ASSOC_REQUEST _MAC802154IOC(0x0000)
  106. #define MAC802154IOC_MLME_ASSOC_RESPONSE _MAC802154IOC(0x0001)
  107. #define MAC802154IOC_MLME_DISASSOC_REQUEST _MAC802154IOC(0x0002)
  108. #define MAC802154IOC_MLME_GET_REQUEST _MAC802154IOC(0x0003)
  109. #define MAC802154IOC_MLME_GTS_REQUEST _MAC802154IOC(0x0004)
  110. #define MAC802154IOC_MLME_ORPHAN_RESPONSE _MAC802154IOC(0x0005)
  111. #define MAC802154IOC_MLME_RESET_REQUEST _MAC802154IOC(0x0006)
  112. #define MAC802154IOC_MLME_RXENABLE_REQUEST _MAC802154IOC(0x0007)
  113. #define MAC802154IOC_MLME_SCAN_REQUEST _MAC802154IOC(0x0008)
  114. #define MAC802154IOC_MLME_SET_REQUEST _MAC802154IOC(0x0009)
  115. #define MAC802154IOC_MLME_START_REQUEST _MAC802154IOC(0x000a)
  116. #define MAC802154IOC_MLME_SYNC_REQUEST _MAC802154IOC(0x000b)
  117. #define MAC802154IOC_MLME_POLL_REQUEST _MAC802154IOC(0x000c)
  118. #define MAC802154IOC_MLME_DPS_REQUEST _MAC802154IOC(0x000d)
  119. #define MAC802154IOC_MLME_SOUNDING_REQUEST _MAC802154IOC(0x000e)
  120. #define MAC802154IOC_MLME_CALIBRATE_REQUEST _MAC802154IOC(0x000f)
  121. /* Non-standard MAC ioctl calls */
  122. #define MAC802154IOC_NOTIFY_REGISTER _MAC802154IOC(0x00fd)
  123. #define MAC802154IOC_GET_EVENT _MAC802154IOC(0x00fe)
  124. #define MAC802154IOC_ENABLE_EVENTS _MAC802154IOC(0x00ff)
  125. /* IEEE 802.15.4 MAC Interface ***********************************************/
  126. /* Frame control field masks, 2 bytes
  127. * Seee IEEE 802.15.4/2011 5.2.1.1 page 57
  128. */
  129. #define IEEE802154_FRAMECTRL_FTYPE 0x0007 /* Frame type, bits 0-2 */
  130. #define IEEE802154_FRAMECTRL_SEC 0x0008 /* Security Enabled, bit 3 */
  131. #define IEEE802154_FRAMECTRL_PEND 0x0010 /* Frame pending, bit 4 */
  132. #define IEEE802154_FRAMECTRL_ACKREQ 0x0020 /* Acknowledge request, bit 5 */
  133. #define IEEE802154_FRAMECTRL_PANIDCOMP 0x0040 /* PAN ID Compression, bit 6 */
  134. #define IEEE802154_FRAMECTRL_DADDR 0x0c00 /* Dest addressing mode, bits 10-11 */
  135. #define IEEE802154_FRAMECTRL_VERSION 0x3000 /* Source addressing mode, bits 12-13 */
  136. #define IEEE802154_FRAMECTRL_SADDR 0xc000 /* Source addressing mode, bits 14-15 */
  137. #define IEEE802154_FRAMECTRL_SHIFT_FTYPE 0 /* Frame type, bits 0-2 */
  138. #define IEEE802154_FRAMECTRL_SHIFT_SEC 3 /* Security Enabled, bit 3 */
  139. #define IEEE802154_FRAMECTRL_SHIFT_PEND 4 /* Frame pending, bit 4 */
  140. #define IEEE802154_FRAMECTRL_SHIFT_ACKREQ 5 /* Acknowledge request, bit 5 */
  141. #define IEEE802154_FRAMECTRL_SHIFT_PANIDCOMP 6 /* PAN ID Compression, bit 6 */
  142. #define IEEE802154_FRAMECTRL_SHIFT_DADDR 10 /* Dest addressing mode, bits 10-11 */
  143. #define IEEE802154_FRAMECTRL_SHIFT_VERSION 12 /* Source addressing mode, bits 12-13 */
  144. #define IEEE802154_FRAMECTRL_SHIFT_SADDR 14 /* Source addressing mode, bits 14-15 */
  145. /* Superframe Specification field masks, 2 bytes
  146. * Seee IEEE 802.15.4/2011 5.2.2.1.2 page 62
  147. */
  148. #define IEEE802154_SFSPEC_BEACONORDER 0x000f /* Beacon order, bits 0-3 */
  149. #define IEEE802154_SFSPEC_SFORDER 0x00f0 /* Superframe Order, bit 4-7 */
  150. #define IEEE802154_SFSPEC_FINCAPSLOT 0x0f00 /* Final CAP Slot, bit 8-11 */
  151. #define IEEE802154_SFSPEC_BLE 0x1000 /* Battery Life Ext, bit 12 */
  152. #define IEEE802154_SFSPEC_PANCOORD 0x4000 /* PAN Coordinator, bit 14 */
  153. #define IEEE802154_SFSPEC_ASSOCPERMIT 0x8000 /* Association Permit, bit 15 */
  154. #define IEEE802154_SFSPEC_SHIFT_BEACONORDER 0 /* Beacon order, bits 0-3 */
  155. #define IEEE802154_SFSPEC_SHIFT_SFORDER 4 /* Superframe order, bit 4-7 */
  156. #define IEEE802154_SFSPEC_SHIFT_FINCAPSLOT 8 /* Final CAP Slot, bit 8-11 */
  157. #define IEEE802154_SFSPEC_SHIFT_BLE 12 /* Battery Life Ext, bit 12 */
  158. #define IEEE802154_SFSPEC_SHIFT_PANCOORD 14 /* PAN Coordinator, bit 14 */
  159. #define IEEE802154_SFSPEC_SHIFT_ASSOCPERMIT 15 /* Association Permit, bit 15 */
  160. /* GTS Specification field masks, 1 byte
  161. * Seee IEEE 802.15.4/2011 5.2.2.1.3 page 63
  162. */
  163. #define IEEE802154_GTSSPEC_DESCCOUNT 0x07 /* GTS Desc. count, bits 0-2 */
  164. #define IEEE802154_GTSSPEC_PERMIT 0x80 /* GTS Desc. count, bit 7 */
  165. #define IEEE802154_GTSSPEC_SHIFT_DESCCOUNT 0 /* GTS Desc. count, bits 0-2 */
  166. #define IEEE802154_GTSSPEC_SHIFT_PERMIT 7 /* GTS Desc. count, bit 7 */
  167. /* GTS Directions field masks, 1 byte
  168. * Seee IEEE 802.15.4/2011 5.2.2.1.3 page 63
  169. */
  170. #define IEEE802154_GTSDIR_MASK 0x7f /* GTS Directions Mask, bits 0-6 */
  171. #define IEEE802154_GTSDIR_SHIFT_MASK 0 /* GTS Directions Mask, bits 0-6 */
  172. /* Pending address specifications field masks, 1 byte
  173. * See IEEE 802.15.4/2011 5.2.2.1.6 page 64
  174. */
  175. #define IEEE802154_PENDADDR_NSADDR 0x07 /* # of short addresses, bits 0-2 */
  176. #define IEEE802154_PENDADDR_NEADDR 0x70 /* # of extended addresses, bits 4-6 */
  177. #define IEEE802154_PENDADDR_SHIFT_NSADDR 0 /* # of short addresses, bits 0-2 */
  178. #define IEEE802154_PENDADDR_SHIFT_NEADDR 4 /* # of extended addresses, bits 4-6 */
  179. /* Capability Information Bitfield
  180. */
  181. #define IEEE802154_CAPABILITY_DEVTYPE 0x02
  182. #define IEEE802154_CAPABILITY_PWRSRC 0x04
  183. #define IEEE802154_CAPABILITY_RXONIDLE 0x08
  184. #define IEEE802154_CAPABILITY_SECURITY 0x40
  185. #define IEEE802154_CAPABILITY_ALLOCADDR 0x80
  186. #define IEEE802154_CAPABILITY_SHIFT_DEVTYPE 1
  187. #define IEEE802154_CAPABILITY_SHIFT_PWRSRC 2
  188. #define IEEE802154_CAPABILITY_SHIFT_RXONIDLE 3
  189. #define IEEE802154_CAPABILITY_SHIFT_SECURITY 6
  190. #define IEEE802154_CAPABILITY_SHIFT_ALLOCADDR 7
  191. /* IEEE 802.15.4 PHY constants */
  192. #define IEEE802154_MAX_PHY_PACKET_SIZE 127
  193. #define IEEE802154_TURN_AROUND_TIME 12 /* symbol periods*/
  194. /* IEEE 802.15.4 MAC constants */
  195. #define IEEE802154_BASE_SLOT_DURATION 60
  196. #define IEEE802154_NUM_SUPERFRAME_SLOTS 16
  197. #define IEEE802154_BASE_SUPERFRAME_DURATION \
  198. (IEEE802154_BASE_SLOT_DURATION * IEEE802154_NUM_SUPERFRAME_SLOTS)
  199. #define IEEE802154_GTS_DESC_PERSISTENCE_TIME 4
  200. #define IEEE802154_MAX_BEACON_OVERHEAD 75
  201. #define IEEE802154_MAX_BEACON_PAYLOAD_LEN \
  202. (IEEE802154_MAX_PHY_PACKET_SIZE - IEEE802154_MAX_BEACON_OVERHEAD)
  203. #define IEEE802154_MAX_LOST_BEACONS 4
  204. #define IEEE802154_MIN_MPDU_OVERHEAD 9
  205. #define IEEE802154_MAX_UNSEC_MHR_OVERHEAD 23
  206. #define IEEE802154_MFR_LENGTH 2
  207. #define IEEE802154_MAX_MPDU_UNSEC_OVERHEAD \
  208. (IEEE802154_MAX_UNSEC_MHR_OVERHEAD + IEEE802154_MFR_LENGTH)
  209. #define IEEE802154_MAX_SAFE_MAC_PAYLOAD_SIZE \
  210. (IEEE802154_MAX_PHY_PACKET_SIZE - IEEE802154_MAX_MPDU_UNSEC_OVERHEAD)
  211. #define IEEE802154_MAX_MAC_PAYLOAD_SIZE \
  212. (IEEE802154_MAX_PHY_PACKET_SIZE - IEEE802154_MIN_MPDU_OVERHEAD)
  213. #define IEEE802154_MAX_SIFS_FRAME_SIZE 18
  214. #define IEEE802154_MIN_CAP_LENGTH 440
  215. #define IEEE802154_UNIT_BACKOFF_PERIOD 20
  216. /* IEEE 802.15.4 MAC PIB Attribute Defaults */
  217. /* Definitions used by IOCTL calls */
  218. #define MAX_ORPHAN_ADDR 32 /* REVISIT */
  219. /*****************************************************************************
  220. * Public Types
  221. *****************************************************************************/
  222. /* IEEE 802.15.4 MAC status codes */
  223. enum ieee802154_status_e
  224. {
  225. /* This first section of enums is defined in the standard. [1] pg. 70
  226. * They must be in this order
  227. */
  228. IEEE802154_STATUS_SUCCESS = 0,
  229. IEEE802154_STATUS_OUT_OF_CAPACITY,
  230. IEEE802154_STATUS_DENIED,
  231. /* As of now, all values below do not have a specific value defined in the
  232. * standard
  233. */
  234. IEEE802154_STATUS_FAILURE, /* This value is not outlined in the standard. It
  235. * is a catch-all for any failures that are not
  236. * outlined in the standard
  237. */
  238. IEEE802154_STATUS_BEACON_LOSS,
  239. IEEE802154_STATUS_CHANNEL_ACCESS_FAILURE,
  240. IEEE802154_STATUS_DISABLE_TRX_FAILURE,
  241. IEEE802154_STATUS_FAILED_SECURITY_CHECK,
  242. IEEE802154_STATUS_FRAME_TOO_LONG,
  243. IEEE802154_STATUS_INVALID_GTS,
  244. IEEE802154_STATUS_INVALID_HANDLE,
  245. IEEE802154_STATUS_INVALID_PARAMETER,
  246. IEEE802154_STATUS_NO_ACK,
  247. IEEE802154_STATUS_NO_BEACON,
  248. IEEE802154_STATUS_NO_DATA,
  249. IEEE802154_STATUS_NO_SHORT_ADDRESS,
  250. IEEE802154_STATUS_PAN_ID_CONFLICT,
  251. IEEE802154_STATUS_REALIGNMENT,
  252. IEEE802154_STATUS_TRANSACTION_EXPIRED,
  253. IEEE802154_STATUS_TRANSACTION_OVERFLOW,
  254. IEEE802154_STATUS_TX_ACTIVE,
  255. IEEE802154_STATUS_UNAVAILABLE_KEY,
  256. IEEE802154_STATUS_UNSUPPORTED_ATTRIBUTE,
  257. IEEE802154_STATUS_LIMITREACHED,
  258. };
  259. static const char *IEEE802154_STATUS_STRING[] =
  260. {
  261. "Success",
  262. "Out of capacity",
  263. "Denied",
  264. "Failure",
  265. "Beacon loss",
  266. "Channel access failure",
  267. "Disable TRX failure",
  268. "Failed security check",
  269. "Frame too long",
  270. "Invalid GTS",
  271. "Invalid handle",
  272. "Invalid parameter",
  273. "No ack",
  274. "No beacon",
  275. "No data",
  276. "No short address",
  277. "PAN ID conflict",
  278. "Realignment",
  279. "Transaction expired",
  280. "Transaction overflow",
  281. "Tx active",
  282. "Unavailable key",
  283. "Unsupported attribute",
  284. "Limit reached",
  285. };
  286. /* IEEE 802.15.4 PHY/MAC PIB attributes IDs */
  287. enum ieee802154_attr_e
  288. {
  289. /* PHY PIB Attributes */
  290. IEEE802154_ATTR_PHY_CHAN,
  291. IEEE802154_ATTR_PHY_CHANNELS_SUPPORTED,
  292. IEEE802154_ATTR_PHY_TX_POWER_TOLERANCE,
  293. IEEE802154_ATTR_PHY_TX_POWER,
  294. IEEE802154_ATTR_PHY_CCA_MODE,
  295. IEEE802154_ATTR_PHY_CURRENT_PAGE,
  296. IEEE802154_ATTR_PHY_MAX_FRAME_DURATION,
  297. IEEE802154_ATTR_PHY_SHR_DURATION,
  298. IEEE802154_ATTR_PHY_SYM_PER_OCTET,
  299. IEEE802154_ATTR_PHY_PREAMBLE_SYM_LEN,
  300. IEEE802154_ATTR_PHY_UWB_DATARATES_SUP,
  301. IEEE802154_ATTR_PHY_CSS_LOW_DATARATE_SUP,
  302. IEEE802154_ATTR_PHY_UWB_COU_PULSES_SUP,
  303. IEEE802154_ATTR_PHY_UWB_CS_PULSES_SUP,
  304. IEEE802154_ATTR_PHY_UWB_LCP_PULSES_SUP,
  305. IEEE802154_ATTR_PHY_UWB_CURR_PULSE_SHAPE,
  306. IEEE802154_ATTR_PHY_UWB_COU_PULSE,
  307. IEEE802154_ATTR_PHY_UWB_CS_PULSE,
  308. IEEE802154_ATTR_PHY_UWB_LCP_WEIGHT1,
  309. IEEE802154_ATTR_PHY_UWB_LCP_WEIGHT2,
  310. IEEE802154_ATTR_PHY_UWB_LCP_WEIGHT3,
  311. IEEE802154_ATTR_PHY_UWB_LCP_WEIGHT4,
  312. IEEE802154_ATTR_PHY_UWB_LCP_DELAY2,
  313. IEEE802154_ATTR_PHY_UWB_LCP_DELAY3,
  314. IEEE802154_ATTR_PHY_UWB_LCP_DELAY4,
  315. IEEE802154_ATTR_PHY_RANGING,
  316. IEEE802154_ATTR_PHY_RANGING_CRYSTAL_OFFSET,
  317. IEEE802154_ATTR_PHY_RANGING_DPS,
  318. IEEE802154_ATTR_PHY_CURRENT_CODE,
  319. IEEE802154_ATTR_PHY_NATIVE_PRF,
  320. IEEE802154_ATTR_PHY_UWB_SCAN_BINS_PER_CHAN,
  321. IEEE802154_ATTR_PHY_UWB_INS_PREAMBLE_INTERVAL,
  322. IEEE802154_ATTR_PHY_UWB_TX_RMARKER,
  323. IEEE802154_ATTR_PHY_UWB_RX_RMARKER,
  324. IEEE802154_ATTR_PHY_RFRAME_PROC_TIME,
  325. IEEE802154_ATTR_PHY_CCA_DURATION,
  326. /* Non-standard PHY attributes */
  327. IEEE802154_ATTR_PHY_SYMBOL_DURATION,
  328. IEEE802154_ATTR_PHY_FCS_LEN,
  329. IEEE802154_ATTR_PHY_REGDUMP,
  330. /* MAC PIB Attributes */
  331. IEEE802154_ATTR_MAC_EADDR,
  332. IEEE802154_ATTR_MAC_ACK_WAIT_DUR,
  333. IEEE802154_ATTR_MAC_ASSOCIATED_PANCOORD,
  334. IEEE802154_ATTR_MAC_ASSOCIATION_PERMIT,
  335. IEEE802154_ATTR_MAC_AUTO_REQUEST,
  336. IEEE802154_ATTR_MAC_BATT_LIFE_EXT,
  337. IEEE802154_ATTR_MAC_BATT_LIFE_EXT_PERIODS,
  338. IEEE802154_ATTR_MAC_BEACON_PAYLOAD,
  339. IEEE802154_ATTR_MAC_BEACON_PAYLOAD_LEN,
  340. IEEE802154_ATTR_MAC_BEACON_ORDER,
  341. IEEE802154_ATTR_MAC_BEACON_TX_TIME,
  342. IEEE802154_ATTR_MAC_BSN,
  343. IEEE802154_ATTR_MAC_COORD_EADDR,
  344. IEEE802154_ATTR_MAC_COORD_SADDR,
  345. IEEE802154_ATTR_MAC_DSN,
  346. IEEE802154_ATTR_MAC_GTS_PERMIT,
  347. IEEE802154_ATTR_MAC_MAX_BE,
  348. IEEE802154_ATTR_MAC_MAX_CSMA_BACKOFFS,
  349. IEEE802154_ATTR_MAC_MAX_FRAME_WAITTIME,
  350. IEEE802154_ATTR_MAC_MAX_FRAME_RETRIES,
  351. IEEE802154_ATTR_MAC_MIN_BE,
  352. IEEE802154_ATTR_MAC_LIFS_PERIOD,
  353. IEEE802154_ATTR_MAC_SIFS_PERIOD,
  354. IEEE802154_ATTR_MAC_PANID,
  355. IEEE802154_ATTR_MAC_PROMISCUOUS_MODE,
  356. IEEE802154_ATTR_MAC_RANGING_SUPPORT,
  357. IEEE802154_ATTR_MAC_RESPONSE_WAIT_TIME,
  358. IEEE802154_ATTR_MAC_RX_ON_WHEN_IDLE,
  359. IEEE802154_ATTR_MAC_SECURITY_ENABLED,
  360. IEEE802154_ATTR_MAC_SADDR,
  361. IEEE802154_ATTR_MAC_SUPERFRAME_ORDER,
  362. IEEE802154_ATTR_MAC_SYNC_SYMBOL_OFFSET,
  363. IEEE802154_ATTR_MAC_TIMESTAMP_SUPPORT,
  364. IEEE802154_ATTR_MAC_TRANSACTION_PERSIST_TIME,
  365. IEEE802154_ATTR_MAC_TX_CTRL_ACTIVE_DUR,
  366. IEEE802154_ATTR_MAC_TX_CTRL_PAUSE_DUR,
  367. IEEE802154_ATTR_MAC_TX_TOTAL_DUR,
  368. /* MAC Security Attributes */
  369. IEEE802154_ATTR_MAC_KEY_TABLE,
  370. IEEE802154_ATTR_MAC_DEV_TABLE,
  371. IEEE802154_ATTR_MAC_SEC_LVL_TABLE,
  372. IEEE802154_ATTR_MAC_FRAME_COUNTER,
  373. IEEE802154_ATTR_MAC_AUTOREQ_SEC_LVL,
  374. IEEE802154_ATTR_MAC_AUTOREQ_KEY_ID_MODE,
  375. IEEE802154_ATTR_MAC_AUTOREQ_KEY_SOURCE,
  376. IEEE802154_ATTR_MAC_AUTOREQ_KEY_INDEX,
  377. IEEE802154_ATTR_MAC_DEFAULT_KEY_SRC,
  378. IEEE802154_ATTR_MAC_PANCOORD_EXT_ADDR,
  379. IEEE802154_ATTR_MAC_PANCOORD_SHORT_ADDR,
  380. /* Non-standard MAC Attributes */
  381. IEEE802154_ATTR_MAC_DEVMODE,
  382. };
  383. /* Frame Type */
  384. enum ieee802154_frametype_e
  385. {
  386. IEEE802154_FRAME_BEACON = 0,
  387. IEEE802154_FRAME_DATA,
  388. IEEE802154_FRAME_ACK,
  389. IEEE802154_FRAME_COMMAND
  390. };
  391. /* MAC command IDs */
  392. /* TODO: Change terminology to be "current primitive" */
  393. enum ieee802154_cmdid_e
  394. {
  395. IEEE802154_CMD_ASSOC_REQ = 1,
  396. IEEE802154_CMD_ASSOC_RESP,
  397. IEEE802154_CMD_DISASSOC_NOT,
  398. IEEE802154_CMD_DATA_REQ,
  399. IEEE802154_CMD_PANID_CONF_NOT,
  400. IEEE802154_CMD_ORPHAN_NOT,
  401. IEEE802154_CMD_BEACON_REQ,
  402. IEEE802154_CMD_COORD_REALIGN,
  403. IEEE802154_CMD_GTS_REQ,
  404. };
  405. enum ieee802154_devmode_e
  406. {
  407. IEEE802154_DEVMODE_ENDPOINT = 0x00,
  408. IEEE802154_DEVMODE_COORD,
  409. IEEE802154_DEVMODE_PANCOORD
  410. };
  411. #define IEEE802154_PANIDSIZE 2
  412. #define IEEE802154_SADDRSIZE 2
  413. #define IEEE802154_EADDRSIZE 8
  414. /* IEEE 802.15.4 Device address
  415. * The addresses in ieee802154 have several formats:
  416. * No address : [none]
  417. * Short address + PAN id : PPPP/SSSS
  418. * Extended address + PAN id : PPPP/LLLLLLLLLLLLLLLL
  419. */
  420. enum ieee802154_addrmode_e
  421. {
  422. IEEE802154_ADDRMODE_NONE = 0,
  423. IEEE802154_ADDRMODE_SHORT = 2,
  424. IEEE802154_ADDRMODE_EXTENDED
  425. /* TODO: Add a IEEE802154_ADDRMODE_ANY setting for structs where both the
  426. * extended and short addresses are safe to use.
  427. */
  428. };
  429. struct ieee802154_addr_s
  430. {
  431. /* Address mode. Short or Extended */
  432. enum ieee802154_addrmode_e mode;
  433. uint8_t panid[IEEE802154_PANIDSIZE]; /* PAN identifier */
  434. uint8_t saddr[IEEE802154_SADDRSIZE]; /* short address */
  435. uint8_t eaddr[IEEE802154_EADDRSIZE]; /* extended address */
  436. };
  437. #define IEEE802154_ADDRSTRLEN 22 /* (2*2+1+8*2, PPPP/EEEEEEEEEEEEEEEE) */
  438. #ifdef CONFIG_IEEE802154_SECURITY
  439. struct ieee802154_security_s
  440. {
  441. uint8_t level; /* Security level to be used */
  442. uint8_t key_id_mode; /* Mode used to identify the key to be used */
  443. uint8_t key_source[8]; /* Originator of the key to be used */
  444. uint8_t key_index; /* Index of the key to be used */
  445. };
  446. #endif
  447. #ifdef CONFIG_IEEE802154_UWB
  448. enum ieee802154_uwbprf_e
  449. {
  450. IEEE802154_UWBPRF_OFF = 0,
  451. IEEE802154_UWBPRF_4M,
  452. IEEE802154_UWBPRF_16M,
  453. IEEE802154_UWBPRF_64M
  454. };
  455. enum ieee802154_uwb_datarate_e
  456. {
  457. IEEE802154_UWB_DATARATE_0 = 0,
  458. IEEE802154_UWB_DATARATE_16,
  459. IEEE802154_UWB_DATARATE_64,
  460. IEEE802154_UWB_DATARATE_1024,
  461. IEEE802154_UWB_DATARATE_4096
  462. };
  463. #endif
  464. enum ieee802154_ranging_e
  465. {
  466. IEEE802154_NON_RANGING = 0,
  467. IEEE802154_ALL_RANGING,
  468. IEEE802154_PHY_HEADER_ONLY
  469. };
  470. struct ieee802154_capability_info_s
  471. {
  472. uint8_t reserved_0 : 1; /* Reserved */
  473. uint8_t devtype : 1; /* 0=RFD, 1=FFD */
  474. uint8_t powersource : 1; /* 1=AC, 0=Other */
  475. uint8_t rxonidle : 1; /* 0=Receiver off when idle
  476. * 1=Receiver on when idle */
  477. uint8_t reserved_45 : 2; /* Reserved */
  478. uint8_t security : 1; /* 0=disabled, 1=enabled */
  479. uint8_t allocaddr : 1; /* 1=Coordinator allocates short address
  480. * 0=otherwise */
  481. };
  482. struct ieee802154_superframespec_s
  483. {
  484. uint16_t beaconorder : 4; /* Transmission interval of beacon */
  485. uint16_t sforder : 4; /* Length of active portion of superframe */
  486. uint16_t final_capslot : 4; /* Last slot utilized by CAP */
  487. uint16_t ble : 1; /* Battery Life Extension (BLE) */
  488. uint16_t pancoord : 1; /* 1 if beacon sent by pan coordinator */
  489. uint16_t assocpermit : 1; /* 1 if coordinator is accepting associaton */
  490. };
  491. struct ieee802154_pandesc_s
  492. {
  493. /* The coordinator address of the received beacon frame */
  494. struct ieee802154_addr_s coordaddr;
  495. uint8_t chan; /* current channel occupied by the network */
  496. uint8_t chpage; /* current channel page occupied by the network */
  497. /* The superframe specifications received in the beacon frame */
  498. struct ieee802154_superframespec_s sfspec;
  499. uint8_t gtspermit; /* 0=No GTS requests allowed
  500. * 1=GTS request allowed */
  501. uint8_t lqi; /* Link Quality Indication of the beacon */
  502. uint32_t timestamp; /* Time at which the beacon frame was received
  503. * in symbols */
  504. };
  505. struct ieee802154_pendaddr_s
  506. {
  507. uint8_t nsaddr : 3; /* Number of short addresses pending */
  508. uint8_t neaddr : 3; /* Number of extended addresses pending */
  509. struct ieee802154_addr_s addr[7]; /* Array of at most 7 addresses */
  510. };
  511. struct ieee802154_cca_s
  512. {
  513. uint8_t use_ed : 1; /* CCA using ED */
  514. uint8_t use_cs : 1; /* CCA using carrier sense */
  515. uint8_t edth; /* Energy detection threshold for CCA */
  516. uint8_t csth; /* Carrier sense threshold for CCA */
  517. };
  518. /* Primitive Support Types ***************************************************/
  519. union ieee802154_macattr_u
  520. {
  521. uint8_t eaddr[IEEE802154_EADDRSIZE];
  522. uint8_t saddr[IEEE802154_SADDRSIZE];
  523. uint8_t panid[IEEE802154_PANIDSIZE];
  524. uint8_t coordeaddr[IEEE802154_EADDRSIZE];
  525. uint8_t coordsaddr[IEEE802154_SADDRSIZE];
  526. enum ieee802154_devmode_e devmode;
  527. bool is_assoc;
  528. bool assocpermit;
  529. bool autoreq;
  530. bool batt_life_ext;
  531. bool gts_permit;
  532. bool promisc_mode;
  533. bool rng_support;
  534. bool rxonidle;
  535. bool sec_enabled;
  536. bool timestamp_support;
  537. uint32_t ack_waitdur;
  538. uint8_t batt_life_ext_periods;
  539. uint8_t max_csma_backoffs : 3;
  540. uint8_t max_be : 4;
  541. uint8_t min_be : 4;
  542. uint32_t max_frame_waittime;
  543. uint8_t max_retries;
  544. uint8_t lifs_period;
  545. uint8_t sifs_period;
  546. uint32_t sync_symb_offset : 12;
  547. uint16_t trans_persist_time;
  548. uint32_t tx_ctrl_active_dur;
  549. uint32_t tx_ctrl_pause_dur;
  550. uint32_t tx_total_dur;
  551. uint8_t resp_waittime;
  552. uint8_t beacon_payload[IEEE802154_ATTR_MAC_BEACON_PAYLOAD_LEN];
  553. uint8_t beacon_payload_len;
  554. uint8_t beacon_order;
  555. uint32_t beacon_tx_time : 24;
  556. uint8_t superframeorder;
  557. uint8_t bsn;
  558. uint8_t dsn;
  559. };
  560. union ieee802154_phyattr_u
  561. {
  562. uint8_t chan;
  563. int32_t txpwr;
  564. uint32_t symdur_picosec;
  565. uint8_t fcslen;
  566. /* TODO: Fill this out as we implement supported get/set commands */
  567. };
  568. #if 0 /* Empty union causes errors on some compilers */
  569. union ieee802154_secattr_u
  570. {
  571. /* TODO: Fill this out as we implement supported get/set commands */
  572. };
  573. #endif
  574. union ieee802154_attr_u
  575. {
  576. union ieee802154_macattr_u mac;
  577. union ieee802154_phyattr_u phy;
  578. #if 0 /* Empty union causes errors on some compilers */
  579. union ieee802154_secattr_u sec;
  580. #endif
  581. };
  582. struct ieee802154_gts_info_s
  583. {
  584. uint8_t length : 4; /* Number of SF slots for GTS */
  585. uint8_t direction : 1; /* 0=transmit-only, 1=receive-only */
  586. uint8_t type : 1; /* 0=GTS deallocation, 1= GTS allocation */
  587. uint8_t reserved : 2;
  588. };
  589. enum ieee802154_scantype_e
  590. {
  591. IEEE802154_SCANTYPE_ED,
  592. IEEE802154_SCANTYPE_ACTIVE,
  593. IEEE802154_SCANTYPE_PASSIVE,
  594. IEEE802154_SCANTYPE_ORPHAN
  595. };
  596. struct ieee802154_frame_meta_s
  597. {
  598. enum ieee802154_addrmode_e srcmode; /* Source Address Mode */
  599. struct ieee802154_addr_s destaddr; /* Destination Address */
  600. uint8_t handle; /* User-specified handle identifier */
  601. struct
  602. {
  603. uint8_t ackreq : 1;
  604. uint8_t usegts : 1;
  605. uint8_t indirect : 1;
  606. } flags;
  607. #ifdef CONFIG_IEEE802154_SECURITY
  608. /* Security information if enabled */
  609. struct ieee802154_security_s security;
  610. #endif
  611. #ifdef CONFIG_IEEE802154_UWB
  612. /* The UWB Pulse Repetition Frequency to be used for the transmission */
  613. enum ieee802154_uwbprf_e uwbprf;
  614. /* The UWB preamble symbol repititions
  615. * Should be one of:
  616. * 0, 16, 64, 1024, 4096
  617. */
  618. uint16_t uwb_presym_rep;
  619. /* The UWB Data Rate to be used for the transmission */
  620. enum ieee802154_uwb_datarate_e datarate;
  621. #endif
  622. enum ieee802154_ranging_e ranging;
  623. };
  624. /* Primitive Semantics *******************************************************/
  625. /*****************************************************************************
  626. * Primitive: MCPS-DATA.confirm
  627. *
  628. * Description:
  629. * Reports the results of a request to transfer data to another device.
  630. *
  631. *****************************************************************************/
  632. struct ieee802154_data_conf_s
  633. {
  634. /* Each primitive must have a forward-link to a primitive to support lists */
  635. FAR struct ieee802154_primitive_s *flink;
  636. uint8_t handle; /* Handle assoc. with MSDU */
  637. /* The time, in symbols, at which the data were transmitted */
  638. uint32_t timestamp;
  639. enum ieee802154_status_e status; /* The status of the MSDU transmission */
  640. #ifdef CONFIG_IEEE802154_RANGING
  641. bool rng_rcvd; /* Ranging indicated by MSDU */
  642. /* A count of the time units corresponding to an RMARKER at the antenna at
  643. * the beginning of the ranging exchange
  644. */
  645. uint32_t rng_counter_start;
  646. /* A count of the time units corresponding to an RMARKER at the antenna at
  647. * end of the ranging exchange
  648. */
  649. uint32_t rng_counter_stop;
  650. /* A count of the time units in a message exchange over which the tracking
  651. * offset was measured
  652. */
  653. uint32_t rng_tracking_interval;
  654. /* A count of the time units slipped or advanced by the radio tracking
  655. * system over the course of the entire tracking interval
  656. */
  657. uint32_t rng_offset;
  658. /* The Figure of Merit (FoM) characterizing the ranging measurement */
  659. uint8_t rng_fom;
  660. #endif
  661. };
  662. /*****************************************************************************
  663. * Primitive: MCPS-DATA.indication
  664. *
  665. * Description:
  666. * Indicates the reception of data from another device.
  667. *
  668. *****************************************************************************/
  669. struct ieee802154_data_ind_s
  670. {
  671. /* Each primitive must have a forward-link to a primitive to support lists */
  672. FAR struct ieee802154_primitive_s *flink;
  673. FAR struct iob_s *frame;
  674. struct ieee802154_addr_s src; /* Source addressing information */
  675. struct ieee802154_addr_s dest; /* Destination addressing information */
  676. uint8_t lqi; /* Link Quality Index */
  677. uint8_t rssi; /* Non-standard field */
  678. uint8_t dsn; /* Data Sequence Number */
  679. uint32_t timestamp; /* Time of received frame */
  680. #ifdef CONFIG_IEEE802154_SECURITY
  681. /* Security information if enabled */
  682. struct ieee802154_security_s security;
  683. #endif /* CONFIG_IEEE802154_SECURITY */
  684. #ifdef CONFIG_IEEE802154_UWB
  685. /* The UWB Pulse Repetition Frequency to be used for the transmission */
  686. enum ieee802154_uwbprf_e uwb_prf;
  687. /* The UWB preamble symbol repititions
  688. * Should be one of:
  689. * 0, 16, 64, 1024, 4096
  690. */
  691. uint16_t uwb_presym_rep;
  692. /* The UWB Data Rate to be used for the transmission */
  693. enum ieee802154_uwb_datarate_e data_rate;
  694. #endif /* CONFIG_IEEE802154_UWB */
  695. #ifdef CONFIG_IEEE802154_RANGING
  696. bool rng_rcvd; /* Ranging indicated by MSDU */
  697. /* A count of the time units corresponding to an RMARKER at the antenna at
  698. * the beginning of the ranging exchange
  699. */
  700. uint32_t rng_counter_start;
  701. /* A count of the time units corresponding to an RMARKER at the antenna at
  702. * end of the ranging exchange
  703. */
  704. uint32_t rng_counter_stop;
  705. /* A count of the time units in a message exchange over which the tracking
  706. * offset was measured
  707. */
  708. uint34_t rng_tracking_interval;
  709. /* A count of the time units slipped or advanced by the radio tracking
  710. * system over the course of the entire tracking interval
  711. */
  712. uint32_t rng_offset;
  713. /* The Figure of Merit (FoM) characterizing the ranging measurement */
  714. uint8_t rng_fom;
  715. #endif /* CONFIG_IEEE802154_RANGING */
  716. };
  717. /*****************************************************************************
  718. * Primitive: MCPS-PURGE.request
  719. *
  720. * Description:
  721. * Allows the next higher layer to purge an MSDU from the transaction
  722. * queue.
  723. *
  724. *****************************************************************************/
  725. struct ieee802154_purge_req_s
  726. {
  727. /* Each primitive must have a forward-link to a primitive to support lists */
  728. FAR struct ieee802154_primitive_s *flink;
  729. uint8_t msdu_handle; /* Handle assoc. with MSDU */
  730. };
  731. /*****************************************************************************
  732. * Primitive: MLME-ASSOCIATE.request
  733. *
  734. * Description:
  735. * Used by a device to request an association with a coordinator.
  736. *
  737. *****************************************************************************/
  738. struct ieee802154_assoc_req_s
  739. {
  740. /* Each primitive must have a forward-link to a primitive to support lists */
  741. FAR struct ieee802154_primitive_s *flink;
  742. uint8_t chan; /* Channel number to attempt association */
  743. uint8_t chpage; /* Channel page to attempt association */
  744. /* TODO:
  745. * This is a non-standard field. I believe there is a catch 22 in the
  746. * standard and until I can figure it out, I'm adding this boolean to let
  747. * the application tell the MAC whether it is trying to associate with a
  748. * beacon enabled PAN or non-beacon enabled PAN. If it is beacon-enabled,
  749. * the MAC will track the beacon first before transmitting the
  750. * association. This can take some time depending on the beacon interval.
  751. * If the PAN is non-beacon enabled, the association request is sent
  752. * immediately via CSMA.
  753. *
  754. * The catch 22: The standard outlines the procedure for associating: reset
  755. * the MAC, scan to find PAN's and pass coordinator address info to
  756. * application, application calls associate passing address info of
  757. * coordinator. Which sounds good. The problem is that the primitive has no
  758. * field for determining if the PAN we are trying to join is beacon enabled
  759. * or not. Which means we don't know whether to tranmsit immediately or try
  760. * to track the beacon. The standard does say that ALL command frames should
  761. * be sent during the Contention Access Period (CAP), but how could you send
  762. * it at the right time, if you are not tracking the beacon. What's worse is
  763. * in the association section, it says if you are tracking the beacon, to
  764. * send the association request during the CAP. But how can you track the
  765. * beacon if you are not associated. Normally tracking the beacon would be
  766. * triggered by the SYNC.request primitive. But from my understanding that
  767. * primitive is intended to be used AFTER association since it requires the
  768. * MAC to already have a coordinator address and PAN ID so that it can track
  769. * the beacon frames properly. Which, of course, how could the MAC have that
  770. * info if it is not associated.
  771. */
  772. bool beacon;
  773. /* Coordinator Address with which to associate */
  774. struct ieee802154_addr_s coordaddr;
  775. /* Capabilities of associating device */
  776. struct ieee802154_capability_info_s capabilities;
  777. #ifdef CONFIG_IEEE802154_SECURITY
  778. /* Security information if enabled */
  779. struct ieee802154_security_s security;
  780. #endif
  781. };
  782. /*****************************************************************************
  783. * Primitive: MLME-ASSOCIATE.indication
  784. *
  785. * Description:
  786. * Used to indicate the reception of an association request command.
  787. *
  788. *****************************************************************************/
  789. struct ieee802154_assoc_ind_s
  790. {
  791. /* Each primitive must have a forward-link to a primitive to support lists */
  792. FAR struct ieee802154_primitive_s *flink;
  793. /* Address of device requesting association. Always in extended mode */
  794. uint8_t devaddr[IEEE802154_EADDRSIZE];
  795. /* Capabilities of associating device */
  796. struct ieee802154_capability_info_s capabilities;
  797. #ifdef CONFIG_IEEE802154_SECURITY
  798. /* Security information if enabled */
  799. struct ieee802154_security_s security;
  800. #endif
  801. };
  802. /*****************************************************************************
  803. * Primitive: MLME-ASSOCIATE.response
  804. *
  805. * Description:
  806. * Used to initiate a response to an MLME-ASSOCIATE.indication primitive.
  807. *
  808. *****************************************************************************/
  809. struct ieee802154_assoc_resp_s
  810. {
  811. /* Each primitive must have a forward-link to a primitive to support lists */
  812. FAR struct ieee802154_primitive_s *flink;
  813. /* Address of device requesting association. Always in extended mode */
  814. uint8_t devaddr[IEEE802154_EADDRSIZE];
  815. /* Address assigned to the device. 0xffff if failure */
  816. uint8_t assocsaddr[IEEE802154_SADDRSIZE];
  817. /* Status of association attempt */
  818. enum ieee802154_status_e status;
  819. #ifdef CONFIG_IEEE802154_SECURITY
  820. /* Security information if enabled */
  821. struct ieee802154_security_s security;
  822. #endif
  823. };
  824. /*****************************************************************************
  825. * Primitive: MLME-ASSOCIATE.confirm
  826. *
  827. * Description:
  828. * Used to inform the next higher layer of the initiating device whether
  829. * its request to associate was successful or unsuccessful.
  830. *
  831. *****************************************************************************/
  832. struct ieee802154_assoc_conf_s
  833. {
  834. /* Each primitive must have a forward-link to a primitive to support lists */
  835. FAR struct ieee802154_primitive_s *flink;
  836. /* Associated device address ALWAYS passed in short address mode. The
  837. * address will be IEEE802154_SADDR_UNSPEC if association was
  838. * unsuccessful.
  839. */
  840. uint8_t saddr[IEEE802154_SADDRSIZE];
  841. /* Status of association attempt */
  842. enum ieee802154_status_e status;
  843. #ifdef CONFIG_IEEE802154_SECURITY
  844. /* Security information if enabled */
  845. struct ieee802154_security_s security;
  846. #endif
  847. };
  848. /*****************************************************************************
  849. * Primitive: MLME-DISASSOCIATE.request
  850. *
  851. * Description:
  852. * Used by an associated device to notify the coordinator of its intent to
  853. * leave the PAN. It is also used by the coordinator to instruct an
  854. * associated device to leave the PAN.
  855. *
  856. *****************************************************************************/
  857. struct ieee802154_disassoc_req_s
  858. {
  859. /* Each primitive must have a forward-link to a primitive to support lists */
  860. FAR struct ieee802154_primitive_s *flink;
  861. /* Address of device to send disassociation notification */
  862. struct ieee802154_addr_s dev_addr;
  863. /* Reason for the disassosiation */
  864. enum ieee802154_status_e disassoc_reason;
  865. uint8_t tx_indirect; /* 0=Send Direct, 1=Send Indirect */
  866. #ifdef CONFIG_IEEE802154_SECURITY
  867. /* Security information if enabled */
  868. struct ieee802154_security_s security;
  869. #endif
  870. };
  871. /*****************************************************************************
  872. * Primitive: MLME-DISASSOCIATE.indication
  873. *
  874. * Description:
  875. * Used to indicate the reception of a disassociation notification command.
  876. *
  877. *****************************************************************************/
  878. struct ieee802154_disassoc_ind_s
  879. {
  880. /* Each primitive must have a forward-link to a primitive to support lists */
  881. FAR struct ieee802154_primitive_s *flink;
  882. /* Address of device requesting disassociation. Always extended mode */
  883. struct ieee802154_addr_s dev_addr;
  884. /* Reason for the disassosiation */
  885. enum ieee802154_status_e disassoc_reason;
  886. #ifdef CONFIG_IEEE802154_SECURITY
  887. /* Security information if enabled */
  888. struct ieee802154_security_s security;
  889. #endif
  890. };
  891. /*****************************************************************************
  892. * Primitive: MLME-DISASSOCIATE.confirm
  893. *
  894. * Description:
  895. * Reports the results of an MLME-DISASSOCIATE.request primitive.
  896. *
  897. *****************************************************************************/
  898. struct ieee802154_disassoc_conf_s
  899. {
  900. /* Each primitive must have a forward-link to a primitive to support lists */
  901. FAR struct ieee802154_primitive_s *flink;
  902. /* Status of the disassociation attempt */
  903. enum ieee802154_status_e status;
  904. /* Address of device either requesting or being intructed to disassociate */
  905. struct ieee802154_addr_s dev_addr;
  906. };
  907. /*****************************************************************************
  908. * Primitive: MLME-BEACONNOTIFY.indication
  909. *
  910. * Description:
  911. * Used to send parameters contained within a beacon frame received by
  912. * the MAC sublayer to the next higher layer when either macAutoRequest is
  913. * set to FALSE or when the beacon frame contains one or more octets of
  914. * payload. The primitive also sends a measure of the LQI and the time the
  915. * beacon frame was received.
  916. *
  917. *****************************************************************************/
  918. struct ieee802154_beacon_ind_s
  919. {
  920. /* Each primitive must have a forward-link to a primitive to support lists */
  921. FAR struct ieee802154_primitive_s *flink;
  922. uint8_t bsn; /* Beacon sequence number */
  923. /* PAN descriptor for the received beacon */
  924. struct ieee802154_pandesc_s pandesc;
  925. /* Beacon pending addresses */
  926. struct ieee802154_pendaddr_s pendaddr;
  927. uint8_t payloadlength; /* # of octets contained in the beacon payload */
  928. uint8_t payload[IEEE802154_MAX_BEACON_PAYLOAD_LEN];
  929. };
  930. /*****************************************************************************
  931. * Primitive: MLME-COMM-STATUS.indication
  932. *
  933. * Description:
  934. * Allows the MLME to indicate a communications status.
  935. *
  936. *****************************************************************************/
  937. struct ieee802154_commstatus_ind_s
  938. {
  939. /* Each primitive must have a forward-link to a primitive to support lists */
  940. FAR struct ieee802154_primitive_s *flink;
  941. struct ieee802154_addr_s src_addr;
  942. struct ieee802154_addr_s dest_addr;
  943. enum ieee802154_status_e status;
  944. #ifdef CONFIG_IEEE802154_SECURITY
  945. /* Security information if enabled */
  946. struct ieee802154_security_s security;
  947. #endif
  948. };
  949. /*****************************************************************************
  950. * Primitive: MLME-GTS.request
  951. *
  952. * Description:
  953. * Allows a device to send a request to the PAN coordinator to allocate a
  954. * new GTS or to deallocate an existing GTS. This primitive is also used
  955. * by the PAN coordinator to initiate a GTS deallocation.
  956. *
  957. *****************************************************************************/
  958. struct ieee802154_gts_req_s
  959. {
  960. /* Each primitive must have a forward-link to a primitive to support lists */
  961. FAR struct ieee802154_primitive_s *flink;
  962. struct ieee802154_gts_info_s gts_info;
  963. #ifdef CONFIG_IEEE802154_SECURITY
  964. /* Security information if enabled */
  965. struct ieee802154_security_s security;
  966. #endif
  967. };
  968. /*****************************************************************************
  969. * Primitive: MLME-GTS.confirm
  970. *
  971. * Description:
  972. * Reports the results of a request to allocate a new GTS or to deallocate
  973. * an existing GTS.
  974. *
  975. *****************************************************************************/
  976. struct ieee802154_gts_conf_s
  977. {
  978. /* Each primitive must have a forward-link to a primitive to support lists */
  979. FAR struct ieee802154_primitive_s *flink;
  980. struct ieee802154_gts_info_s gts_info;
  981. enum ieee802154_status_e status;
  982. };
  983. /*****************************************************************************
  984. * Primitive: MLME-GTS.indication
  985. *
  986. * Description:
  987. * Indicates that a GTS has been allocated or that a previously allocated
  988. * GTS has been deallocated.
  989. *
  990. *****************************************************************************/
  991. struct ieee802154_gts_ind_s
  992. {
  993. /* Each primitive must have a forward-link to a primitive to support lists */
  994. FAR struct ieee802154_primitive_s *flink;
  995. uint16_t dev_addr;
  996. struct ieee802154_gts_info_s gts_info;
  997. #ifdef CONFIG_IEEE802154_SECURITY
  998. /* Security information if enabled */
  999. struct ieee802154_security_s security;
  1000. #endif
  1001. };
  1002. /*****************************************************************************
  1003. * Primitive: MLME-ORPHAN.indication
  1004. *
  1005. * Description:
  1006. * Generated by the MLME of a coordinator and issued to its next higher
  1007. * layer on receipt of an orphan notification command.
  1008. *
  1009. *****************************************************************************/
  1010. struct ieee802154_orphan_ind_s
  1011. {
  1012. /* Each primitive must have a forward-link to a primitive to support lists */
  1013. FAR struct ieee802154_primitive_s *flink;
  1014. uint8_t orphan_addr[8];
  1015. #ifdef CONFIG_IEEE802154_SECURITY
  1016. /* Security information if enabled */
  1017. struct ieee802154_security_s security;
  1018. #endif
  1019. };
  1020. /*****************************************************************************
  1021. * Primitive: MLME-ORPHAN.response
  1022. *
  1023. * Description:
  1024. * Allows the next higher layer of a coordinator to respond to the
  1025. * MLME-ORPHAN.indication primitive.
  1026. *
  1027. *****************************************************************************/
  1028. struct ieee802154_orphan_resp_s
  1029. {
  1030. /* Each primitive must have a forward-link to a primitive to support lists */
  1031. FAR struct ieee802154_primitive_s *flink;
  1032. uint8_t orphan_addr[8];
  1033. #ifdef CONFIG_IEEE802154_SECURITY
  1034. /* Security information if enabled */
  1035. struct ieee802154_security_s security;
  1036. #endif
  1037. };
  1038. /*****************************************************************************
  1039. * Primitive: MLME-RESET.request
  1040. *
  1041. * Description:
  1042. * Used by the next higher layer to request that the MLME performs a reset
  1043. * operation.
  1044. *
  1045. *****************************************************************************/
  1046. struct ieee802154_reset_req_s
  1047. {
  1048. /* Each primitive must have a forward-link to a primitive to support lists */
  1049. FAR struct ieee802154_primitive_s *flink;
  1050. bool resetattr;
  1051. };
  1052. /*****************************************************************************
  1053. * Primitive: MLME-RXENABLE.request
  1054. *
  1055. * Description:
  1056. * Allows the next higher layer to request that the receiver is either
  1057. * enabled for a finite period of time or disabled.
  1058. *
  1059. *****************************************************************************/
  1060. struct ieee802154_rxenable_req_s
  1061. {
  1062. /* Each primitive must have a forward-link to a primitive to support lists */
  1063. FAR struct ieee802154_primitive_s *flink;
  1064. /* Number of symbols measured from the start of the superframe before the
  1065. * receiver is to be enabled or disabled.
  1066. */
  1067. uint32_t rxon_time;
  1068. /* Number of symbols for which the receiver is to be enabled */
  1069. uint32_t rxon_dur;
  1070. uint8_t defer_permit : 1; /* 0=Only attempt operation on current superframe
  1071. * 1=Operation can be deferred to next superframe */
  1072. uint8_t rng_rxctrl : 1; /* 0=RANGING_OFF, 1=RANGING_OFF */
  1073. };
  1074. /*****************************************************************************
  1075. * Primitive: MLME-RXENABLE.confirm
  1076. *
  1077. * Description:
  1078. * Reports the results of the attempt to enable or disable the receiver.
  1079. *
  1080. *****************************************************************************/
  1081. struct ieee802154_rxenable_conf_s
  1082. {
  1083. /* Each primitive must have a forward-link to a primitive to support lists */
  1084. FAR struct ieee802154_primitive_s *flink;
  1085. enum ieee802154_status_e status;
  1086. };
  1087. /*****************************************************************************
  1088. * Primitive: MLME-SCAN.request
  1089. *
  1090. * Description:
  1091. * Used to initiate a channel scan over a given list of channels.
  1092. *
  1093. *****************************************************************************/
  1094. struct ieee802154_scan_req_s
  1095. {
  1096. /* Each primitive must have a forward-link to a primitive to support lists */
  1097. FAR struct ieee802154_primitive_s *flink;
  1098. enum ieee802154_scantype_e type;
  1099. uint8_t duration;
  1100. uint8_t chpage;
  1101. uint8_t channels[15];
  1102. uint8_t numchan;
  1103. #ifdef CONFIG_IEEE802154_SECURITY
  1104. /* Security information if enabled */
  1105. struct ieee802154_security_s security;
  1106. #endif
  1107. };
  1108. /*****************************************************************************
  1109. * Primitive: MLME-SCAN.confirm
  1110. *
  1111. * Description:
  1112. * Reports the result of the channel scan request.
  1113. *
  1114. *****************************************************************************/
  1115. struct ieee802154_scan_conf_s
  1116. {
  1117. /* Each primitive must have a forward-link to a primitive to support lists */
  1118. FAR struct ieee802154_primitive_s *flink;
  1119. enum ieee802154_status_e status;
  1120. enum ieee802154_scantype_e type;
  1121. uint8_t chpage;
  1122. uint8_t chlist[15]; /* Used for both scanned channels (ED) and unscanned
  1123. * channels (Active/Passive) */
  1124. uint8_t numunscanned;
  1125. struct ieee802154_pandesc_s pandescs[MAC802154_NPANDESC];
  1126. uint8_t edlist[15];
  1127. uint8_t numresults;
  1128. };
  1129. /*****************************************************************************
  1130. * Primitive: MLME-GET.request
  1131. *
  1132. * Description:
  1133. * Requests information about a given PIB attribute.
  1134. *
  1135. *****************************************************************************/
  1136. struct ieee802154_get_req_s
  1137. {
  1138. /* Each primitive must have a forward-link to a primitive to support lists */
  1139. FAR struct ieee802154_primitive_s *flink;
  1140. enum ieee802154_attr_e attr;
  1141. union ieee802154_attr_u attrval;
  1142. };
  1143. /*****************************************************************************
  1144. * Primitive: MLME-SET.request
  1145. *
  1146. * Description:
  1147. * Attempts to write the given value to the indicated PIB attribute.
  1148. *
  1149. * NOTE: The standard specifies that confirmation should be indicated via
  1150. * the asynchronous MLME-SET.confirm primitive. However, in our
  1151. * implementation there is no reason not to synchronously return the status
  1152. * immediately. Therefore, we do merge the functionality of the
  1153. * MLME-SET.request and MLME-SET.confirm primitives together.
  1154. *
  1155. *****************************************************************************/
  1156. struct ieee802154_set_req_s
  1157. {
  1158. /* Each primitive must have a forward-link to a primitive to support lists */
  1159. FAR struct ieee802154_primitive_s *flink;
  1160. enum ieee802154_attr_e attr;
  1161. union ieee802154_attr_u attrval;
  1162. };
  1163. /*****************************************************************************
  1164. * Primitive: MLME-START.request
  1165. *
  1166. * Description:
  1167. * Used by the PAN coordinator to initiate a new PAN or to begin using a
  1168. * new superframe configuration. This primitive is also used by a device
  1169. * already associated with an existing PAN to begin using a new superframe
  1170. * configuration.
  1171. *
  1172. *****************************************************************************/
  1173. struct ieee802154_start_req_s
  1174. {
  1175. /* Each primitive must have a forward-link to a primitive to support lists */
  1176. FAR struct ieee802154_primitive_s *flink;
  1177. uint8_t panid[IEEE802154_PANIDSIZE];
  1178. uint8_t chan;
  1179. uint8_t chpage;
  1180. uint32_t starttime : 24;
  1181. uint32_t beaconorder : 8;
  1182. uint8_t superframeorder;
  1183. uint8_t pancoord : 1;
  1184. uint8_t battlifeext : 1;
  1185. uint8_t coordrealign : 1;
  1186. #ifdef CONFIG_IEEE802154_SECURITY
  1187. /* Security information if enabled */
  1188. struct ieee802154_security_s coordrealign;
  1189. struct ieee802154_security_s beacon;
  1190. #endif
  1191. };
  1192. /*****************************************************************************
  1193. * Primitive: MLME-START.confirm
  1194. *
  1195. * Description:
  1196. * Reports the results of the attempt to start using a new superframe
  1197. * configuration.
  1198. *
  1199. *****************************************************************************/
  1200. struct ieee802154_start_conf_s
  1201. {
  1202. /* Each primitive must have a forward-link to a primitive to support lists */
  1203. FAR struct ieee802154_primitive_s *flink;
  1204. enum ieee802154_status_e status;
  1205. };
  1206. /*****************************************************************************
  1207. * Primitive: MLME-SYNC.request
  1208. *
  1209. * Description:
  1210. * Requests to synchronize with the coordinator by acquiring and, if
  1211. * specified, tracking its beacons.
  1212. *
  1213. *****************************************************************************/
  1214. struct ieee802154_sync_req_s
  1215. {
  1216. /* Each primitive must have a forward-link to a primitive to support lists */
  1217. FAR struct ieee802154_primitive_s *flink;
  1218. uint8_t ch_num;
  1219. uint8_t ch_page;
  1220. bool track_beacon;
  1221. };
  1222. /*****************************************************************************
  1223. * Primitive: MLME-SYNC-LOSS.indication
  1224. *
  1225. * Description:
  1226. * Indicates the loss of synchronization with a coordinator.
  1227. *
  1228. *****************************************************************************/
  1229. struct ieee802154_syncloss_ind_s
  1230. {
  1231. /* Each primitive must have a forward-link to a primitive to support lists */
  1232. FAR struct ieee802154_primitive_s *flink;
  1233. enum ieee802154_status_e loss_reason;
  1234. uint16_t pan_id;
  1235. uint8_t ch_num;
  1236. uint8_t ch_page;
  1237. #ifdef CONFIG_IEEE802154_SECURITY
  1238. /* Security information if enabled */
  1239. struct ieee802154_security_s security;
  1240. #endif
  1241. };
  1242. /*****************************************************************************
  1243. * Primitive: MLME-POLL.request
  1244. *
  1245. * Description:
  1246. * Prompts the device to request data from the coordinator.
  1247. *
  1248. *****************************************************************************/
  1249. struct ieee802154_poll_req_s
  1250. {
  1251. /* Each primitive must have a forward-link to a primitive to support lists */
  1252. FAR struct ieee802154_primitive_s *flink;
  1253. struct ieee802154_addr_s coordaddr;
  1254. #ifdef CONFIG_IEEE802154_SECURITY
  1255. /* Security information if enabled */
  1256. struct ieee802154_security_s security;
  1257. #endif
  1258. };
  1259. /*****************************************************************************
  1260. * Primitive: MLME-POLL.confirm
  1261. *
  1262. * Description:
  1263. * Reports the results of a request to poll the coordinator for data.
  1264. *
  1265. *****************************************************************************/
  1266. struct ieee802154_poll_conf_s
  1267. {
  1268. /* Each primitive must have a forward-link to a primitive to support lists */
  1269. FAR struct ieee802154_primitive_s *flink;
  1270. enum ieee802154_status_e status;
  1271. };
  1272. /* MAC Service Primitives */
  1273. enum ieee802154_primitive_e
  1274. {
  1275. /* MCPS Notifications */
  1276. IEEE802154_PRIMITIVE_CONF_DATA = 0x00,
  1277. IEEE802154_PRIMITIVE_IND_DATA,
  1278. /* MLME Notifications */
  1279. IEEE802154_PRIMITIVE_CONF_ASSOC,
  1280. IEEE802154_PRIMITIVE_CONF_DISASSOC,
  1281. IEEE802154_PRIMITIVE_CONF_GTS,
  1282. IEEE802154_PRIMITIVE_CONF_RESET,
  1283. IEEE802154_PRIMITIVE_CONF_RXENABLE,
  1284. IEEE802154_PRIMITIVE_CONF_SCAN,
  1285. IEEE802154_PRIMITIVE_CONF_START,
  1286. IEEE802154_PRIMITIVE_CONF_POLL,
  1287. IEEE802154_PRIMITIVE_IND_ASSOC,
  1288. IEEE802154_PRIMITIVE_IND_DISASSOC,
  1289. IEEE802154_PRIMITIVE_IND_BEACONNOTIFY,
  1290. IEEE802154_PRIMITIVE_IND_GTS,
  1291. IEEE802154_PRIMITIVE_IND_ORPHAN,
  1292. IEEE802154_PRIMITIVE_IND_COMMSTATUS,
  1293. IEEE802154_PRIMITIVE_IND_SYNCLOSS
  1294. };
  1295. union ieee802154_primitive_u
  1296. {
  1297. /* MCPS Primitives */
  1298. struct ieee802154_data_conf_s dataconf;
  1299. struct ieee802154_data_ind_s dataind;
  1300. /* MLME Primitives */
  1301. struct ieee802154_assoc_conf_s assocconf;
  1302. struct ieee802154_disassoc_conf_s disassocconf;
  1303. struct ieee802154_gts_conf_s gtsconf;
  1304. struct ieee802154_rxenable_conf_s rxenableconf;
  1305. struct ieee802154_scan_conf_s scanconf;
  1306. struct ieee802154_start_conf_s startconf;
  1307. struct ieee802154_poll_conf_s pollconf;
  1308. struct ieee802154_assoc_ind_s assocind;
  1309. struct ieee802154_disassoc_ind_s disassocind;
  1310. struct ieee802154_beacon_ind_s beaconind;
  1311. struct ieee802154_gts_ind_s gtsind;
  1312. struct ieee802154_orphan_ind_s orphanind;
  1313. struct ieee802154_commstatus_ind_s commstatusind;
  1314. struct ieee802154_syncloss_ind_s synclossind;
  1315. /* Forward link contained as first entry of all primitives */
  1316. FAR struct ieee802154_primitive_s *flink;
  1317. };
  1318. struct ieee802154_primitive_s
  1319. {
  1320. /* Must be first member so that we can interchange between the actual
  1321. * primitive and this extended struct. Note, all frames also have the
  1322. * first entry as a forward link to a primitive so that primitives can be
  1323. * contained in lists.
  1324. */
  1325. union ieee802154_primitive_u u;
  1326. enum ieee802154_primitive_e type;
  1327. int nclients; /* Number of clients to call ieee802154_primitive_free before freed */
  1328. };
  1329. /* A pointer to this structure is passed as the argument of each IOCTL
  1330. * command.
  1331. */
  1332. union ieee802154_macarg_u
  1333. {
  1334. struct ieee802154_assoc_req_s assocreq; /* MAC802154IOC_MLME_ASSOC_REQUEST */
  1335. struct ieee802154_assoc_resp_s assocresp; /* MAC802154IOC_MLME_ASSOC_RESPONSE */
  1336. struct ieee802154_disassoc_req_s disassocreq; /* MAC802154IOC_MLME_DISASSOC_REQUEST */
  1337. struct ieee802154_get_req_s getreq; /* MAC802154IOC_MLME_GET_REQUEST */
  1338. struct ieee802154_gts_req_s gtsreq; /* MAC802154IOC_MLME_GTS_REQUEST */
  1339. struct ieee802154_orphan_resp_s orphanresp; /* MAC802154IOC_MLME_ORPHAN_RESPONSE */
  1340. struct ieee802154_reset_req_s resetreq; /* MAC802154IOC_MLME_RESET_REQUEST */
  1341. struct ieee802154_rxenable_req_s rxenabreq; /* MAC802154IOC_MLME_RXENABLE_REQUEST */
  1342. struct ieee802154_scan_req_s scanreq; /* MAC802154IOC_MLME_SCAN_REQUEST */
  1343. struct ieee802154_set_req_s setreq; /* MAC802154IOC_MLME_SET_REQUEST */
  1344. struct ieee802154_start_req_s startreq; /* MAC802154IOC_MLME_START_REQUEST */
  1345. struct ieee802154_sync_req_s syncreq; /* MAC802154IOC_MLME_SYNC_REQUEST */
  1346. struct ieee802154_poll_req_s pollreq; /* MAC802154IOC_MLME_POLL_REQUEST */
  1347. /* MAC802154IOC_MLME_DPS_REQUEST */
  1348. /* MAC802154IOC_MLME_SOUNDING_REQUEST */
  1349. /* MAC802154IOC_MLME_CALIBRATE_REQUEST */
  1350. struct sigevent event; /* MAC802154IOC_NOTIFY_REGISTER */
  1351. struct ieee802154_primitive_s primitive; /* MAC802154IOC_GET_EVENT */
  1352. bool enable; /* MAC802154IOC_ENABLE_EVENTS */
  1353. };
  1354. #if defined(CONFIG_NET_6LOWPAN) || defined(CONFIG_NET_IEEE802154)
  1355. /* For the case of network IOCTLs, the network IOCTL to the MAC network
  1356. * driver will include a device name like "wpan0" as the destination of
  1357. * the IOCTL command.
  1358. */
  1359. struct ieee802154_netmac_s
  1360. {
  1361. char ifr_name[IFNAMSIZ]; /* Interface name, e.g. "wpan0" */
  1362. union ieee802154_macarg_u u; /* Data payload */
  1363. };
  1364. #endif
  1365. /* This is an opaque reference to the MAC's internal private state. It is
  1366. * returned by mac802154_create() when it is created. It may then be used
  1367. * at other interfaces in order to interact with the MAC.
  1368. */
  1369. typedef FAR void *MACHANDLE;
  1370. #ifdef __cplusplus
  1371. #define EXTERN extern "C"
  1372. extern "C"
  1373. {
  1374. #else
  1375. #define EXTERN extern
  1376. #endif
  1377. /*****************************************************************************
  1378. * Public Function Prototypes
  1379. *****************************************************************************/
  1380. struct ieee802154_radio_s; /* Forward reference */
  1381. /*****************************************************************************
  1382. * Name: mac802154_create
  1383. *
  1384. * Description:
  1385. * Create a 802.15.4 MAC device from a 802.15.4 compatible radio device.
  1386. *
  1387. * The returned MAC structure should be passed to either the next highest
  1388. * layer in the network stack, or registered with a mac802154dev character
  1389. * or network drivers. In any of these scenarios, the next highest layer
  1390. * should register a set of callbacks with the MAC layer by setting the
  1391. * mac->cbs member.
  1392. *
  1393. * NOTE: This API does not create any device accessible to userspace. If you
  1394. * want to call these APIs from userspace, you have to wrap your mac in a
  1395. * character device via mac802154_device.c.
  1396. *
  1397. * Input Parameters:
  1398. * radiodev - an instance of an IEEE 802.15.4 radio
  1399. *
  1400. * Returned Value:
  1401. * An opaque reference to the MAC state data.
  1402. *
  1403. *****************************************************************************/
  1404. MACHANDLE mac802154_create(FAR struct ieee802154_radio_s *radiodev);
  1405. /*****************************************************************************
  1406. * Name: mac802154dev_register
  1407. *
  1408. * Description:
  1409. * Register a character driver to access the IEEE 802.15.4 MAC layer from
  1410. * user-space
  1411. *
  1412. * Input Parameters:
  1413. * mac - Pointer to the mac layer struct to be registered.
  1414. * minor - The device minor number. The IEEE802.15.4 MAC character device
  1415. * will be registered as /dev/ieeeN where N is the minor number
  1416. *
  1417. * Returned Value:
  1418. * Zero (OK) is returned on success. Otherwise a negated errno value is
  1419. * returned to indicate the nature of the failure.
  1420. *
  1421. *****************************************************************************/
  1422. int mac802154dev_register(MACHANDLE mac, int minor);
  1423. /*****************************************************************************
  1424. * Name: mac802154netdev_register
  1425. *
  1426. * Description:
  1427. * Register a network driver to access the IEEE 802.15.4 MAC layer from
  1428. * a socket using 6LoWPAN
  1429. *
  1430. * Input Parameters:
  1431. * mac - Pointer to the mac layer struct to be registered.
  1432. *
  1433. * Returned Value:
  1434. * Zero (OK) is returned on success. Otherwise a negated errno value is
  1435. * returned to indicate the nature of the failure.
  1436. *
  1437. *****************************************************************************/
  1438. int mac802154netdev_register(MACHANDLE mac);
  1439. /*****************************************************************************
  1440. * Name: ieee802154_primitivepool_initialize
  1441. *
  1442. * Description:
  1443. * This function initializes the primitive allocator. Primitives are
  1444. * defined in the standard and are used to pass information between the
  1445. * MAC layer and the next highest layer. They are a data type abstraction.
  1446. * This function must be called early in the initialization sequence
  1447. * before any radios begin operation.
  1448. *
  1449. * Input Parameters:
  1450. * None
  1451. *
  1452. * Returned Value:
  1453. * None
  1454. *
  1455. *****************************************************************************/
  1456. void ieee802154_primitivepool_initialize(void);
  1457. /*****************************************************************************
  1458. * Name: ieee802154_primitive_allocate
  1459. *
  1460. * Description:
  1461. * The ieee802154_primitive_allocate function will get a free primitive
  1462. * structure from the pool, for use with the IEEE 802.15.4 MAC.
  1463. *
  1464. * Interrupt handling logic will first attempt to allocate from the
  1465. * g_primfree list. If that list is empty, it will attempt to allocate
  1466. * from its reserve, g_primfree_irq. If that list is empty, then the
  1467. * allocation fails (NULL is returned).
  1468. *
  1469. * Non-interrupt handler logic will attempt to allocate from g_primfree
  1470. * list. If that the list is empty, then the primitive structure will be
  1471. * allocated from the dynamic memory pool.
  1472. *
  1473. * Input Parameters:
  1474. * None
  1475. *
  1476. * Returned Value:
  1477. * A reference to the allocated primitive structure. All user fields in
  1478. * this structure have been zeroed. On a failure to allocate, NULL is
  1479. * returned.
  1480. *
  1481. *****************************************************************************/
  1482. FAR struct ieee802154_primitive_s *ieee802154_primitive_allocate(void);
  1483. /*****************************************************************************
  1484. * Name: ieee802154_primitive_free
  1485. *
  1486. * Description:
  1487. * The ieee802154_primitive_free function will return a primitive
  1488. * structure to the free pool if it was a pre-allocated primitive
  1489. * structure. If the primitive was allocated dynamically it will be
  1490. * deallocated.
  1491. *
  1492. * Input Parameters:
  1493. * prim - primitive structure to free
  1494. *
  1495. * Returned Value:
  1496. * None
  1497. *
  1498. *****************************************************************************/
  1499. void ieee802154_primitive_free(FAR struct ieee802154_primitive_s *prim);
  1500. #undef EXTERN
  1501. #ifdef __cplusplus
  1502. }
  1503. #endif
  1504. #endif /* __INCLUDE_NUTTX_WIRELESS_IEEE802154_IEEE802154_MAC_H */