MS_net_api.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848
  1. /**
  2. * \file MS_net_api.h
  3. *
  4. * \brief This file defines the Mesh Network Layer Interface - includes
  5. * Data Structures and Methods.
  6. */
  7. /*
  8. * Copyright (C) 2017. Mindtree Ltd.
  9. * All rights reserved.
  10. */
  11. #ifndef _H_MS_NET_API_
  12. #define _H_MS_NET_API_
  13. /* --------------------------------------------- Header File Inclusion */
  14. /* Bearer Layer */
  15. #include "MS_brr_api.h"
  16. #include "MS_prov_api.h"
  17. /* --------------------------------------------- Global Definitions */
  18. /**
  19. * \defgroup net_module NETWORK (Mesh Network Layer)
  20. * \{
  21. * This section describes the interfaces & APIs offered by the EtherMind
  22. * Mesh Network (NETWORK) module to the Application and other upper
  23. * layers of the stack.
  24. */
  25. /**
  26. * \defgroup net_defines Defines
  27. * \{
  28. * Describes defines for the module.
  29. */
  30. /**
  31. * \defgroup net_constants Constants
  32. * \{
  33. * Describes Constants defined by the module.
  34. */
  35. /**
  36. * \defgroup net_addressing Addressing
  37. * \{
  38. * Describes five basic type of addresses, the Network Layer defines.
  39. */
  40. /**
  41. * Unassigned Address.
  42. * An unassigned address is an address that means that the component of a node
  43. * has not been configured yet or no address has been allocated.
  44. *
  45. * An unassigned address shall not be used in a source or destination address
  46. * field of a message.
  47. *
  48. * A Primary Component shall not have an unassigned address.
  49. * A Secondary Component may have an unassigned address.
  50. * A component with an unassigned address is inactive (i.e., it cannot send
  51. * nor receive and process messages).
  52. */
  53. #define MS_NET_ADDR_UNASSIGNED 0x0000
  54. /** Network Address Type - Invalid */
  55. #define MS_NET_ADDR_TYPE_INVALID 0x00
  56. /**
  57. * Unicast Address.
  58. * A unicast address is a unique address allocated to each component within a node.
  59. * A unicast address has bit 15 cleared to zero.
  60. * The unicast address shall not have the value 0x0000,
  61. * and therefore can have any value from 0x0001 to 0x7FFF inclusive.
  62. *
  63. * A unicast address is allocated to a primary component of an unprovisioned
  64. * device by the Provisioner during provisioning for the lifetime of the node
  65. * on the network.
  66. *
  67. * A unicast address can be allocated to any secondary component within
  68. * an already provisioned node.
  69. *
  70. * A unicast address shall be used in the source address field of a message
  71. * and can be used in a destination address field of a message.
  72. * A message sent to a unicast address will be processed by at most one node
  73. * or one component within a node.
  74. */
  75. /** Bitmask for Network Address Type - Unicast */
  76. #define MS_NET_ADDR_UNICAST_BIT_MASK 0x8000
  77. /** Comparison value for Network Address Type - Unicast */
  78. #define MS_NET_ADDR_UNICAST_COMPARE 0x0000
  79. /** Network Address Type - Unicast */
  80. #define MS_NET_ADDR_TYPE_UNICAST 0x01
  81. /**
  82. * Virtual Address.
  83. * A virtual address is an address that is similar to a group address,
  84. * in that multiple devices may know such an address.
  85. * This type of address is used to identify a label to which devices
  86. * may publish or subscribe.
  87. * The label referred to by a given virtual address is uniquely identified
  88. * by a 128-bit UUID, called virtual label UUID.
  89. *
  90. * The format of a Virtual Address is 10vv vvvv vvvv vvvv.
  91. * The fourteen v-bits are the least significant bits of the following calculation:
  92. * v = AES-CMAC (virtual label UUID, "vtad")[0-13]
  93. */
  94. /** Bitmask for Network Address Type - Virtual */
  95. #define MS_NET_ADDR_VIRTUAL_BIT_MASK 0xC000
  96. /** Comparison value for Network Address Type - Virtual */
  97. #define MS_NET_ADDR_VIRTUAL_COMPARE 0x8000
  98. /** Network Address Type - Virtual */
  99. #define MS_NET_ADDR_TYPE_VIRTUAL 0x02
  100. /**
  101. * Group Address.
  102. * A group address is an address that is programmed into zero or more nodes or
  103. * components within nodes.
  104. * A group address has bit 15 set to one and bit 14 set to one.
  105. * The group address shall not have the value 0xFFFF, and therefore can have
  106. * any value from 0xC000 to 0xFFFE.
  107. * A group address shall only be used in the destination address field of a message.
  108. * A message sent to a group address will be processed by all the nodes that know
  109. * this group address.
  110. */
  111. /** Bitmask for Network Address Type - Group */
  112. #define MS_NET_ADDR_GROUP_BIT_MASK 0xC000
  113. /** Comparison value for Network Address Type - Group */
  114. #define MS_NET_ADDR_GROUP_COMPARE 0xC000
  115. /** Network Address Type - Group */
  116. #define MS_NET_ADDR_TYPE_GROUP 0x03
  117. /**
  118. * Fixed Group Addresses are all-proxies, all-friends, all-relays and all-nodes.
  119. *
  120. * Note: Fixed Group Addresses in the range 0xFF00 - 0xFFFB are Reserved for Future.
  121. */
  122. /** Fixed Group Address - All-Proxies */
  123. #define MS_NET_ADDR_ALL_PROXIES 0xFFFC
  124. /** Fixed Group Address - All-Friends */
  125. #define MS_NET_ADDR_ALL_FRIENDS 0xFFFD
  126. /** Fixed Group Address - All-Relays */
  127. #define MS_NET_ADDR_ALL_RELAYS 0xFFFE
  128. /** Fixed Group Address - All-Nodes */
  129. #define MS_NET_ADDR_ALL_NODES 0xFFFF
  130. /**
  131. * Address Validity
  132. *
  133. * | Address Type | Valid in Source Address Field | Valid in Destination Address Field |
  134. * | :----------: | :----------------------------: | :--------------------------------: |
  135. * | Unassigned | No | No |
  136. * | Unicast | Yes | Yes |
  137. * | Virtual | No | Yes |
  138. * | Group | No | Yes |
  139. * | Broadcast | No | Yes |
  140. */
  141. /** Network Layer Feature Idenfiers */
  142. /** Network Layer Feature - Proxy */
  143. #define MS_NET_FEATURE_PROXY 0x00
  144. /** Network Layer Feature - Relay */
  145. #define MS_NET_FEATURE_RELAY 0x01
  146. /** Primary Subnet - NetKey Index is 0x000 */
  147. #define MS_PRIMARY_SUBNET 0x000
  148. /** Invalid Subnet Handle */
  149. #define MS_INVALID_SUBNET_HANDLE 0xFFFF
  150. /** Invalid AppKey Handle */
  151. #define MS_INVALID_APPKEY_HANDLE 0xFFFF
  152. /** \} */
  153. /**
  154. * \defgroup net_proxy Proxy
  155. * \{
  156. * Describes Network Layer Proxy Feature related defines.
  157. */
  158. /** GATT Proxy Filter Types */
  159. /** GATT Proxy Filter Type - Whitelist */
  160. #define MS_PROXY_WHITELIST_FILTER 0x00
  161. /** GATT Proxy Filter Type - Blacklist */
  162. #define MS_PROXY_BLACKLIST_FILTER 0x01
  163. /** GATT Proxy Configuration Opcodes */
  164. /** GATT Proxy Configuration - Set Filter Opcode */
  165. #define MS_PROXY_SET_FILTER_OPCODE 0x00
  166. /** GATT Proxy Configuration - Add to Filter Opcode */
  167. #define MS_PROXY_ADD_TO_FILTER_OPCODE 0x01
  168. /** GATT Proxy Configuration - Remove From Filter Opcode */
  169. #define MS_PROXY_REM_FROM_FILTER_OPCODE 0x02
  170. /** GATT Proxy Configuration - Filter Status Opcode */
  171. #define MS_PROXY_FILTER_STATUS_OPCODE 0x03
  172. /** GATT Proxy ADV Modes */
  173. /** Network ID Type */
  174. #define MS_PROXY_NET_ID_ADV_MODE 0x01
  175. /** Node Idetity Type */
  176. #define MS_PROXY_NODE_ID_ADV_MODE 0x02
  177. /** \} */
  178. /** \} */
  179. /**
  180. * \defgroup net_events Events
  181. * \{
  182. * This section lists the Asynchronous Events notified to Application by the
  183. * Module.
  184. */
  185. /** GATT Proxy Events */
  186. /** GATT Proxy Event - Interface UP */
  187. #define MS_PROXY_UP_EVENT 0x00
  188. /** GATT Proxy Event - Interface Down */
  189. #define MS_PROXY_DOWN_EVENT 0x01
  190. /** GATT Proxy Event - Status */
  191. #define MS_PROXY_STATUS_EVENT 0x02
  192. /** \} */
  193. /**
  194. * \defgroup net_proxy states
  195. * \{
  196. * This section lists the various states of Proxy Module exposed by it to
  197. * other Modules.
  198. */
  199. /**
  200. * GATT Proxy States.
  201. *
  202. * | Proxy Callback | Proxy Iface | Error Code
  203. * |------------------|--------------|-------------------
  204. * | NULL | Down | MS_PROXY_NULL
  205. * | NULL | Up | MS_PROXY_NULL
  206. * | !NULL | Down | MS_PROXY_READY
  207. * | !NULL | UP | MS_PROXY_CONNECTED
  208. */
  209. /** GATT Proxy State - Invalid/Not Initialized */
  210. #define MS_PROXY_NULL 0x00
  211. /** GATT Proxy State - Ready/Initialized */
  212. #define MS_PROXY_READY 0x01
  213. /** GATT Proxy State - Connected */
  214. #define MS_PROXY_CONNECTED 0x02
  215. /* Secure Beacon Network Timer (minimum of 10 s) */
  216. extern EM_timer_handle ms_snb_timer_handle;
  217. extern EM_timer_handle ms_iv_update_timer_handle;
  218. extern EM_timer_handle net_key_refresh_timer_handle;
  219. /* Secure Beacon Network Beacon Timeout value - default 10s */
  220. #define MS_SNB_TIMEOUT (10 * 1000) /* in ms */
  221. /** \} */
  222. /** \} */
  223. /**
  224. * \defgroup net_marcos Utility Macros
  225. * \{
  226. * Initialization and other Utility Macros offered by the module.
  227. */
  228. /** \} */
  229. /* --------------------------------------------- Data Types/ Structures */
  230. /**
  231. * \addtogroup net_defines Defines
  232. * \{
  233. */
  234. /**
  235. * \addtogroup net_structures Structures
  236. * \{
  237. */
  238. /** Network Address Type */
  239. typedef UINT16 MS_NET_ADDR;
  240. /** Subnet Handle */
  241. typedef UINT16 MS_SUBNET_HANDLE;
  242. /** AppKey Handle */
  243. typedef UINT16 MS_APPKEY_HANDLE;
  244. /** Address Type */
  245. typedef UCHAR MS_NET_ADDR_TYPE;
  246. /** Network Header Type */
  247. typedef struct _MS_NET_HEADER
  248. {
  249. /** Least significant bit of IV Index - 1 bit */
  250. UINT8 ivi;
  251. /**
  252. * Value derived from the NetKey used to identify
  253. * the Encrytion Key and Privacy Key used to secure
  254. * this PDU - 7 bits
  255. */
  256. UINT8 nid;
  257. /** Network Control - 1 bit */
  258. UINT8 ctl;
  259. /** Time To Live - 7 bits */
  260. UINT8 ttl;
  261. /** 16 Bit Source Address */
  262. MS_NET_ADDR saddr;
  263. /** 16 Bit Destination Address */
  264. MS_NET_ADDR daddr;
  265. /** 24 bit sequence number - currently filled only in recption path */
  266. UINT32 seq_num;
  267. } MS_NET_HEADER;
  268. /** Data structures for filter type and address list */
  269. typedef UCHAR PROXY_FILTER_TYPE;
  270. /** Proxy Address */
  271. typedef MS_NET_ADDR PROXY_ADDR;
  272. /** Network Interface Handle */
  273. typedef UINT8 NETIF_HANDLE;
  274. /** Current Sequence Number and Block State */
  275. typedef struct _NET_SEQ_NUMBER_STATE
  276. {
  277. /** Current Sequence Number */
  278. UINT32 seq_num;
  279. /** Block Sequence number - maximum available */
  280. UINT32 block_seq_num_max;
  281. } NET_SEQ_NUMBER_STATE;
  282. /** \} */
  283. /** \} */
  284. /**
  285. * \defgroup net_cb Application Callback
  286. * \{
  287. * This Section Describes the module Notification Callback interface offered
  288. * to the application
  289. */
  290. /**
  291. * NETWORK Application Asynchronous Notification Callback.
  292. *
  293. * NETWORK calls the registered callback to indicate events occurred to the
  294. * application.
  295. *
  296. * \param brr_type Bearer Type.
  297. * \param net_hdr Network Header.
  298. * \param subnet_handle Associated Subnet Handle.
  299. * \param data_param Data associated with the event if any or NULL.
  300. * \param data_len Size of the event data. 0 if event data is NULL.
  301. *
  302. * \return
  303. * - \ref NET_POST_PROCESS_RX_PKT: To inform Network Layer if the packet to be
  304. * further processed, e.g. to be relayed or proxied etc.
  305. *
  306. * - Any Other Result/Error Code defined in MS_error.h: Ignored by Network Layer.
  307. */
  308. typedef API_RESULT (*NET_NTF_CB)
  309. (
  310. MS_NET_HEADER * net_hdr,
  311. MS_SUBNET_HANDLE subnet_handle,
  312. UCHAR * data_param,
  313. UINT16 data_len
  314. ) DECL_REENTRANT;
  315. /**
  316. * Network Proxy Application Asynchronous Notification Callback.
  317. *
  318. * NETWORK PROXY calls the registered callback to indicate events occurred to the
  319. * application.
  320. *
  321. * \param handle Network Interface Handle.
  322. * \param p_evt Proxy Event.
  323. * \param data_param Data associated with the event if any or NULL.
  324. * \param data_len Size of the event data. 0 if event data is NULL.
  325. */
  326. typedef void (*PROXY_NTF_CB)
  327. (
  328. NETIF_HANDLE * handle,
  329. UCHAR p_evt,
  330. UCHAR * data_param,
  331. UINT16 data_len
  332. ) DECL_REENTRANT;
  333. /** \} */
  334. /**
  335. * \defgroup net_api_defs API Definitions
  336. * \{
  337. * This section describes the EtherMind Mesh Network Layer APIs.
  338. */
  339. /**
  340. * Macro to check if Unicast Address
  341. */
  342. #define MS_IS_UNICAST_ADDR(addr) \
  343. (((MS_NET_ADDR_UNASSIGNED != (addr)) && \
  344. (MS_NET_ADDR_UNICAST_COMPARE == ((addr) & MS_NET_ADDR_UNICAST_BIT_MASK))) \
  345. ? MS_TRUE : MS_FALSE)
  346. /**
  347. * Macro to check if Virtual Address
  348. */
  349. #define MS_IS_VIRTUAL_ADDR(addr) \
  350. ((MS_NET_ADDR_VIRTUAL_COMPARE == ((addr) & MS_NET_ADDR_VIRTUAL_BIT_MASK)) \
  351. ? MS_TRUE : MS_FALSE)
  352. /**
  353. * Macro to check if Group Address
  354. */
  355. #define MS_IS_GROUP_ADDR(addr) \
  356. ((MS_NET_ADDR_GROUP_COMPARE == ((addr) & MS_NET_ADDR_GROUP_BIT_MASK)) \
  357. ? MS_TRUE : MS_FALSE)
  358. /**
  359. * Source address shall be Unicast Address.
  360. */
  361. #define NET_IS_VALID_SRC_ADDR(addr) \
  362. MS_IS_UNICAST_ADDR(addr)
  363. /**
  364. * Destination address
  365. * - Shall not be Unassigned Address.
  366. * - Control Message shall not be a Virtual Address.
  367. */
  368. #define NET_IS_VALID_DST_ADDR(addr, ctl) \
  369. (((MS_NET_ADDR_UNASSIGNED != (addr)) && \
  370. ((0x01 != (ctl)) || (MS_FALSE == MS_IS_VIRTUAL_ADDR(addr)))) \
  371. ? MS_TRUE : MS_FALSE)
  372. #ifdef MS_PROXY_CLIENT
  373. /* GATT Proxy Client Related defines */
  374. /**
  375. * \brief Set Proxy WhiteList Filter.
  376. *
  377. * \par Description This function is used by the Proxy Client
  378. * to set the filter type on the Proxy Server to \ref MS_PROXY_WHITELIST_FILTER.
  379. *
  380. * \param [in] nh Network Interface Handle
  381. * \param [in] sh Subnet Handle
  382. *
  383. * \note This API will be used by the Proxy Client only.
  384. *
  385. * \return API_SUCCESS or Error Code on failure
  386. */
  387. #define MS_proxy_set_whitelist_filter(nh,sh) \
  388. MS_proxy_set_filter \
  389. ( \
  390. (nh), \
  391. (sh), \
  392. MS_PROXY_WHITELIST_FILTER \
  393. );
  394. /**
  395. * \brief Set Proxy BlackList Filter.
  396. *
  397. * \par Description This function is used by the Proxy Client
  398. * to set the filter type on the Proxy Server to \ref MS_PROXY_BLACKLIST_FILTER.
  399. *
  400. * \param [in] nh Network Interface Handle
  401. * \param [in] sh Subnet Handle
  402. *
  403. * \note This API will be used by the Proxy Client only.
  404. *
  405. * \return API_SUCCESS or Error Code on failure
  406. */
  407. #define MS_proxy_set_blacklist_filter(nh,sh) \
  408. MS_proxy_set_filter \
  409. ( \
  410. (nh), \
  411. (sh), \
  412. MS_PROXY_BLACKLIST_FILTER \
  413. );
  414. /**
  415. * \brief Add addressess to Proxy Filter List.
  416. *
  417. * \par Description This function is used by the Proxy Client
  418. * to add Addressess to the Proxy Server's filter List.
  419. *
  420. * \param [in] nh Network Interface Handle
  421. * \param [in] sh Subnet Handle
  422. * \param [in] a Pointer to List of Address to be added
  423. * \param [in] c Count of Addressess present in the provided List
  424. *
  425. * \note This API will be used by the Proxy Client only.
  426. *
  427. * \return API_SUCCESS or Error Code on failure
  428. */
  429. #define MS_proxy_add_to_list(nh,sh,a,c) \
  430. MS_proxy_filter_op \
  431. ( \
  432. (nh), \
  433. (sh), \
  434. MS_PROXY_ADD_TO_FILTER_OPCODE, \
  435. (a), \
  436. (c) \
  437. );
  438. /**
  439. * \brief Delete addresses from Proxy Filter List.
  440. *
  441. * \par Description This function is used by the Proxy Client
  442. * to delete/remove Addresses from the Proxy Server's filter List.
  443. *
  444. * \param [in] nh Network Interface Handle
  445. * \param [in] sh Subnet Handle
  446. * \param [in] a Pointer to List of Address to be deleted/removed
  447. * \param [in] c Count of Addressess present in the provided List
  448. *
  449. * \note This API will be used by the Proxy Client only.
  450. *
  451. * \return API_SUCCESS or Error Code on failure
  452. */
  453. #define MS_proxy_del_from_list(nh,sh,a,c) \
  454. MS_proxy_filter_op \
  455. ( \
  456. (nh), \
  457. (sh), \
  458. MS_PROXY_REM_FROM_FILTER_OPCODE, \
  459. (a), \
  460. (c) \
  461. );
  462. #endif /* MS_PROXY_CLIENT */
  463. /* --------------------------------------------- Function */
  464. #ifdef __cplusplus
  465. extern "C" {
  466. #endif
  467. /**
  468. * \brief Register Inerface with NETWORK Layer
  469. *
  470. * \par Description
  471. * This routine registers interface with the NETWORK Layer.
  472. * NETWORK Layer supports only one upper layer, hence this routine shall be called once.
  473. *
  474. * \param [in] net_cb
  475. * Upper Layer Notification Callback
  476. *
  477. * \return API_SUCCESS or an error code indicating reason for failure
  478. */
  479. API_RESULT MS_net_register
  480. (
  481. /* IN */ NET_NTF_CB net_cb
  482. );
  483. /**
  484. * \brief API to send Secure Network Beacon
  485. *
  486. * \par Description
  487. * This routine sends Secure Network Beacon for the
  488. * given subnet handle
  489. *
  490. * \param [in] subnet_handle
  491. * Subnet handle of the network to be broadcasted.
  492. *
  493. * \return API_SUCCESS or an error code indicating reason for failure
  494. */
  495. API_RESULT MS_net_broadcast_secure_beacon
  496. (
  497. /* IN */ MS_SUBNET_HANDLE subnet_handle
  498. );
  499. /**
  500. * \brief API to send NETWORK PDUs
  501. *
  502. * \par Description
  503. * This routine sends NETWORK PDUs to peer device.
  504. *
  505. * \param [in] hdr
  506. * Network Header
  507. *
  508. * \param [in] subnet_handle
  509. * Subnet Handle
  510. *
  511. * \param [in] buffer
  512. * Lower Transport Payload
  513. *
  514. * \return API_SUCCESS or an error code indicating reason for failure
  515. */
  516. API_RESULT MS_net_send_pdu
  517. (
  518. /* IN */ MS_NET_HEADER * hdr,
  519. /* IN */ MS_SUBNET_HANDLE subnet_handle,
  520. /* IN */ MS_BUFFER * buffer
  521. );
  522. /**
  523. * \brief To get address type.
  524. *
  525. * \par Description
  526. * This routine is to get address type for a given address.
  527. *
  528. * \param [in] addr Input Network Address
  529. *
  530. * \return One of the following address type
  531. * \ref MS_NET_ADDR_TYPE_INVALID
  532. * \ref MS_NET_ADDR_TYPE_UNICAST
  533. * \ref MS_NET_ADDR_TYPE_VIRTUAL
  534. * \ref MS_NET_ADDR_TYPE_GROUP
  535. */
  536. MS_NET_ADDR_TYPE MS_net_get_address_type
  537. (
  538. /* IN */ MS_NET_ADDR addr
  539. );
  540. /**
  541. * \brief Register Interface with NETWORK PROXY Layer
  542. *
  543. * \par Description
  544. * This routine registers interface with the NETWORK PROXY Layer.
  545. * NETWORK PROXY Layer supports only one upper layer, hence this rouine shall be called once.
  546. *
  547. * \param [in] proxy_cb
  548. * Upper Layer Notification Callback
  549. *
  550. * \return API_SUCCESS or an error code indicating reason for failure
  551. */
  552. API_RESULT MS_proxy_register
  553. (
  554. /* IN */ PROXY_NTF_CB proxy_cb
  555. );
  556. /**
  557. * \brief Check if the Proxy Module is ready to handle Proxy Messages/Events
  558. *
  559. * \par Description
  560. * This routine returns the current state of the Proxy. The valid states of
  561. * proxy are:
  562. * 1. MS_PROXY_NULL - If no callback registered by Upper Layers
  563. * 2. MS_PROXY_READY - If callback registered and Proxy not connected
  564. * 3. MS_PROXY_CONNECTED - if callback registered and Proxy connected
  565. *
  566. * \param [out] proxy_state returns the current state of the Proxy
  567. *
  568. * \return API_SUCCESS or an error code indicating reason for failure
  569. */
  570. API_RESULT MS_proxy_fetch_state (UCHAR * proxy_state);
  571. #ifdef MS_PROXY_CLIENT
  572. /**
  573. * \cond ignore_this Ignore this block while generating doxygen document
  574. */
  575. /**
  576. * \brief Set Proxy Server's Filter Type.
  577. *
  578. * \par Description This function is used by the Proxy Client
  579. * to set the filter type on the Proxy Server.
  580. *
  581. * \param [in] handle Network Interface Handle
  582. * \param [in] subnet_handle Subnet Handle
  583. * \param [in] type Type of the Proxy Filter to be set. Either
  584. * \ref MS_PROXY_WHITELIST_FILTER or
  585. * \ref MS_PROXY_BLACKLIST_FILTER
  586. *
  587. * \note This API will be used by the Proxy Client only.
  588. *
  589. * \return API_SUCCESS or Error Code on failure
  590. */
  591. API_RESULT MS_proxy_set_filter
  592. (
  593. /* IN */ NETIF_HANDLE * handle,
  594. /* IN */ MS_SUBNET_HANDLE subnet_handle,
  595. /* IN */ PROXY_FILTER_TYPE type
  596. );
  597. /**
  598. * \brief Add or Delete/Remove addresses to/from Proxy Filter List.
  599. *
  600. * \par Description This function is used by the Proxy Client
  601. * to add/delete Addresses to/from the Proxy Server's filter List.
  602. *
  603. * \param [in] handle Network Interface Handle
  604. * \param [in] subnet_handle Subnet Handle
  605. * \param [in] opcode Operation to be performed. Either
  606. * \ref MS_PROXY_ADD_TO_FILTER_OPCODE or
  607. * \ref MS_PROXY_REM_FROM_FILTER_OPCODE
  608. * \param [in] addr Pointer to List of Address to be added/deleted
  609. * \param [in] addr_count Count of Addresses present in the provided List
  610. *
  611. * \note This API will be used by the Proxy Client only.
  612. *
  613. * \return API_SUCCESS or Error Code on failure
  614. */
  615. API_RESULT MS_proxy_filter_op
  616. (
  617. /* IN */ NETIF_HANDLE * handle,
  618. /* IN */ MS_SUBNET_HANDLE subnet_handle,
  619. /* IN */ UCHAR opcode,
  620. /* IN */ PROXY_ADDR * addr,
  621. /* IN */ UINT16 addr_count
  622. );
  623. /**
  624. * \endcond
  625. */
  626. #endif /* MS_PROXY_CLIENT */
  627. /* Function to Start ADV using Proxy */
  628. #ifdef MS_PROXY_SERVER
  629. /**
  630. * \brief Start Connectable Advertisements for a Proxy Server.
  631. *
  632. * \par Description This function is used by the Proxy Server
  633. * to start Connectable Undirected Advertisements.
  634. *
  635. * \param [in] subnet_handle Subnet Handle which the Proxy Server is
  636. * part of.
  637. * \param [in] proxy_adv_mode Mode of Proxy Advertisements. This could
  638. * be of two types
  639. * \ref MS_PROXY_NET_ID_ADV_MODE or
  640. * \ref MS_PROXY_NODE_ID_ADV_MODE
  641. *
  642. * \note This API will be used by the Proxy Server only.
  643. *
  644. * \return API_SUCCESS or Error Code on failure
  645. */
  646. API_RESULT MS_proxy_server_adv_start
  647. (
  648. /* IN */ MS_SUBNET_HANDLE subnet_handle,
  649. /* IN */ UCHAR proxy_adv_mode
  650. );
  651. API_RESULT MS_proxy_server_stop_timer(void);
  652. /**
  653. * \brief Stop Connectable Advertisements for a Proxy Server.
  654. *
  655. * \par Description This function is used by the Proxy Server
  656. * to stop Connectable Undirected Advertisements.
  657. *
  658. * \note This API will be used by the Proxy Server only.
  659. *
  660. * \return API_SUCCESS or Error Code on failure
  661. */
  662. API_RESULT MS_proxy_server_adv_stop (void);
  663. #endif /* MS_PROXY_SERVER */
  664. /**
  665. * \brief To allocate Sequence Number.
  666. *
  667. * \par Description This function is used to allocate
  668. * Sequence Number.
  669. *
  670. * \param [out] seq_num Location where SeqNum to be filled.
  671. *
  672. * \return API_SUCCESS or Error Code on failure
  673. */
  674. API_RESULT MS_net_alloc_seq_num(/* OUT */ UINT32 * seq_num);
  675. API_RESULT MS_net_start_iv_update_timer(UINT8 timer_flag,UINT8 reset_en);
  676. void MS_net_stop_iv_update_timer(void);
  677. /**
  678. * \brief To get current Sequence Number state.
  679. *
  680. * \par Description This function is used to get current
  681. * Sequence Number state.
  682. *
  683. * \param [out] seq_num_state Location where Seq Number state to be filled.
  684. *
  685. * \return API_SUCCESS or Error Code on failure
  686. */
  687. API_RESULT MS_net_get_seq_num_state(/* OUT */ NET_SEQ_NUMBER_STATE * seq_num_state);
  688. /**
  689. * \brief To set current Sequence Number state.
  690. *
  691. * \par Description This function is used to set current
  692. * Sequence Number state.
  693. *
  694. * \param [in] seq_num_state Location from where Seq Number state to be taken.
  695. *
  696. * \return API_SUCCESS or Error Code on failure
  697. */
  698. API_RESULT MS_net_set_seq_num_state(/* IN */ NET_SEQ_NUMBER_STATE * seq_num_state);
  699. /* Start Secure Network Beacon Timer */
  700. void MS_net_start_snb_timer
  701. (
  702. /* IN */ MS_SUBNET_HANDLE subnet_handle
  703. );
  704. /* Stop Timer */
  705. void MS_net_stop_snb_timer
  706. (
  707. /* IN */ MS_SUBNET_HANDLE subnet_handle
  708. );
  709. void MS_net_iv_update_rcv_pro
  710. (
  711. /* IN */ UINT32 iv_index,
  712. /* IN */ UINT8 iv_update_flag
  713. );
  714. void MS_net_key_refresh
  715. (
  716. /* IN */ MS_NET_ADDR *key_refresh_whitelist,
  717. /* IN */ UINT16 num,
  718. /* IN */ UINT8 *new_net_key
  719. );
  720. /* Start Secure Network Beacon Timer */
  721. void MS_net_start_key_refresh_timer
  722. (
  723. /* IN */ UINT16 context,
  724. /* IN */ UINT32 time
  725. );
  726. /* Stop Key refresh Timer */
  727. void MS_net_stop_key_refresh_timer
  728. (
  729. void
  730. );
  731. void MS_net_key_refresh_init(void);
  732. #ifdef __cplusplus
  733. };
  734. #endif
  735. /** \} */
  736. /** \} */
  737. #endif /* _H_MS_NET_API_ */