Start()
Stop()
EnableAutoStartMode()
Enables the auto-start mode. Config option `OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_DEFAULT_MODE` specifies the default auto-start mode (whether it is enabled or disabled at the start of OT stack). When auto-start is enabled, the SRP client will monitor the Thread Network Data to discover SRP servers and select the preferred server and automatically start and stop the client when an SRP server is detected. There are three categories of Network Data entries indicating presence of SRP sever. They are preferred in the following order: 1) Preferred unicast entries where server address is included in the service data. If there are multiple options, the one with numerically lowest IPv6 address is preferred. 2) Anycast entries each having a seq number. A larger sequence number in the sense specified by Serial Number Arithmetic logic in RFC-1982 is considered more recent and therefore preferred. The largest seq number using serial number arithmetic is preferred if it is well-defined (i.e., the seq number is larger than all other seq numbers). If it is not well-defined, then the numerically largest seq number is preferred. 3) Unicast entries where the server address info is included in server data. If there are multiple options, the one with numerically lowest IPv6 address is preferred. When there is a change in the Network Data entries, client will check that the currently selected server is still present in the Network Data and is still the preferred one. Otherwise the client will switch to the new preferred server or stop if there is none. When the SRP client is explicitly started through a successful call to `Start()`, the given SRP server address in `Start()` will continue to be used regardless of the state of auto-start mode and whether the same SRP server address is discovered or not in the Thread Network Data. In this case, only an explicit `Stop()` call will stop the client.
DisableAutoStartMode()
Disables the auto-start mode. Disabling the auto-start mode will not stop the client if it is already running but the client stops monitoring the Thread Network Data to verify that the selected SRP server is still present in it. Note that a call to `Stop()` will also disable the auto-start mode.
IsAutoStartModeEnabled() const
Indicates the current state of auto-start mode (enabled or disabled).
IsServerSelectedByAutoStart() const
Indicates whether or not the current SRP server's address is selected by auto-start.
IsRunning() const
Indicates whether the SRP client is running or not.
GetServerAddress() const
Gets the socket address (IPv6 address and port number) of the SRP server which is being used by SRP client. If the client is not running, the address is unspecified (all zero) with zero port number.
SetCallback()
Sets the callback used to notify caller of events/changes. The SRP client allows a single callback to be registered. So consecutive calls to this method will overwrite any previously set callback functions.
GetTtl() const
Gets the TTL used in SRP update requests. Note that this is the TTL requested by the SRP client. The server may choose to accept a different TTL. By default, the TTL will equal the lease interval. Passing 0 or a value larger than the lease interval via `otSrpClientSetTtl()` will also cause the TTL to equal the lease interval.
SetTtl()
Sets the TTL used in SRP update requests. Changing the TTL does not impact the TTL of already registered services/host-info. It only changes any future SRP update messages (i.e adding new services and/or refreshes of existing services).
GetLeaseInterval() const
Gets the lease interval used in SRP update requests. Note that this is lease duration that would be requested by the SRP client. Server may choose to accept a different lease interval.
SetLeaseInterval()
Sets the lease interval used in SRP update requests. Changing the lease interval does not impact the accepted lease interval of already registered services/host-info. It only changes any future SRP update messages (i.e adding new services and/or refreshes of existing services).
GetKeyLeaseInterval() const
Gets the key lease interval used in SRP update requests.
SetKeyLeaseInterval()
Sets the key lease interval used in SRP update requests. Changing the lease interval does not impact the accepted lease interval of already registered services/host-info. It only changes any future SRP update messages (i.e adding new services and/or refreshes of existing services).
GetHostInfo() const
Gets the host info.
SetHostName()
Sets the host name label. After a successful call to this method, `Callback` will be called to report the status of host info registration with SRP server. The host name can be set before client is started or after start but before host info is registered with server (host info should be in either `kToAdd` or `kRemoved`).
EnableAutoHostAddress()
Enables auto host address mode. When enabled host IPv6 addresses are automatically set by SRP client using all the unicast addresses on Thread netif excluding the link-local and mesh-local addresses. If there is no valid address, then Mesh Local EID address is added. The SRP client will automatically re-register when/if addresses on Thread netif are updated (new addresses are added or existing addresses are removed). The auto host address mode can be enabled before start or during operation of SRP client except when the host info is being removed (client is busy handling a remove request from an call to `RemoveHostAndServices()` and host info still being in either `kStateToRemove` or `kStateRemoving` states). After auto host address mode is enabled, it can be disabled by a call to `SetHostAddresses()` which then explicitly sets the host addresses.
SetHostAddresses()
Sets/updates the list of host IPv6 address. Host IPv6 addresses can be set/changed before start or even during operation of SRP client (e.g. to add/remove or change a previously registered host address), except when the host info is being removed (client is busy handling a remove request from an earlier call to `RemoveHostAndServices()` and host info still being in either `kStateToRemove` or `kStateRemoving` states). After a successful call to this method, `Callback` will be called to report the status of the address registration with SRP server. Calling this method disables auto host address mode if it was previously enabled from a successful call to `EnableAutoHostAddress()`.
AddService()
Adds a service to be registered with server. After a successful call to this method, `Callback` will be called to report the status of the service addition/registration with SRP server.
RemoveService()
Removes a service to be unregistered with server.
ClearService()
Clears a service, immediately removing it from the client service list. Unlike `RemoveService()` which sends an update message to the server to remove the service, this method clears the service from the client's service list without any interaction with the server. On a successful call to this method, the `Callback` will NOT be called and the @p aService entry can be reclaimed and re-used by the caller immediately.
GetServices() const
Gets the list of services being managed by client.
RemoveHostAndServices()
Starts the remove process of the host info and all services. After returning from this method, `Callback` will be called to report the status of remove request with SRP server. If the host info is to be permanently removed from server, @p aRemoveKeyLease should be set to `true` which removes the key lease associated with host on server. Otherwise, the key lease record is kept as before, which ensures that the server holds the host name in reserve for when the client once again able to provide and register its service(s). The @p aSendUnregToServer determines the behavior when the host info is not yet registered with the server. If @p aSendUnregToServer 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 @p aSendUnregToServer 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 @p aSendUnregToServer does not matter and the SRP client will always send an update message to server requesting removal of all info. One situation where @p aSendUnregToServer can be useful is on a device reset/reboot, 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`.
ClearHostAndServices()
Clears all host info and all the services. Unlike `RemoveHostAndServices()` which sends an update message to the server to remove all the info, this method clears all the info immediately without any interaction with the server.
ItemStateToString()
Converts a `ItemState` to a string.
SetServiceKeyRecordEnabled()
Enables/disables "service key record inclusion" mode. When enabled, SRP client will include KEY record in Service Description Instructions in the SRP update messages that it sends.
IsServiceKeyRecordEnabled() const
Indicates whether the "service key record inclusion" mode is enabled or disabled.
SetUseShortLeaseOption()
Enables/disables "use short Update Lease Option" behavior. When enabled, the SRP client will use the short variant format of Update Lease Option in its message. The short format only includes the lease interval. Is added under `REFERENCE_DEVICE` config and is intended to override the default behavior for testing only.
GetUseShortLeaseOption() const
Gets the current "use short Update Lease Option" mode.
SetNextMessageId()
Set the next DNS message ID for client to use. This is intended for testing only. @pram[in] aMessageId A message ID.
Start()
Stop()
Resume()
Pause()
HandleNotifierEvents()
HandleRoleChanged()
HandleUnicastAddressEvent()
ShouldUpdateHostAutoAddresses() const
ShouldHostAutoAddressRegister() const
UpdateHostInfoStateOnAddressChange()
UpdateServiceStateToRemove()
GetState() const
SetState()
ChangeHostAndServiceStates()
InvokeCallback() const
InvokeCallback() const
HandleHostInfoOrServiceChange()
SendUpdate()
PrepareUpdateMessage()
ReadOrGenerateKey()
AppendServiceInstructions()
CanAppendService()
AppendServiceInstruction()
AppendHostDescriptionInstruction()
AppendKeyRecord() const
AppendDeleteAllRrsets() const
AppendHostName() const
AppendAaaaRecord() const
AppendUpdateLeaseOptRecord()
AppendSignature()
UpdateRecordLengthInMessage() const
HandleUdpReceive()
ProcessResponse()
IsResponseMessageIdValid() const
HandleUpdateDone()
GetRemovedServices()
ReadResourceRecord()
ProcessOptRecord()
UpdateState()
GetRetryWaitInterval() const
ResetRetryWaitInterval()
GrowRetryWaitInterval()
DetermineLeaseInterval() const
DetermineTtl() const
ShouldRenewEarly() const
HandleTimer()
ApplyAutoStartGuardOnAttach()
ProcessAutoStart()
SelectUnicastEntry() const
HandleGuardTimer()
SelectNextServer()
StateToString()
LogRetryWaitInterval() const