|
| otError | otSrpClientAddService (otInstance *aInstance, otSrpClientService *aService) |
| |
| otSrpClientBuffersServiceEntry * | otSrpClientBuffersAllocateService (otInstance *aInstance) |
| |
| void | otSrpClientBuffersFreeAllServices (otInstance *aInstance) |
| |
| void | otSrpClientBuffersFreeService (otInstance *aInstance, otSrpClientBuffersServiceEntry *aService) |
| |
| otIp6Address * | otSrpClientBuffersGetHostAddressesArray (otInstance *aInstance, uint8_t *aArrayLength) |
| |
| char * | otSrpClientBuffersGetHostNameString (otInstance *aInstance, uint16_t *aSize) |
| |
| char * | otSrpClientBuffersGetServiceEntryInstanceNameString (otSrpClientBuffersServiceEntry *aEntry, uint16_t *aSize) |
| |
| char * | otSrpClientBuffersGetServiceEntryServiceNameString (otSrpClientBuffersServiceEntry *aEntry, uint16_t *aSize) |
| |
| uint8_t * | otSrpClientBuffersGetServiceEntryTxtBuffer (otSrpClientBuffersServiceEntry *aEntry, uint16_t *aSize) |
| |
| const char ** | otSrpClientBuffersGetSubTypeLabelsArray (otSrpClientBuffersServiceEntry *aEntry, uint16_t *aArrayLength) |
| |
| void | otSrpClientClearHostAndServices (otInstance *aInstance) |
| |
| otError | otSrpClientClearService (otInstance *aInstance, otSrpClientService *aService) |
| |
| void | otSrpClientDisableAutoStartMode (otInstance *aInstance) |
| |
| otError | otSrpClientEnableAutoHostAddress (otInstance *aInstance) |
| |
| void | otSrpClientEnableAutoStartMode (otInstance *aInstance, otSrpClientAutoStartCallback aCallback, void *aContext) |
| |
| const char * | otSrpClientGetDomainName (otInstance *aInstance) |
| |
| const otSrpClientHostInfo * | otSrpClientGetHostInfo (otInstance *aInstance) |
| |
| uint32_t | otSrpClientGetKeyLeaseInterval (otInstance *aInstance) |
| |
| uint32_t | otSrpClientGetLeaseInterval (otInstance *aInstance) |
| |
| const otSockAddr * | otSrpClientGetServerAddress (otInstance *aInstance) |
| |
| const otSrpClientService * | otSrpClientGetServices (otInstance *aInstance) |
| |
| uint32_t | otSrpClientGetTtl (otInstance *aInstance) |
| |
| bool | otSrpClientIsAutoStartModeEnabled (otInstance *aInstance) |
| |
| bool | otSrpClientIsRunning (otInstance *aInstance) |
| |
| bool | otSrpClientIsServiceKeyRecordEnabled (otInstance *aInstance) |
| |
| const char * | otSrpClientItemStateToString (otSrpClientItemState aItemState) |
| |
| otError | otSrpClientRemoveHostAndServices (otInstance *aInstance, bool aRemoveKeyLease, bool aSendUnregToServer) |
| |
| otError | otSrpClientRemoveService (otInstance *aInstance, otSrpClientService *aService) |
| |
| void | otSrpClientSetCallback (otInstance *aInstance, otSrpClientCallback aCallback, void *aContext) |
| |
| otError | otSrpClientSetDomainName (otInstance *aInstance, const char *aName) |
| |
| otError | otSrpClientSetHostAddresses (otInstance *aInstance, const otIp6Address *aIp6Addresses, uint8_t aNumAddresses) |
| |
| otError | otSrpClientSetHostName (otInstance *aInstance, const char *aName) |
| |
| void | otSrpClientSetKeyLeaseInterval (otInstance *aInstance, uint32_t aInterval) |
| |
| void | otSrpClientSetLeaseInterval (otInstance *aInstance, uint32_t aInterval) |
| |
| void | otSrpClientSetServiceKeyRecordEnabled (otInstance *aInstance, bool aEnabled) |
| |
| void | otSrpClientSetTtl (otInstance *aInstance, uint32_t aTtl) |
| |
| otError | otSrpClientStart (otInstance *aInstance, const otSockAddr *aServerSockAddr) |
| |
| void | otSrpClientStop (otInstance *aInstance) |
| |
| otSrpServerAddressMode | otSrpServerGetAddressMode (otInstance *aInstance) |
| |
| uint8_t | otSrpServerGetAnycastModeSequenceNumber (otInstance *aInstance) |
| |
| const char * | otSrpServerGetDomain (otInstance *aInstance) |
| |
| void | otSrpServerGetLeaseConfig (otInstance *aInstance, otSrpServerLeaseConfig *aLeaseConfig) |
| |
| const otSrpServerHost * | otSrpServerGetNextHost (otInstance *aInstance, const otSrpServerHost *aHost) |
| |
| uint16_t | otSrpServerGetPort (otInstance *aInstance) |
| |
| const otSrpServerResponseCounters * | otSrpServerGetResponseCounters (otInstance *aInstance) |
| |
| otSrpServerState | otSrpServerGetState (otInstance *aInstance) |
| |
| void | otSrpServerGetTtlConfig (otInstance *aInstance, otSrpServerTtlConfig *aTtlConfig) |
| |
| void | otSrpServerHandleServiceUpdateResult (otInstance *aInstance, otSrpServerServiceUpdateId aId, otError aError) |
| |
| const otSrpServerService * | otSrpServerHostFindNextService (const otSrpServerHost *aHost, const otSrpServerService *aPrevService, otSrpServerServiceFlags aFlags, const char *aServiceName, const char *aInstanceName) |
| |
| const otIp6Address * | otSrpServerHostGetAddresses (const otSrpServerHost *aHost, uint8_t *aAddressesNum) |
| |
| const char * | otSrpServerHostGetFullName (const otSrpServerHost *aHost) |
| |
| void | otSrpServerHostGetLeaseInfo (const otSrpServerHost *aHost, otSrpServerLeaseInfo *aLeaseInfo) |
| |
| const otSrpServerService * | otSrpServerHostGetNextService (const otSrpServerHost *aHost, const otSrpServerService *aService) |
| |
| bool | otSrpServerHostIsDeleted (const otSrpServerHost *aHost) |
| |
| const char * | otSrpServerServiceGetFullName (const otSrpServerService *aService) |
| |
| const otSrpServerHost * | otSrpServerServiceGetHost (const otSrpServerService *aService) |
| |
| const char * | otSrpServerServiceGetInstanceName (const otSrpServerService *aService) |
| |
| void | otSrpServerServiceGetLeaseInfo (const otSrpServerService *aService, otSrpServerLeaseInfo *aLeaseInfo) |
| |
| uint16_t | otSrpServerServiceGetPort (const otSrpServerService *aService) |
| |
| uint16_t | otSrpServerServiceGetPriority (const otSrpServerService *aService) |
| |
| const char * | otSrpServerServiceGetServiceName (const otSrpServerService *aService) |
| |
| otError | otSrpServerServiceGetServiceSubTypeLabel (const otSrpServerService *aService, char *aLabel, uint8_t aMaxSize) |
| |
| uint32_t | otSrpServerServiceGetTtl (const otSrpServerService *aService) |
| |
| const uint8_t * | otSrpServerServiceGetTxtData (const otSrpServerService *aService, uint16_t *aDataLength) |
| |
| uint16_t | otSrpServerServiceGetWeight (const otSrpServerService *aService) |
| |
| bool | otSrpServerServiceIsDeleted (const otSrpServerService *aService) |
| |
| bool | otSrpServerServiceIsSubType (const otSrpServerService *aService) |
| |
| otError | otSrpServerSetAddressMode (otInstance *aInstance, otSrpServerAddressMode aMode) |
| |
| otError | otSrpServerSetAnycastModeSequenceNumber (otInstance *aInstance, uint8_t aSequenceNumber) |
| |
| otError | otSrpServerSetDomain (otInstance *aInstance, const char *aDomain) |
| |
| void | otSrpServerSetEnabled (otInstance *aInstance, bool aEnabled) |
| |
| otError | otSrpServerSetLeaseConfig (otInstance *aInstance, const otSrpServerLeaseConfig *aLeaseConfig) |
| |
| void | otSrpServerSetServiceUpdateHandler (otInstance *aInstance, otSrpServerServiceUpdateHandler aServiceHandler, void *aContext) |
| |
| otError | otSrpServerSetTtlConfig (otInstance *aInstance, const otSrpServerTtlConfig *aTtlConfig) |
| |
This module includes functions that control SRP client behavior.
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.
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).
- Parameters
-
| [in] | aError | The error (see above). |
| [in] | aHostInfo | A pointer to host info. |
| [in] | aServices | The head of linked-list containing all services (excluding the ones removed). NULL if the list is empty. |
| [in] | aRemovedServices | The head of linked-list containing all removed services. NULL if the list is empty. |
| [in] | aContext | A pointer to an arbitrary context (provided when callback was registered). |
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.
- Parameters
-
| [in] | aId | The service update transaction ID. This ID must be passed back with otSrpServerHandleServiceUpdateResult. |
| [in] | aHost | A pointer to the otSrpServerHost object which contains the SRP updates. The handler should publish/un-publish the host and each service points to this host with below rules:
- If the host is not deleted (indicated by
otSrpServerHostIsDeleted), then it should be published or updated with mDNS. Otherwise, the host should be un-published (remove AAAA RRs).
- For each service points to this host, it must be un-published if the host is to be un-published. Otherwise, the handler should publish or update the service when it is not deleted (indicated by
otSrpServerServiceIsDeleted) and un-publish it when deleted.
|
| [in] | aTimeout | The maximum time in milliseconds for the handler to process the service event. |
| [in] | aContext | A pointer to application-specific context. |
- See also
- otSrpServerSetServiceUpdateHandler
-
otSrpServerHandleServiceUpdateResult
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 for SRP Server Service entries and automatically start and stop the client when an SRP server is detected.
If multiple SRP servers are found, a random one will be selected. If the selected SRP server is no longer detected (not longer present in the Thread Network Data), the SRP client will be stopped and then it may switch to another SRP server (if available).
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.
- Parameters
-
| [in] | aInstance | A pointer to the OpenThread instance. |
| [in] | aCallback | A callback to notify when client is auto-started/stopped. Can be NULL if not needed. |
| [in] | aContext | A context to be passed when invoking aCallback. |
| 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.
- Parameters
-
| [in] | aInstance | A pointer to the OpenThread instance. |
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).
- Parameters
-
| [in] | aInstance | A pointer to the OpenThread instance. |
| [in] | aName | A pointer to host name label string (MUST NOT be NULL). Pointer to the string buffer MUST persist and remain valid and constant after return from this function. |
- Return values
-
| OT_ERROR_NONE | The host name label was set successfully. |
| OT_ERROR_INVALID_ARGS | The aName is NULL. |
| OT_ERROR_INVALID_STATE | The host name is already set and registered with the server. |
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.
- Return values
-
| OT_ERROR_NONE | Successfully enabled auto host address mode. |
| OT_ERROR_INVALID_STATE | Host is being removed and therefore cannot enable auto host address mode. |
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().
- Parameters
-
| [in] | aInstance | A pointer to the OpenThread instance. |
| [in] | aIp6Addresses | A pointer to the an array containing the host IPv6 addresses. |
| [in] | aNumAddresses | The number of addresses in the aIp6Addresses array. |
- Return values
-
| OT_ERROR_NONE | The host IPv6 address list change started successfully. The otSrpClientCallback will be called to report the status of registering addresses with server. |
| OT_ERROR_INVALID_ARGS | The address list is invalid (e.g., must contain at least one address). |
| OT_ERROR_INVALID_STATE | Host is being removed and therefore cannot change host address. |
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.
- Parameters
-
| [in] | aInstance | A pointer to the OpenThread instance. |
| [in] | aService | A pointer to a otSrpClientService instance to delete. |
- Return values
-
| OT_ERROR_NONE | The aService is deleted successfully. It can be reclaimed and re-used immediately. |
| OT_ERROR_NOT_FOUND | The service could not be found in the list. |
| 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.
- Parameters
-
| [in] | aInstance | A pointer to the OpenThread instance. |
| [in] | aRemoveKeyLease | A boolean indicating whether or not the host key lease should also be removed. |
| [in] | aSendUnregToServer | A boolean indicating whether to send update to server when host info is not registered. |
- Return values
-
| OT_ERROR_NONE | The removal of host info and services started successfully. The otSrpClientCallback will be called to report the status. |
| OT_ERROR_ALREADY | The host info is already removed. |
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).
- Parameters
-
| [in] | aInstance | A pointer to the OpenThread instance. |
| [in] | aName | A pointer to the domain name string. If NULL sets it to default "default.service.arpa". |
- Return values
-
| OT_ERROR_NONE | The domain name label was set successfully. |
| OT_ERROR_INVALID_STATE | The host info is already registered with server. |
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);
- Parameters
-
| [in] | aHost | A pointer to the SRP service host (MUST NOT be NULL). |
| [in] | aPrevService | A pointer to the previous service or NULL to start from the beginning of the list. |
| [in] | aFlags | Flags indicating which services to include (base/sub-type, active/deleted). |
| [in] | aServiceName | The service name to match. Set to NULL to accept any name. |
| [in] | aInstanceName | The service instance name to match. Set to NULL to accept any name. |
- Returns
- A pointer to the next matching service or NULL if no matching service could be found.
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 "<sub-label>._sub.<service-labels>.<domain>.". This function copies the <sub-label> into the aLabel buffer.
The aLabel is ensured to always be null-terminated after returning even in case of failure.
- Parameters
-
| [in] | aService | A pointer to the SRP service. |
| [out] | aLabel | A pointer to a buffer to copy the sub-type label name into. |
| [in] | aMaxSize | Maximum size of aLabel buffer. |
- Return values
-
| OT_ERROR_NONE | aLabel was updated successfully. |
| OT_ERROR_NO_BUFS | The sub-type label could not fit in aLabel buffer (number of chars from label that could fit are copied in aLabel ensuring it is null-terminated). |
| OT_ERROR_INVALID_ARGS | SRP service is not a sub-type. |