APSMEDE.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913
  1. /**************************************************************************************************
  2. Filename: APSMEDE.h
  3. Revised: $Date: 2011-04-18 16:30:05 -0700 (Mon, 18 Apr 2011) $
  4. Revision: $Revision: 25757 $
  5. Description: Primitives of the Application Support Sub Layer Data Entity (APSDE) and
  6. Management Entity (APSME).
  7. Copyright 2004-2011 Texas Instruments Incorporated. All rights reserved.
  8. IMPORTANT: Your use of this Software is limited to those specific rights
  9. granted under the terms of a software license agreement between the user
  10. who downloaded the software, his/her employer (which must be your employer)
  11. and Texas Instruments Incorporated (the "License"). You may not use this
  12. Software unless you agree to abide by the terms of the License. The License
  13. limits your use, and you acknowledge, that the Software may not be modified,
  14. copied or distributed unless embedded on a Texas Instruments microcontroller
  15. or used solely and exclusively in conjunction with a Texas Instruments radio
  16. frequency transceiver, which is integrated into your product. Other than for
  17. the foregoing purpose, you may not use, reproduce, copy, prepare derivative
  18. works of, modify, distribute, perform, display or sell this Software and/or
  19. its documentation for any purpose.
  20. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  21. PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  22. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  23. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  24. TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
  25. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  26. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  27. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  28. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  29. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  30. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  31. Should you have any questions regarding your right to use this Software,
  32. contact Texas Instruments Incorporated at www.TI.com.
  33. **************************************************************************************************/
  34. #ifndef APSMEDE_H
  35. #define APSMEDE_H
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. /******************************************************************************
  40. * INCLUDES
  41. */
  42. #include "ZComDef.h"
  43. #include "nwk_globals.h"
  44. #include "AssocList.h"
  45. #include "nwk_bufs.h"
  46. #include "BindingTable.h"
  47. #include "ssp.h"
  48. /******************************************************************************
  49. * MACROS
  50. */
  51. /******************************************************************************
  52. * CONSTANTS
  53. */
  54. // Frame control fields
  55. #define APS_FRAME_TYPE_MASK 0x03
  56. #define APS_DATA_FRAME 0x00
  57. #define APS_CMD_FRAME 0x01
  58. #define APS_ACK_FRAME 0x02
  59. #define STUB_APS_FRAME 0x03
  60. #define APS_DELIVERYMODE_MASK 0x0C
  61. #define APS_FC_DM_UNICAST 0x00
  62. #define APS_FC_DM_INDIRECT 0x04
  63. #define APS_FC_DM_BROADCAST 0x08
  64. #define APS_FC_DM_GROUP 0x0C
  65. #define APS_FC_ACK_FORMAT 0x10
  66. #define APS_FC_SECURITY 0x20
  67. #define APS_FC_ACK_REQ 0x40
  68. #define APS_FC_EXTENDED 0x80
  69. #define APS_XFC_FRAG_MASK 0x03
  70. #define APS_XFC_FIRST_FRAG 0x01
  71. #define APS_XFC_FRAGMENT 0x02
  72. #define APS_XFC_RESERVED 0xFC
  73. #define APS_FRAME_CTRL_FIELD_LEN 0x01
  74. #define APS_DSTEP_ID_FIELD_LEN 0x01
  75. #define APS_GROUP_ID_FIELD_LEN 0x02
  76. #define APS_SRCEP_ID_FIELD_LEN 0x01
  77. #define APS_CLUSTERID_FIELD_LEN_V1_0 0x01
  78. #define APS_CLUSTERID_FIELD_LEN 0x02
  79. #define APS_PROFILEID_FIELD_LEN 0x02
  80. #define APS_FRAME_CNT_FIELD_LEN 0x01
  81. #define APS_XFRAME_CTRL_FIELD_LEN 0x01
  82. #define APS_BLOCK_CNT_FIELD_LEN 0x01
  83. #define APS_ACK_BITS_FIELD_LEN 0x01
  84. // Tx Options (bitmap values)
  85. #define APS_TX_OPTIONS_SECURITY_ENABLE 0x01u
  86. //#define APS_TX_OPTIONS_USE_NWK_KEY 0x02u remove from spec
  87. #define APS_TX_OPTIONS_ACK 0x04u
  88. #define APS_TX_OPTIONS_PERMIT_FRAGMENT 0x08u
  89. #define APS_TX_OPTIONS_SKIP_ROUTING 0x10u
  90. #define APS_TX_OPTIONS_FIRST_FRAGMENT 0x20u
  91. #define APS_TX_OPTIONS_PREPROCESS 0x40u
  92. // APSDE header fields
  93. #define APS_HDR_FC 0
  94. // APSME CMD id index
  95. #define APSME_CMD_ID 0
  96. // APS commands
  97. #define APSME_CMD_SKKE_1 0x01
  98. #define APSME_CMD_SKKE_2 0x02
  99. #define APSME_CMD_SKKE_3 0x03
  100. #define APSME_CMD_SKKE_4 0x04
  101. #define APSME_CMD_TRANSPORT_KEY 0x05
  102. #define APSME_CMD_UPDATE_DEVICE 0x06
  103. #define APSME_CMD_REMOVE_DEVICE 0x07
  104. #define APSME_CMD_REQUEST_KEY 0x08
  105. #define APSME_CMD_SWITCH_KEY 0x09
  106. #define APSME_CMD_EA_INIT_CHLNG 0x0A
  107. #define APSME_CMD_EA_RSP_CHLNG 0x0B
  108. #define APSME_CMD_EA_INIT_MAC_DATA 0x0C
  109. #define APSME_CMD_EA_RSP_MAC_DATA 0x0D
  110. #define APSME_CMD_TUNNEL 0x0E
  111. // APSME CMD packet fields (APSME_CMD_SKKE_*)
  112. #define APSME_SKKE_METHOD 0
  113. #define APSME_SKKE_INIT_ADDR 1
  114. #define APSME_SKKE_RESP_ADDR 9
  115. #define APSME_SKKE_PAYLOAD 17
  116. #define APSME_SKKE_LEN 33
  117. // APSME CMD packet fields (APSME_CMD_TRANSPORT_KEY)
  118. #define APSME_TK_KEY_TYPE 1
  119. #define APSME_TK_KEY 2
  120. #define APSME_TK_COMMON_LEN (uint8) \
  121. (APSME_TK_KEY + \
  122. SEC_KEY_LEN )
  123. #define APSME_TK_KEY_SEQ_LEN 1
  124. #define APSME_TK_INITIATOR_LEN 1
  125. #define APSME_TK_TC_DST_ADDR 18
  126. #define APSME_TK_TC_SRC_ADDR 26
  127. #define APSME_TK_TC_KEY_LEN 34
  128. #define APSME_TK_NWK_KEY_SEQ 18
  129. #define APSME_TK_NWK_DST_ADDR 19
  130. #define APSME_TK_NWK_SRC_ADDR 27
  131. #define APSME_TK_NWK_KEY_LEN 35
  132. #define APSME_TK_APP_PARTNER_ADDR 18
  133. #define APSME_TK_APP_INITIATOR 26
  134. #define APSME_TK_APP_KEY_LEN 27
  135. // APSME CMD packet fields (APSME_CMD_UPDATE_DEVICE)
  136. #define APSME_UD_STANDARD_SECURED_REJOIN 0
  137. #define APSME_UD_STANDARD_UNSECURED_JOIN 1
  138. #define APSME_UD_STANDARD_UNSECURED_REJOIN 3
  139. #define APSME_UD_HIGH_SECURED_REJOIN 4
  140. #define APSME_UD_HIGH_UNSECURED_JOIN 5
  141. #define APSME_UD_HIGH_UNSECURED_REJOIN 7
  142. #define APSME_UD_EADDR 1
  143. #define APSME_UD_SADDR_LSB 9
  144. #define APSME_UD_SADDR_MSB 10
  145. #define APSME_UD_STATUS 11
  146. #define APSME_UD_LEN 12
  147. // APSME CMD packet fields (APSME_CMD_REMOVE_DEVICE)
  148. #define APSME_RD_LEN 9
  149. #define APSME_RD_EADDR 1
  150. // APSME CMD packet fields (APSME_CMD_REQUEST_KEY)
  151. #define APSME_RK_KEY_TYPE 1
  152. #define APSME_RK_EADDR 2
  153. #define APSME_RK_SYS_LEN 2
  154. #define APSME_RK_APP_LEN 10
  155. // APSME CMD packet fields (APSME_CMD_SWITCH_KEY)
  156. #define APSME_SK_SEQ_NUM 1
  157. #define APSME_SK_LEN 2
  158. // APSME CMD packet fields (APSME_CMD_EA*)
  159. // challenge packets
  160. #define APSME_EA_CHLNG_KEY_TYPE 1
  161. #define APSME_EA_CHLNG_SEQ_NUM 2
  162. #define APSME_EA_CHLNG_INIT_ADDR 3
  163. #define APSME_EA_CHLNG_RESP_ADDR 11
  164. #define APSME_EA_CHLNG_PAYLOAD 19
  165. #define APSME_EA_CHLNG_LEN 35
  166. // data packets
  167. #define APSME_EA_DATA_TAG 1
  168. #define APSME_EA_DATA_TYPE 17
  169. #define APSME_EA_DATA_TEXT 18
  170. #define APSME_EA_DATA_LEN 22
  171. // APSME_AuthenticateReq_t::action types
  172. #define APSME_EA_INITIATE 0x00
  173. #define APSME_EA_ACCEPT 0x01
  174. #define APSME_EA_REJECT 0x02
  175. // APSME CMD packet fields (APSME_CMD_TUNNEL)
  176. #define APSME_TUNNEL_DEA 1 //destination extended address
  177. //devtag.pro.security.remove
  178. // APSME_TUNNEL_AUX 9 //auxillary header(obsolete)
  179. #define APSME_TUNNEL_TCMD 9 //tunnelled command
  180. #define APSME_TUNNEL_LEN 9
  181. // APSME Coordinator/Trust Center NWK addresses
  182. #define APSME_TRUSTCENTER_NWKADDR NWK_PAN_COORD_ADDR
  183. #if !defined( MAX_APS_FRAMECOUNTER_CHANGES )
  184. // The number of times the frame counter can change before
  185. // saving to NV
  186. #define MAX_APS_FRAMECOUNTER_CHANGES 1000
  187. #endif
  188. #if !defined( MAX_TCLK_FRAMECOUNTER_CHANGES )
  189. // The number of times the frame counter can change before
  190. // saving to NV
  191. #define MAX_TCLK_FRAMECOUNTER_CHANGES 10
  192. #endif
  193. /******************************************************************************
  194. * TYPEDEFS
  195. */
  196. // AIB item Ids
  197. typedef enum
  198. {
  199. apsAddressMap = 0xA0,
  200. // Proprietary Items
  201. apsMaxBindingTime,
  202. apsBindingTable,
  203. apsNumBindingTableEntries,
  204. apsUseExtendedPANID,
  205. apsUseInsecureJoin,
  206. apsMAX_AIB_ITEMS // Must be the last entry
  207. } ZApsAttributes_t;
  208. // Type of information being queried
  209. typedef enum
  210. {
  211. NWK_ADDR_LIST,
  212. EXT_ADDRESS,
  213. SIMPLE_DESC,
  214. NODE_DESC,
  215. POWER_DESC,
  216. SVC_MATCH
  217. } APSME_query_t;
  218. #define APS_ILLEGAL_DEVICES 0x02
  219. // Structure returned from APSME_GetRequest for apsBindingTable
  220. typedef struct
  221. {
  222. uint8 srcAddr[Z_EXTADDR_LEN]; // Src address
  223. byte srcEP; // Endpoint/interface of source device
  224. uint16 clusterID; // Cluster ID
  225. zAddrType_t dstAddr; // Destination address
  226. byte dstEP; // Endpoint/interface of dest device
  227. } apsBindingItem_t;
  228. typedef struct
  229. {
  230. byte FrmCtrl;
  231. byte XtndFrmCtrl;
  232. byte DstEndPoint;
  233. byte SrcEndPoint;
  234. uint16 GroupID;
  235. uint16 ClusterID;
  236. uint16 ProfileID;
  237. uint16 macDestAddr;
  238. byte wasBroadcast;
  239. byte apsHdrLen;
  240. byte *asdu;
  241. byte asduLength;
  242. byte ApsCounter;
  243. uint8 transID;
  244. uint8 BlkCount;
  245. uint8 AckBits;
  246. } aps_FrameFormat_t;
  247. typedef struct
  248. {
  249. uint16 tna; // tunnel network address
  250. uint8* dea; // destination extended address
  251. } APSDE_FrameTunnel_t;
  252. // APS Data Service Primitives
  253. typedef struct
  254. {
  255. zAddrType_t dstAddr;
  256. uint8 srcEP;
  257. uint8 dstEP;
  258. uint16 dstPanId;
  259. uint16 clusterID;
  260. uint16 profileID;
  261. uint16 asduLen;
  262. uint8* asdu;
  263. uint16 txOptions;
  264. uint8 transID;
  265. uint8 discoverRoute;
  266. uint8 radiusCounter;
  267. uint8 apsCount;
  268. uint8 blkCount;
  269. } APSDE_DataReq_t;
  270. typedef struct
  271. {
  272. uint16 dstAddr;
  273. uint8 dstEP;
  274. uint8 srcEP;
  275. uint8 transID;
  276. uint8 status;
  277. } APSDE_DataCnf_t;
  278. typedef struct
  279. {
  280. uint8 secure;
  281. } APSDE_DataReqMTU_t;
  282. // APS Security Related Primitives
  283. typedef struct
  284. {
  285. uint16 dstAddr;
  286. uint8* respExtAddr;
  287. uint8 method;
  288. uint8 apsSecure;
  289. uint8 nwkSecure;
  290. //devtag.0604.todo - remove obsolete
  291. } APSME_EstablishKeyReq_t;
  292. typedef struct
  293. {
  294. uint8* partExtAddr;
  295. uint8 status;
  296. } APSME_EstablishKeyCfm_t;
  297. typedef struct
  298. {
  299. uint16 srcAddr;
  300. uint8* initExtAddr;
  301. uint8 method;
  302. uint8 apsSecure;
  303. uint8 nwkSecure;
  304. //devtag.0604.todo - remove obsolete
  305. } APSME_EstablishKeyInd_t;
  306. typedef struct
  307. {
  308. uint16 dstAddr;
  309. uint8* initExtAddr;
  310. uint8 accept;
  311. uint8 apsSecure;
  312. uint8 nwkSecure;
  313. //devtag.0604.todo - remove obsolete
  314. } APSME_EstablishKeyRsp_t;
  315. typedef struct
  316. {
  317. uint16 dstAddr;
  318. uint8 keyType;
  319. uint8 keySeqNum;
  320. uint8* key;
  321. uint8* extAddr;
  322. uint8 initiator;
  323. uint8 apsSecure;
  324. uint8 nwkSecure;
  325. APSDE_FrameTunnel_t* tunnel;
  326. } APSME_TransportKeyReq_t;
  327. typedef struct
  328. {
  329. uint16 srcAddr;
  330. uint8 keyType;
  331. uint8 keySeqNum;
  332. uint8* key;
  333. uint8* dstExtAddr;
  334. uint8* srcExtAddr;
  335. uint8 initiator;
  336. uint8 secure;
  337. } APSME_TransportKeyInd_t;
  338. typedef struct
  339. {
  340. uint16 dstAddr;
  341. uint16 devAddr;
  342. uint8* devExtAddr;
  343. uint8 status;
  344. uint8 apsSecure;
  345. } APSME_UpdateDeviceReq_t;
  346. typedef struct
  347. {
  348. uint16 srcAddr;
  349. uint8* devExtAddr;
  350. uint16 devAddr;
  351. uint8 status;
  352. } APSME_UpdateDeviceInd_t;
  353. typedef struct
  354. {
  355. uint16 parentAddr;
  356. uint8* childExtAddr;
  357. } APSME_RemoveDeviceReq_t;
  358. typedef struct
  359. {
  360. uint16 srcAddr;
  361. uint8* childExtAddr;
  362. } APSME_RemoveDeviceInd_t;
  363. typedef struct
  364. {
  365. uint8 dstAddr;
  366. uint8 keyType;
  367. uint8* partExtAddr;
  368. } APSME_RequestKeyReq_t;
  369. typedef struct
  370. {
  371. uint16 srcAddr;
  372. uint8 keyType;
  373. uint8* partExtAddr;
  374. } APSME_RequestKeyInd_t;
  375. typedef struct
  376. {
  377. uint16 dstAddr;
  378. uint8 keySeqNum;
  379. } APSME_SwitchKeyReq_t;
  380. typedef struct
  381. {
  382. uint16 srcAddr;
  383. uint8 keySeqNum;
  384. } APSME_SwitchKeyInd_t;
  385. typedef struct
  386. {
  387. uint16 nwkAddr;
  388. uint8* extAddr;
  389. uint8* challenge;
  390. uint8 action;
  391. } APSME_AuthenticateReq_t;
  392. typedef struct
  393. {
  394. uint16 initNwkAddr;
  395. uint8 initExtAddr[Z_EXTADDR_LEN];
  396. uint8 challenge[SEC_KEY_LEN];
  397. } APSME_AuthenticateInd_t;
  398. typedef struct
  399. {
  400. uint8 initiator;
  401. uint8 partExtAddr[Z_EXTADDR_LEN];
  402. uint8 status;
  403. } APSME_AuthenticateCfm_t;
  404. // APS Incoming Command Packet
  405. typedef struct
  406. {
  407. osal_event_hdr_t hdr;
  408. uint8* asdu;
  409. uint8 asduLen;
  410. uint8 secure;
  411. uint16 nwkAddr;
  412. uint8 nwkSecure;
  413. } APSME_CmdPkt_t;
  414. typedef struct
  415. {
  416. uint8 key[SEC_KEY_LEN];
  417. uint32 txFrmCntr;
  418. uint32 rxFrmCntr;
  419. } APSME_LinkKeyData_t;
  420. typedef struct
  421. {
  422. uint8 frmCtrl;
  423. uint8 xtndFrmCtrl;
  424. uint8 srcEP;
  425. uint8 dstEP;
  426. uint16 groupID;
  427. uint16 clusterID;
  428. uint16 profileID;
  429. uint8 asduLen;
  430. uint8* asdu;
  431. uint8 hdrLen;
  432. uint8 apsCounter;
  433. uint8 transID;
  434. uint8 blkCount;
  435. uint8 ackBits;
  436. } APSDE_FrameData_t;
  437. typedef struct
  438. {
  439. uint8 frmCtrl;
  440. uint8 xtndFrmCtrl;
  441. uint8 srcEP;
  442. uint8 dstEP;
  443. uint16 clusterID;
  444. uint16 profileID;
  445. uint8 asduLen;
  446. uint16 dstAddr;
  447. uint8 transID;
  448. } APSDE_StoredFrameData_t;
  449. typedef struct
  450. {
  451. //ZMacDataReq_t mfd;
  452. NLDE_FrameData_t nfd;
  453. APSDE_FrameData_t afd;
  454. } APSDE_FrameFormat_t;
  455. typedef struct
  456. {
  457. uint16 dstAddr;
  458. uint8 frmCtrl;
  459. uint8 xtndFrmCtrl;
  460. uint8 asduLen;
  461. uint8 nwkSecure;
  462. APSDE_FrameTunnel_t* tunnel;
  463. } APSDE_FrameAlloc_t;
  464. typedef struct
  465. {
  466. //input
  467. APSDE_FrameAlloc_t fa;
  468. //output
  469. APSDE_FrameFormat_t* aff;
  470. SSP_Info_t* si;
  471. uint8 status;
  472. } APSDE_FrameBlk_t;
  473. typedef struct
  474. {
  475. uint8 extAddr[Z_EXTADDR_LEN];
  476. uint8 key[SEC_KEY_LEN];
  477. uint32 txFrmCntr;
  478. uint32 rxFrmCntr;
  479. } APSME_TCLinkKey_t;
  480. typedef struct
  481. {
  482. uint32 txFrmCntr;
  483. uint32 rxFrmCntr;
  484. uint8 pendingFlag;
  485. } APSME_ApsLinkKeyFrmCntr_t;
  486. typedef struct
  487. {
  488. uint32 txFrmCntr;
  489. uint32 rxFrmCntr;
  490. uint8 pendingFlag;
  491. } APSME_TCLinkKeyFrmCntr_t;
  492. // Function pointer prototype to preprocess messages before calling NWK layer
  493. typedef void (*apsPreProcessDataReq_t)( APSDE_FrameBlk_t *blk );
  494. /******************************************************************************
  495. * GLOBAL VARIABLES
  496. */
  497. // Store Frame Counters in RAM and update NV periodically
  498. extern APSME_ApsLinkKeyFrmCntr_t ApsLinkKeyFrmCntr[];
  499. extern APSME_TCLinkKeyFrmCntr_t TCLinkKeyFrmCntr[];
  500. /******************************************************************************
  501. * APS Data Service
  502. * APSDE-DATA
  503. */
  504. /*
  505. * This function requests the transfer of data from the next higher layer
  506. * to a single peer entity.
  507. */
  508. extern ZStatus_t APSDE_DataReq( APSDE_DataReq_t* req );
  509. /*
  510. * This function requests the MTU(Max Transport Unit) of the APS Data Service
  511. */
  512. extern uint8 APSDE_DataReqMTU( APSDE_DataReqMTU_t* fields );
  513. /*
  514. * This function reports the results of a request to transfer a data
  515. * PDU (ASDU) from a local higher layer entity to another single peer entity.
  516. */
  517. extern void APSDE_DataConfirm( nwkDB_t *rec, ZStatus_t Status );
  518. extern void APSDE_DataCnf( APSDE_DataCnf_t* cnf );
  519. /*
  520. * This function indicates the transfer of a data PDU (ASDU) from the
  521. * APS sub-layer to the local application layer entity.
  522. */
  523. extern void APSDE_DataIndication( aps_FrameFormat_t *aff, zAddrType_t *SrcAddress,
  524. uint16 SrcPanId, NLDE_Signal_t *sig, uint8 nwkSeqNum,
  525. byte SecurityUse, uint32 timestamp );
  526. /******************************************************************************
  527. * APS Management Service
  528. * APSME-BIND
  529. * APSME-UNBIND
  530. */
  531. /*
  532. * This function allows the next higher layer to request to bind two devices together
  533. * either by proxy or directly, if issued on the coordinator.
  534. *
  535. * NOTE: The APSME-BIND.confirm is returned by this function and is not a
  536. * seperate callback function.
  537. */
  538. extern ZStatus_t APSME_BindRequest( byte SrcEndpInt, uint16 ClusterId,
  539. zAddrType_t *DstAddr, byte DstEndpInt);
  540. /*
  541. * This function allows the next higher layer to request to unbind two devices
  542. * either by proxy or directly, if issued on the coordinator.
  543. *
  544. * NOTE: The APSME-UNBIND.confirm is returned by this function and is not a
  545. * seperate callback function.
  546. */
  547. extern ZStatus_t APSME_UnBindRequest( byte SrcEndpInt,
  548. uint16 ClusterId, zAddrType_t *DstAddr, byte DstEndpInt);
  549. /*
  550. * This function allows the next higher layer to read the value of an attribute
  551. * from the AIB (APS Information Base)
  552. */
  553. extern ZStatus_t APSME_GetRequest( ZApsAttributes_t AIBAttribute,
  554. uint16 Index, byte *AttributeValue );
  555. /*
  556. * This function allows the next higher layer to write the value of an attribute
  557. * into the AIB (APS Information Base)
  558. */
  559. extern ZStatus_t APSME_SetRequest( ZApsAttributes_t AIBAttribute,
  560. uint16 Index, byte *AttributeValue );
  561. /*
  562. * This function gets the EXT address based on the NWK address.
  563. */
  564. extern uint8 APSME_LookupExtAddr( uint16 nwkAddr, uint8* extAddr );
  565. /*
  566. * This function gets the NWK address based on the EXT address.
  567. */
  568. extern uint8 APSME_LookupNwkAddr( uint8* extAddr, uint16* nwkAddr );
  569. #if 0 // NOT IMPLEMENTED
  570. /*
  571. * This function allows the next higher layer to be notified of the results of its
  572. * request to unbind two devices directly or by proxy.
  573. */
  574. extern void APSME_UnbindConfirm( zAddrType_t CoorAddr,ZStatus_t Status,
  575. uint16 SrcAddr, byte SrcEndpInt, byte ObjectId,
  576. uint16 DstAddr, byte DstEndpInt);
  577. /*
  578. * This function allows the next higher layer to be notified of the results of its
  579. * request to bind two devices directly or by proxy.
  580. */
  581. extern void APSME_BindConfirm( zAddrType_t CoorAddr,ZStatus_t Status,
  582. uint16 SrcAddr, byte SrcEndpInt, byte ObjectId,
  583. uint16 DstAddr, byte DstEndpInt);
  584. #endif // NOT IMPLEMENTED
  585. /*
  586. * Set the Preprocess function pointer. The APS Layer will call this function
  587. * right before calling APSDE_FrameSend() [setup function that calls NLDE_DataReq()].
  588. */
  589. extern void APSDE_SetPreProcessFnp( apsPreProcessDataReq_t pfnCB );
  590. /******************************************************************************
  591. * APS Incoming Command Packet Handler
  592. */
  593. /*
  594. * APSME_CmdPkt handles APS CMD packets.
  595. */
  596. extern void APSME_CmdPkt( APSME_CmdPkt_t* pkt );
  597. /******************************************************************************
  598. * APS Frame Allocation And Routing
  599. */
  600. /*
  601. * APSDE_FrameAlloc allocates an APS frame.
  602. */
  603. extern void APSDE_FrameAlloc( APSDE_FrameBlk_t* blk );
  604. /*
  605. * APSDE_FrameSend sends an APS frame.
  606. */
  607. extern void APSDE_FrameSend( APSDE_FrameBlk_t* blk );
  608. /*
  609. * APSME_HoldDataRequests holds all data request for a timeout.
  610. */
  611. void APSME_HoldDataRequests( uint16 holdTime );
  612. /******************************************************************************
  613. * APS Security Related Functions
  614. */
  615. /*
  616. * APSME_FrameSecurityRemove removes security from APS frame.
  617. */
  618. extern ZStatus_t APSME_FrameSecurityRemove(uint16 srcAddr,
  619. aps_FrameFormat_t* aff);
  620. /*
  621. * APSME_FrameSecurityApply applies security to APS frame.
  622. */
  623. extern ZStatus_t APSME_FrameSecurityApply(uint16 dstAddr,
  624. aps_FrameFormat_t* aff);
  625. /*
  626. * Configure APS security mode
  627. */
  628. extern void APSME_SecurityNM( void ); // NULL MODE - NO SECURITY
  629. extern void APSME_SecurityRM_ED( void );// RESIDENTIAL MODE - END DEVICE
  630. extern void APSME_SecurityRM_RD( void );// RESIDENTIAL MODE - ROUTER DEVICE
  631. extern void APSME_SecurityRM_CD( void );// RESIDENTIAL MODE - COORD DEVICE
  632. extern void APSME_SecurityCM_ED( void );// COMMERCIAL MODE - END DEVICE
  633. extern void APSME_SecurityCM_RD( void );// COMMERCIAL MODE - ROUTER DEVICE
  634. extern void APSME_SecurityCM_CD( void );// COMMERCIAL MODE - COORD DEVICE
  635. /*
  636. * Configure SKA(Shared Key Authentication) slot data
  637. */
  638. extern void APSME_SKA_SlotInit( uint8 total );
  639. /*
  640. * Handle the SKA(Shared Key Authentication) slot timer.
  641. */
  642. extern void APSME_SKA_SlotTimerHandler( void );
  643. /******************************************************************************
  644. * APS Security Service Primitives - API, NHLE Calls Routines
  645. *
  646. * APSME_EstablishKeyReq
  647. * APSME_EstablishKeyRsp
  648. * APSME_TransportKeyReq
  649. * APSME_UpdateDeviceReq
  650. * APSME_RemoveDeviceReq
  651. * APSME_RequestKeyReq
  652. * APSME_SwitchKeyReq
  653. * APSME_AuthenticateReq
  654. */
  655. /*
  656. * APSME_EstablishKeyReq primitive.
  657. */
  658. extern ZStatus_t APSME_EstablishKeyReq( APSME_EstablishKeyReq_t* req );
  659. /*
  660. * APSME_EstablishKeyRsp primitive.
  661. */
  662. extern ZStatus_t APSME_EstablishKeyRsp( APSME_EstablishKeyRsp_t* rsp );
  663. /*
  664. * APSME_TransportKeyReq primitive.
  665. */
  666. extern ZStatus_t APSME_TransportKeyReq( APSME_TransportKeyReq_t* req );
  667. /*
  668. * APSME_UpdateDeviceReq primitive.
  669. */
  670. extern ZStatus_t APSME_UpdateDeviceReq( APSME_UpdateDeviceReq_t* req );
  671. /*
  672. * APSME_RemoveDeviceReq primitive.
  673. */
  674. extern ZStatus_t APSME_RemoveDeviceReq( APSME_RemoveDeviceReq_t* req );
  675. /*
  676. * APSME_RequestKeyReq primitive.
  677. */
  678. extern ZStatus_t APSME_RequestKeyReq( APSME_RequestKeyReq_t* req );
  679. /*
  680. * APSME_SwitchKeyReq primitive.
  681. */
  682. extern ZStatus_t APSME_SwitchKeyReq( APSME_SwitchKeyReq_t* req );
  683. /*
  684. * APSME_AuthenticateReq primitive.
  685. */
  686. extern ZStatus_t APSME_AuthenticateReq( APSME_AuthenticateReq_t* req );
  687. /******************************************************************************
  688. * APS Security Primitive Stubs - API, NHLE Implements Callback Stubs
  689. *
  690. * APSME_EstablishKeyCfm
  691. * APSME_EstablishKeyInd
  692. * APSME_TransportKeyInd
  693. * APSME_UpdateDeviceInd
  694. * APSME_RemoveDeviceInd
  695. * APSME_RequestKeyInd
  696. * APSME_SwitchKeyInd
  697. * APSME_AuthenticateInd
  698. * APSME_AuthenticateCfm
  699. */
  700. /*
  701. * APSME_EstablishKeyCfm primitive.
  702. */
  703. extern void APSME_EstablishKeyCfm( APSME_EstablishKeyCfm_t* cfm );
  704. /*
  705. * APSME_EstablishKeyInd primitive.
  706. */
  707. extern void APSME_EstablishKeyInd( APSME_EstablishKeyInd_t* ind );
  708. /*
  709. * APSME_TransportKeyInd primitive.
  710. */
  711. extern void APSME_TransportKeyInd( APSME_TransportKeyInd_t* ind );
  712. /*
  713. * APSME_UpdateDeviceInd primitive.
  714. */
  715. extern void APSME_UpdateDeviceInd( APSME_UpdateDeviceInd_t* ind );
  716. /*
  717. * APSME_RemoveDeviceInd primitive.
  718. */
  719. extern void APSME_RemoveDeviceInd( APSME_RemoveDeviceInd_t* ind );
  720. /*
  721. * APSME_RequestKeyInd primitive.
  722. */
  723. extern void APSME_RequestKeyInd( APSME_RequestKeyInd_t* ind );
  724. /*
  725. * APSME_SwitchKeyInd primitive.
  726. */
  727. extern void APSME_SwitchKeyInd( APSME_SwitchKeyInd_t* ind );
  728. /*
  729. * APSME_AuthenticateInd primitive.
  730. */
  731. extern void APSME_AuthenticateInd( APSME_AuthenticateInd_t* ind );
  732. /*
  733. * APSME_AuthenticateCfm primitive.
  734. */
  735. extern void APSME_AuthenticateCfm( APSME_AuthenticateCfm_t* cfm );
  736. /******************************************************************************
  737. * APS Security Support - NHLE Implements Callback Stubs
  738. *
  739. * APSME_MasterKeyGet
  740. * APSME_LinkKeySet
  741. * APSME_LinkKeyNVIdGet
  742. * APSME_KeyFwdToChild
  743. */
  744. /*
  745. * APSME_MasterKeyExtGet stub.
  746. */
  747. extern ZStatus_t APSME_MasterKeyGet( uint8* extAddr, uint16* pKeyNvId );
  748. /*
  749. * APSME_LinkKeySet stub.
  750. */
  751. extern ZStatus_t APSME_LinkKeySet( uint8* extAddr, uint8* key );
  752. /*
  753. * APSME_LinkKeyNVIdGet stub.
  754. */
  755. extern ZStatus_t APSME_LinkKeyNVIdGet(uint8* extAddr, uint16 *pKeyNvId);
  756. /*
  757. * APSME_IsLinkKeyValid stub.
  758. */
  759. extern uint8 APSME_IsLinkKeyValid(uint8* extAddr);
  760. /*
  761. * APSME_KeyFwdToChild stub.
  762. */
  763. extern uint8 APSME_KeyFwdToChild( APSME_TransportKeyInd_t* ind );
  764. /*
  765. * APSME_TCAddrSetup - Configure the Trust Center short address.
  766. * Use with ZG_SECURITY_SE_STANDARD
  767. *
  768. * shortAddr - Trust Center short address
  769. */
  770. extern void APSME_TCAddrSetup( uint16 shortAddr );
  771. /******************************************************************************
  772. ******************************************************************************/
  773. #ifdef __cplusplus
  774. }
  775. #endif
  776. #endif /* APSMEDE_H */