AddrMgr.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. /**************************************************************************************************
  2. Filename: AddrMgr.h
  3. Revised: $Date: 2011-05-05 13:52:19 -0700 (Thu, 05 May 2011) $
  4. Revision: $Revision: 25878 $
  5. Description: This file contains the interface to the Address Manager.
  6. Copyright 2005-2011 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 AddrMgrReset
  93. *
  94. * @brief Reset Address Manager.
  95. *
  96. * @param none
  97. *
  98. * @return none
  99. */
  100. extern void AddrMgrReset( void );
  101. /******************************************************************************
  102. * @fn AddrMgrInitNV
  103. *
  104. * @brief Initialize the address entry data in NV.
  105. *
  106. * @param none
  107. *
  108. * @return uint8 - <osal_nv_item_init> return codes
  109. */
  110. extern uint8 AddrMgrInitNV( void );
  111. /******************************************************************************
  112. * @fn AddrMgrSetDefaultNV
  113. *
  114. * @brief Set default address entry data in NV.
  115. *
  116. * @param none
  117. *
  118. * @return none
  119. */
  120. extern void AddrMgrSetDefaultNV( void );
  121. /******************************************************************************
  122. * @fn AddrMgrRestoreFromNV
  123. *
  124. * @brief Restore the address entry data from NV.
  125. *
  126. * @param none
  127. *
  128. * @return none
  129. */
  130. extern void AddrMgrRestoreFromNV( void );
  131. /******************************************************************************
  132. * @fn AddrMgrWriteNV
  133. *
  134. * @brief Save the address entry data to NV.
  135. *
  136. * @param none
  137. *
  138. * @return none
  139. */
  140. extern void AddrMgrWriteNV( void );
  141. /******************************************************************************
  142. * @fn AddrMgrWriteNVRequest
  143. *
  144. * @brief Stub routine implemented by NHLE. NHLE should call
  145. * <AddrMgrWriteNV> when appropriate.
  146. *
  147. * @param none
  148. *
  149. * @return none
  150. */
  151. extern void AddrMgrWriteNVRequest( void );
  152. #if ( ADDRMGR_CALLBACK_ENABLED == 1 )
  153. /******************************************************************************
  154. * @fn AddrMgrRegister
  155. *
  156. * @brief Register as a user of the Address Manager.
  157. *
  158. * @param reg - [in] register ID
  159. * @param cb - [in] user callback
  160. *
  161. * @return uint8 - success(TRUE:FALSE)
  162. */
  163. extern uint8 AddrMgrRegister( uint8 reg, AddrMgrUserCB_t cb );
  164. #endif //ADDRMGR_CALLBACK_ENABLED
  165. /******************************************************************************
  166. * @fn AddrMgrExtAddrSet
  167. *
  168. * @brief Set destination address to source address or empty{0x00}.
  169. *
  170. * @param dstExtAddr - [in] destination EXT address
  171. * srcExtAddr - [in] source EXT address
  172. *
  173. * @return none
  174. */
  175. extern void AddrMgrExtAddrSet( uint8* dstExtAddr, uint8* srcExtAddr );
  176. /******************************************************************************
  177. * @fn AddrMgrExtAddrValid
  178. *
  179. * @brief Check if EXT address is valid - not NULL, not empty{0x00}.
  180. *
  181. * @param extAddr - [in] EXT address
  182. *
  183. * @return uint8 - success(TRUE:FALSE)
  184. */
  185. extern uint8 AddrMgrExtAddrValid( uint8* extAddr );
  186. /******************************************************************************
  187. * @fn AddrMgrExtAddrEqual
  188. *
  189. * @brief Compare two EXT addresses.
  190. *
  191. * @param extAddr1 - [in] EXT address 1
  192. * extAddr2 - [in] EXT address 2
  193. *
  194. * @return uint8 - success(TRUE:FALSE)
  195. */
  196. extern uint8 AddrMgrExtAddrEqual( uint8* extAddr1, uint8* extAddr2 );
  197. /******************************************************************************
  198. * @fn AddrMgrExtAddrLookup
  199. *
  200. * @brief Lookup EXT address using the NWK address.
  201. *
  202. * @param nwkAddr - [in] NWK address
  203. * extAddr - [out] EXT address
  204. *
  205. * @return uint8 - success(TRUE:FALSE)
  206. */
  207. extern uint8 AddrMgrExtAddrLookup( uint16 nwkAddr, uint8* extAddr );
  208. /******************************************************************************
  209. * @fn AddrMgrNwkAddrLookup
  210. *
  211. * @brief Lookup NWK address using the EXT address.
  212. *
  213. * @param extAddr - [in] EXT address
  214. * nwkAddr - [out] NWK address
  215. *
  216. * @return uint8 - success(TRUE:FALSE)
  217. */
  218. extern uint8 AddrMgrNwkAddrLookup( uint8* extAddr, uint16* nwkAddr );
  219. /******************************************************************************
  220. * @fn AddrMgrEntryRelease
  221. *
  222. * @brief Release a user reference from an entry in the Address Manager.
  223. *
  224. * @param entry
  225. * ::user - [in] user ID
  226. * ::index - [in] index of data
  227. * ::nwkAddr - not used
  228. * ::extAddr - not used
  229. *
  230. * @return uint8 - success(TRUE:FALSE)
  231. */
  232. extern uint8 AddrMgrEntryRelease( AddrMgrEntry_t* entry );
  233. /******************************************************************************
  234. * @fn AddrMgrEntryAddRef
  235. *
  236. * @brief Add a user reference to an entry in the Address Manager.
  237. *
  238. * @param entry
  239. * ::user - [in] user ID
  240. * ::index - [in] index of data
  241. * ::nwkAddr - not used
  242. * ::extAddr - not used
  243. *
  244. * @return uint8 - success(TRUE:FALSE)
  245. */
  246. extern uint8 AddrMgrEntryAddRef( AddrMgrEntry_t* entry );
  247. /******************************************************************************
  248. * @fn AddrMgrEntryLookupNwk
  249. *
  250. * @brief Lookup entry based on NWK address.
  251. *
  252. * @param entry
  253. * ::user - [in] user ID
  254. * ::nwkAddr - [in] NWK address
  255. * ::extAddr - [out] EXT address
  256. * ::index - [out] index of data
  257. *
  258. * @return uint8 - success(TRUE:FALSE)
  259. */
  260. extern uint8 AddrMgrEntryLookupNwk( AddrMgrEntry_t* entry );
  261. /******************************************************************************
  262. * @fn AddrMgrEntryLookupExt
  263. *
  264. * @brief Lookup entry based on EXT address.
  265. *
  266. * @param entry
  267. * ::user - [in] user ID
  268. * ::extAddr - [in] EXT address
  269. * ::nwkAddr - [out] NWK address
  270. * ::index - [out] index of data
  271. *
  272. * @return uint8 - success(TRUE:FALSE)
  273. */
  274. extern uint8 AddrMgrEntryLookupExt( AddrMgrEntry_t* entry );
  275. /******************************************************************************
  276. * @fn AddrMgrEntryGet
  277. *
  278. * @brief Get NWK address and EXT address based on index.
  279. *
  280. * @param entry
  281. * ::user - [in] user ID
  282. * ::index - [in] index of data
  283. * ::nwkAddr - [out] NWK address
  284. * ::extAddr - [out] EXT address
  285. *
  286. * @return uint8 - success(TRUE:FALSE)
  287. */
  288. extern uint8 AddrMgrEntryGet( AddrMgrEntry_t* entry );
  289. /******************************************************************************
  290. * @fn AddrMgrEntryUpdate
  291. *
  292. * @brief Update an entry into the Address Manager.
  293. *
  294. * @param entry
  295. * ::user - [in] user ID
  296. * ::nwkAddr - [in] NWK address
  297. * ::extAddr - [in] EXT address
  298. * ::index - [out] index of data
  299. *
  300. * @return uint8 - success(TRUE:FALSE)
  301. */
  302. uint8 AddrMgrEntryUpdate( AddrMgrEntry_t* entry );
  303. /******************************************************************************
  304. * @fn AddrMgrIsFull
  305. *
  306. * @brief Checks to see if the address manager is full.
  307. *
  308. * @param none
  309. *
  310. * @return uint8 - success(TRUE:FALSE)
  311. * TRUE if there are no more empty slots,
  312. * FALSE if available slot
  313. */
  314. extern uint8 AddrMgrIsFull( void );
  315. /******************************************************************************
  316. ******************************************************************************/
  317. #ifdef __cplusplus
  318. }
  319. #endif
  320. #endif /* ADDRMGR_H */