SRP
This module includes functions that control SRP client behavior.
Summary
This module includes functions of the Service Registration Protocol.
This module includes functions for SRP client buffers and service pool.
Functions in this module are only available when feature OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_ENABLE is enabled.
Enumerations |
|
---|---|
Anonymous Enum 28{
|
enum |
Anonymous Enum 29{
|
enum |
otSrpClientItemState{
|
enum This enumeration specifies an SRP client item (service or host info) state. |
otSrpServerAddressMode{
|
enum This enumeration represents the address mode used by the SRP server. |
otSrpServerState{
|
enum This enumeration represents the state of the SRP server. |
Typedefs |
|
---|---|
otSrpClientAutoStartCallback)(const otSockAddr *aServerSockAddr, void *aContext)
|
typedefvoid(*
This function pointer type defines the callback used by SRP client to notify user when it is auto-started or stopped. |
otSrpClientBuffersServiceEntry
|
typedef This struct represents a SRP client service pool entry. |
otSrpClientCallback)(otError aError, const otSrpClientHostInfo *aHostInfo, const otSrpClientService *aServices, const otSrpClientService *aRemovedServices, void *aContext)
|
typedefvoid(*
This function pointer type defines the callback used by SRP client to notify user of changes/events/errors. |
otSrpClientHostInfo
|
typedefstruct otSrpClientHostInfo
This structure represents an SRP client host info. |
otSrpClientService
|
typedefstruct otSrpClientService
This structure represents an SRP client service. |
otSrpServerAddressMode
|
typedef This enumeration represents the address mode used by the SRP server. |
otSrpServerHost
|
typedefstruct otSrpServerHost
This opaque type represents a SRP service host. |
otSrpServerLeaseConfig
|
typedefstruct otSrpServerLeaseConfig
This structure includes SRP server LEASE and KEY-LEASE configurations. |
otSrpServerLeaseInfo
|
typedefstruct otSrpServerLeaseInfo
This structure includes SRP server lease information of a host/service. |
otSrpServerResponseCounters
|
typedefstruct otSrpServerResponseCounters
This structure includes the statistics of SRP server responses. |
otSrpServerService
|
typedefstruct otSrpServerService
This opaque type represents a SRP service. |
otSrpServerServiceFlags
|
typedefuint8_t
The service flag type to indicate which services to include or exclude when searching in (or iterating over) the list of SRP services. |
otSrpServerServiceUpdateHandler)(otSrpServerServiceUpdateId aId, const otSrpServerHost *aHost, uint32_t aTimeout, void *aContext)
|
typedefvoid(*
This function handles SRP service updates. |
otSrpServerServiceUpdateId
|
typedefuint32_t
The ID of a SRP service update transaction on the SRP Server. |
otSrpServerTtlConfig
|
typedefstruct otSrpServerTtlConfig
This structure includes SRP server TTL configurations. |
Functions |
|
---|---|
otSrpClientAddService(otInstance *aInstance, otSrpClientService *aService)
|
This function adds a service to be registered with server.
|
otSrpClientBuffersAllocateService(otInstance *aInstance)
|
This function allocates a new service entry from the pool.
|
otSrpClientBuffersFreeAllServices(otInstance *aInstance)
|
void
This function frees all previously allocated service entries.
|
otSrpClientBuffersFreeService(otInstance *aInstance, otSrpClientBuffersServiceEntry *aService)
|
void
This function frees a previously allocated service entry.
|
otSrpClientBuffersGetHostAddressesArray(otInstance *aInstance, uint8_t *aArrayLength)
|
This function gets the array of IPv6 address entries to use as SRP client host address list.
|
otSrpClientBuffersGetHostNameString(otInstance *aInstance, uint16_t *aSize)
|
char *
This function gets the string buffer to use for SRP client host name.
|
otSrpClientBuffersGetServiceEntryInstanceNameString(otSrpClientBuffersServiceEntry *aEntry, uint16_t *aSize)
|
char *
This function gets the string buffer for service instance name from a service entry.
|
otSrpClientBuffersGetServiceEntryServiceNameString(otSrpClientBuffersServiceEntry *aEntry, uint16_t *aSize)
|
char *
This function gets the string buffer for service name from a service entry.
|
otSrpClientBuffersGetServiceEntryTxtBuffer(otSrpClientBuffersServiceEntry *aEntry, uint16_t *aSize)
|
uint8_t *
This function gets the buffer for TXT record from a service entry.
|
otSrpClientBuffersGetSubTypeLabelsArray(otSrpClientBuffersServiceEntry *aEntry, uint16_t *aArrayLength)
|
const char **
This function gets the array for service subtype labels from the service entry.
|
otSrpClientClearHostAndServices(otInstance *aInstance)
|
void
This function clears all host info and all the services.
|
otSrpClientClearService(otInstance *aInstance, otSrpClientService *aService)
|
This function clears a service, immediately removing it from the client service list.
|
otSrpClientDisableAutoStartMode(otInstance *aInstance)
|
void
This function disables the auto-start mode.
|
otSrpClientEnableAutoHostAddress(otInstance *aInstance)
|
This function enables auto host address mode.
|
otSrpClientEnableAutoStartMode(otInstance *aInstance, otSrpClientAutoStartCallback aCallback, void *aContext)
|
void
This function enables the auto-start mode.
|
otSrpClientGetDomainName(otInstance *aInstance)
|
const char *
This function gets the domain name being used by SRP client.
|
otSrpClientGetHostInfo(otInstance *aInstance)
|
const otSrpClientHostInfo *
This function gets the host info.
|
otSrpClientGetKeyLeaseInterval(otInstance *aInstance)
|
uint32_t
This function gets the default key lease interval used in SRP update requests.
|
otSrpClientGetLeaseInterval(otInstance *aInstance)
|
uint32_t
This function gets the default lease interval used in SRP update requests.
|
otSrpClientGetServerAddress(otInstance *aInstance)
|
const otSockAddr *
This function gets the socket address (IPv6 address and port number) of the SRP server which is being used by SRP client.
|
otSrpClientGetServices(otInstance *aInstance)
|
const otSrpClientService *
This function gets the list of services being managed by client.
|
otSrpClientGetTtl(otInstance *aInstance)
|
uint32_t
This function gets the TTL value in every record included in SRP update requests.
|
otSrpClientIsAutoStartModeEnabled(otInstance *aInstance)
|
bool
This function indicates the current state of auto-start mode (enabled or disabled).
|
otSrpClientIsRunning(otInstance *aInstance)
|
bool
This function indicates whether the SRP client is running or not.
|
otSrpClientIsServiceKeyRecordEnabled(otInstance *aInstance)
|
bool
This method indicates whether the "service key record inclusion" mode is enabled or disabled.
|
otSrpClientItemStateToString(otSrpClientItemState aItemState)
|
const char *
This function converts a
otSrpClientItemState to a string. |
otSrpClientRemoveHostAndServices(otInstance *aInstance, bool aRemoveKeyLease, bool aSendUnregToServer)
|
This function starts the remove process of the host info and all services.
|
otSrpClientRemoveService(otInstance *aInstance, otSrpClientService *aService)
|
This function requests a service to be unregistered with server.
|
otSrpClientSetCallback(otInstance *aInstance, otSrpClientCallback aCallback, void *aContext)
|
void
This function sets the callback to notify caller of events/changes from SRP client.
|
otSrpClientSetDomainName(otInstance *aInstance, const char *aName)
|
This function sets the domain name to be used by SRP client.
|
otSrpClientSetHostAddresses(otInstance *aInstance, const otIp6Address *aIp6Addresses, uint8_t aNumAddresses)
|
This function sets/updates the list of host IPv6 address.
|
otSrpClientSetHostName(otInstance *aInstance, const char *aName)
|
This function sets the host name label.
|
otSrpClientSetKeyLeaseInterval(otInstance *aInstance, uint32_t aInterval)
|
void
This function sets the default key lease interval used in SRP update requests.
|
otSrpClientSetLeaseInterval(otInstance *aInstance, uint32_t aInterval)
|
void
This function sets the default lease interval used in SRP update requests.
|
otSrpClientSetServiceKeyRecordEnabled(otInstance *aInstance, bool aEnabled)
|
void
This function enables/disables "service key record inclusion" mode.
|
otSrpClientSetTtl(otInstance *aInstance, uint32_t aTtl)
|
void
This function sets the TTL value in every record included in SRP update requests.
|
otSrpClientStart(otInstance *aInstance, const otSockAddr *aServerSockAddr)
|
This function starts the SRP client operation.
|
otSrpClientStop(otInstance *aInstance)
|
void
This function stops the SRP client operation.
|
otSrpServerGetAddressMode(otInstance *aInstance)
|
This function returns the address mode being used by the SRP server.
|
otSrpServerGetAnycastModeSequenceNumber(otInstance *aInstance)
|
uint8_t
This function returns the sequence number used with anycast address mode.
|
otSrpServerGetDomain(otInstance *aInstance)
|
const char *
This function returns the domain authorized to the SRP server.
|
otSrpServerGetLeaseConfig(otInstance *aInstance, otSrpServerLeaseConfig *aLeaseConfig)
|
void
This function returns SRP server LEASE and KEY-LEASE configurations.
|
otSrpServerGetNextHost(otInstance *aInstance, const otSrpServerHost *aHost)
|
const otSrpServerHost *
This function returns the next registered host on the SRP server.
|
otSrpServerGetPort(otInstance *aInstance)
|
uint16_t
This function returns the port the SRP server is listening to.
|
otSrpServerGetResponseCounters(otInstance *aInstance)
|
const otSrpServerResponseCounters *
This function returns the response counters of the SRP server.
|
otSrpServerGetState(otInstance *aInstance)
|
This function returns the state of the SRP server.
|
otSrpServerGetTtlConfig(otInstance *aInstance, otSrpServerTtlConfig *aTtlConfig)
|
void
This function returns SRP server TTL configuration.
|
otSrpServerHandleServiceUpdateResult(otInstance *aInstance, otSrpServerServiceUpdateId aId, otError aError)
|
void
This function reports the result of processing a SRP update to the SRP server.
|
otSrpServerHostFindNextService(const otSrpServerHost *aHost, const otSrpServerService *aPrevService, otSrpServerServiceFlags aFlags, const char *aServiceName, const char *aInstanceName)
|
const otSrpServerService *
This function finds the next matching service on the host.
|
otSrpServerHostGetAddresses(const otSrpServerHost *aHost, uint8_t *aAddressesNum)
|
const otIp6Address *
This function returns the addresses of given host.
|
otSrpServerHostGetFullName(const otSrpServerHost *aHost)
|
const char *
This function returns the full name of the host.
|
otSrpServerHostGetLeaseInfo(const otSrpServerHost *aHost, otSrpServerLeaseInfo *aLeaseInfo)
|
void
This function returns the LEASE and KEY-LEASE information of a given host.
|
otSrpServerHostGetNextService(const otSrpServerHost *aHost, const otSrpServerService *aService)
|
const otSrpServerService *
This function returns the next service (excluding any sub-type services) of given host.
|
otSrpServerHostIsDeleted(const otSrpServerHost *aHost)
|
bool
This function tells if the SRP service host has been deleted.
|
otSrpServerIsAutoEnableMode(otInstance *aInstance)
|
bool
This function indicates whether the auto-enable mode is enabled or disabled.
|
otSrpServerServiceGetFullName(const otSrpServerService *aService)
|
const char *
This function returns the full service instance name of the service.
|
otSrpServerServiceGetHost(const otSrpServerService *aService)
|
const otSrpServerHost *
This function returns the host which the service instance reside on.
|
otSrpServerServiceGetInstanceName(const otSrpServerService *aService)
|
const char *
This function returns the full service instance name of the service.
|
otSrpServerServiceGetLeaseInfo(const otSrpServerService *aService, otSrpServerLeaseInfo *aLeaseInfo)
|
void
This function returns the LEASE and KEY-LEASE information of a given service.
|
otSrpServerServiceGetPort(const otSrpServerService *aService)
|
uint16_t
This function returns the port of the service instance.
|
otSrpServerServiceGetPriority(const otSrpServerService *aService)
|
uint16_t
This function returns the priority of the service instance.
|
otSrpServerServiceGetServiceName(const otSrpServerService *aService)
|
const char *
This function returns the full service name of the service.
|
otSrpServerServiceGetServiceSubTypeLabel(const otSrpServerService *aService, char *aLabel, uint8_t aMaxSize)
|
This function gets the sub-type label from service name.
|
otSrpServerServiceGetTtl(const otSrpServerService *aService)
|
uint32_t
This function returns the TTL of the service instance.
|
otSrpServerServiceGetTxtData(const otSrpServerService *aService, uint16_t *aDataLength)
|
const uint8_t *
This function returns the TXT record data of the service instance.
|
otSrpServerServiceGetWeight(const otSrpServerService *aService)
|
uint16_t
This function returns the weight of the service instance.
|
otSrpServerServiceIsDeleted(const otSrpServerService *aService)
|
bool
This function indicates whether or not the SRP service has been deleted.
|
otSrpServerServiceIsSubType(const otSrpServerService *aService)
|
bool
This function indicates whether or not the SRP service is sub-type.
|
otSrpServerSetAddressMode(otInstance *aInstance, otSrpServerAddressMode aMode)
|
This function sets the address mode to be used by the SRP server.
|
otSrpServerSetAnycastModeSequenceNumber(otInstance *aInstance, uint8_t aSequenceNumber)
|
This function sets the sequence number used with anycast address mode.
|
otSrpServerSetAutoEnableMode(otInstance *aInstance, bool aEnabled)
|
void
This function enables/disables the auto-enable mode on SRP server.
|
otSrpServerSetDomain(otInstance *aInstance, const char *aDomain)
|
This function sets the domain on the SRP server.
|
otSrpServerSetEnabled(otInstance *aInstance, bool aEnabled)
|
void
This function enables/disables the SRP server.
|
otSrpServerSetLeaseConfig(otInstance *aInstance, const otSrpServerLeaseConfig *aLeaseConfig)
|
This function sets SRP server LEASE and KEY-LEASE configurations.
|
otSrpServerSetServiceUpdateHandler(otInstance *aInstance, otSrpServerServiceUpdateHandler aServiceHandler, void *aContext)
|
void
This function sets the SRP service updates handler on SRP server.
|
otSrpServerSetTtlConfig(otInstance *aInstance, const otSrpServerTtlConfig *aTtlConfig)
|
This function sets SRP server TTL configuration.
|
Structs |
|
---|---|
otSrpClientBuffersServiceEntry |
This struct represents a SRP client service pool entry. |
otSrpClientHostInfo |
This structure represents an SRP client host info. |
otSrpClientService |
This structure represents an SRP client service. |
otSrpServerLeaseConfig |
This structure includes SRP server LEASE and KEY-LEASE configurations. |
otSrpServerLeaseInfo |
This structure includes SRP server lease information of a host/service. |
otSrpServerResponseCounters |
This structure includes the statistics of SRP server responses. |
otSrpServerTtlConfig |
This structure includes SRP server TTL configurations. |
Enumerations
Anonymous Enum 28
Anonymous Enum 28
Properties | |
---|---|
OT_SRP_SERVER_SERVICE_FLAG_ACTIVE
|
Include active (not deleted) services. |
OT_SRP_SERVER_SERVICE_FLAG_BASE_TYPE
|
Include base services (not a sub-type). |
OT_SRP_SERVER_SERVICE_FLAG_DELETED
|
Include deleted services. |
OT_SRP_SERVER_SERVICE_FLAG_SUB_TYPE
|
Include sub-type services. |
Anonymous Enum 29
Anonymous Enum 29
Properties | |
---|---|
OT_SRP_SERVER_FLAGS_ANY_SERVICE
|
This constant defines an |
OT_SRP_SERVER_FLAGS_ANY_TYPE_ACTIVE_SERVICE
|
This constant defines an |
OT_SRP_SERVER_FLAGS_ANY_TYPE_DELETED_SERVICE
|
This constant defines an |
OT_SRP_SERVER_FLAGS_BASE_TYPE_SERVICE_ONLY
|
This constant defines an |
OT_SRP_SERVER_FLAGS_SUB_TYPE_SERVICE_ONLY
|
This constant defines an |
otSrpClientItemState
otSrpClientItemState
This enumeration specifies an SRP client item (service or host info) state.
Properties | |
---|---|
OT_SRP_CLIENT_ITEM_STATE_ADDING
|
Item is being added/registered. |
OT_SRP_CLIENT_ITEM_STATE_REFRESHING
|
Item is being refreshed. |
OT_SRP_CLIENT_ITEM_STATE_REGISTERED
|
Item is registered with server. |
OT_SRP_CLIENT_ITEM_STATE_REMOVED
|
Item is removed. |
OT_SRP_CLIENT_ITEM_STATE_REMOVING
|
Item is being removed. |
OT_SRP_CLIENT_ITEM_STATE_TO_ADD
|
Item to be added/registered. |
OT_SRP_CLIENT_ITEM_STATE_TO_REFRESH
|
Item to be refreshed (re-register to renew lease). |
OT_SRP_CLIENT_ITEM_STATE_TO_REMOVE
|
Item to be removed. |
otSrpServerAddressMode
otSrpServerAddressMode
This enumeration represents the address mode used by the SRP server.
Address mode specifies how the address and port number are determined by the SRP server and how this info is published in the Thread Network Data.
Properties | |
---|---|
OT_SRP_SERVER_ADDRESS_MODE_ANYCAST
|
Anycast address mode. |
OT_SRP_SERVER_ADDRESS_MODE_UNICAST
|
Unicast address mode. |
otSrpServerState
otSrpServerState
This enumeration represents the state of the SRP server.
Properties | |
---|---|
OT_SRP_SERVER_STATE_DISABLED
|
The SRP server is disabled. |
OT_SRP_SERVER_STATE_RUNNING
|
The SRP server is enabled and running. |
OT_SRP_SERVER_STATE_STOPPED
|
The SRP server is enabled but stopped. |
Typedefs
otSrpClientAutoStartCallback
void(* otSrpClientAutoStartCallback)(const otSockAddr *aServerSockAddr, void *aContext)
This function pointer type defines the callback used by SRP client to notify user when it is auto-started or stopped.
This is only used when auto-start feature OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE
is enabled.
This callback is invoked when auto-start mode is enabled and the SRP client is either automatically started or stopped.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
otSrpClientBuffersServiceEntry
struct otSrpClientBuffersServiceEntry otSrpClientBuffersServiceEntry
This struct represents a SRP client service pool entry.
otSrpClientCallback
void(* otSrpClientCallback)(otError aError, const otSrpClientHostInfo *aHostInfo, const otSrpClientService *aServices, const otSrpClientService *aRemovedServices, void *aContext)
This function pointer type defines the callback used by SRP client to notify user of changes/events/errors.
This callback is invoked on a successful registration of an update (i.e., add/remove of host-info and/or some service(s)) with the SRP server, or if there is a failure or error (e.g., server rejects a update request or client times out waiting for response, etc).
In case of a successful reregistration of an update, aError
parameter would be OT_ERROR_NONE
and the host info and the full list of services is provided as input parameters to the callback. Note that host info and services each track its own state in the corresponding mState
member variable of the related data structure (the state indicating whether the host-info/service is registered or removed or still being added/removed, etc).
The list of removed services is passed as its own linked-list aRemovedServices
in the callback. Note that when the callback is invoked, the SRP client (OpenThread implementation) is done with the removed service instances listed in aRemovedServices
and no longer tracks/stores them (i.e., if from the callback we call otSrpClientGetServices()
the removed services will not be present in the returned list). Providing a separate list of removed services in the callback helps indicate to user which items are now removed and allow user to re-claim/reuse the instances.
If the server rejects an SRP update request, the DNS response code (RFC 2136) is mapped to the following errors:
- (0) NOERROR Success (no error condition) -> OT_ERROR_NONE
- (1) FORMERR Server unable to interpret due to format error -> OT_ERROR_PARSE
- (2) SERVFAIL Server encountered an internal failure -> OT_ERROR_FAILED
- (3) NXDOMAIN Name that ought to exist, does not exist -> OT_ERROR_NOT_FOUND
- (4) NOTIMP Server does not support the query type (OpCode) -> OT_ERROR_NOT_IMPLEMENTED
- (5) REFUSED Server refused for policy/security reasons -> OT_ERROR_SECURITY
- (6) YXDOMAIN Some name that ought not to exist, does exist -> OT_ERROR_DUPLICATED
- (7) YXRRSET Some RRset that ought not to exist, does exist -> OT_ERROR_DUPLICATED
- (8) NXRRSET Some RRset that ought to exist, does not exist -> OT_ERROR_NOT_FOUND
- (9) NOTAUTH Service is not authoritative for zone -> OT_ERROR_SECURITY
- (10) NOTZONE A name is not in the zone -> OT_ERROR_PARSE
- (20) BADNAME Bad name -> OT_ERROR_PARSE
- (21) BADALG Bad algorithm -> OT_ERROR_SECURITY
- (22) BADTRUN Bad truncation -> OT_ERROR_PARSE
- Other response codes -> OT_ERROR_FAILED
The following errors are also possible:
- OT_ERROR_RESPONSE_TIMEOUT : Timed out waiting for response from server (client would continue to retry).
- OT_ERROR_INVALID_ARGS : The provided service structure is invalid (e.g., bad service name or
otDnsTxtEntry
). - OT_ERROR_NO_BUFS : Insufficient buffer to prepare or send the update message.
Note that in case of any failure, the client continues the operation, i.e. it prepares and (re)transmits the SRP update message to the server, after some wait interval. The retry wait interval starts from the minimum value and is increased by the growth factor every failure up to the max value (please see configuration parameter OPENTHREAD_CONFIG_SRP_CLIENT_MIN_RETRY_WAIT_INTERVAL
and the related ones for more details).
Details | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
otSrpClientHostInfo
struct otSrpClientHostInfo otSrpClientHostInfo
This structure represents an SRP client host info.
otSrpClientService
struct otSrpClientService otSrpClientService
This structure represents an SRP client service.
The values in this structure, including the string buffers for the names and the TXT record entries, MUST persist and stay constant after an instance of this structure is passed to OpenThread from otSrpClientAddService()
or otSrpClientRemoveService()
.
The mState
, mData
, mNext
fields are used/managed by OT core only. Their value is ignored when an instance of otSrpClientService
is passed in otSrpClientAddService()
or otSrpClientRemoveService()
or other functions. The caller does not need to set these fields.
The mLease
and mKeyLease
fields specify the desired lease and key lease intervals for this service. Zero value indicates that the interval is unspecified and then the default lease or key lease intervals from otSrpClientGetLeaseInterval()
and otSrpClientGetKeyLeaseInterval()
are used for this service. If the key lease interval (whether set explicitly or determined from the default) is shorter than the lease interval for a service, SRP client will re-use the lease interval value for key lease interval as well. For example, if in service mLease
is explicitly set to 2 days and mKeyLease
is set to zero and default key lease is set to 1 day, then when registering this service, the requested key lease for this service is also set to 2 days.
otSrpServerAddressMode
enum otSrpServerAddressMode otSrpServerAddressMode
This enumeration represents the address mode used by the SRP server.
Address mode specifies how the address and port number are determined by the SRP server and how this info is published in the Thread Network Data.
otSrpServerHost
struct otSrpServerHost otSrpServerHost
This opaque type represents a SRP service host.
otSrpServerLeaseConfig
struct otSrpServerLeaseConfig otSrpServerLeaseConfig
This structure includes SRP server LEASE and KEY-LEASE configurations.
otSrpServerLeaseInfo
struct otSrpServerLeaseInfo otSrpServerLeaseInfo
This structure includes SRP server lease information of a host/service.
otSrpServerResponseCounters
struct otSrpServerResponseCounters otSrpServerResponseCounters
This structure includes the statistics of SRP server responses.
otSrpServerService
struct otSrpServerService otSrpServerService
This opaque type represents a SRP service.
otSrpServerServiceFlags
uint8_t otSrpServerServiceFlags
The service flag type to indicate which services to include or exclude when searching in (or iterating over) the list of SRP services.
This is a combination of bit-flags. The specific bit-flags are defined in the enumeration OT_SRP_SERVER_FLAG_*
.
otSrpServerServiceUpdateHandler
void(* otSrpServerServiceUpdateHandler)(otSrpServerServiceUpdateId aId, const otSrpServerHost *aHost, uint32_t aTimeout, void *aContext)
This function handles SRP service updates.
This function is called by the SRP server to notify that a SRP host and possibly SRP services are being updated. It is important that the SRP updates are not committed until the handler returns the result by calling otSrpServerHandleServiceUpdateResult or times out after aTimeout
.
A SRP service observer should always call otSrpServerHandleServiceUpdateResult with error code OT_ERROR_NONE immediately after receiving the update events.
A more generic handler may perform validations on the SRP host/services and rejects the SRP updates if any validation fails. For example, an Advertising Proxy should advertise (or remove) the host and services on a multicast-capable link and returns specific error code if any failure occurs.
Details | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
otSrpServerSetServiceUpdateHandler
otSrpServerHandleServiceUpdateResult
otSrpServerServiceUpdateId
uint32_t otSrpServerServiceUpdateId
The ID of a SRP service update transaction on the SRP Server.
otSrpServerTtlConfig
struct otSrpServerTtlConfig otSrpServerTtlConfig
This structure includes SRP server TTL configurations.
Functions
otSrpClientAddService
otError otSrpClientAddService( otInstance *aInstance, otSrpClientService *aService )
This function adds a service to be registered with server.
After a successful call to this function, otSrpClientCallback
will be called to report the status of the service addition/registration with SRP server.
The otSrpClientService
instance being pointed to by aService
MUST persist and remain unchanged after returning from this function (with OT_ERROR_NONE
). OpenThread will save the pointer to the service instance.
The otSrpClientService
instance is not longer tracked by OpenThread and can be reclaimed only when
- It is removed explicitly by a call to
otSrpClientRemoveService()
or removed along with other services by a call tootSrpClientRemoveHostAndServices() and only after the
otSrpClientCallback` is called indicating the service was removed. Or, - A call to
otSrpClientClearHostAndServices()
which removes the host and all related services immediately.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otSrpClientBuffersAllocateService
otSrpClientBuffersServiceEntry * otSrpClientBuffersAllocateService( otInstance *aInstance )
This function allocates a new service entry from the pool.
The returned service entry instance will be initialized as follows:
mService.mName
will point to an allocated string buffer which can be retrieved using the functionotSrpClientBuffersGetServiceEntryServiceNameString()
.mService.mInstanceName
will point to an allocated string buffer which can be retrieved using the functionotSrpClientBuffersGetServiceEntryInstanceNameString()
.mService.mSubTypeLabels
points to an array that is returned fromotSrpClientBuffersGetSubTypeLabelsArray()
.mService.mTxtEntries
will point tomTxtEntry
.mService.mNumTxtEntries
will be set to one.- Other
mService
fields (port, priority, weight) are set to zero. mTxtEntry.mKey
is set to NULL (value is treated as already encoded).mTxtEntry.mValue
will point to an allocated buffer which can be retrieved using the functionotSrpClientBuffersGetServiceEntryTxtBuffer()
.mTxtEntry.mValueLength
is set to zero.- All related data/string buffers and arrays are cleared to all zero.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
A pointer to the newly allocated service entry or NULL if not more entry available in the pool.
|
otSrpClientBuffersFreeAllServices
void otSrpClientBuffersFreeAllServices( otInstance *aInstance )
This function frees all previously allocated service entries.
Details | |||
---|---|---|---|
Parameters |
|
otSrpClientBuffersFreeService
void otSrpClientBuffersFreeService( otInstance *aInstance, otSrpClientBuffersServiceEntry *aService )
This function frees a previously allocated service entry.
The aService
MUST be previously allocated using otSrpClientBuffersAllocateService()
and not yet freed. Otherwise the behavior of this function is undefined.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
otSrpClientBuffersGetHostAddressesArray
otIp6Address * otSrpClientBuffersGetHostAddressesArray( otInstance *aInstance, uint8_t *aArrayLength )
This function gets the array of IPv6 address entries to use as SRP client host address list.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Returns |
A pointer to an array of
otIp6Address entries (number of entries is returned in aArrayLength ). |
otSrpClientBuffersGetHostNameString
char * otSrpClientBuffersGetHostNameString( otInstance *aInstance, uint16_t *aSize )
This function gets the string buffer to use for SRP client host name.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Returns |
A pointer to char buffer to use for SRP client host name.
|
otSrpClientBuffersGetServiceEntryInstanceNameString
char * otSrpClientBuffersGetServiceEntryInstanceNameString( otSrpClientBuffersServiceEntry *aEntry, uint16_t *aSize )
This function gets the string buffer for service instance name from a service entry.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Returns |
A pointer to the string buffer.
|
otSrpClientBuffersGetServiceEntryServiceNameString
char * otSrpClientBuffersGetServiceEntryServiceNameString( otSrpClientBuffersServiceEntry *aEntry, uint16_t *aSize )
This function gets the string buffer for service name from a service entry.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Returns |
A pointer to the string buffer.
|
otSrpClientBuffersGetServiceEntryTxtBuffer
uint8_t * otSrpClientBuffersGetServiceEntryTxtBuffer( otSrpClientBuffersServiceEntry *aEntry, uint16_t *aSize )
This function gets the buffer for TXT record from a service entry.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Returns |
A pointer to the buffer.
|
otSrpClientBuffersGetSubTypeLabelsArray
const char ** otSrpClientBuffersGetSubTypeLabelsArray( otSrpClientBuffersServiceEntry *aEntry, uint16_t *aArrayLength )
This function gets the array for service subtype labels from the service entry.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Returns |
A pointer to the array.
|
otSrpClientClearHostAndServices
void otSrpClientClearHostAndServices( otInstance *aInstance )
This function clears all host info and all the services.
Unlike otSrpClientRemoveHostAndServices()
which sends an update message to the server to remove all the info, this function clears all the info immediately without any interaction with the server.
Details | |||
---|---|---|---|
Parameters |
|
otSrpClientClearService
otError otSrpClientClearService( otInstance *aInstance, otSrpClientService *aService )
This function clears a service, immediately removing it from the client service list.
Unlike otSrpClientRemoveService()
which sends an update message to the server to remove the service, this function clears the service from the client's service list without any interaction with the server. On a successful call to this function, the otSrpClientCallback
will NOT be called and the aService
entry can be reclaimed and re-used by the caller immediately.
This function can be used along with a subsequent call to otSrpClientAddService()
(potentially reusing the same aService
entry with the same service and instance names) to update some of the parameters in an existing service.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Return Values |
|
otSrpClientDisableAutoStartMode
void otSrpClientDisableAutoStartMode( otInstance *aInstance )
This function disables the auto-start mode.
This is only available when auto-start feature OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE
is enabled.
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 otSrpClientStop()
will also disable the auto-start mode.
Details | |||
---|---|---|---|
Parameters |
|
otSrpClientEnableAutoHostAddress
otError otSrpClientEnableAutoHostAddress( otInstance *aInstance )
This function 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 all 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 otSrpClientRemoveHostAndServices()
and host info still being in either STATE_TO_REMOVE
or STATE_REMOVING
states).
After auto host address mode is enabled, it can be disabled by a call to otSrpClientSetHostAddresses()
which then explicitly sets the host addresses.
Details | |||||
---|---|---|---|---|---|
Return Values |
|
otSrpClientEnableAutoStartMode
void otSrpClientEnableAutoStartMode( otInstance *aInstance, otSrpClientAutoStartCallback aCallback, void *aContext )
This function enables the auto-start mode.
This is only available when auto-start feature OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE
is enabled.
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 otSrpClientStart()
, the given SRP server address in otSrpClientStart()
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 otSrpClientStop()
call will stop the client.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
otSrpClientGetDomainName
const char * otSrpClientGetDomainName( otInstance *aInstance )
This function gets the domain name being used by SRP client.
This function requires OPENTHREAD_CONFIG_SRP_CLIENT_DOMAIN_NAME_API_ENABLE
to be enabled.
If domain name is not set, "default.service.arpa" will be used.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The domain name string.
|
otSrpClientGetHostInfo
const otSrpClientHostInfo * otSrpClientGetHostInfo( otInstance *aInstance )
This function gets the host info.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
A pointer to host info structure.
|
otSrpClientGetKeyLeaseInterval
uint32_t otSrpClientGetKeyLeaseInterval( otInstance *aInstance )
This function gets the default key lease interval used in SRP update requests.
The default interval is used only for otSrpClientService
instances with mKeyLease
set to zero.
Note that this is the lease duration requested by the SRP client. The server may choose to accept a different lease interval.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The key lease interval (in seconds).
|
otSrpClientGetLeaseInterval
uint32_t otSrpClientGetLeaseInterval( otInstance *aInstance )
This function gets the default lease interval used in SRP update requests.
The default interval is used only for otSrpClientService
instances with mLease
set to zero.
Note that this is the lease duration requested by the SRP client. The server may choose to accept a different lease interval.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The lease interval (in seconds).
|
otSrpClientGetServerAddress
const otSockAddr * otSrpClientGetServerAddress( otInstance *aInstance )
This function 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.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
A pointer to the SRP server's socket address (is always non-NULL).
|
otSrpClientGetServices
const otSrpClientService * otSrpClientGetServices( otInstance *aInstance )
This function gets the list of services being managed by client.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
A pointer to the head of linked-list of all services or NULL if the list is empty.
|
otSrpClientGetTtl
uint32_t otSrpClientGetTtl( otInstance *aInstance )
This function gets the TTL value in every record included 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.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The TTL (in seconds).
|
otSrpClientIsAutoStartModeEnabled
bool otSrpClientIsAutoStartModeEnabled( otInstance *aInstance )
This function indicates the current state of auto-start mode (enabled or disabled).
This is only available when auto-start feature OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE
is enabled.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
TRUE if the auto-start mode is enabled, FALSE otherwise.
|
otSrpClientIsRunning
bool otSrpClientIsRunning( otInstance *aInstance )
This function indicates whether the SRP client is running or not.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
TRUE if the SRP client is running, FALSE otherwise.
|
otSrpClientIsServiceKeyRecordEnabled
bool otSrpClientIsServiceKeyRecordEnabled( otInstance *aInstance )
This method indicates whether the "service key record inclusion" mode is enabled or disabled.
This function is available when OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
configuration is enabled.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
TRUE if "service key record inclusion" mode is enabled, FALSE otherwise.
|
otSrpClientItemStateToString
const char * otSrpClientItemStateToString( otSrpClientItemState aItemState )
This function converts a otSrpClientItemState
to a string.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
A string representation of
aItemState . |
otSrpClientRemoveHostAndServices
otError otSrpClientRemoveHostAndServices( otInstance *aInstance, bool aRemoveKeyLease, bool aSendUnregToServer )
This function starts the remove process of the host info and all services.
After returning from this function, otSrpClientCallback
will be called to report the status of remove request with SRP server.
If the host info is to be permanently removed from server, 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 is once again able to provide and register its service(s).
The aSendUnregToServer
determines the behavior when the host info is not yet registered with the server. If 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 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 aSendUnregToServer
does not matter and the SRP client will always send an update message to server requesting removal of all info.
One situation where 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 otSrpClientSetHostName()
and then request otSrpClientRemoveHostAndServices()
with aSendUnregToServer
as true
.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otSrpClientRemoveService
otError otSrpClientRemoveService( otInstance *aInstance, otSrpClientService *aService )
This function requests a service to be unregistered with server.
After a successful call to this function, otSrpClientCallback
will be called to report the status of remove request with SRP server.
The otSrpClientService
instance being pointed to by aService
MUST persist and remain unchanged after returning from this function (with OT_ERROR_NONE
). OpenThread will keep the service instance during the remove process. Only after the otSrpClientCallback
is called indicating the service instance is removed from SRP client service list and can be be freed/reused.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Return Values |
|
otSrpClientSetCallback
void otSrpClientSetCallback( otInstance *aInstance, otSrpClientCallback aCallback, void *aContext )
This function sets the callback to notify caller of events/changes from SRP client.
The SRP client allows a single callback to be registered. So consecutive calls to this function will overwrite any previously set callback functions.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
otSrpClientSetDomainName
otError otSrpClientSetDomainName( otInstance *aInstance, const char *aName )
This function sets the domain name to be used by SRP client.
This function requires OPENTHREAD_CONFIG_SRP_CLIENT_DOMAIN_NAME_API_ENABLE
to be enabled.
If not set "default.service.arpa" will be used.
The name string buffer pointed to by aName
MUST persist and stay unchanged after returning from this function. OpenThread will keep the pointer to the string.
The domain 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 STATE_TO_ADD
or STATE_TO_REMOVE
).
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Return Values |
|
otSrpClientSetHostAddresses
otError otSrpClientSetHostAddresses( otInstance *aInstance, const otIp6Address *aIp6Addresses, uint8_t aNumAddresses )
This function sets/updates the list of host IPv6 address.
Host IPv6 addresses can be set/changed before start or 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 otSrpClientRemoveHostAndServices()
and host info still being in either STATE_TO_REMOVE
or STATE_REMOVING
states).
The host IPv6 address array pointed to by aIp6Addresses
MUST persist and remain unchanged after returning from this function (with OT_ERROR_NONE
). OpenThread will save the pointer to the array.
After a successful call to this function, otSrpClientCallback
will be called to report the status of the address registration with SRP server.
Calling this function disables auto host address mode if it was previously enabled from a successful call to otSrpClientEnableAutoHostAddress()
.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otSrpClientSetHostName
otError otSrpClientSetHostName( otInstance *aInstance, const char *aName )
This function sets the host name label.
After a successful call to this function, otSrpClientCallback
will be called to report the status of host info registration with SRP server.
The name string buffer pointed to by aName
MUST persist and stay unchanged after returning from this function. OpenThread will keep the pointer to the string.
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 STATE_TO_ADD
or STATE_REMOVED
).
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otSrpClientSetKeyLeaseInterval
void otSrpClientSetKeyLeaseInterval( otInstance *aInstance, uint32_t aInterval )
This function sets the default key lease interval used in SRP update requests.
The default interval is used only for otSrpClientService
instances with mKeyLease
set to zero.
Changing the lease interval does not impact the accepted lease interval of already registered services/host-info. It only affects any future SRP update messages (i.e., adding new services and/or refreshes of existing services).
Details | |||||
---|---|---|---|---|---|
Parameters |
|
otSrpClientSetLeaseInterval
void otSrpClientSetLeaseInterval( otInstance *aInstance, uint32_t aInterval )
This function sets the default lease interval used in SRP update requests.
The default interval is used only for otSrpClientService
instances with mLease
set to zero.
Changing the lease interval does not impact the accepted lease interval of already registered services/host-info. It only affects any future SRP update messages (i.e., adding new services and/or refreshes of the existing services).
Details | |||||
---|---|---|---|---|---|
Parameters |
|
otSrpClientSetServiceKeyRecordEnabled
void otSrpClientSetServiceKeyRecordEnabled( otInstance *aInstance, bool aEnabled )
This function 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.
This function is available when OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
configuration is enabled.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
otSrpClientSetTtl
void otSrpClientSetTtl( otInstance *aInstance, uint32_t aTtl )
This function sets the TTL value in every record included in SRP update requests.
Changing the TTL does not impact the TTL of already registered services/host-info. It only affects future SRP update messages (i.e., adding new services and/or refreshes of the existing services).
Details | |||||
---|---|---|---|---|---|
Parameters |
|
otSrpClientStart
otError otSrpClientStart( otInstance *aInstance, const otSockAddr *aServerSockAddr )
This function starts the SRP client operation.
SRP client will prepare and send "SRP Update" message to the SRP server once all the following conditions are met:
- The SRP client is started -
otSrpClientStart()
is called. - Host name is set -
otSrpClientSetHostName()
is called. - At least one host IPv6 address is set -
otSrpClientSetHostName()
is called. - At least one service is added -
otSrpClientAddService()
is called.
It does not matter in which order these functions are called. When all conditions are met, the SRP client will wait for a short delay before preparing an "SRP Update" message and sending it to server. This delay allows for user to add multiple services and/or IPv6 addresses before the first SRP Update message is sent (ensuring a single SRP Update is sent containing all the info). The config OPENTHREAD_CONFIG_SRP_CLIENT_UPDATE_TX_DELAY
specifies the delay interval.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otSrpClientStop
void otSrpClientStop( otInstance *aInstance )
This function stops the SRP client operation.
This function stops any further interactions with the SRP server. Note that it does not remove or clear host info and/or list of services. It marks all services to be added/removed again once the client is (re)started.
Details | |||
---|---|---|---|
Parameters |
|
otSrpServerGetAddressMode
otSrpServerAddressMode otSrpServerGetAddressMode( otInstance *aInstance )
This function returns the address mode being used by the SRP server.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The SRP server's address mode.
|
otSrpServerGetAnycastModeSequenceNumber
uint8_t otSrpServerGetAnycastModeSequenceNumber( otInstance *aInstance )
This function returns the sequence number used with anycast address mode.
The sequence number is included in "DNS/SRP Service Anycast Address" entry published in the Network Data.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The anycast sequence number.
|
otSrpServerGetDomain
const char * otSrpServerGetDomain( otInstance *aInstance )
This function returns the domain authorized to the SRP server.
If the domain if not set by SetDomain, "default.service.arpa." will be returned. A trailing dot is always appended even if the domain is set without it.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
A pointer to the dot-joined domain string.
|
otSrpServerGetLeaseConfig
void otSrpServerGetLeaseConfig( otInstance *aInstance, otSrpServerLeaseConfig *aLeaseConfig )
This function returns SRP server LEASE and KEY-LEASE configurations.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
otSrpServerGetNextHost
const otSrpServerHost * otSrpServerGetNextHost( otInstance *aInstance, const otSrpServerHost *aHost )
This function returns the next registered host on the SRP server.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Returns |
A pointer to the registered host. NULL, if no more hosts can be found.
|
otSrpServerGetPort
uint16_t otSrpServerGetPort( otInstance *aInstance )
This function returns the port the SRP server is listening to.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The port of the SRP server. It returns 0 if the server is not running.
|
otSrpServerGetResponseCounters
const otSrpServerResponseCounters * otSrpServerGetResponseCounters( otInstance *aInstance )
This function returns the response counters of the SRP server.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
A pointer to the response counters of the SRP server.
|
otSrpServerGetState
otSrpServerState otSrpServerGetState( otInstance *aInstance )
This function returns the state of the SRP server.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The current state of the SRP server.
|
otSrpServerGetTtlConfig
void otSrpServerGetTtlConfig( otInstance *aInstance, otSrpServerTtlConfig *aTtlConfig )
This function returns SRP server TTL configuration.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
otSrpServerHandleServiceUpdateResult
void otSrpServerHandleServiceUpdateResult( otInstance *aInstance, otSrpServerServiceUpdateId aId, otError aError )
This function reports the result of processing a SRP update to the SRP server.
The Service Update Handler should call this function to return the result of its processing of a SRP update.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
otSrpServerHostFindNextService
const otSrpServerService * otSrpServerHostFindNextService( const otSrpServerHost *aHost, const otSrpServerService *aPrevService, otSrpServerServiceFlags aFlags, const char *aServiceName, const char *aInstanceName )
This function finds the next matching service on the host.
The combination of flags and service and instance names enables iterating over the full list of services and/or a subset of them matching certain conditions, or finding a specific service.
To iterate over all services of a host: service = otSrpServerHostFindNextService(host, service, OT_SRP_SERVER_FLAGS_ANY_SERVICE, NULL, NULL);
To iterate over base services only (exclude sub-types): service = otSrpServerHostFindNextService(host, service, OT_SRP_SERVER_FLAGS_BASE_TYPE_SERVICE_ONLY, NULL, NULL);
To iterate over sub-types of a specific instance name instanceName
: service = otSrpServerHostFindNextService(host, service, OT_SRP_SERVER_FLAGS_SUB_TYPE_SERVICE_ONLY, NULL, instanceName);
To find a specific service with service name serviceName
and service instance name instanceName
: service = otSrpServerHostFindNextService(host, NULL, OT_SRP_SERVER_FLAGS_ANY_SERVICE, serviceName, instanceName);
To find the base type service with a given service instance name instanceName
: service = otSrpServerHostFindNextService(host, NULL, OT_SRP_SERVER_FLAGS_BASE_TYPE_SERVICE_ONLY, NULL, instanceName);
Details | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||||
Returns |
A pointer to the next matching service or NULL if no matching service could be found.
|
otSrpServerHostGetAddresses
const otIp6Address * otSrpServerHostGetAddresses( const otSrpServerHost *aHost, uint8_t *aAddressesNum )
This function returns the addresses of given host.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Returns |
A pointer to the array of IPv6 Address.
|
otSrpServerHostGetFullName
const char * otSrpServerHostGetFullName( const otSrpServerHost *aHost )
This function returns the full name of the host.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
A pointer to the null-terminated host name string.
|
otSrpServerHostGetLeaseInfo
void otSrpServerHostGetLeaseInfo( const otSrpServerHost *aHost, otSrpServerLeaseInfo *aLeaseInfo )
This function returns the LEASE and KEY-LEASE information of a given host.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
otSrpServerHostGetNextService
const otSrpServerService * otSrpServerHostGetNextService( const otSrpServerHost *aHost, const otSrpServerService *aService )
This function returns the next service (excluding any sub-type services) of given host.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Returns |
A pointer to the next service or NULL if there is no more services.
|
otSrpServerHostIsDeleted
bool otSrpServerHostIsDeleted( const otSrpServerHost *aHost )
This function tells if the SRP service host has been deleted.
A SRP service host can be deleted but retains its name for future uses. In this case, the host instance is not removed from the SRP server/registry.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
TRUE if the host has been deleted, FALSE if not.
|
otSrpServerIsAutoEnableMode
bool otSrpServerIsAutoEnableMode( otInstance *aInstance )
This function indicates whether the auto-enable mode is enabled or disabled.
This function requires OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
feature.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Return Values |
|
otSrpServerServiceGetFullName
const char * otSrpServerServiceGetFullName( const otSrpServerService *aService )
This function returns the full service instance name of the service.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
A pointer to the null-terminated service instance name string.
|
otSrpServerServiceGetHost
const otSrpServerHost * otSrpServerServiceGetHost( const otSrpServerService *aService )
This function returns the host which the service instance reside on.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
A pointer to the host instance.
|
otSrpServerServiceGetInstanceName
const char * otSrpServerServiceGetInstanceName( const otSrpServerService *aService )
This function returns the full service instance name of the service.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
A pointer to the null-terminated service instance name string.
|
otSrpServerServiceGetLeaseInfo
void otSrpServerServiceGetLeaseInfo( const otSrpServerService *aService, otSrpServerLeaseInfo *aLeaseInfo )
This function returns the LEASE and KEY-LEASE information of a given service.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
otSrpServerServiceGetPort
uint16_t otSrpServerServiceGetPort( const otSrpServerService *aService )
This function returns the port of the service instance.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The port of the service.
|
otSrpServerServiceGetPriority
uint16_t otSrpServerServiceGetPriority( const otSrpServerService *aService )
This function returns the priority of the service instance.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The priority of the service.
|
otSrpServerServiceGetServiceName
const char * otSrpServerServiceGetServiceName( const otSrpServerService *aService )
This function returns the full service name of the service.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
A pointer to the null-terminated service name string.
|
otSrpServerServiceGetServiceSubTypeLabel
otError otSrpServerServiceGetServiceSubTypeLabel( const otSrpServerService *aService, char *aLabel, uint8_t aMaxSize )
This function gets the sub-type label from service name.
This function is intended to be used when the aService
is a sub-type, i.e., otSrpServerServiceIsSubType()
for the service returns TRUE. If it is not a sub-type this function returns OT_ERROR_INVALID_ARGS
.
The full service name for a sub-type service follows "
into the aLabel
buffer.
The aLabel
is ensured to always be null-terminated after returning even in case of failure.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otSrpServerServiceGetTtl
uint32_t otSrpServerServiceGetTtl( const otSrpServerService *aService )
This function returns the TTL of the service instance.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The TTL of the service instance..
|
otSrpServerServiceGetTxtData
const uint8_t * otSrpServerServiceGetTxtData( const otSrpServerService *aService, uint16_t *aDataLength )
This function returns the TXT record data of the service instance.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Returns |
A pointer to the buffer containing the TXT record data (the TXT data length is returned in
aDataLength ). |
otSrpServerServiceGetWeight
uint16_t otSrpServerServiceGetWeight( const otSrpServerService *aService )
This function returns the weight of the service instance.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The weight of the service.
|
otSrpServerServiceIsDeleted
bool otSrpServerServiceIsDeleted( const otSrpServerService *aService )
This function indicates whether or not the SRP service has been deleted.
A SRP service can be deleted but retains its name for future uses. In this case, the service instance is not removed from the SRP server/registry. It is guaranteed that all services are deleted if the host is deleted.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
TRUE if the service has been deleted, FALSE if not.
|
otSrpServerServiceIsSubType
bool otSrpServerServiceIsSubType( const otSrpServerService *aService )
This function indicates whether or not the SRP service is sub-type.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
TRUE if the service is a sub-type, FALSE if not.
|
otSrpServerSetAddressMode
otError otSrpServerSetAddressMode( otInstance *aInstance, otSrpServerAddressMode aMode )
This function sets the address mode to be used by the SRP server.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Return Values |
|
otSrpServerSetAnycastModeSequenceNumber
otError otSrpServerSetAnycastModeSequenceNumber( otInstance *aInstance, uint8_t aSequenceNumber )
This function sets the sequence number used with anycast address mode.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Return Values |
|
otSrpServerSetAutoEnableMode
void otSrpServerSetAutoEnableMode( otInstance *aInstance, bool aEnabled )
This function enables/disables the auto-enable mode on SRP server.
This function requires OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
feature.
When this mode is enabled, the Border Routing Manager controls if/when to enable or disable the SRP server. SRP sever is auto-enabled if/when Border Routing is started and it is done with the initial prefix and route configurations (when the OMR and on-link prefixes are determined, advertised in emitted Router Advertisement message on infrastructure side and published in the Thread Network Data). The SRP server is auto-disabled if/when BR is stopped (e.g., if the infrastructure network interface is brought down or if BR gets detached).
This mode can be disabled by a otSrpServerSetAutoEnableMode()
call with aEnabled
set to false
or if the SRP server is explicitly enabled or disabled by a call to otSrpServerSetEnabled()
function. Disabling auto-enable mode using otSrpServerSetAutoEnableMode(false)
will not change the current state of SRP sever (e.g., if it is enabled it stays enabled).
Details | |||||
---|---|---|---|---|---|
Parameters |
|
otSrpServerSetDomain
otError otSrpServerSetDomain( otInstance *aInstance, const char *aDomain )
This function sets the domain on the SRP server.
A trailing dot will be appended to aDomain
if it is not already there. This function should only be called before the SRP server is enabled.
Details | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||
Return Values |
|
otSrpServerSetEnabled
void otSrpServerSetEnabled( otInstance *aInstance, bool aEnabled )
This function enables/disables the SRP server.
On a Border Router, it is recommended to use otSrpServerSetAutoEnableMode()
instead.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
otSrpServerSetLeaseConfig
otError otSrpServerSetLeaseConfig( otInstance *aInstance, const otSrpServerLeaseConfig *aLeaseConfig )
This function sets SRP server LEASE and KEY-LEASE configurations.
When a non-zero LEASE time is requested from a client, the granted value will be limited in range [aMinLease, aMaxLease]; and a non-zero KEY-LEASE will be granted in range [aMinKeyLease, aMaxKeyLease]. For zero LEASE or KEY-LEASE time, zero will be granted.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Return Values |
|
otSrpServerSetServiceUpdateHandler
void otSrpServerSetServiceUpdateHandler( otInstance *aInstance, otSrpServerServiceUpdateHandler aServiceHandler, void *aContext )
This function sets the SRP service updates handler on SRP server.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
otSrpServerSetTtlConfig
otError otSrpServerSetTtlConfig( otInstance *aInstance, const otSrpServerTtlConfig *aTtlConfig )
This function sets SRP server TTL configuration.
The granted TTL will always be no greater than the max lease interval configured via otSrpServerSetLeaseConfig()
, regardless of the minimum and maximum TTL configuration.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Return Values |
|
Resources
OpenThread API Reference topics originate from the source code, available on GitHub. For more information, or to contribute to our documentation, refer to Resources.