AddrMgr.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. /**************************************************************************************************
  2. Filename: AddrMgr.h
  3. Revised: $Date: 2009-03-12 16:25:22 -0700 (Thu, 12 Mar 2009) $
  4. Revision: $Revision: 19404 $
  5. Description: This file contains the interface to the Address Manager.
  6. Copyright 2005-2007 Texas Instruments Incorporated. All rights reserved.
  7. IMPORTANT: Your use of this Software is limited to those specific rights
  8. granted under the terms of a software license agreement between the user
  9. who downloaded the software, his/her employer (which must be your employer)
  10. and Texas Instruments Incorporated (the "License"). You may not use this
  11. Software unless you agree to abide by the terms of the License. The License
  12. limits your use, and you acknowledge, that the Software may not be modified,
  13. copied or distributed unless embedded on a Texas Instruments microcontroller
  14. or used solely and exclusively in conjunction with a Texas Instruments radio
  15. frequency transceiver, which is integrated into your product. Other than for
  16. the foregoing purpose, you may not use, reproduce, copy, prepare derivative
  17. works of, modify, distribute, perform, display or sell this Software and/or
  18. its documentation for any purpose.
  19. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  20. PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  21. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  22. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  23. TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
  24. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  25. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  26. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  27. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  28. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  29. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  30. Should you have any questions regarding your right to use this Software,
  31. contact Texas Instruments Incorporated at www.TI.com.
  32. **************************************************************************************************/
  33. #ifndef ADDRMGR_H
  34. #define ADDRMGR_H
  35. #ifdef __cplusplus
  36. extern "C"
  37. {
  38. #endif
  39. /******************************************************************************
  40. * INCLUDES
  41. */
  42. #include "ZComDef.h"
  43. /******************************************************************************
  44. * CONSTANTS
  45. */
  46. // registration IDs - use with <AddrMgrRegister>
  47. #define ADDRMGR_REG_ASSOC 0x00
  48. #define ADDRMGR_REG_SECURITY 0x01
  49. #define ADDRMGR_REG_BINDING 0x02
  50. #define ADDRMGR_REG_PRIVATE1 0x03
  51. // user IDs - use with <AddrMgrEntry_t>
  52. #define ADDRMGR_USER_DEFAULT 0x00
  53. #define ADDRMGR_USER_ASSOC 0x01
  54. #define ADDRMGR_USER_SECURITY 0x02
  55. #define ADDRMGR_USER_BINDING 0x04
  56. #define ADDRMGR_USER_PRIVATE1 0x08
  57. // update types - use with registered callback <AddrMgrUserCB_t>
  58. #define ADDRMGR_ENTRY_NWKADDR_SET 1
  59. #define ADDRMGR_ENTRY_NWKADDR_DUP 2
  60. #define ADDRMGR_ENTRY_EXTADDR_SET 3
  61. // address manager callback feature enable/disable
  62. #define ADDRMGR_CALLBACK_ENABLED 0
  63. /******************************************************************************
  64. * TYPEDEFS
  65. */
  66. // entry data
  67. typedef struct
  68. {
  69. uint8 user;
  70. uint16 nwkAddr;
  71. uint8 extAddr[Z_EXTADDR_LEN];
  72. uint16 index;
  73. } AddrMgrEntry_t;
  74. // user callback set during registration
  75. typedef void (*AddrMgrUserCB_t)( uint8 update,
  76. AddrMgrEntry_t* newEntry,
  77. AddrMgrEntry_t* oldEntry );
  78. /******************************************************************************
  79. * PUBLIC FUNCTIONS
  80. */
  81. /******************************************************************************
  82. * @fn AddrMgrInit
  83. *
  84. * @brief Initialize Address Manager.
  85. *
  86. * @param entryTotal - [in] total number of address entries
  87. *
  88. * @return none
  89. */
  90. extern void AddrMgrInit( uint16 entryTotal );
  91. /******************************************************************************
  92. * @fn AddrMgrInitNV
  93. *
  94. * @brief Initialize the address entry data in NV.
  95. *
  96. * @param none
  97. *
  98. * @return uint8 - <osal_nv_item_init> return codes
  99. */
  100. extern uint8 AddrMgrInitNV( void );
  101. /******************************************************************************
  102. * @fn AddrMgrSetDefaultNV
  103. *
  104. * @brief Set default address entry data in NV.
  105. *
  106. * @param none
  107. *
  108. * @return none
  109. */
  110. extern void AddrMgrSetDefaultNV( void );
  111. /******************************************************************************
  112. * @fn AddrMgrRestoreFromNV
  113. *
  114. * @brief Restore the address entry data from NV.
  115. *
  116. * @param none
  117. *
  118. * @return none
  119. */
  120. extern void AddrMgrRestoreFromNV( void );
  121. /******************************************************************************
  122. * @fn AddrMgrWriteNV
  123. *
  124. * @brief Save the address entry data to NV.
  125. *
  126. * @param none
  127. *
  128. * @return none
  129. */
  130. extern void AddrMgrWriteNV( void );
  131. /******************************************************************************
  132. * @fn AddrMgrWriteNVRequest
  133. *
  134. * @brief Stub routine implemented by NHLE. NHLE should call
  135. * <AddrMgrWriteNV> when appropriate.
  136. *
  137. * @param none
  138. *
  139. * @return none
  140. */
  141. extern void AddrMgrWriteNVRequest( void );
  142. #if ( ADDRMGR_CALLBACK_ENABLED == 1 )
  143. /******************************************************************************
  144. * @fn AddrMgrRegister
  145. *
  146. * @brief Register as a user of the Address Manager.
  147. *
  148. * @param reg - [in] register ID
  149. * @param cb - [in] user callback
  150. *
  151. * @return uint8 - success(TRUE:FALSE)
  152. */
  153. extern uint8 AddrMgrRegister( uint8 reg, AddrMgrUserCB_t cb );
  154. #endif //ADDRMGR_CALLBACK_ENABLED
  155. /******************************************************************************
  156. * @fn AddrMgrExtAddrSet
  157. *
  158. * @brief Set destination address to source address or empty{0x00}.
  159. *
  160. * @param dstExtAddr - [in] destination EXT address
  161. * srcExtAddr - [in] source EXT address
  162. *
  163. * @return none
  164. */
  165. extern void AddrMgrExtAddrSet( uint8* dstExtAddr, uint8* srcExtAddr );
  166. /******************************************************************************
  167. * @fn AddrMgrExtAddrValid
  168. *
  169. * @brief Check if EXT address is valid - not NULL, not empty{0x00}.
  170. *
  171. * @param extAddr - [in] EXT address
  172. *
  173. * @return uint8 - success(TRUE:FALSE)
  174. */
  175. extern uint8 AddrMgrExtAddrValid( uint8* extAddr );
  176. /******************************************************************************
  177. * @fn AddrMgrExtAddrEqual
  178. *
  179. * @brief Compare two EXT addresses.
  180. *
  181. * @param extAddr1 - [in] EXT address 1
  182. * extAddr2 - [in] EXT address 2
  183. *
  184. * @return uint8 - success(TRUE:FALSE)
  185. */
  186. extern uint8 AddrMgrExtAddrEqual( uint8* extAddr1, uint8* extAddr2 );
  187. /******************************************************************************
  188. * @fn AddrMgrExtAddrLookup
  189. *
  190. * @brief Lookup EXT address using the NWK address.
  191. *
  192. * @param nwkAddr - [in] NWK address
  193. * extAddr - [out] EXT address
  194. *
  195. * @return uint8 - success(TRUE:FALSE)
  196. */
  197. extern uint8 AddrMgrExtAddrLookup( uint16 nwkAddr, uint8* extAddr );
  198. /******************************************************************************
  199. * @fn AddrMgrNwkAddrLookup
  200. *
  201. * @brief Lookup NWK address using the EXT address.
  202. *
  203. * @param extAddr - [in] EXT address
  204. * nwkAddr - [out] NWK address
  205. *
  206. * @return uint8 - success(TRUE:FALSE)
  207. */
  208. extern uint8 AddrMgrNwkAddrLookup( uint8* extAddr, uint16* nwkAddr );
  209. /******************************************************************************
  210. * @fn AddrMgrEntryRelease
  211. *
  212. * @brief Release a user reference from an entry in the Address Manager.
  213. *
  214. * @param entry
  215. * ::user - [in] user ID
  216. * ::index - [in] index of data
  217. * ::nwkAddr - not used
  218. * ::extAddr - not used
  219. *
  220. * @return uint8 - success(TRUE:FALSE)
  221. */
  222. extern uint8 AddrMgrEntryRelease( AddrMgrEntry_t* entry );
  223. /******************************************************************************
  224. * @fn AddrMgrEntryAddRef
  225. *
  226. * @brief Add a user reference to an entry in the Address Manager.
  227. *
  228. * @param entry
  229. * ::user - [in] user ID
  230. * ::index - [in] index of data
  231. * ::nwkAddr - not used
  232. * ::extAddr - not used
  233. *
  234. * @return uint8 - success(TRUE:FALSE)
  235. */
  236. extern uint8 AddrMgrEntryAddRef( AddrMgrEntry_t* entry );
  237. /******************************************************************************
  238. * @fn AddrMgrEntryLookupNwk
  239. *
  240. * @brief Lookup entry based on NWK address.
  241. *
  242. * @param entry
  243. * ::user - [in] user ID
  244. * ::nwkAddr - [in] NWK address
  245. * ::extAddr - [out] EXT address
  246. * ::index - [out] index of data
  247. *
  248. * @return uint8 - success(TRUE:FALSE)
  249. */
  250. extern uint8 AddrMgrEntryLookupNwk( AddrMgrEntry_t* entry );
  251. /******************************************************************************
  252. * @fn AddrMgrEntryLookupExt
  253. *
  254. * @brief Lookup entry based on EXT address.
  255. *
  256. * @param entry
  257. * ::user - [in] user ID
  258. * ::extAddr - [in] EXT address
  259. * ::nwkAddr - [out] NWK address
  260. * ::index - [out] index of data
  261. *
  262. * @return uint8 - success(TRUE:FALSE)
  263. */
  264. extern uint8 AddrMgrEntryLookupExt( AddrMgrEntry_t* entry );
  265. /******************************************************************************
  266. * @fn AddrMgrEntryGet
  267. *
  268. * @brief Get NWK address and EXT address based on index.
  269. *
  270. * @param entry
  271. * ::user - [in] user ID
  272. * ::index - [in] index of data
  273. * ::nwkAddr - [out] NWK address
  274. * ::extAddr - [out] EXT address
  275. *
  276. * @return uint8 - success(TRUE:FALSE)
  277. */
  278. extern uint8 AddrMgrEntryGet( AddrMgrEntry_t* entry );
  279. /******************************************************************************
  280. * @fn AddrMgrEntryUpdate
  281. *
  282. * @brief Update an entry into the Address Manager.
  283. *
  284. * @param entry
  285. * ::user - [in] user ID
  286. * ::nwkAddr - [in] NWK address
  287. * ::extAddr - [in] EXT address
  288. * ::index - [out] index of data
  289. *
  290. * @return uint8 - success(TRUE:FALSE)
  291. */
  292. uint8 AddrMgrEntryUpdate( AddrMgrEntry_t* entry );
  293. /******************************************************************************
  294. ******************************************************************************/
  295. #ifdef __cplusplus
  296. }
  297. #endif
  298. #endif /* ADDRMGR_H */