mirror of
https://github.com/espressif/openthread.git
synced 2026-07-09 05:40:27 +00:00
7563ee8d1d
This commit updates `Srp::Server` to add support for selecting its address mode (unicast or anycast). The address mode specifies how the SRP server determines its address and port number and how this info is published in Thread Network Data. In anycast address mode, the SRP server will use port number 53 which is also used by DNS resolver/server. So if both `Srp::Server` and `Dns::ServiceDiscovery::Server` are enabled on a device, they both need to listen on the same port number and share the same UDP socket instance. This commit adds the mechanism in the code to realize this. The `Srp::Server` will monitor when/if DNS-SD is active and checks whether the port numbers match and if so it will close its own socket and re-use the one from DNS-SD. In this case, an incoming UDP message is first given to `Srp::Server` to process and if it fails to process it then the message is given to DNS-SD. This commit also adds CLI commands under `srp server` to get/set the address mode (and update the `README_SRP_SERVER.md` documentation). It also adds a new test `test_srp_server_anycast_mode` which covers the SRP server address mode and the newly added behaviors.