Skip to content

Commit 3a128bc

Browse files
committed
wiseconnect: MDNS NetStack Application protocol
Origin: Silicon Labs WiseConnect SDK License: Zlib URL: https://github.com/siliconlabs/wiseconnect Commit: 05ef77e82bb473fdf157d33fb9cbf6e1d9a11a9e Version: v3.5.0-rc3 Purpose: To support the SiWx917 MDNS Network Stack Application protocol offloading, we need to add the Silicon Labs APIs,so adding the corresponding source files and include files Signed-off-by: Rahul Gurram <[email protected]>
1 parent 23b53f8 commit 3a128bc

File tree

2 files changed

+558
-0
lines changed

2 files changed

+558
-0
lines changed
Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
/***************************************************************************/ /**
2+
* @file sl_mdns.h
3+
*******************************************************************************
4+
* # License
5+
* <b>Copyright 2025 Silicon Laboratories Inc. www.silabs.com</b>
6+
*******************************************************************************
7+
*
8+
* SPDX-License-Identifier: Zlib
9+
*
10+
* The licensor of this software is Silicon Laboratories Inc.
11+
*
12+
* This software is provided 'as-is', without any express or implied
13+
* warranty. In no event will the authors be held liable for any damages
14+
* arising from the use of this software.
15+
*
16+
* Permission is granted to anyone to use this software for any purpose,
17+
* including commercial applications, and to alter it and redistribute it
18+
* freely, subject to the following restrictions:
19+
*
20+
* 1. The origin of this software must not be misrepresented; you must not
21+
* claim that you wrote the original software. If you use this software
22+
* in a product, an acknowledgment in the product documentation would be
23+
* appreciated but is not required.
24+
* 2. Altered source versions must be plainly marked as such, and must not be
25+
* misrepresented as being the original software.
26+
* 3. This notice may not be removed or altered from any source distribution.
27+
*
28+
******************************************************************************/
29+
#ifndef SL_MDNS_INCLUDED_H
30+
#define SL_MDNS_INCLUDED_H
31+
32+
#include <stdint.h>
33+
#include "sl_status.h"
34+
#include "sl_wifi_host_interface.h"
35+
#include "sl_ip_types.h"
36+
#include "sl_net_constants.h"
37+
38+
/**
39+
* @addtogroup SERVICE_MDNS
40+
* @{
41+
*/
42+
43+
/// mDNS events
44+
typedef enum {
45+
SL_MDNS_SERVICE_DISCOVERED_EVENT = 0 ///< Event for mDNS service discovery. (Currently not supported.)
46+
} sl_mdns_event_t;
47+
48+
/// mDNS protocol
49+
typedef enum {
50+
SL_MDNS_PROTO_PHY = 0, ///< Run mDNS using ethernet frames. (Not supported in offload mode.)
51+
SL_MDNS_PROTO_UDP ///< Run mDNS using UDP.
52+
} sl_mdns_protocol_t;
53+
54+
/******************************************************
55+
* Type Definitions
56+
******************************************************/
57+
/// mDNS service query
58+
typedef struct {
59+
const char *instance_name; ///< mDNS instance service name
60+
const char *service_type; ///< mDNS service type
61+
const char *service_sub_type; ///< mDNS service sub type
62+
sl_net_interface_t interface; ///< Target interface
63+
uint16_t timeout; ///< Time out for query
64+
} sl_mdns_service_query_t;
65+
66+
/// mDNS service
67+
typedef struct {
68+
const char *instance_name; ///< mDNS instance service name
69+
const char *service_type; ///< mDNS service type
70+
const char *service_message; ///< mDNS service message
71+
uint16_t port; ///< Service port number
72+
uint16_t ttl; ///< Service TTL
73+
74+
/* NOTE: The following parameters are not used in offload mode. */
75+
sl_ipv4_address_t
76+
ipv4; ///< IPv4 address of service. (In case of offload mode, it is provided by embedded network stack.)
77+
sl_ipv6_address_t
78+
ipv6; ///< IPv6 address of service. (In case of offload mode, it is provided by embedded network stack.)
79+
} sl_mdns_service_t;
80+
81+
/// mDNS service discovery request
82+
typedef struct {
83+
char *service_name; ///< Target service name for discovery
84+
sl_net_interface_t
85+
interface; ///< Interface on which to discover the service from [sl_net_interface_t](../wiseconnect-api-reference-guide-nwk-mgmt/sl-net-constants#sl-net-interface-t).
86+
uint16_t timeout; ///< timeout for the discovery
87+
} sl_mdns_discover_request_t;
88+
89+
/// MDNS instance configuration
90+
typedef struct {
91+
sl_mdns_protocol_t protocol; ///< Protocol to use for mDNS from @ref sl_mdns_protocol_t.
92+
sl_ip_version_t
93+
type; ///< IP version to use for mDNS from [sl_ip_version_t](../wiseconnect-api-reference-guide-nwk-mgmt/sl-ip-address-t).
94+
char host_name
95+
[32]; ///< Host Name to use for the mDNS Instance. The host name Should contain dot(.) at the end (for example, "wiseconnect.local."). The string length should not exceed 32 including NULL terminator.
96+
} sl_mdns_configuration_t;
97+
98+
/// mDNS interface
99+
typedef struct {
100+
sl_net_interface_t
101+
interface; ///< Network interface of type [sl_net_interface_t](../wiseconnect-api-reference-guide-nwk-mgmt/sl-net-constants#sl-net-interface-t).
102+
sl_wifi_buffer_t *
103+
service_list; ///< Pointer to the service list of type [sl_wifi_buffer_t](../wiseconnect-api-reference-guide-wi-fi/sl-wifi-buffer-t).
104+
} sl_mdns_interface_t;
105+
106+
// Forward declaration of the structure to allow usage in the sl_mdns_event_handler_t definition.
107+
/// mDNS instance handle
108+
typedef struct sl_mdns_s sl_mdns_t;
109+
110+
/**
111+
* @typedef sl_mdns_event_handler_t
112+
* @brief mDNS event handler
113+
* @param[in] mdns mDNS instance handle of type @ref sl_mdns_t.
114+
* @param[in] event mDNS event of type @ref sl_mdns_event_t.
115+
* @param[in] data Data pointer containing data structure of corresponding to corresponding event of type @ref sl_mdns_event_t.
116+
*/
117+
typedef void (*sl_mdns_event_handler_t)(sl_mdns_t *mdns, sl_mdns_event_t event, void *data);
118+
119+
/// mDNS instance handle
120+
struct sl_mdns_s {
121+
sl_mdns_configuration_t configuration; ///< mDNS configuration of type @ref sl_mdns_configuration_t
122+
sl_mdns_event_handler_t event_handler; ///< mDNS event handler of type @ref sl_mdns_event_handler_t
123+
sl_wifi_buffer_t *
124+
interface_list; ///< Pointer to interface list of type [sl_wifi_buffer_t](../wiseconnect-api-reference-guide-wi-fi/sl-wifi-buffer-t).
125+
uint8_t service_count; ///< Count of the total number of services being registered on all interfaces.
126+
};
127+
128+
/**
129+
* @brief
130+
* Initialize mDNS instance.
131+
* @param[in] mdns mDNS instance handle of type @ref sl_mdns_t. This cannot be modified by the application after this API call.
132+
* @param[in] config Valid pointer to mDNS configuration structure of type @ref sl_mdns_configuration_t. This value cannot be null.
133+
* @param[in] event_handler Event handler of type @ref sl_mdns_event_handler_t for receiving asynchronous events.
134+
* @return
135+
* sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details.
136+
* @note
137+
* This API needs to be called before calling any other mDNS API
138+
* @note
139+
* @ref sl_mdns_event_handler_t currently not supported. User should pass NULL for event_handler.
140+
*/
141+
sl_status_t sl_mdns_init(sl_mdns_t *mdns, const sl_mdns_configuration_t *config, sl_mdns_event_handler_t event_handler);
142+
143+
/**
144+
* @brief
145+
* De-initialize mDNS instance.
146+
* @param[in] mdns mDNS instance handle of type @ref sl_mdns_t.
147+
* @return
148+
* sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details.
149+
*/
150+
sl_status_t sl_mdns_deinit(sl_mdns_t *mdns);
151+
152+
/**
153+
* @brief
154+
* Add network interface to mDNS instance.
155+
* @param[in] mdns mDNS instance handle of type @ref sl_mdns_t.
156+
* @param[in] interface Network interface of type [sl_net_interface_t](../wiseconnect-api-reference-guide-nwk-mgmt/sl-net-constants#sl-net-interface-t) that needs to be added to mDNS instance.
157+
* @return
158+
* sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details.
159+
*/
160+
sl_status_t sl_mdns_add_interface(sl_mdns_t *mdns, sl_net_interface_t interface);
161+
162+
/**
163+
* @brief
164+
* Remove network interface to mDNS instance. (Currently not supported.)
165+
* @param[in] mdns mDNS instance handle of type @ref sl_mdns_t.
166+
* @param[in] interface Network interface of type [sl_net_interface_t](../wiseconnect-api-reference-guide-nwk-mgmt/sl-net-constants#sl-net-interface-t) that needs to be removed from mDNS instance.
167+
* @return
168+
* sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details.
169+
*/
170+
sl_status_t sl_mdns_remove_interface(const sl_mdns_t *mdns, sl_net_interface_t interface);
171+
172+
/**
173+
* @brief
174+
* Register a service in mDNS instance.
175+
* @param[in] mdns mDNS instance handle of type @ref sl_mdns_t.
176+
* @param[in] interface Network interface of type [sl_net_interface_t](../wiseconnect-api-reference-guide-nwk-mgmt/sl-net-constants#sl-net-interface-t) to which service needed to be added to mDNS instance.
177+
* @param[in] service Valid pointer to mDNS service configuration structure of type @ref sl_mdns_service_t . This value cannot be null.
178+
* @return
179+
* sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details.
180+
*/
181+
sl_status_t sl_mdns_register_service(sl_mdns_t *mdns, sl_net_interface_t interface, const sl_mdns_service_t *service);
182+
183+
/**
184+
* @brief
185+
* Unregister a service from mDNS instance. (Currently not supported.)
186+
* @param[in] mdns mDNS instance handle of type @ref sl_mdns_t
187+
* @param[in] service_query Valid pointer to mDNS service query structure of type @ref sl_mdns_service_query_t . This value cannot be null.
188+
* @return
189+
* sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details.
190+
*/
191+
sl_status_t sl_mdns_unregister_service(const sl_mdns_t *mdns, const sl_mdns_service_query_t *service_query);
192+
193+
/**
194+
* @brief
195+
* Update service message of a service in mDNS instance. (Currently not supported.)
196+
* @param[in] mdns mDNS instance handle of type @ref sl_mdns_t.
197+
* @param[in] service_query Valid pointer to mDNS service query structure of type @ref sl_mdns_service_query_t. This value cannot be null.
198+
* @param[in] message Valid pointer to a buffer containing service message string . This value cannot be null.
199+
* @param[in] message_length Length of the message buffer.
200+
* @return
201+
* sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details.
202+
*/
203+
sl_status_t sl_mdns_update_service_message(const sl_mdns_t *mdns,
204+
const sl_mdns_service_query_t *service_query,
205+
const char *message,
206+
uint32_t message_length);
207+
208+
/**
209+
* @brief
210+
* Discover services using mDNS instance. (Currently not supported.)
211+
* @param[in] mdns mDNS instance handle of type @ref sl_mdns_t
212+
* @param[in] service_query Valid pointer to mDNS service query structure of type @ref sl_mdns_service_query_t . This value cannot be null.
213+
* @return
214+
* sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details.
215+
*/
216+
sl_status_t sl_mdns_discover_service(const sl_mdns_t *mdns, const sl_mdns_service_query_t *service_query);
217+
218+
/** @} */
219+
220+
#endif //SL_MDNS_INCLUDED_H

0 commit comments

Comments
 (0)