mirror of
https://github.com/espressif/openthread.git
synced 2026-06-06 05:24:51 +00:00
[cli] add srp server port command to retrieve SRP server port (#11373)
This commit adds the `srp server port` CLI command, which maps to the `otSrpServerGetPort()` API. This new command is now used in `thread-cert/node.py` to implement `get_srp_server_port()`, allowing direct retrieval of the SRP server port instead of indirectly parsing the network data entry.
This commit is contained in:
committed by
GitHub
parent
793dd9896d
commit
8c30b93fee
@@ -1264,17 +1264,8 @@ class NodeImpl:
|
||||
return service
|
||||
|
||||
def get_srp_server_port(self):
|
||||
"""Returns the SRP server UDP port by parsing
|
||||
the SRP Server Data in Network Data.
|
||||
"""
|
||||
|
||||
for service in self.get_services():
|
||||
# 0x5d is used to indicate SRP/DNS unicast entry
|
||||
if int(service[1], 16) == 0x5d:
|
||||
# The SRP server data contains IPv6 address (16 bytes)
|
||||
# followed by UDP port number (two bytes) and then
|
||||
# the version field (one byte)
|
||||
return int(service[2][2 * 16:2 * 16 + 4], 16)
|
||||
self.send_command('srp server port')
|
||||
return int(self._expect_result(r'\d+'))
|
||||
|
||||
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