APIs#
This section provides a reference to the Multicast Domain Name System (mDNS) API including functions, data types, and constants.
Modules#
Enumerations#
mDNS service query types.
Typedefs#
mDNS service query types.
mDNS event handler
Represents the result of an mDNS query.
Functions#
Initialize mDNS instance.
De-initialize mDNS instance.
Add network interface to mDNS instance.
Remove network interface to mDNS instance.
Register a service in mDNS instance.
Unregister a service from mDNS instance.
Update service message of a service in mDNS instance.
Initiates mDNS service discovery on the specified network interface.
Stops an ongoing mDNS service discovery operation on the specified network interface.
Enumeration Documentation#
sl_mdns_event_t#
sl_mdns_event_t
mDNS events
| Enumerator | |
|---|---|
| SL_MDNS_SERVICE_DISCOVERED_EVENT | Event for mDNS service discovery. (Currently not supported.) |
sl_mdns_protocol_t#
sl_mdns_protocol_t
mDNS protocol
| Enumerator | |
|---|---|
| SL_MDNS_PROTO_PHY | Run mDNS using ethernet frames. (Not supported in offload mode.) |
| SL_MDNS_PROTO_UDP | Run mDNS using UDP. |
sl_mdns_query_type#
sl_mdns_query_type
mDNS service query types.
| Enumerator | |
|---|---|
| SL_MDNS_QUERY_TYPE_A | IPv4 address record. |
| SL_MDNS_QUERY_TYPE_PTR | Pointer record. |
| SL_MDNS_QUERY_TYPE_TXT | Text record. |
| SL_MDNS_QUERY_TYPE_AAAA | IPv6 address record. |
| SL_MDNS_QUERY_TYPE_SRV | Service locator record. |
| SL_MDNS_QUERY_TYPE_ANY | Wildcard for any record type. |
Typedef Documentation#
sl_mdns_event_handler_t#
sl_mdns_event_handler_t )(sl_mdns_t *mdns, sl_mdns_event_t event, void *data)
mDNS event handler
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| [in] | mdns | mDNS instance handle of type sl_mdns_t. | |
| [in] | event | mDNS event of type sl_mdns_event_t. | |
| [in] | data | Data pointer containing data structure of corresponding to corresponding event of type sl_mdns_event_t. |
sl_mdns_response_t#
typedef struct sl_mdns_response_s sl_mdns_response_t
Represents the result of an mDNS query.
This structure contains details about the discovered mDNS service, including instance name, service type, protocol, hostname, port, TXT records, IP addresses, and TTL.
Function Documentation#
sl_mdns_init#
sl_status_t sl_mdns_init (sl_mdns_t * mdns, const sl_mdns_configuration_t * config, sl_mdns_event_handler_t event_handler)
Initialize mDNS instance.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_mdns_t * | [in] | mdns | mDNS instance handle of type sl_mdns_t. This cannot be modified by the application after this API call. |
| const sl_mdns_configuration_t * | [in] | config | Valid pointer to mDNS configuration structure of type sl_mdns_configuration_t. This value cannot be null. |
| sl_mdns_event_handler_t | [in] | event_handler | Event handler of type sl_mdns_event_handler_t for receiving asynchronous events. |
Returns
sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details.
Note
This API needs to be called before calling any other mDNS API
sl_mdns_event_handler_t currently not supported. User should pass NULL for event_handler.
sl_mdns_deinit#
sl_status_t sl_mdns_deinit (sl_mdns_t * mdns)
De-initialize mDNS instance.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_mdns_t * | [in] | mdns | mDNS instance handle of type sl_mdns_t. |
Returns
sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details.
sl_mdns_add_interface#
sl_status_t sl_mdns_add_interface (sl_mdns_t * mdns, sl_net_interface_t interface)
Add network interface to mDNS instance.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_mdns_t * | [in] | mdns | mDNS instance handle of type sl_mdns_t. |
| sl_net_interface_t | [in] | interface | Network interface of type sl_net_interface_t that needs to be added to mDNS instance. |
Returns
sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details.
sl_mdns_remove_interface#
sl_status_t sl_mdns_remove_interface (const sl_mdns_t * mdns, sl_net_interface_t interface)
Remove network interface to mDNS instance.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| const sl_mdns_t * | [in] | mdns | mDNS instance handle of type sl_mdns_t. |
| sl_net_interface_t | [in] | interface | Network interface of type sl_net_interface_t that needs to be removed from mDNS instance. |
(Currently not supported.) Returns
sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details.
sl_mdns_register_service#
sl_status_t sl_mdns_register_service (sl_mdns_t * mdns, sl_net_interface_t interface, const sl_mdns_service_t * service)
Register a service in mDNS instance.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_mdns_t * | [in] | mdns | mDNS instance handle of type sl_mdns_t. |
| sl_net_interface_t | [in] | interface | Network interface of type sl_net_interface_t to which service needed to be added to mDNS instance. |
| const sl_mdns_service_t * | [in] | service | Valid pointer to mDNS service configuration structure of type sl_mdns_service_t . This value cannot be null. |
Returns
sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details.
sl_mdns_unregister_service#
sl_status_t sl_mdns_unregister_service (const sl_mdns_t * mdns, const sl_mdns_service_query_t * service_query)
Unregister a service from mDNS instance.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| const sl_mdns_t * | [in] | mdns | mDNS instance handle of type sl_mdns_t |
| const sl_mdns_service_query_t * | [in] | service_query | Valid pointer to mDNS service query structure of type sl_mdns_service_query_t . This value cannot be null. |
(Currently not supported.) Returns
sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details.
sl_mdns_update_service_message#
sl_status_t sl_mdns_update_service_message (const sl_mdns_t * mdns, const sl_mdns_service_query_t * service_query, const char * message, uint32_t message_length)
Update service message of a service in mDNS instance.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| const sl_mdns_t * | [in] | mdns | mDNS instance handle of type sl_mdns_t. |
| const sl_mdns_service_query_t * | [in] | service_query | Valid pointer to mDNS service query structure of type sl_mdns_service_query_t. This value cannot be null. |
| const char * | [in] | message | Valid pointer to a buffer containing service message string . This value cannot be null. |
| uint32_t | [in] | message_length | Length of the message buffer. |
(Currently not supported.) Returns
sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details.
sl_mdns_service_discovery_start#
sl_status_t sl_mdns_service_discovery_start (const sl_mdns_t * mdns, sl_net_interface_t interface, const sl_mdns_service_query_t * service_query)
Initiates mDNS service discovery on the specified network interface.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| const sl_mdns_t * | [in] | mdns | mDNS instance handle of type sl_mdns_t. |
| sl_net_interface_t | [in] | interface | Network interface of type sl_net_interface_t. |
| const sl_mdns_service_query_t * | [in] | service_query | Valid pointer to mDNS service query structure of type sl_mdns_service_query_t. Cannot be NULL. |
This is an asynchronous API. Discovery results are delivered via the registered mDNS event callback.
The discovery process queries for a specific DNS record type using the provided service query. The query type determines the nature of the response:
SL_MDNS_QUERY_TYPE_PTR→ Returns service instance name, service type, and protocol.SL_MDNS_QUERY_TYPE_SRV→ Returns target hostname and port for a given instance name.SL_MDNS_QUERY_TYPE_A→ Returns IPv4 address for a given hostname.SL_MDNS_QUERY_TYPE_AAAA→ Returns IPv6 address for a given hostname.SL_MDNS_QUERY_TYPE_TXT→ Returns metadata (key-value pairs) for a given service instance.SL_MDNS_QUERY_TYPE_ANY→ Returns all available record types. For broad discovery, use service type_services._dns-sd._udp.local.to enumerate available services via PTR records.
Note
For
SRV,A,AAAA, andTXTqueries, theservice_typefield must be set to the instance name or hostname as appropriate.For
PTRqueries,service_typemust be set to the service type, e.g.,_http._tcp.local..Minimum timeout value must be greater than 250 ms.
Internal stop handler is triggered automatically after 5 seconds of inactivity.
sl_mdns_register_service()must be called before initiating discovery.mDNS works best with the DTIM-based power save method. Performance issues may be observed with the listen interval-based power save method due to multicast packet loss.
Returns
Returns
SL_STATUS_IN_PROGRESSif the discovery request was successfully initiated, or an appropriate error code from sl_status_t.
Note
Discovery results are received asynchronously via the registered mDNS event handler.
sl_mdns_service_discovery_stop#
sl_status_t sl_mdns_service_discovery_stop (const sl_mdns_t * mdns, const sl_net_interface_t interface)
Stops an ongoing mDNS service discovery operation on the specified network interface.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| const sl_mdns_t * | [in] | mdns | mDNS instance handle of type sl_mdns_t. |
| const sl_net_interface_t | [in] | interface | Network interface of type sl_net_interface_t on which discovery was started. |
This is a synchronous API and is used to explicitly terminate the discovery process from the host side.
This function halts any active discovery initiated via sl_mdns_service_discovery_start. It is typically used when the application no longer requires discovery results or wants to cancel the operation early.
Returns
Returns
SL_STATUS_OKif the discovery was successfully stopped, or an appropriate error code from sl_status_t.