# SRP Client

This module includes configuration variables for the SRP Client.

## Summary

| ### Macros ||
|---|---|
| `https://openthread.io/reference/config/group/config-srp-client#group__config-srp-client_1ga65225dbc69e1cca264661aee5c9d9a18 1` | Define to 1 to enable SRP Client auto-start feature and its APIs. |
| `https://openthread.io/reference/config/group/config-srp-client#group__config-srp-client_1ga732553c364856dfb1885bc89563dda58 1` | Define the default mode (enabled or disabled) of auto-start mode. |
| `https://openthread.io/reference/config/group/config-srp-client#group__config-srp-client_1ga2528a97d0145acc5951f5755574f1077 OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE` | Define to 1 to enable SRP Client buffers and service pool feature. |
| `https://openthread.io/reference/config/group/config-srp-client#group__config-srp-client_1ga19c5c00e19167a9b3652f15142e7211a 64` | Specifies the size (number of chars) of host name string buffer in the SRP client buffers and service pool. |
| `https://openthread.io/reference/config/group/config-srp-client#group__config-srp-client_1gabac30b191713ea7d6b8d303d8f5e79b0 2` | Specifies number of host IPv6 address entries in the SRP client buffers and service pool. |
| `https://openthread.io/reference/config/group/config-srp-client#group__config-srp-client_1ga05639034cc64caf878ec96321562d40f 2` | Specifies number of service entries in the SRP client service pool. |
| `https://openthread.io/reference/config/group/config-srp-client#group__config-srp-client_1ga84da7dfc302f16acd45bdffe4c7f8ea9 64` | Specifies the size (number of chars) of service instance name string buffer in the SRP client buffers and service pool. |
| `https://openthread.io/reference/config/group/config-srp-client#group__config-srp-client_1ga28c05ed22562985b877960fee2f2c208 6` | Specifies the maximum number of service subtype labels (array length) in the SRP client buffers and service pool. |
| `https://openthread.io/reference/config/group/config-srp-client#group__config-srp-client_1ga164ab85753387fbde9acc53b9d36576c 96` | Specifies the size (number of chars) of service name string buffer in the SRP client buffers and service pool. |
| `https://openthread.io/reference/config/group/config-srp-client#group__config-srp-client_1gaf191a7243a740d4d3c3cdb5782b13d14 64` | Specifies the size (number of bytes) of TXT record value buffer in the SRP client buffers and service pool. |
| `https://openthread.io/reference/config/group/config-srp-client#group__config-srp-client_1gaf44d35ce0af37a8949e733a2bf5d5308 (OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE && OPENTHREAD_CONFIG_UPTIME_ENABLE)` | Define to 1 to enable SRP Client counters APIs (`otSrpClientGetCounters` and `otSrpClientResetCounters`). |
| `https://openthread.io/reference/config/group/config-srp-client#group__config-srp-client_1ga5862d106ef6ede879632a5a6669c5f22 (14 * 24 * 60 * 60)` | Specifies the default requested key lease interval (in seconds). |
| `https://openthread.io/reference/config/group/config-srp-client#group__config-srp-client_1gad8f380e40302f40ad08573d0ba4ab1c4 (2 * 60 * 60)` | Specifies the default requested lease interval (in seconds). |
| `https://openthread.io/reference/config/group/config-srp-client#group__config-srp-client_1ga16ff51934ce30629316163e977b3f8a2 1` | Define to 1 to disallow SRP client to switch server (when auto-start is used) on failure if host (or any services) were previously successfully registered with the currently selected server. |
| `https://openthread.io/reference/config/group/config-srp-client#group__config-srp-client_1ga53608f43e17038896e9aa1f22e05ed52 0` | Define to 1 for the SRP client implementation to provide APIs that get/set the domain name. |
| `https://openthread.io/reference/config/group/config-srp-client#group__config-srp-client_1gaa68a13a066580bcdb836d1bbcae0decf 2` | Specifies the denominator of early lease renewal factor. |
| `https://openthread.io/reference/config/group/config-srp-client#group__config-srp-client_1ga8bc6443dda9754356ed4fc2eff993ead 1` | Specifies the numerator of early lease renewal factor. |
| `https://openthread.io/reference/config/group/config-srp-client#group__config-srp-client_1ga5ddbc7a04f6c9ce119824f24fb30af89 0` | Define to 1 to enable SRP Client support. |
| `https://openthread.io/reference/config/group/config-srp-client#group__config-srp-client_1gacde4e3548a9e91c7772566313fdfa03c 120` | Specifies the guard interval (in seconds) for lease renew time. |
| `https://openthread.io/reference/config/group/config-srp-client#group__config-srp-client_1gaa816d9e4744b562370f001e221d34364 (1 * 60 * 60 * 1000)` | Specifies the maximum wait interval (in msec) between SRP update message retries. |
| `https://openthread.io/reference/config/group/config-srp-client#group__config-srp-client_1ga16fe13343c599e9011431e5a39278f0a 3` | Specifies number of timeout failures to trigger a switch of server. |
| `https://openthread.io/reference/config/group/config-srp-client#group__config-srp-client_1ga24d63f047a7b720ad567e244552a7d06 1800` | Specifies the minimum wait interval (in msec) between SRP update message retries. |
| `https://openthread.io/reference/config/group/config-srp-client#group__config-srp-client_1gac51afa241c93e3adaa118752981d3559 10` | Specifies the denominator of the retry wait interval growth factor fraction. |
| `https://openthread.io/reference/config/group/config-srp-client#group__config-srp-client_1ga9935d5ace65a0734c7c5c11a7ceec867 17` | Specifies the numerator of the retry wait interval growth factor fraction. |
| `https://openthread.io/reference/config/group/config-srp-client#group__config-srp-client_1ga984bfc0417147d40daf1535041fc2135 500` | Specifies jitter (in msec) for retry wait interval. |
| `https://openthread.io/reference/config/group/config-srp-client#group__config-srp-client_1ga8a00dee529877a50090656ffa5dd92d4 1` | Define to 1 to enable SRP client feature to save the selected server in non-volatile settings. |
| `https://openthread.io/reference/config/group/config-srp-client#group__config-srp-client_1ga7b92497cdce23bd326d2f65f7b3b6050 1` | Define to 1 to enable SRP client to switch server on failure (when auto-start feature is used). |

## Macros

### OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE

```
 OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE 1
```
Define to 1 to enable SRP Client auto-start feature and its APIs.

When enabled, the SRP client can be configured to automatically start when it detects the presence of an SRP server (by monitoring the Thread Network Data for SRP Server Service entries).

### OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_DEFAULT_MODE

```
 OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_DEFAULT_MODE 1
```
Define the default mode (enabled or disabled) of auto-start mode.

This config is applicable only when `OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE` is enabled.

### OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_ENABLE

```
 OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_ENABLE OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE
```
Define to 1 to enable SRP Client buffers and service pool feature.

### OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_HOST_NAME_SIZE

```
 OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_HOST_NAME_SIZE 64
```
Specifies the size (number of chars) of host name string buffer in the SRP client buffers and service pool.

This config is applicable only when `OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_ENABLE` is enabled.

### OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_MAX_HOST_ADDRESSES

```
 OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_MAX_HOST_ADDRESSES 2
```
Specifies number of host IPv6 address entries in the SRP client buffers and service pool.

This config is applicable only when `OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_ENABLE` is enabled.

### OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_MAX_SERVICES

```
 OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_MAX_SERVICES 2
```
Specifies number of service entries in the SRP client service pool.

This config is applicable only when `OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_ENABLE` is enabled.

### OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_SERVICE_INSTANCE_NAME_SIZE

```
 OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_SERVICE_INSTANCE_NAME_SIZE 64
```
Specifies the size (number of chars) of service instance name string buffer in the SRP client buffers and service pool.

This config is applicable only when `OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_ENABLE` is enabled.

### OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_SERVICE_MAX_SUB_TYPES

```
 OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_SERVICE_MAX_SUB_TYPES 6
```
Specifies the maximum number of service subtype labels (array length) in the SRP client buffers and service pool.

This config is applicable only when `OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_ENABLE` is enabled.

### OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_SERVICE_NAME_SIZE

```
 OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_SERVICE_NAME_SIZE 96
```
Specifies the size (number of chars) of service name string buffer in the SRP client buffers and service pool.

This config is applicable only when `OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_ENABLE` is enabled.

### OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_TXT_BUFFER_SIZE

```
 OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_TXT_BUFFER_SIZE 64
```
Specifies the size (number of bytes) of TXT record value buffer in the SRP client buffers and service pool.

This config is applicable only when `OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_ENABLE` is enabled.

### OPENTHREAD_CONFIG_SRP_CLIENT_COUNTERS_ENABLE

```
 OPENTHREAD_CONFIG_SRP_CLIENT_COUNTERS_ENABLE (OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE && OPENTHREAD_CONFIG_UPTIME_ENABLE)
```
Define to 1 to enable SRP Client counters APIs (`otSrpClientGetCounters` and `otSrpClientResetCounters`).

Defaults to enabled when both `OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE` and `OPENTHREAD_CONFIG_UPTIME_ENABLE` are enabled, and disabled otherwise. Requires `OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE` and `OPENTHREAD_CONFIG_UPTIME_ENABLE`.

### OPENTHREAD_CONFIG_SRP_CLIENT_DEFAULT_KEY_LEASE

```
 OPENTHREAD_CONFIG_SRP_CLIENT_DEFAULT_KEY_LEASE (14 * 24 * 60 * 60)
```
Specifies the default requested key lease interval (in seconds).

Set to 14 days.

### OPENTHREAD_CONFIG_SRP_CLIENT_DEFAULT_LEASE

```
 OPENTHREAD_CONFIG_SRP_CLIENT_DEFAULT_LEASE (2 * 60 * 60)
```
Specifies the default requested lease interval (in seconds).

Set to two hours.

### OPENTHREAD_CONFIG_SRP_CLIENT_DISALLOW_SERVER_SWITCH_WITH_REGISTERED_HOST

```
 OPENTHREAD_CONFIG_SRP_CLIENT_DISALLOW_SERVER_SWITCH_WITH_REGISTERED_HOST 1
```
Define to 1 to disallow SRP client to switch server (when auto-start is used) on failure if host (or any services) were previously successfully registered with the currently selected server.

This config is only applicable when `OPENTHREAD_CONFIG_SRP_CLIENT_SWITCH_SERVER_ON_FAILURE` is enabled.

If this is enabled, once SRP client successfully registers with an auto-start selected SRP server, it stays with the selected SRP server (even if future SRP updates fail or timeout) while the related server entry remains present in the Thread Network Data. If the entry is removed from Network Data, then SRP client will try to select a new server.

Enabling this behavior would be useful allowing more aggressive switch logic (e.g., switch after fewer timeouts `OPENTHREAD_CONFIG_SRP_CLIENT_MAX_TIMEOUT_FAILURES_TO_SWITCH_SERVER`) while not allowing switch due to temporary failures on the currently selected server. This can help avoid situation where the old server may still remember the registered host/service info and client switching to a new server then failing due to name conflict (when new server probes for the host/service name original server would not allow new registration).

### OPENTHREAD_CONFIG_SRP_CLIENT_DOMAIN_NAME_API_ENABLE

```
 OPENTHREAD_CONFIG_SRP_CLIENT_DOMAIN_NAME_API_ENABLE 0
```
Define to 1 for the SRP client implementation to provide APIs that get/set the domain name.

### OPENTHREAD_CONFIG_SRP_CLIENT_EARLY_LEASE_RENEW_FACTOR_DENOMINATOR

```
 OPENTHREAD_CONFIG_SRP_CLIENT_EARLY_LEASE_RENEW_FACTOR_DENOMINATOR 2
```
Specifies the denominator of early lease renewal factor.

Please see OPENTHREAD_CONFIG_SRP_CLIENT_EARLY_LEASE_RENEW_FACTOR_NUMERATOR for more details.

### OPENTHREAD_CONFIG_SRP_CLIENT_EARLY_LEASE_RENEW_FACTOR_NUMERATOR

```
 OPENTHREAD_CONFIG_SRP_CLIENT_EARLY_LEASE_RENEW_FACTOR_NUMERATOR 1
```
Specifies the numerator of early lease renewal factor.

This value is used for opportunistic early refresh behave. When sending an SRP update, the services that are not yet expired but are close, are allowed to refresh early and are included in the SRP update.

The "early lease renewal interval" is used to determine if a service can renew early. The interval is calculated by multiplying the accepted lease interval by the "early lease renewal factor" which is given as a fraction (numerator and denominator).

If the factor is set to zero (numerator=0, denominator=1), the opportunistic early refresh behavior is disabled. If denominator is set to zero (the factor is set to infinity), then all services (including previously registered ones) are always included in SRP update message.

Default value is 1/2 (i.e., services that are within half of the lease interval are allowed to refresh early).

### OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE

```
 OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE 0
```
Define to 1 to enable SRP Client support.

### OPENTHREAD_CONFIG_SRP_CLIENT_LEASE_RENEW_GUARD_INTERVAL

```
 OPENTHREAD_CONFIG_SRP_CLIENT_LEASE_RENEW_GUARD_INTERVAL 120
```
Specifies the guard interval (in seconds) for lease renew time.

The guard interval determines how much earlier (relative to the lease expiration time) the SRP client will send an SRP update for lease renewal.

### OPENTHREAD_CONFIG_SRP_CLIENT_MAX_RETRY_WAIT_INTERVAL

```
 OPENTHREAD_CONFIG_SRP_CLIENT_MAX_RETRY_WAIT_INTERVAL (1 * 60 * 60 * 1000)
```
Specifies the maximum wait interval (in msec) between SRP update message retries.

### OPENTHREAD_CONFIG_SRP_CLIENT_MAX_TIMEOUT_FAILURES_TO_SWITCH_SERVER

```
 OPENTHREAD_CONFIG_SRP_CLIENT_MAX_TIMEOUT_FAILURES_TO_SWITCH_SERVER 3
```
Specifies number of timeout failures to trigger a switch of server.

This is applicable only when `OPENTHREAD_CONFIG_SRP_CLIENT_SWITCH_SERVER_ON_FAILURE` is used.

### OPENTHREAD_CONFIG_SRP_CLIENT_MIN_RETRY_WAIT_INTERVAL

```
 OPENTHREAD_CONFIG_SRP_CLIENT_MIN_RETRY_WAIT_INTERVAL 1800
```
Specifies the minimum wait interval (in msec) between SRP update message retries.

The update message is retransmitted if there is no response from server or if server rejects the update. The wait interval starts from the minimum value and is increased by the growth factor every failure up to the max value.

### OPENTHREAD_CONFIG_SRP_CLIENT_RETRY_INTERVAL_GROWTH_FACTOR_DENOMINATOR

```
 OPENTHREAD_CONFIG_SRP_CLIENT_RETRY_INTERVAL_GROWTH_FACTOR_DENOMINATOR 10
```
Specifies the denominator of the retry wait interval growth factor fraction.

### OPENTHREAD_CONFIG_SRP_CLIENT_RETRY_INTERVAL_GROWTH_FACTOR_NUMERATOR

```
 OPENTHREAD_CONFIG_SRP_CLIENT_RETRY_INTERVAL_GROWTH_FACTOR_NUMERATOR 17
```
Specifies the numerator of the retry wait interval growth factor fraction.

The growth factor is represented as a fraction (e.g., for 1.5, we can use 15 as the numerator and 10 as the denominator).

### OPENTHREAD_CONFIG_SRP_CLIENT_RETRY_WAIT_INTERVAL_JITTER

```
 OPENTHREAD_CONFIG_SRP_CLIENT_RETRY_WAIT_INTERVAL_JITTER 500
```
Specifies jitter (in msec) for retry wait interval.

If the current retry wait interval is smaller than the jitter then the wait interval itself is used as jitter (e.g., with jitter 500 msec and if retry interval is 300ms the retry interval is then randomly selected from \[0, 2\*300\] ms).

### OPENTHREAD_CONFIG_SRP_CLIENT_SAVE_SELECTED_SERVER_ENABLE

```
 OPENTHREAD_CONFIG_SRP_CLIENT_SAVE_SELECTED_SERVER_ENABLE 1
```
Define to 1 to enable SRP client feature to save the selected server in non-volatile settings.

When enabled, the SRP client will save the selected server info by auto-start feature in the non-volatile settings and on a client restart (e.g., due to a device reset) it will select the same server when searching to discover and pick one from the Thread Network Data service entries. The server info is saved only after the host info is successfully registered with the server and if it is selected by auto-start from a network data SRP *unicast* service entry.

### OPENTHREAD_CONFIG_SRP_CLIENT_SWITCH_SERVER_ON_FAILURE

```
 OPENTHREAD_CONFIG_SRP_CLIENT_SWITCH_SERVER_ON_FAILURE 1
```
Define to 1 to enable SRP client to switch server on failure (when auto-start feature is used).

This config is only used when `OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE` is enabled.

When enabled, the client will try to select the next server from entries in Thread Network Data when the current server rejects an SRP update or there is no response (timeout waiting for response from server).

## Resources

OpenThread API Reference topics originate from the source code, available
on [GitHub](https://github.com/openthread/openthread/tree/main/include/openthread).
For more information, or to contribute to our documentation, refer to
[Resources](https://openthread.io/resources).