[srp-client] add aSendUnregToServer param to RemoveHostAndServices() (#6927)

This commit adds a new parameter `aSendUnregToServer` to SRP client's
`RemoveHostAndServices()` API. This parameter determines the behavior
when the host info is not yet registered with the server. If it is
set to `false` (which is the default/expected value) then the SRP
client will immediately remove the host info and services without
sending an update message to server (no need to update the server if
nothing is yet registered with it). If it is set to `true` then the
SRP client will send an update message to the server. Note that if
the host info is registered then the value of `aSendUnregToServer`
does not matter and the SRP client will always send an update message
to the server requesting removal of all info.

One situation where this parameter can be useful is on a device
reset/reboot where the caller may want to remove any previously
registered services with the server. In this case, caller can
`SetHostName()` and then request `RemoveHostAndServices()` with
`aSendUnregToServer` as `true`.

This commit also adds `test_srp_client_remove_host.py` which
verifies the behavior the newly added mechanism between client and
server.
This commit is contained in:
Abtin Keshavarzian
2021-08-23 23:07:57 -07:00
committed by Jonathan Hui
parent da629d63ff
commit 5851524d7a
12 changed files with 244 additions and 29 deletions
+2 -2
View File
@@ -989,8 +989,8 @@ class NodeImpl:
self.send_command(f'srp client host name')
self._expect_done()
def srp_client_remove_host(self, remove_key=False):
self.send_command(f'srp client host remove {"1" if remove_key else "0"}')
def srp_client_remove_host(self, remove_key=False, send_unreg_to_server=False):
self.send_command(f'srp client host remove {int(remove_key)} {int(send_unreg_to_server)}')
self._expect_done()
def srp_client_clear_host(self):