ieee802154.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. * IEEE802.15.4-2003 specification
  3. *
  4. * Copyright (C) 2007, 2008 Siemens AG
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2
  8. * as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18. *
  19. * Written by:
  20. * Pavel Smolenskiy <pavel.smolenskiy@gmail.com>
  21. * Maxim Gorbachyov <maxim.gorbachev@siemens.com>
  22. * Maxim Osipov <maxim.osipov@siemens.com>
  23. * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
  24. */
  25. #ifndef NET_IEEE802154_H
  26. #define NET_IEEE802154_H
  27. #define IEEE802154_FC_TYPE_BEACON 0x0 /* Frame is beacon */
  28. #define IEEE802154_FC_TYPE_DATA 0x1 /* Frame is data */
  29. #define IEEE802154_FC_TYPE_ACK 0x2 /* Frame is acknowledgment */
  30. #define IEEE802154_FC_TYPE_MAC_CMD 0x3 /* Frame is MAC command */
  31. #define IEEE802154_FC_TYPE_SHIFT 0
  32. #define IEEE802154_FC_TYPE_MASK ((1 << 3) - 1)
  33. #define IEEE802154_FC_TYPE(x) ((x & IEEE802154_FC_TYPE_MASK) >> IEEE802154_FC_TYPE_SHIFT)
  34. #define IEEE802154_FC_SET_TYPE(v, x) do { \
  35. v = (((v) & ~IEEE802154_FC_TYPE_MASK) | \
  36. (((x) << IEEE802154_FC_TYPE_SHIFT) & IEEE802154_FC_TYPE_MASK)); \
  37. } while (0)
  38. #define IEEE802154_FC_SECEN (1 << 3)
  39. #define IEEE802154_FC_FRPEND (1 << 4)
  40. #define IEEE802154_FC_ACK_REQ (1 << 5)
  41. #define IEEE802154_FC_INTRA_PAN (1 << 6)
  42. #define IEEE802154_FC_SAMODE_SHIFT 14
  43. #define IEEE802154_FC_SAMODE_MASK (3 << IEEE802154_FC_SAMODE_SHIFT)
  44. #define IEEE802154_FC_DAMODE_SHIFT 10
  45. #define IEEE802154_FC_DAMODE_MASK (3 << IEEE802154_FC_DAMODE_SHIFT)
  46. #define IEEE802154_FC_SAMODE(x) \
  47. (((x) & IEEE802154_FC_SAMODE_MASK) >> IEEE802154_FC_SAMODE_SHIFT)
  48. #define IEEE802154_FC_DAMODE(x) \
  49. (((x) & IEEE802154_FC_DAMODE_MASK) >> IEEE802154_FC_DAMODE_SHIFT)
  50. /* MAC's Command Frames Identifiers */
  51. #define IEEE802154_CMD_ASSOCIATION_REQ 0x01
  52. #define IEEE802154_CMD_ASSOCIATION_RESP 0x02
  53. #define IEEE802154_CMD_DISASSOCIATION_NOTIFY 0x03
  54. #define IEEE802154_CMD_DATA_REQ 0x04
  55. #define IEEE802154_CMD_PANID_CONFLICT_NOTIFY 0x05
  56. #define IEEE802154_CMD_ORPHAN_NOTIFY 0x06
  57. #define IEEE802154_CMD_BEACON_REQ 0x07
  58. #define IEEE802154_CMD_COORD_REALIGN_NOTIFY 0x08
  59. #define IEEE802154_CMD_GTS_REQ 0x09
  60. /*
  61. * The return values of MAC operations
  62. */
  63. enum {
  64. /*
  65. * The requested operation was completed successfully.
  66. * For a transmission request, this value indicates
  67. * a successful transmission.
  68. */
  69. IEEE802154_SUCCESS = 0x0,
  70. /* The beacon was lost following a synchronization request. */
  71. IEEE802154_BEACON_LOSS = 0xe0,
  72. /*
  73. * A transmission could not take place due to activity on the
  74. * channel, i.e., the CSMA-CA mechanism has failed.
  75. */
  76. IEEE802154_CHNL_ACCESS_FAIL = 0xe1,
  77. /* The GTS request has been denied by the PAN coordinator. */
  78. IEEE802154_DENINED = 0xe2,
  79. /* The attempt to disable the transceiver has failed. */
  80. IEEE802154_DISABLE_TRX_FAIL = 0xe3,
  81. /*
  82. * The received frame induces a failed security check according to
  83. * the security suite.
  84. */
  85. IEEE802154_FAILED_SECURITY_CHECK = 0xe4,
  86. /*
  87. * The frame resulting from secure processing has a length that is
  88. * greater than aMACMaxFrameSize.
  89. */
  90. IEEE802154_FRAME_TOO_LONG = 0xe5,
  91. /*
  92. * The requested GTS transmission failed because the specified GTS
  93. * either did not have a transmit GTS direction or was not defined.
  94. */
  95. IEEE802154_INVALID_GTS = 0xe6,
  96. /*
  97. * A request to purge an MSDU from the transaction queue was made using
  98. * an MSDU handle that was not found in the transaction table.
  99. */
  100. IEEE802154_INVALID_HANDLE = 0xe7,
  101. /* A parameter in the primitive is out of the valid range.*/
  102. IEEE802154_INVALID_PARAMETER = 0xe8,
  103. /* No acknowledgment was received after aMaxFrameRetries. */
  104. IEEE802154_NO_ACK = 0xe9,
  105. /* A scan operation failed to find any network beacons.*/
  106. IEEE802154_NO_BEACON = 0xea,
  107. /* No response data were available following a request. */
  108. IEEE802154_NO_DATA = 0xeb,
  109. /* The operation failed because a short address was not allocated. */
  110. IEEE802154_NO_SHORT_ADDRESS = 0xec,
  111. /*
  112. * A receiver enable request was unsuccessful because it could not be
  113. * completed within the CAP.
  114. */
  115. IEEE802154_OUT_OF_CAP = 0xed,
  116. /*
  117. * A PAN identifier conflict has been detected and communicated to the
  118. * PAN coordinator.
  119. */
  120. IEEE802154_PANID_CONFLICT = 0xee,
  121. /* A coordinator realignment command has been received. */
  122. IEEE802154_REALIGMENT = 0xef,
  123. /* The transaction has expired and its information discarded. */
  124. IEEE802154_TRANSACTION_EXPIRED = 0xf0,
  125. /* There is no capacity to store the transaction. */
  126. IEEE802154_TRANSACTION_OVERFLOW = 0xf1,
  127. /*
  128. * The transceiver was in the transmitter enabled state when the
  129. * receiver was requested to be enabled.
  130. */
  131. IEEE802154_TX_ACTIVE = 0xf2,
  132. /* The appropriate key is not available in the ACL. */
  133. IEEE802154_UNAVAILABLE_KEY = 0xf3,
  134. /*
  135. * A SET/GET request was issued with the identifier of a PIB attribute
  136. * that is not supported.
  137. */
  138. IEEE802154_UNSUPPORTED_ATTR = 0xf4,
  139. /*
  140. * A request to perform a scan operation failed because the MLME was
  141. * in the process of performing a previously initiated scan operation.
  142. */
  143. IEEE802154_SCAN_IN_PROGRESS = 0xfc,
  144. };
  145. #endif