Skip to content

Commit

Permalink
[mdns] add native mDNS support in OT (#9797)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
abtink authored Apr 9, 2024
1 parent 6de5cd8 commit bf41332
Show file tree
Hide file tree
Showing 41 changed files with 18,547 additions and 3 deletions.
2 changes: 2 additions & 0 deletions doc/ot_api_doc.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
* @defgroup api-dnssd-server DNS-SD Server
* @defgroup api-icmp6 ICMPv6
* @defgroup api-ip6 IPv6
* @defgroup api-mdns Multicast DNS
* @defgroup api-nat64 NAT64
* @defgroup api-srp SRP
* @defgroup api-ping-sender Ping Sender
Expand Down Expand Up @@ -181,6 +182,7 @@
* @defgroup plat-memory Memory
* @defgroup plat-messagepool Message Pool
* @defgroup plat-misc Miscellaneous
* @defgroup plat-mdns Multicast DNS
* @defgroup plat-multipan Multipan
* @defgroup plat-otns Network Simulator
* @defgroup plat-radio Radio
Expand Down
1 change: 1 addition & 0 deletions doc/ot_config_doc.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
* @defgroup config-mesh-forwarder Mesh Forwarder
* @defgroup config-misc Miscellaneous Constants
* @defgroup config-mle MLE Service
* @defgroup config-mdns Multicast DNS
* @defgroup config-nat64 NAT64
* @defgroup config-netdata-publisher Network Data Publisher
* @defgroup config-network-diagnostic Network Diagnostics
Expand Down
1 change: 1 addition & 0 deletions etc/cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ ot_option(OT_LINK_METRICS_SUBJECT OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENA
ot_option(OT_LINK_RAW OPENTHREAD_CONFIG_LINK_RAW_ENABLE "link raw service")
ot_option(OT_LOG_LEVEL_DYNAMIC OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE "dynamic log level control")
ot_option(OT_MAC_FILTER OPENTHREAD_CONFIG_MAC_FILTER_ENABLE "mac filter")
ot_option(OT_MDNS OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE "multicast DNS (mDNS)")
ot_option(OT_MESH_DIAG OPENTHREAD_CONFIG_MESH_DIAG_ENABLE "mesh diag")
ot_option(OT_MESSAGE_USE_HEAP OPENTHREAD_CONFIG_MESSAGE_USE_HEAP_ENABLE "heap allocator for message buffers")
ot_option(OT_MLE_LONG_ROUTES OPENTHREAD_CONFIG_MLE_LONG_ROUTES_ENABLE "MLE long routes extension (experimental)")
Expand Down
2 changes: 2 additions & 0 deletions examples/config/ot-core-config-check-size-br.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
#define OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE 1
#define OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE 1
#define OPENTHREAD_CONFIG_MLR_ENABLE 1
#define OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE 1
#define OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE 0
#define OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE 1
#define OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE 1
Expand All @@ -99,5 +100,6 @@
#define OPENTHREAD_CONFIG_DNS_DSO_MOCK_PLAT_APIS_ENABLE 1
#define OPENTHREAD_CONFIG_BORDER_ROUTING_MOCK_PLAT_APIS_ENABLE 1
#define OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_MOCK_PLAT_APIS_ENABLE 1
#define OPENTHREAD_CONFIG_MULTICAST_DNS_MOCK_PLAT_APIS_ENABLE 1

#endif // OT_CORE_CONFIG_CHECK_SIZE_BR_H_
1 change: 1 addition & 0 deletions examples/platforms/simulation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ add_library(openthread-simulation
flash.c
infra_if.c
logging.c
mdns_socket.c
misc.c
multipan.c
radio.c
Expand Down
Loading

0 comments on commit bf41332

Please sign in to comment.