MS_trn_api.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032
  1. /**
  2. * \file MS_trn_api.h
  3. *
  4. * \brief This file defines the Mesh Transport Application Interface - includes
  5. * Data Structures and Methods.
  6. */
  7. /*
  8. * Copyright (C) 2017. Mindtree Ltd.
  9. * All rights reserved.
  10. */
  11. #ifndef _H_MS_TRN_API_
  12. #define _H_MS_TRN_API_
  13. /* --------------------------------------------- Header File Inclusion */
  14. /* Lower Transport Layer */
  15. #include "MS_ltrn_api.h"
  16. extern uint8 cfg_retry_flag;
  17. extern void blebrr_scan_pl (UCHAR enable);
  18. /* --------------------------------------------- Global Definitions */
  19. /**
  20. * \defgroup trn_module TRANSPORT (Mesh Transport Layer)
  21. * \{
  22. * This section describes the interfaces & APIs offered by the EtherMind
  23. * Mesh Transport (TRANSPORT) module to the Application and other upper
  24. * layers of the stack.
  25. */
  26. /**
  27. * \defgroup trn_defines Defines
  28. * \{
  29. * Describes defines for the module.
  30. */
  31. /**
  32. * \defgroup trn_constants Constants
  33. * \{
  34. * Describes Constants defined by the module.
  35. */
  36. /**
  37. * Tranport Layer Control Packet Opcodes
  38. *
  39. * RFU: 0x02 - 0x0F
  40. */
  41. /**
  42. * Sent by a Low Power node to its Friend node to request any messages
  43. * that it has cached for the Low Power node
  44. */
  45. #define MS_TRN_CTRL_OPCODE_FRND_POLL 0x01
  46. /**
  47. * Sent by a Friend node to a Low Power node to inform it about cache
  48. * and/or security updates
  49. */
  50. #define MS_TRN_CTRL_OPCODE_FRND_UPDATE 0x02
  51. /** Broadcast by a Low Power node to start to find a friend */
  52. #define MS_TRN_CTRL_OPCODE_FRND_REQ 0x03
  53. /** Sent by a Friend node to a Low Power node to offer to become its friend */
  54. #define MS_TRN_CTRL_OPCODE_FRND_OFFER 0x04
  55. /**
  56. * Sent to a Friend node to inform a previous friend of a Low Power node
  57. * about the removal of a friendship
  58. */
  59. #define MS_TRN_CTRL_OPCODE_FRND_CLEAR 0x05
  60. /**
  61. * Sent from a previous friend to Friend node to confirm that a prior friend
  62. * relationship has been removed
  63. */
  64. #define MS_TRN_CTRL_OPCODE_FRND_CLEAR_CNF 0x06
  65. /**
  66. * Sent to a Friend node to add one or more addresses
  67. * to the Friend Subscription List
  68. */
  69. #define MS_TRN_CTRL_OPCODE_FRND_SUBSCRN_LIST_ADD 0x07
  70. /**
  71. * Sent to a Friend node to remove one or more addresses
  72. * from the Friend Subscription List
  73. */
  74. #define MS_TRN_CTRL_OPCODE_FRND_SUBSCRN_LIST_REMOVE 0x08
  75. /** Sent by a Friend node to confirm Friend Subscription List updates */
  76. #define MS_TRN_CTRL_OPCODE_FRND_SUBSCRN_LIST_CNF 0x09
  77. /** Sent by a node to let other nodes determine topology of a Subnet */
  78. #define MS_TRN_CTRL_OPCODE_HEARTBEAT 0x0A
  79. /**
  80. * Parameter defines for Friendship Opcodes
  81. */
  82. /**
  83. * Friend Update Flags
  84. *
  85. * Bit 0: Key Refresh Flag
  86. * 0: Not-In-Phase2
  87. * 1: In-Phase2
  88. *
  89. * Bit 1: IV Update Flag
  90. * 0: Normal operation
  91. * 1: IV Update active
  92. */
  93. #define MS_FRNDUPD_FLAG_KEYREF_BIT 0
  94. #define MS_FRNDUPD_FLAG_KEYREF_NOTINPHASE_2 0x00
  95. #define MS_FRNDUPD_FLAG_KEYREF_INPHASE_2 0x01
  96. #define MS_FRNDUPD_FLAG_IVUPDATE_BIT 1
  97. #define MS_FRNDUPD_FLAG_IVUPDATE_NORMAL 0x00
  98. #define MS_FRNDUPD_FLAG_IVUPDATE_ACTIVE 0x01
  99. /**
  100. * Friend Update More Data
  101. */
  102. #define MS_FRNDUPD_MD_QUEUE_EMPTY 0x00
  103. #define MS_FRNDUPD_MD_QUEUE_NOTEMPTY 0x01
  104. /**
  105. * Friend Request Criteria
  106. */
  107. #define MS_FRNDREQ_RSSIFACTOR_OFFSET 5
  108. #define MS_FRNDREQ_RSSIFACTOR_MASK 0x60
  109. #define MS_FRNDREQ_RSSIFACTOR_1 0x00
  110. #define MS_FRNDREQ_RSSIFACTOR_1_5 0x01
  111. #define MS_FRNDREQ_RSSIFACTOR_2 0x02
  112. #define MS_FRNDREQ_RSSIFACTOR_2_5 0x03
  113. #define MS_FRNDREQ_RCVWINFACTOR_OFFSET 3
  114. #define MS_FRNDREQ_RCVWINFACTOR_MASK 0x18
  115. #define MS_FRNDREQ_RCVWINFACTOR_1 0x00
  116. #define MS_FRNDREQ_RCVWINFACTOR_1_5 0x01
  117. #define MS_FRNDREQ_RCVWINFACTOR_2 0x02
  118. #define MS_FRNDREQ_RCVWINFACTOR_2_5 0x03
  119. #define MS_FRNDREQ_MINQSIZELOG_OFFSET 0
  120. #define MS_FRNDREQ_MINQSIZELOG_MASK 0x07
  121. #define MS_FRNDREQ_MINQSIZE_INVALID 0x00
  122. #define MS_FRNDREQ_MINQSIZE_2 0x01
  123. #define MS_FRNDREQ_MINQSIZE_4 0x02
  124. #define MS_FRNDREQ_MINQSIZE_8 0x03
  125. #define MS_FRNDREQ_MINQSIZE_16 0x04
  126. #define MS_FRNDREQ_MINQSIZE_32 0x05
  127. #define MS_FRNDREQ_MINQSIZE_64 0x06
  128. #define MS_FRNDREQ_MINQSIZE_128 0x07
  129. /**
  130. * Heartbeat features
  131. */
  132. #define MS_HEARTBEAT_FEATURE_RELAY (1 << 0)
  133. #define MS_HEARTBEAT_FEATURE_PROXY (1 << 1)
  134. #define MS_HEARTBEAT_FEATURE_FRIEND (1 << 2)
  135. #define MS_HEARTBEAT_FEATURE_LOWPOWER (1 << 3)
  136. /** Friendship constants as defined in the specification */
  137. #define MS_MIN_FRNDOFFER_DELAY 100 /* ms */
  138. #define MS_TRN_INITIAL_FRNDPOLL_TIMEOUT 1000 /* ms */
  139. /** \} */
  140. /**
  141. * \defgroup trn_events Events
  142. * \{
  143. * This section lists the Asynchronous Events notified to Application by the
  144. * Module.
  145. */
  146. #define MS_TRN_FRIEND_SETUP_CNF 0x00
  147. #define MS_TRN_FRIEND_SUBSCRNLIST_CNF 0x01
  148. #define MS_TRN_FRIEND_CLEAR_CNF 0x02
  149. #define MS_TRN_FRIEND_TERMINATE_IND 0x03
  150. /** \} */
  151. /** \} */
  152. /**
  153. * \defgroup trn_marcos Utility Macros
  154. * \{
  155. * Initialization and other Utility Macros offered by the module.
  156. */
  157. /** \} */
  158. /* --------------------------------------------- Data Types/ Structures */
  159. /**
  160. * \addtogroup trn_defines Defines
  161. * \{
  162. */
  163. /**
  164. * \addtogroup trn_structures Structures
  165. * \{
  166. */
  167. /** \} */
  168. /** \} */
  169. typedef API_RESULT (*TRN_HEARTBEAT_RCV_CB)
  170. (
  171. MS_NET_ADDR addr,
  172. MS_SUBNET_HANDLE subnet_handle,
  173. UINT8 countlog
  174. ) DECL_REENTRANT;
  175. typedef API_RESULT (*TRN_HEARTBEAT_RCV_TIMEOUT_CB)
  176. (
  177. void
  178. ) DECL_REENTRANT;
  179. /**
  180. * \defgroup trn_cb Application Callback
  181. * \{
  182. * This Section Describes the module Notification Callback interface offered
  183. * to the application
  184. */
  185. /**
  186. * TRANSPORT Application Asynchronous Notification Callback.
  187. *
  188. * TRANSPORT calls the registered callback to indicate events occurred to the
  189. * application.
  190. *
  191. * \param brr_type Bearer Type.
  192. * \param net_hdr Network Header.
  193. * \param subnet_handle Associated Subnet Handle.
  194. * \param appkey_handle Associated AppKey Handle.
  195. * \param data_param Data associated with the event if any or NULL.
  196. * \param data_len Size of the event data. 0 if event data is NULL.
  197. */
  198. typedef void (*TRN_NTF_CB)
  199. (
  200. MS_NET_HEADER * net_hdr,
  201. MS_SUBNET_HANDLE subnet_handle,
  202. MS_APPKEY_HANDLE appkey_handle,
  203. UCHAR * data_param,
  204. UINT16 data_len
  205. ) DECL_REENTRANT;
  206. /**
  207. * TRANSPORT Application Friendship Asynchronous Notification Callback.
  208. *
  209. * TRANSPORT calls the registered callback to indicate the status of froednship
  210. * setup procedure to the application
  211. *
  212. * \param subnet_handle Associated Subnet Handle.
  213. * \param event_type Friendship event. \ref trn_events
  214. * \param status Result of the procedure.
  215. */
  216. typedef void (*TRN_FRND_CB)
  217. (
  218. MS_SUBNET_HANDLE subnet_handle,
  219. UCHAR event_type,
  220. UINT16 status
  221. ) DECL_REENTRANT;
  222. /** \} */
  223. /**
  224. * \addtogroup trn_defines Defines
  225. * \{
  226. */
  227. /**
  228. * \addtogroup trn_structures Structures
  229. * \{
  230. */
  231. /** Transport Control Packet Opcode Type */
  232. typedef UCHAR MS_TRN_CTRL_PKT_OPCODE;
  233. /** Friend Data Structure */
  234. typedef struct _MS_TRN_FRIEND_ENTRY
  235. {
  236. /** Friend Seqnece Number - 7 bit value */
  237. UINT8 fsn;
  238. /** Low Power Node Address */
  239. MS_NET_ADDR addr;
  240. /** Number of Elements in LPN */
  241. UINT8 num_elements;
  242. /** Previous Friend Address */
  243. MS_NET_ADDR prev_faddr;
  244. /** Friend Queue */
  245. /* UINT32 q; */
  246. /** Subscription List of LPN */
  247. /* UINT32 subscription_list; */
  248. } MS_TRN_FRIEND_ENTRY;
  249. /** Transport Friend Poll Message */
  250. typedef struct _MS_TRN_FRND_POLL_PARAM
  251. {
  252. /**
  253. * Friend Sequence Number used to acknowledge receipt of
  254. * previous messages from the Friend node to the Low Power node.
  255. */
  256. UINT8 fsn;
  257. } MS_TRN_FRND_POLL_PARAM;
  258. /** Transport Friend Update Message */
  259. typedef struct _MS_TRN_FRND_UPDATE_PARAM
  260. {
  261. /** Contains the IV Update Flag and the Key Refresh Flag */
  262. UINT8 flags;
  263. /** The current IV Index value known by the Friend node */
  264. UINT32 ivi;
  265. /**
  266. * Availability of data in friend queue
  267. *
  268. * Value | Description
  269. * ------|------------
  270. * 0 | Friend Queue is empty
  271. * 1 | Friend Queue is not empty
  272. */
  273. UCHAR md;
  274. } MS_TRN_FRND_UPDATE_PARAM;
  275. /** Transport Friend Request Message */
  276. typedef struct _MS_TRN_FRND_REQ_PARAM
  277. {
  278. /**
  279. * The criteria that a Friend node should support
  280. * in order to participate in friendship negotiation
  281. */
  282. UCHAR criteria;
  283. /** Receive delay requested by the Low Power node */
  284. UCHAR rx_delay;
  285. /** Poll timeout requested by the Low Power node */
  286. UINT32 poll_to;
  287. /** Previous Friend's unicast address */
  288. UINT16 prev_addr;
  289. /** Number of Elements in the Low Power node */
  290. UCHAR num_elem;
  291. /** Number of Friend Request messages that the Low Power node has sent */
  292. UINT16 lpn_counter;
  293. } MS_TRN_FRND_REQ_PARAM;
  294. /** Transport Friend Offer Message */
  295. typedef struct _MS_TRN_FRND_OFFER_PARAM
  296. {
  297. /** Receive Window value supported by the Friend node */
  298. UINT8 rx_window;
  299. /** Queue Size available on the Friend node */
  300. UINT8 queue_size;
  301. /**
  302. * Size of the Subscription List that can be supported
  303. * by a Friend node for a Low Power node
  304. */
  305. UINT8 sublist_size;
  306. /** RSSI measured by the Friend node */
  307. UINT8 rssi;
  308. /** Number of Friend Offer messages that the Friend node has sent */
  309. UINT16 frnd_counter;
  310. } MS_TRN_FRND_OFFER_PARAM;
  311. /** Transport Friend Clear Message */
  312. typedef struct _MS_TRN_FRND_CLEAR_PARAM
  313. {
  314. /** The unicast address of the Low Power node being removed */
  315. UINT16 lpn_addr;
  316. /** Value of the LPNCounter of new relationship */
  317. UINT16 lpn_counter;
  318. } MS_TRN_FRND_CLEAR_PARAM;
  319. /** Transport Friend Clear Confirm Message */
  320. typedef struct _MS_TRN_FRND_CLEAR_CNF_PARAM
  321. {
  322. /** The unicast address of the Low Power node being removed */
  323. UINT16 lpn_addr;
  324. /** Value of the LPNCounter of corresponding Friend Clear message */
  325. UINT16 lpn_counter;
  326. } MS_TRN_FRND_CLEAR_CNF_PARAM;
  327. /** Transport Friend Subscription List Add/Remove Message */
  328. typedef struct _MS_TRN_FRND_MANAGE_PARAM
  329. {
  330. /** The number for identifying a transaction */
  331. UINT8 txn_num;
  332. /**
  333. * List of group addresses and virtual addresses where N is
  334. * the number of group addresses and virtual addresses in this message.
  335. *
  336. * Address octet stream packed in big-endian format.
  337. */
  338. void * addr_list;
  339. /**
  340. * Number of Addresses in the list
  341. *
  342. * Note: Number of addresses is half of the octets in the addr_list field.
  343. */
  344. UINT16 num_addr;
  345. /** Opcode - Add/Delete */
  346. UINT8 opcode;
  347. } MS_TRN_FRND_MANAGE_PARAM;
  348. /** Transport Friend Subscription List Confirm Message */
  349. typedef struct _MS_TRN_FRND_SUBSCRN_LIST_CNF_PARAM
  350. {
  351. /** The number for identifying a transaction */
  352. UINT8 txn_num;
  353. } MS_TRN_FRND_SUBSCRN_LIST_CNF_PARAM;
  354. /** Transport Heartbeat Message */
  355. typedef struct _MS_TRN_HEARTBEAT_PARAM
  356. {
  357. /** Initial TTL used when sending the message */
  358. UINT8 init_ttl;
  359. /** Bit field of currently active features of the node */
  360. UINT16 features;
  361. } MS_TRN_HEARTBEAT_PARAM;
  362. /** Low Power Node element information */
  363. typedef struct _MS_TRN_FRNDSHIP_INFO
  364. {
  365. /* Main subnet handle of the element */
  366. MS_SUBNET_HANDLE subnet_handle;
  367. /* Peer LPN/Friend Address */
  368. MS_NET_ADDR addr;
  369. /* Low Power Node Counter */
  370. UINT16 lpn_counter;
  371. /* Friend Counter - TODO: Should be a global index? */
  372. UINT16 frnd_counter;
  373. } MS_TRN_FRNDSHIP_INFO;
  374. /* Invalid LPN Handle */
  375. #define LPN_HANDLE_INVALID MS_CONFIG_LIMITS(MS_MAX_LPNS)
  376. /** Hearbeat Publication state */
  377. typedef struct _MS_TRN_HEARTBEAT_PUBLICATION_INFO
  378. {
  379. /**
  380. * Destination address for Heartbeat messages
  381. */
  382. MS_NET_ADDR daddr;
  383. /**
  384. * Count to control the number of periodic heartbeat
  385. * transport messages to be sent
  386. */
  387. UINT8 count_log;
  388. /**
  389. * Period to control the cadence of periodic heartbeat
  390. * transport messages
  391. */
  392. UINT8 period_log;
  393. /**
  394. * TTL value to be used when sending Heartbeat messages
  395. */
  396. UINT8 ttl;
  397. /**
  398. * Features that trigger sending Heartbeat messages when changed
  399. */
  400. UINT16 features;
  401. /**
  402. * Global NetKey index of the NetKey to be used to send Heartbeat messges
  403. */
  404. UINT16 netkey_index;
  405. }MS_TRN_HEARTBEAT_PUBLICATION_INFO;
  406. /** Hearbeat Subscription state */
  407. typedef struct _MS_TRN_HEARTBEAT_SUBSCRIPTION_INFO
  408. {
  409. /**
  410. * Source address for Heartbeat messages that a node shall process
  411. */
  412. MS_NET_ADDR saddr;
  413. /**
  414. * Destination address for Heartbeat messages
  415. */
  416. MS_NET_ADDR daddr;
  417. /**
  418. * Counter that tracks the number of periodic heartbeat transport message
  419. * received since receiving the most recent Config Heartbeat Subscription
  420. * Set message
  421. */
  422. UINT8 count_log;
  423. /**
  424. * Period that controls the period for processing periodical Heartbeat
  425. * transport control messages
  426. */
  427. UINT8 period_log;
  428. /**
  429. * Minimum hops value registered when receiving heartbeat messages since
  430. * receiving the most recent Config Heartbeat Subscription Set message
  431. */
  432. UINT16 min_hops;
  433. /**
  434. * Maximum hops value registered when receiving heartbeat messages since
  435. * receiving the most recent Config Heartbeat Subscription Set message
  436. */
  437. UINT16 max_hops;
  438. }MS_TRN_HEARTBEAT_SUBSCRIPTION_INFO;
  439. /** \} */
  440. /** \} */
  441. /** TCF (Transport Control Field) - Transport Field Value */
  442. /* --------------------------------------------- Function */
  443. /**
  444. * \defgroup trn_api_defs API Definitions
  445. * \{
  446. * This section describes the EtherMind Mesh Transport Layer APIs.
  447. */
  448. #ifdef __cplusplus
  449. extern "C" {
  450. #endif
  451. /**
  452. * \brief Register Inerface with Transport Layer
  453. *
  454. * \par Description
  455. * This routine registers interface with the Transport Layer.
  456. * Transport Layer supports single Application, hence this rouine shall be called once.
  457. *
  458. * \param [in] trn_cb
  459. * Upper Layer Notification Callback for specific message type
  460. *
  461. * \param [in] msg_type
  462. * Message type (Control or Access) for which the callback to be called.
  463. *
  464. * \return API_SUCCESS or an error code indicating reason for failure
  465. */
  466. API_RESULT MS_trn_register
  467. (
  468. /* IN */ TRN_NTF_CB trn_cb,
  469. /* IN */ MS_TRN_MSG_TYPE msg_type
  470. );
  471. API_RESULT MS_trn_heartbeat_register
  472. (
  473. /* IN */ TRN_HEARTBEAT_RCV_CB rcv_cb,
  474. /* IN */ TRN_HEARTBEAT_RCV_TIMEOUT_CB rcv_to_cb
  475. );
  476. /**
  477. * \brief API to send Access Layer PDUs
  478. *
  479. * \par Description
  480. * This routine sends Access Layer PDUs to peer device.
  481. *
  482. * \param [in] src_addr
  483. * Source Address
  484. *
  485. * \param [in] dst_addr
  486. * Destination Address
  487. *
  488. * \param [in] label
  489. * Lable UUID, represending Virtual Address of Destination
  490. *
  491. * \param [in] subnet_handle
  492. * Handle identifying the Subnet
  493. *
  494. * \param [in] appkey_handle
  495. * Handle identifying the AppKey to be used for Transport Layer encryption.
  496. *
  497. * \param [in] ttl
  498. * Time to Live
  499. *
  500. * \param [in] param
  501. * Transport parameter, based on the type and header
  502. *
  503. * \param [in] reliable
  504. * If requires lower transport Ack, set reliable as TRUE
  505. *
  506. * \return API_SUCCESS or an error code indicating reason for failure
  507. */
  508. API_RESULT MS_trn_send_access_pdu
  509. (
  510. /* IN */ MS_NET_ADDR src_addr,
  511. /* IN */ MS_NET_ADDR dst_addr,
  512. /* IN */ UINT8 * label,
  513. /* IN */ MS_SUBNET_HANDLE subnet_handle,
  514. /* IN */ MS_APPKEY_HANDLE appkey_handle,
  515. /* IN */ UINT8 ttl,
  516. /* IN */ void * param,
  517. /* IN */ UINT8 reliable
  518. );
  519. /**
  520. * \brief API to send transport Control PDUs
  521. *
  522. * \par Description
  523. * This routine sends transport Control PDUs to peer device.
  524. *
  525. * \param [in] src_addr
  526. * Source Address
  527. *
  528. * \param [in] dst_addr
  529. * Destination Address
  530. *
  531. * \param [in] subnet_handle
  532. * Handle identifying the Subnet
  533. *
  534. * \param [in] ttl
  535. * Time to Live
  536. *
  537. * \param [in] ctrl_opcode
  538. * Control Packet Opcode.
  539. *
  540. * \param [in] param
  541. * Transport parameter, based on the type and header
  542. *
  543. * \return API_SUCCESS or an error code indicating reason for failure
  544. */
  545. API_RESULT MS_trn_send_control_pdu
  546. (
  547. /* IN */ MS_NET_ADDR src_addr,
  548. /* IN */ MS_NET_ADDR dst_addr,
  549. /* IN */ MS_SUBNET_HANDLE subnet_handle,
  550. /* IN */ UINT8 ttl,
  551. /* IN */ MS_TRN_CTRL_PKT_OPCODE ctrl_opcode,
  552. /* IN */ void * param
  553. );
  554. /**
  555. * \brief API to setup Friendship.
  556. *
  557. * \par Description
  558. * This routine is used by the device acting as a low power node
  559. * to setup a friendship procedure to any available friend nodes.
  560. *
  561. * \param [in] subnet_handle
  562. * The subnet to initiate the friendship procedure.
  563. *
  564. * \param [in] criteria
  565. * Friend criteria that is required. RSSI, Receive Window,
  566. * MessageQueue size requirements can be established.
  567. *
  568. * \param [in] rx_delay
  569. * Receive delay in milliseconds that the LPN will wait before
  570. * listening to response for any request.
  571. *
  572. * \param [in] poll_timeout
  573. * Timeout in milliseconds after which the LPN will send Poll PDU
  574. * to check for data from the friend.
  575. *
  576. * \param [in] setup_timeout
  577. * Timeout in milliseconds for which the Friend Establishment
  578. * procedure is to be tried.
  579. *
  580. * \param [in] cb
  581. * Application Callback to notify the result of friendship procedures.
  582. *
  583. * \return API_SUCCESS or an error code indicating reason for failure
  584. */
  585. API_RESULT MS_trn_lpn_setup_friendship
  586. (
  587. /* IN */ MS_SUBNET_HANDLE subnet_handle,
  588. /* IN */ UCHAR criteria,
  589. /* IN */ UCHAR rx_delay,
  590. /* IN */ UINT32 poll_timeout,
  591. /* IN */ UINT32 setup_timeout,
  592. /* IN */ TRN_FRND_CB cb
  593. );
  594. /**
  595. * \brief API to terminate friendship.
  596. *
  597. * \par Description
  598. * This routine is used by the device acting as a low power node
  599. * terminate friendship with an active Friend node.
  600. *
  601. * \return API_SUCCESS or an error code indicating reason for failure
  602. */
  603. API_RESULT MS_trn_lpn_clear_friendship(void);
  604. /**
  605. * \brief API to manage friend subscription list.
  606. *
  607. * \par Description
  608. * This routine is used by the device acting as a low power node
  609. * add/remove addresses to/from the friends subscription list.
  610. *
  611. * \param [in] action
  612. * Will be one of MS_TRN_CTRL_OPCODE_FRND_SUBSCRN_LIST_ADD or
  613. * MS_TRN_CTRL_OPCODE_FRND_SUBSCRN_LIST_REMOVE
  614. *
  615. * \param [in] addr_list
  616. * Pointer to the packed list of addresses to be managed.
  617. *
  618. * \param [in] count
  619. * Number of addresses given.
  620. *
  621. * \return API_SUCCESS or an error code indicating reason for failure
  622. */
  623. API_RESULT MS_trn_lpn_manage_subscription
  624. (
  625. UCHAR action,
  626. UINT16 * addr_list,
  627. UINT16 count
  628. );
  629. /**
  630. * \brief API to add to friend subscription list.
  631. *
  632. * \par Description
  633. * This routine is used by the device acting as a low power node
  634. * add addresses to the friends subscription list.
  635. *
  636. * \param [in] addr_list
  637. * Pointer to the list of addresses to be managed.
  638. *
  639. * \param [in] count
  640. * Number of addresses given.
  641. *
  642. * \return API_SUCCESS or an error code indicating reason for failure
  643. */
  644. #define MS_trn_lpn_subscrn_list_add(addr_list, count)\
  645. MS_trn_lpn_manage_subscription\
  646. (\
  647. MS_TRN_CTRL_OPCODE_FRND_SUBSCRN_LIST_ADD,\
  648. (addr_list),\
  649. (count)\
  650. );
  651. /**
  652. * \brief API to remove from friend subscription list.
  653. *
  654. * \par Description
  655. * This routine is used by the device acting as a low power node
  656. * remove addresses from the friends subscription list.
  657. *
  658. * \param [in] addr_list
  659. * Pointer to the list of addresses to be managed.
  660. *
  661. * \param [in] count
  662. * Number of addresses given.
  663. *
  664. * \return API_SUCCESS or an error code indicating reason for failure
  665. */
  666. #define MS_trn_lpn_subscrn_list_remove(addr_list, count)\
  667. MS_trn_lpn_manage_subscription\
  668. (\
  669. MS_TRN_CTRL_OPCODE_FRND_SUBSCRN_LIST_REMOVE,\
  670. (addr_list),\
  671. (count)\
  672. );
  673. /**
  674. * \brief To check if address matches with any of the LPN
  675. *
  676. * \par Description
  677. * This routine checks if destination address in a received packet matches
  678. * with any of the known element address of LPN.
  679. *
  680. * \param [in] addr Unicast Address to search
  681. * \param [out] lpn_handle LPN Handle on match
  682. *
  683. * \return API_SUCCESS or an error code indicating reason for failure
  684. */
  685. API_RESULT MS_trn_is_valid_lpn_element_address
  686. (
  687. /* IN */ MS_NET_ADDR addr,
  688. /* OUT */ LPN_HANDLE * lpn_handle
  689. );
  690. /**
  691. * \brief To check if valid subscription address of an LPN to receive a packet
  692. *
  693. * \par Description
  694. * This routine checks if destination address in a received packet matches
  695. * with any of the known subscription address of an LPN.
  696. *
  697. * \param [in] addr Address to search
  698. * \param [out] lpn_handle Pointer to an LPN Handle, which will be filled
  699. * if match found
  700. *
  701. * \return API_SUCCESS or an error code indicating reason for failure
  702. */
  703. API_RESULT MS_trn_is_valid_lpn_subscription_address
  704. (
  705. /* IN */ MS_NET_ADDR addr,
  706. /* OUT */ LPN_HANDLE * lpn_handle
  707. );
  708. /**
  709. * \brief To check if valid uicast address of an LPN to receive a packet
  710. *
  711. * \par Description
  712. * This routine checks if destination address in a received packet matches
  713. * with any of the known subscription address of an LPN.
  714. *
  715. * \param [in] addr Address to search
  716. * \param [in] lpn_handle An LPN Handle, which will be filled
  717. * if match found
  718. *
  719. * \return API_SUCCESS or an error code indicating reason for failure
  720. */
  721. API_RESULT MS_trn_is_valid_lpn_uincast_address
  722. (
  723. /* IN */ MS_NET_ADDR addr,
  724. /* IN */ LPN_HANDLE lpn_handle
  725. );
  726. /**
  727. * \brief To get Poll Timeout of an LPN
  728. *
  729. * \par Description
  730. * This routine checks if LPN address is valid and then returns
  731. * Poll Timeout configured for the LPN.
  732. *
  733. * \param [in] lpn_addr LPN Address to search
  734. * \param [out] poll_timeout Memory where poll timeout of the LPN to be filled
  735. * (if match found)
  736. *
  737. * \return API_SUCCESS or an error code indicating reason for failure
  738. */
  739. API_RESULT MS_trn_get_lpn_polltimeout
  740. (
  741. /* IN */ MS_NET_ADDR lpn_addr,
  742. /* OUT */ UINT32 * poll_timeout
  743. );
  744. /**
  745. * \brief To get the LPN node information
  746. *
  747. * \par Description
  748. * This routine fetches the node information of the LPN element at the
  749. * given index
  750. *
  751. * \param [in] role Local friendship role
  752. * \param [in] lpn_index Index of the LPN element
  753. * \param [out] node Pointer to copy the information
  754. *
  755. * \return API_SUCCESS or an error code indicating reason for failure
  756. */
  757. API_RESULT MS_trn_get_frndship_info
  758. (
  759. UINT8 role,
  760. UINT16 lpn_index,
  761. MS_TRN_FRNDSHIP_INFO * node
  762. );
  763. /**
  764. * \brief To add the security update information
  765. *
  766. * \par Description
  767. * This routine updates the security state of the network to all the active
  768. * LPN elements. This will be forwarded to the elements when it polls for the
  769. * next packet available.
  770. *
  771. * \param [in] subnet_handle Handle to identitfy the network.
  772. * \param [in] flag Flag indicating the Key Refresh and IV Update state.
  773. * \param [in] ivindex Current IV Index of teh network.
  774. *
  775. * \return API_SUCCESS or an error code indicating reason for failure
  776. */
  777. API_RESULT MS_trn_lpn_register_security_update
  778. (
  779. /* IN */ MS_SUBNET_HANDLE subnet_handle,
  780. /* IN */ UCHAR flag,
  781. /* IN */ UINT32 ivindex
  782. );
  783. /**
  784. * \brief To clear information related to all LPNs
  785. *
  786. * \par Description
  787. * This routine clears information related to all LPNs.
  788. *
  789. * \return API_SUCCESS or an error code indicating reason for failure
  790. */
  791. API_RESULT MS_trn_clear_all_lpn
  792. (
  793. void
  794. );
  795. /**
  796. * \brief To set the Heartbeat publication data
  797. *
  798. * \par Description
  799. * This routine configures the Heartbeat publication information
  800. *
  801. * \param [out] info Heartbeat Publication information data as
  802. * in \ref MS_TRN_HEARTBEAT_PUBLICATION_INFO
  803. *
  804. * \return API_SUCCESS or an error code indicating reason for failure
  805. */
  806. API_RESULT MS_trn_set_heartbeat_publication
  807. (
  808. /* INOUT */ MS_TRN_HEARTBEAT_PUBLICATION_INFO * info
  809. );
  810. /**
  811. * \brief To get the Heartbeat publication data
  812. *
  813. * \par Description
  814. * This routine retrieves the Heartbeat publication information
  815. *
  816. * \param [out] info Heartbeat Publication information data as
  817. * in \ref MS_TRN_HEARTBEAT_PUBLICATION_INFO
  818. *
  819. * \return API_SUCCESS or an error code indicating reason for failure
  820. */
  821. API_RESULT MS_trn_get_heartbeat_publication
  822. (
  823. /* OUT */ MS_TRN_HEARTBEAT_PUBLICATION_INFO * info
  824. );
  825. /**
  826. * \brief To set the Heartbeat subscription data
  827. *
  828. * \par Description
  829. * This routine configures the Heartbeat subscription information
  830. *
  831. * \param [in, out] info Heartbeat Subscription information data as
  832. * in \ref MS_TRN_HEARTBEAT_SUBSCRIPTION_INFO
  833. *
  834. * \return API_SUCCESS or an error code indicating reason for failure
  835. */
  836. API_RESULT MS_trn_set_heartbeat_subscription
  837. (
  838. /* INOUT */ MS_TRN_HEARTBEAT_SUBSCRIPTION_INFO * info
  839. );
  840. /**
  841. * \brief To get the Heartbeat subscription data
  842. *
  843. * \par Description
  844. * This routine retrieves the Heartbeat subscription information
  845. *
  846. * \param [out] info Heartbeat Subscription information data as
  847. * in \ref MS_TRN_HEARTBEAT_SUBSCRIPTION_INFO
  848. *
  849. * \return API_SUCCESS or an error code indicating reason for failure
  850. */
  851. API_RESULT MS_trn_get_heartbeat_subscription
  852. (
  853. /* OUT */ MS_TRN_HEARTBEAT_SUBSCRIPTION_INFO * info
  854. );
  855. /**
  856. * \brief To trigger Heartbeat send on change in feature
  857. *
  858. * \par Description
  859. * This routine triggers the Heartbeat send on change in state of supported
  860. * features.
  861. *
  862. * \param [in] change_in_feature_bit Bit mask of the changed feature field
  863. *
  864. * \return API_SUCCESS or an error code indicating reason for failure
  865. */
  866. API_RESULT MS_trn_trigger_heartbeat (/* IN */ UINT8 change_in_feature_bit);
  867. void trn_stop_heartbeat_pub_timer(void);
  868. void trn_start_heartbeat_sub_timer(/* IN */ UINT32 timeout);
  869. void trn_stop_heartbeat_sub_timer(void);
  870. void trn_heartbeat_timer_restart(void);
  871. #ifdef __cplusplus
  872. };
  873. #endif
  874. /** \} */
  875. /** \} */
  876. #endif /* _H_MS_TRN_API_ */