mac_mlme_disassociate.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. /**
  2. * Copyright (c) 2016 - 2020 Nordic Semiconductor ASA and Luxoft Global Operations Gmbh.
  3. *
  4. * All Rights Reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without modification,
  7. * are permitted provided that the following conditions are met:
  8. *
  9. *
  10. * 1. Redistributions of source code must retain the above copyright notice, this
  11. * list of conditions and the following disclaimer.
  12. *
  13. * 2. Redistributions in binary form, except as embedded into a Nordic
  14. * Semiconductor ASA integrated circuit in a product or a software update for
  15. * such product, must reproduce the above copyright notice, this list of
  16. * conditions and the following disclaimer in the documentation and/or other
  17. * materials provided with the distribution.
  18. *
  19. * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
  20. * contributors may be used to endorse or promote products derived from this
  21. * software without specific prior written permission.
  22. *
  23. * 4. This software, with or without modification, must only be used with a
  24. * Nordic Semiconductor ASA integrated circuit.
  25. *
  26. * 5. Any software provided in binary form under this license must not be reverse
  27. * engineered, decompiled, modified and/or disassembled.
  28. *
  29. *
  30. * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
  31. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  32. * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
  33. * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
  34. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  35. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  36. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  37. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  38. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  39. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  40. *
  41. */
  42. #ifndef MAC_MLME_DISASSOCIATE_H_INCLUDED
  43. #define MAC_MLME_DISASSOCIATE_H_INCLUDED
  44. #if (CONFIG_DISASSOCIATE_ENABLED == 1)
  45. #include <stdint.h>
  46. #include <stdbool.h>
  47. #include "mac_common.h"
  48. #include "mac_task_scheduler.h"
  49. /** @file
  50. * The MAC MLME Disassociate module declares the MAC disassociation routines and
  51. * necessary types/macros according to the MAC specification.
  52. *
  53. * @defgroup mac_diassociate MAC MLME Disassociate API
  54. * @ingroup mac_15_4
  55. * @{
  56. * @brief Module to declare MAC MLME Disassociate API.
  57. * @details The MLME Disassociation module declares Disassociation MAC routines and necessary types
  58. * according to the MAC specification. More specifically, MLME Disassociation request aka
  59. * mlme_disassociate_req(), MLME Disassociation confirm callback typedef aka
  60. * mlme_disassociate_conf_cb_t, and MLME Disassociation indication as mlme_disassociate_ind()
  61. * primitives are declared.
  62. */
  63. /**
  64. * @brief MAC Disassociation Reason field
  65. *
  66. * In accordance with IEEE Std 802.15.4-2006, section 7.3.2.2
  67. */
  68. typedef enum
  69. {
  70. /** The coordinator wishes the device to leave the PAN. */
  71. MAC_COORD_REASON = 1,
  72. /** The device wishes to leave the PAN. */
  73. MAC_DEV_REASON = 2
  74. } mac_disassociate_reason_t;
  75. /**
  76. * @brief MLME-DISASSOCIATE.confirm
  77. *
  78. * @details On receipt of the MLME-DISASSOCIATE.confirm primitive, the next
  79. * higher layer of the initiating device is notified of the result of the
  80. * disassociation attempt. If the disassociation attempt was successful,
  81. * the status parameter will be set to SUCCESS. Otherwise, the status parameter
  82. * indicates the error.
  83. *
  84. * In accordance with IEEE Std 802.15.4-2006, section 7.1.4.3
  85. */
  86. typedef struct
  87. {
  88. mac_status_t status; /**< Status of operation. */
  89. mac_addr_mode_t device_addr_mode; /**< Device addressing mode. */
  90. uint16_t device_pan_id; /**< Device PAN ID. */
  91. mac_addr_t device_address; /**< Device address. */
  92. } mlme_disassociate_conf_t;
  93. /**
  94. * @brief MLME-DISASSOCIATE.request
  95. *
  96. * @details The MLME-DISASSOCIATE.request primitive is generated by the next
  97. * higher layer of an associated device and issued to its MLME to request
  98. * disassociation from the PAN. It is also generated by the next higher layer
  99. * of the coordinator and issued to its MLME to instruct an
  100. * associated device to leave the PAN.
  101. *
  102. * In accordance with IEEE Std 802.15.4-2006, section 7.1.4.1
  103. */
  104. typedef struct
  105. {
  106. /** Do not edit this field. */
  107. mac_abstract_req_t service;
  108. /** Confirm to this request. */
  109. mlme_disassociate_conf_t confirm;
  110. mac_addr_mode_t device_addr_mode; /**< Device addressing mode. */
  111. uint16_t device_pan_id; /**< Device PAN ID. */
  112. mac_addr_t device_address; /**< Device address. */
  113. mac_disassociate_reason_t disassociate_reason; /**< Disassociation reason. */
  114. bool tx_indirect; /**< Is TX indirect? */
  115. #if (CONFIG_SECURE == 1)
  116. uint8_t security_level; /**< Security level. */
  117. uint8_t key_id_mode; /**< Key ID mode. */
  118. uint64_t key_source; /**< Key source. */
  119. uint8_t key_index; /**< Key index. */
  120. #endif
  121. } mlme_disassociate_req_t;
  122. /**
  123. * @brief MLME-DISASSOCIATE.indication
  124. *
  125. * @details Is generated by the MLME and issued to its next higher
  126. * layer on receipt of a disassociation notification command.
  127. *
  128. * In accordance with IEEE Std 802.15.4-2006, section 7.1.4.2
  129. */
  130. typedef struct
  131. {
  132. uint64_t device_address; /**< Device address. */
  133. mac_disassociate_reason_t disassociate_reason; /**< Disassociation reason. */
  134. #if (CONFIG_SECURE == 1)
  135. uint8_t security_level; /**< Security level. */
  136. uint8_t key_id_mode; /**< Key ID mode. */
  137. uint64_t key_source; /**< Key source. */
  138. uint8_t key_index; /**< Key index. */
  139. #endif
  140. } mlme_disassociate_ind_t;
  141. /**
  142. * @brief Customer's function of confirmation
  143. *
  144. * @details The MLME-DISASSOCIATE.confirm primitive is generated by the initiating
  145. * MLME and issued to its next higher layer in response to an MLME-DISASSOCIATE.request
  146. * primitive. This primitive returns a status of either SUCCESS, indicating that the
  147. * disassociation request was successful, or the appropriate error code.
  148. * The status values are fully described in 7.1.4.1.3 and subclauses referenced by 7.1.4.1.3.
  149. *
  150. * @param pointer to confirmation primitive
  151. */
  152. typedef void (* mlme_disassociate_conf_cb_t)(mlme_disassociate_conf_t *);
  153. /**
  154. * @brief MLME-DISASSOCIATE request
  155. *
  156. * @details Request disassociation with a PAN
  157. * After request completion, user callback will be issued with
  158. * valid data stored in structure @ref mlme_disassociate_conf_t.
  159. *
  160. * @param req MLME_DISASSOCIATE request structure.
  161. * @param conf_cb pointer to user callback.
  162. *
  163. * In accordance with IEEE Std 802.15.4-2006, section 7.1.4.4
  164. */
  165. void mlme_disassociate_req(mlme_disassociate_req_t * req, mlme_disassociate_conf_cb_t conf_cb);
  166. /**
  167. * @brief MLME-DISASSOCIATE indication handler
  168. *
  169. * @details Indicates an disassociation with a PAN
  170. *
  171. * @param ind MLME_DISASSOCIATE indication structure.
  172. *
  173. * In accordance with IEEE Std 802.15.4-2006, section 7.1.4.4
  174. */
  175. extern void mlme_disassociate_ind(mlme_disassociate_ind_t * ind);
  176. /** @} */
  177. #endif // (CONFIG_DISASSOCIATE_ENABLED == 1)
  178. #endif // MAC_MLME_DISASSOCIATE_H_INCLUDED