mirror of
https://github.com/espressif/openthread.git
synced 2026-08-09 12:17:47 +00:00
[mdns] add native mDNS support in OT (#9797)
This commit introduces native mDNS support within the OpenThread stack, implementing RFC 6762 compliant registration of hosts, services, and keys. It supports the following functionalities: - Sending probes to claim names. - Sending announcements on initial registration and changes. - Sending "goodbye" announcements when unregistered or upon record removal. - Negative responses (NSEC). - Support for service sub-types and their addition/removal. - Support for `_services._dns-sd._udp` queries (all service types). - Responding to queries (including "QU" questions). - Delay mechanism when responding to multi-question query messages, ensuring unique answers. - Providing extra records in the Additional Data section if not already in the Answer section (e.g., on a PTR query, include SRV and host AAAA addresses). - Implementing Known-Answer Suppression. - Supporting multi-packet queries with known answers in follow-up messages. - Rate-limiting record multicasts (once per second). - Rate-limiting probe responses (once per 250ms). - Detecting conflicts after probes. - Limiting the size of emitted responses or probes, breaking into multiple messages if necessary. - Detecting self originating messages (sent by mDNS module). - Support for service browser. - Support for service resolvers (SRV and TXT records) and IPv4/IPv6 address resolvers for hostnames. - Introduces smart cache management: - Passively caches service records for active browsers. - Passively caches address records for active service resolvers. - Enables multiple simultaneous browsers/resolvers for the same service/host. This commit introduces public `otMdns` OpenThread APIs and related CLI commands for the mDNS module. For platform abstraction, `otPlatMdns` APIs are defined in `mdns_socket.h` (e.g., to send or receive mDNS messages): - An implementation of the platform APIs is provided for posix. - Also under the simulation platform, a simplified implementation of the `otPlatMdns` APIs is provided (intended for testing). This commit also adds a detailed `test_mdns` unit test, validating various functionalities and covering potential edge cases.
This commit is contained in:
@@ -555,6 +555,35 @@ otError otPlatRadioSetCcaEnergyDetectThreshold(otInstance *aInstance, int8_t aTh
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE
|
||||
|
||||
OT_TOOL_WEAK otError otPlatMdnsSetListeningEnabled(otInstance *aInstance, bool aEnable, uint32_t aInfraIfIndex)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
OT_UNUSED_VARIABLE(aEnable);
|
||||
OT_UNUSED_VARIABLE(aInfraIfIndex);
|
||||
|
||||
return OT_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OT_TOOL_WEAK void otPlatMdnsSendMulticast(otInstance *aInstance, otMessage *aMessage, uint32_t aInfraIfIndex)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
OT_UNUSED_VARIABLE(aMessage);
|
||||
OT_UNUSED_VARIABLE(aInfraIfIndex);
|
||||
}
|
||||
|
||||
OT_TOOL_WEAK void otPlatMdnsSendUnicast(otInstance *aInstance,
|
||||
otMessage *aMessage,
|
||||
const otPlatMdnsAddressInfo *aAddress)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
OT_UNUSED_VARIABLE(aMessage);
|
||||
OT_UNUSED_VARIABLE(aAddress);
|
||||
}
|
||||
|
||||
#endif // OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE
|
||||
|
||||
#if OPENTHREAD_CONFIG_DNS_DSO_ENABLE
|
||||
|
||||
OT_TOOL_WEAK void otPlatDsoEnableListening(otInstance *aInstance, bool aEnable)
|
||||
|
||||
Reference in New Issue
Block a user