mirror of
https://github.com/espressif/openthread.git
synced 2026-08-30 05:49:54 +00:00
[srp-server] support address modes & sharing of socket with DNS-SD (#6826)
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.
This commit is contained in:
@@ -800,6 +800,23 @@ class NodeImpl:
|
||||
self.send_command('srp server state')
|
||||
return self._expect_result(states)
|
||||
|
||||
def srp_server_get_addr_mode(self):
|
||||
modes = [r'unicast', r'anycast']
|
||||
self.send_command(f'srp server addrmode')
|
||||
return self._expect_result(modes)
|
||||
|
||||
def srp_server_set_addr_mode(self, mode):
|
||||
self.send_command(f'srp server addrmode {mode}')
|
||||
self._expect_done()
|
||||
|
||||
def srp_server_get_anycast_seq_num(self):
|
||||
self.send_command(f'srp server seqnum')
|
||||
return int(self._expect_result(r'\d+'))
|
||||
|
||||
def srp_server_set_anycast_seq_num(self, seqnum):
|
||||
self.send_command(f'srp server seqnum {seqnum}')
|
||||
self._expect_done()
|
||||
|
||||
def srp_server_set_enabled(self, enable):
|
||||
cmd = f'srp server {"enable" if enable else "disable"}'
|
||||
self.send_command(cmd)
|
||||
|
||||
Reference in New Issue
Block a user