• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2020, The OpenThread Authors.
3  *  All rights reserved.
4  *
5  *  Redistribution and use in source and binary forms, with or without
6  *  modification, are permitted provided that the following conditions are met:
7  *  1. Redistributions of source code must retain the above copyright
8  *     notice, this list of conditions and the following disclaimer.
9  *  2. Redistributions in binary form must reproduce the above copyright
10  *     notice, this list of conditions and the following disclaimer in the
11  *     documentation and/or other materials provided with the distribution.
12  *  3. Neither the name of the copyright holder nor the
13  *     names of its contributors may be used to endorse or promote products
14  *     derived from this software without specific prior written permission.
15  *
16  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  *  POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 /**
30  * @file
31  *   This file includes compile-time configurations for the SRP (Service Registration Protocol) Client.
32  */
33 
34 #ifndef CONFIG_SRP_CLIENT_H_
35 #define CONFIG_SRP_CLIENT_H_
36 
37 /**
38  * @addtogroup config-srp-client
39  *
40  * @brief
41  *   This module includes configuration variables for the SRP Client.
42  *
43  * @{
44  */
45 
46 #include "config/misc.h"
47 
48 /**
49  * @def OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE
50  *
51  * Define to 1 to enable SRP Client support.
52  */
53 #ifndef OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE
54 #define OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE 0
55 #endif
56 
57 /**
58  * @def OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE
59  *
60  * Define to 1 to enable SRP Client auto-start feature and its APIs.
61  *
62  * When enabled, the SRP client can be configured to automatically start when it detects the presence of an SRP server
63  * (by monitoring the Thread Network Data for SRP Server Service entries).
64  */
65 #ifndef OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE
66 #define OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE 1
67 #endif
68 
69 /**
70  * @def OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_DEFAULT_MODE
71  *
72  * Define the default mode (enabled or disabled) of auto-start mode.
73  *
74  * This config is applicable only when `OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE` is enabled.
75  */
76 #ifndef OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_DEFAULT_MODE
77 #define OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_DEFAULT_MODE 1
78 #endif
79 
80 /**
81  * @def OPENTHREAD_CONFIG_SRP_CLIENT_SWITCH_SERVER_ON_FAILURE
82  *
83  * Define to 1 to enable SRP client to switch server on failure (when auto-start feature is used).
84  *
85  * This config is only used when `OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE` is enabled.
86  *
87  * When enabled, the client will try to select the next server from entries in Thread Network Data when the current
88  * server rejects an SRP update or there is no response (timeout waiting for response from server).
89  */
90 #ifndef OPENTHREAD_CONFIG_SRP_CLIENT_SWITCH_SERVER_ON_FAILURE
91 #define OPENTHREAD_CONFIG_SRP_CLIENT_SWITCH_SERVER_ON_FAILURE 1
92 #endif
93 
94 /**
95  * @def OPENTHREAD_CONFIG_SRP_CLIENT_DISALLOW_SERVER_SWITCH_WITH_REGISTERED_HOST
96  *
97  * Define to 1 to disallow SRP client to switch server (when auto-start is used) on failure if host (or any services)
98  * were previously successfully registered with the currently selected server.
99  *
100  * This config is only applicable when `OPENTHREAD_CONFIG_SRP_CLIENT_SWITCH_SERVER_ON_FAILURE` is enabled.
101  *
102  * If this is enabled, once SRP client successfully registers with an auto-start selected SRP server, it stays with
103  * the selected SRP server (even if future SRP updates fail or timeout) while the related server entry remains present
104  * in the Thread Network Data. If the entry is removed from Network Data, then SRP client will try to select a new
105  * server.
106  *
107  * Enabling this behavior would be useful allowing more aggressive switch logic (e.g., switch after fewer timeouts
108  * `OPENTHREAD_CONFIG_SRP_CLIENT_MAX_TIMEOUT_FAILURES_TO_SWITCH_SERVER`) while not allowing switch due to temporary
109  * failures on the currently selected server. This can help avoid situation where the old server may still remember the
110  * registered host/service info and client switching to a new server then failing due to name conflict (when new server
111  * probes for the host/service name original server would not allow new registration).
112  */
113 #ifndef OPENTHREAD_CONFIG_SRP_CLIENT_DISALLOW_SERVER_SWITCH_WITH_REGISTERED_HOST
114 #define OPENTHREAD_CONFIG_SRP_CLIENT_DISALLOW_SERVER_SWITCH_WITH_REGISTERED_HOST 1
115 #endif
116 
117 /**
118  * @def OPENTHREAD_CONFIG_SRP_CLIENT_MAX_TIMEOUT_FAILURES_TO_SWITCH_SERVER
119  *
120  * Specifies number of timeout failures to trigger a switch of server.
121  *
122  * This is applicable only when `OPENTHREAD_CONFIG_SRP_CLIENT_SWITCH_SERVER_ON_FAILURE` is used.
123  */
124 #ifndef OPENTHREAD_CONFIG_SRP_CLIENT_MAX_TIMEOUT_FAILURES_TO_SWITCH_SERVER
125 #define OPENTHREAD_CONFIG_SRP_CLIENT_MAX_TIMEOUT_FAILURES_TO_SWITCH_SERVER 3
126 #endif
127 
128 /**
129  * @def OPENTHREAD_CONFIG_SRP_CLIENT_DOMAIN_NAME_API_ENABLE
130  *
131  * Define to 1 for the SRP client implementation to provide APIs that get/set the domain name.
132  */
133 #ifndef OPENTHREAD_CONFIG_SRP_CLIENT_DOMAIN_NAME_API_ENABLE
134 #define OPENTHREAD_CONFIG_SRP_CLIENT_DOMAIN_NAME_API_ENABLE 0
135 #endif
136 
137 /**
138  * @def OPENTHREAD_CONFIG_SRP_CLIENT_SAVE_SELECTED_SERVER_ENABLE
139  *
140  * Define to 1 to enable SRP client feature to save the selected server in non-volatile settings.
141  *
142  * When enabled, the SRP client will save the selected server info by auto-start feature in the non-volatile settings
143  * and on a client restart (e.g., due to a device reset) it will select the same server when searching to discover and
144  * pick one from the Thread Network Data service entries. The server info is saved only after the host info is
145  * successfully registered with the server and if it is selected by auto-start from a network data SRP *unicast*
146  * service entry.
147  */
148 #ifndef OPENTHREAD_CONFIG_SRP_CLIENT_SAVE_SELECTED_SERVER_ENABLE
149 #define OPENTHREAD_CONFIG_SRP_CLIENT_SAVE_SELECTED_SERVER_ENABLE 1
150 #endif
151 
152 /**
153  * @def OPENTHREAD_CONFIG_SRP_CLIENT_DEFAULT_LEASE
154  *
155  * Specifies the default requested lease interval (in seconds). Set to two hours.
156  */
157 #ifndef OPENTHREAD_CONFIG_SRP_CLIENT_DEFAULT_LEASE
158 #define OPENTHREAD_CONFIG_SRP_CLIENT_DEFAULT_LEASE (2 * 60 * 60)
159 #endif
160 
161 /**
162  * @def OPENTHREAD_CONFIG_SRP_CLIENT_DEFAULT_KEY_LEASE
163  *
164  * Specifies the default requested key lease interval (in seconds). Set to 14 days.
165  */
166 #ifndef OPENTHREAD_CONFIG_SRP_CLIENT_DEFAULT_KEY_LEASE
167 #define OPENTHREAD_CONFIG_SRP_CLIENT_DEFAULT_KEY_LEASE (14 * 24 * 60 * 60)
168 #endif
169 
170 /**
171  * @def OPENTHREAD_CONFIG_SRP_CLIENT_LEASE_RENEW_GUARD_INTERVAL
172  *
173  * Specifies the guard interval (in seconds) for lease renew time. The guard interval determines how much earlier
174  * (relative to the lease expiration time) the SRP client will send an SRP update for lease renewal.
175  */
176 #ifndef OPENTHREAD_CONFIG_SRP_CLIENT_LEASE_RENEW_GUARD_INTERVAL
177 #define OPENTHREAD_CONFIG_SRP_CLIENT_LEASE_RENEW_GUARD_INTERVAL 120 // two minutes in seconds
178 #endif
179 
180 /**
181  * @def OPENTHREAD_CONFIG_SRP_CLIENT_EARLY_LEASE_RENEW_FACTOR_NUMERATOR
182  *
183  * Specifies the numerator of early lease renewal factor.
184  *
185  * This value is used for opportunistic early refresh behave. When sending an SRP update, the services that are not yet
186  * expired but are close, are allowed to refresh early and are included in the SRP update.
187  *
188  * The "early lease renewal interval" is used to determine if a service can renew early. The interval is calculated by
189  * multiplying the accepted lease interval by the "early lease renewal factor" which is given as a fraction (numerator
190  * and denominator).
191  *
192  * If the factor is set to zero (numerator=0, denominator=1), the opportunistic early refresh behavior is disabled.
193  * If  denominator is set to zero (the factor is set to infinity), then all services (including previously registered
194  * ones) are always included in SRP update message.
195  *
196  * Default value is 1/2 (i.e., services that are within half of the lease interval are allowed to refresh early).
197  */
198 #ifndef OPENTHREAD_CONFIG_SRP_CLIENT_EARLY_LEASE_RENEW_FACTOR_NUMERATOR
199 #define OPENTHREAD_CONFIG_SRP_CLIENT_EARLY_LEASE_RENEW_FACTOR_NUMERATOR 1
200 #endif
201 
202 /**
203  * @def OPENTHREAD_CONFIG_SRP_CLIENT_EARLY_LEASE_RENEW_FACTOR_DENOMINATOR
204  *
205  * Specifies the denominator of early lease renewal factor.
206  *
207  * Please see OPENTHREAD_CONFIG_SRP_CLIENT_EARLY_LEASE_RENEW_FACTOR_NUMERATOR for more details.
208  */
209 #ifndef OPENTHREAD_CONFIG_SRP_CLIENT_EARLY_LEASE_RENEW_FACTOR_DENOMINATOR
210 #define OPENTHREAD_CONFIG_SRP_CLIENT_EARLY_LEASE_RENEW_FACTOR_DENOMINATOR 2
211 #endif
212 
213 /**
214  * @def OPENTHREAD_CONFIG_SRP_CLIENT_MIN_RETRY_WAIT_INTERVAL
215  *
216  * Specifies the minimum wait interval (in msec) between SRP update message retries.
217  *
218  * The update message is retransmitted if there is no response from server or if server rejects the update. The wait
219  * interval starts from the minimum value and is increased by the growth factor every failure up to the max value.
220  */
221 #ifndef OPENTHREAD_CONFIG_SRP_CLIENT_MIN_RETRY_WAIT_INTERVAL
222 #define OPENTHREAD_CONFIG_SRP_CLIENT_MIN_RETRY_WAIT_INTERVAL 1800
223 #endif
224 
225 /**
226  * @def OPENTHREAD_CONFIG_SRP_CLIENT_MAX_RETRY_WAIT_INTERVAL
227  *
228  * Specifies the maximum wait interval (in msec) between SRP update message retries.
229  */
230 #ifndef OPENTHREAD_CONFIG_SRP_CLIENT_MAX_RETRY_WAIT_INTERVAL
231 #define OPENTHREAD_CONFIG_SRP_CLIENT_MAX_RETRY_WAIT_INTERVAL (1 * 60 * 60 * 1000) // 1 hour in ms.
232 #endif
233 
234 /**
235  * @def OPENTHREAD_CONFIG_SRP_CLIENT_RETRY_WAIT_INTERVAL_JITTER
236  *
237  * Specifies jitter (in msec) for retry wait interval. If the current retry wait interval is smaller than the jitter
238  * then the wait interval itself is used as jitter (e.g., with jitter 500 msec and if retry interval is 300ms
239  * the retry interval is then randomly selected from [0, 2*300] ms).
240  */
241 #ifndef OPENTHREAD_CONFIG_SRP_CLIENT_RETRY_WAIT_INTERVAL_JITTER
242 #define OPENTHREAD_CONFIG_SRP_CLIENT_RETRY_WAIT_INTERVAL_JITTER 500
243 #endif
244 
245 /**
246  * @def OPENTHREAD_CONFIG_SRP_CLIENT_RETRY_INTERVAL_GROWTH_FACTOR_NUMERATOR
247  *
248  * Specifies the numerator of the retry wait interval growth factor fraction. The growth factor is represented as
249  * a fraction (e.g., for 1.5, we can use 15 as the numerator and 10 as the denominator).
250  */
251 #ifndef OPENTHREAD_CONFIG_SRP_CLIENT_RETRY_INTERVAL_GROWTH_FACTOR_NUMERATOR
252 #define OPENTHREAD_CONFIG_SRP_CLIENT_RETRY_INTERVAL_GROWTH_FACTOR_NUMERATOR 17
253 #endif
254 
255 /**
256  * @def OPENTHREAD_CONFIG_SRP_CLIENT_RETRY_INTERVAL_GROWTH_FACTOR_DENOMINATOR
257  *
258  * Specifies the denominator of the retry wait interval growth factor fraction.
259  */
260 #ifndef OPENTHREAD_CONFIG_SRP_CLIENT_RETRY_INTERVAL_GROWTH_FACTOR_DENOMINATOR
261 #define OPENTHREAD_CONFIG_SRP_CLIENT_RETRY_INTERVAL_GROWTH_FACTOR_DENOMINATOR 10
262 #endif
263 
264 /**
265  * @def OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_ENABLE
266  *
267  * Define to 1 to enable SRP Client buffers and service pool feature.
268  */
269 #ifndef OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_ENABLE
270 #define OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_ENABLE OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE
271 #endif
272 
273 /**
274  * @def OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_MAX_SERVICES
275  *
276  * Specifies number of service entries in the SRP client service pool.
277  *
278  * This config is applicable only when `OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_ENABLE` is enabled.
279  */
280 #ifndef OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_MAX_SERVICES
281 #define OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_MAX_SERVICES 2
282 #endif
283 
284 /**
285  * @def OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_MAX_HOST_ADDRESSES
286  *
287  * Specifies number of host IPv6 address entries in the SRP client buffers and service pool.
288  *
289  * This config is applicable only when `OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_ENABLE` is enabled.
290  */
291 #ifndef OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_MAX_HOST_ADDRESSES
292 #if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
293 #define OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_MAX_HOST_ADDRESSES 10
294 #else
295 #define OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_MAX_HOST_ADDRESSES 2
296 #endif
297 #endif
298 
299 /**
300  * @def OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_HOST_NAME_SIZE
301  *
302  * Specifies the size (number of chars) of host name string buffer in the SRP client buffers and service pool.
303  *
304  * This config is applicable only when `OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_ENABLE` is enabled.
305  */
306 #ifndef OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_HOST_NAME_SIZE
307 #define OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_HOST_NAME_SIZE 64
308 #endif
309 
310 /**
311  * @def OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_SERVICE_NAME_SIZE
312  *
313  * Specifies the size (number of chars) of service name string buffer in the SRP client buffers and service pool.
314  *
315  * This config is applicable only when `OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_ENABLE` is enabled.
316  */
317 #ifndef OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_SERVICE_NAME_SIZE
318 #define OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_SERVICE_NAME_SIZE 96
319 #endif
320 
321 /**
322  * @def OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_SERVICE_MAX_SUB_TYPES
323  *
324  * Specifies the maximum number of service subtype labels (array length) in the SRP client buffers and service pool.
325  *
326  * This config is applicable only when `OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_ENABLE` is enabled.
327  */
328 #ifndef OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_SERVICE_MAX_SUB_TYPES
329 #define OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_SERVICE_MAX_SUB_TYPES 6
330 #endif
331 
332 /**
333  * @def OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_SERVICE_INSTANCE_NAME_SIZE
334  *
335  * Specifies the size (number of chars) of service instance name string buffer in the SRP client buffers and service
336  * pool.
337  *
338  * This config is applicable only when `OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_ENABLE` is enabled.
339  */
340 #ifndef OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_SERVICE_INSTANCE_NAME_SIZE
341 #define OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_SERVICE_INSTANCE_NAME_SIZE 64
342 #endif
343 
344 /**
345  * @def OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_TXT_BUFFER_SIZE
346  *
347  * Specifies the size (number of bytes) of TXT record value buffer in the SRP client buffers and service pool.
348  *
349  * This config is applicable only when `OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_ENABLE` is enabled.
350  */
351 #ifndef OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_TXT_BUFFER_SIZE
352 #define OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_TXT_BUFFER_SIZE 64
353 #endif
354 
355 /**
356  * @}
357  */
358 
359 #endif // CONFIG_SRP_CLIENT_H_
360