mirror of
https://github.com/espressif/openthread.git
synced 2026-08-04 01:47:47 +00:00
[network-data] add new DNS/SRP anycast/unicast service definitions (#6501)
This commit adds new network data service entry definitions to indicate presence of DNS/SRP servers within the Thread mesh and provide info about them. Two service TLV formats are added: `NetworkData::Service::DnsSrpAnycast` indicates that DNS/SRP client on a device can use the associated anycast address with this service TLV to reach the DNS/SRP server. The use of anycast address ensures that the messages are routed to the nearest node which has added such a service entry in the network data. The service TLV data in this model contains a one byte sequence number which is used to notify the SRP clients if they need to re-register with the server(s) (e.g., due server reset/reboot and/or loss of previous registrations). `NetworkData::Service::DnsSrpUnicast` directly provides the IPv6 address and port info for a DNS/SRP server which can be included as part of the service TLV data and/or the server TLV data. Using service TLV data allows the info about a common infrastructure SRP/DNS server to be added by multiple BRs. In the case of server TLV, the IPv6 address info can be optionally omitted (i.e. just a port number is provided) which then causes the associated RLOC/ALOC address of the node who added the service entry to be used as the server's IPv6 address. This commit updates the `Srp::Client` to use the new service entries to discover/select the SRP sever when auto-start mode is enabled. The client prefers and uses a `DnsSrpAnycast` over `DnsSrpUnicast` entries. The `Srp::Server` is also updated to publish its info as `DnsSrpAnycast` entry (using mesh-local address). This commit also updates the `test_network_data` unit test to cover the behavior of newly methods which iterate and parse different service entry formats.
This commit is contained in:
@@ -931,8 +931,9 @@ class NodeImpl:
|
||||
# TODO: for now, we are using 0xfd as the SRP service data.
|
||||
# May use a dedicated bit flag for SRP server.
|
||||
if int(service[1], 16) == 0x5d:
|
||||
# The SRP server data are 2-bytes UDP port number.
|
||||
return int(service[2], 16)
|
||||
# The SRP server data contains IPv6 address (16 bytes)
|
||||
# followed by UDP port number.
|
||||
return int(service[2][2 * 16:], 16)
|
||||
|
||||
def srp_client_start(self, server_address, server_port):
|
||||
self.send_command(f'srp client start {server_address} {server_port}')
|
||||
|
||||
Reference in New Issue
Block a user