1 /*
2  *  Copyright (c) 2019, 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 Thread Management Framework service.
32  *
33  */
34 
35 #ifndef CONFIG_TMF_H_
36 #define CONFIG_TMF_H_
37 
38 /**
39  * @addtogroup config-tmf
40  *
41  * @brief
42  *   This module includes configuration variables for the Thread Management
43  *   Framework service.
44  *
45  * @{
46  *
47  */
48 
49 #include "config/border_router.h"
50 
51 /**
52  * @def OPENTHREAD_CONFIG_TMF_ADDRESS_CACHE_ENTRIES
53  *
54  * The number of EID-to-RLOC cache entries.
55  *
56  */
57 #ifndef OPENTHREAD_CONFIG_TMF_ADDRESS_CACHE_ENTRIES
58 #if OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE
59 #define OPENTHREAD_CONFIG_TMF_ADDRESS_CACHE_ENTRIES 256
60 #else
61 #define OPENTHREAD_CONFIG_TMF_ADDRESS_CACHE_ENTRIES 32
62 #endif
63 #endif
64 
65 /**
66  * @def OPENTHREAD_CONFIG_TMF_ADDRESS_CACHE_MAX_SNOOP_ENTRIES
67  *
68  * The maximum number of EID-to-RLOC cache entries that can be used for "snoop optimization" where an entry is created
69  * by inspecting a received message.
70  *
71  * By default a 1/16 fraction of `OPENTHREAD_CONFIG_TMF_ADDRESS_CACHE_ENTRIES` is used.
72  *
73  */
74 #ifndef OPENTHREAD_CONFIG_TMF_ADDRESS_CACHE_MAX_SNOOP_ENTRIES
75 #define OPENTHREAD_CONFIG_TMF_ADDRESS_CACHE_MAX_SNOOP_ENTRIES (OPENTHREAD_CONFIG_TMF_ADDRESS_CACHE_ENTRIES / 16)
76 #endif
77 
78 /**
79  * @def OPENTHREAD_CONFIG_TMF_SNOOP_CACHE_ENTRY_TIMEOUT
80  *
81  * The timeout value (in seconds) blocking eviction of an address cache entry created through snoop optimization (i.e.,
82  * inspection of a received message). After the timeout expires the entry can be reclaimed again. This timeout allows
83  * a longer response delay for a received message giving more chance that a snooped entry will be used (avoiding
84  * sending Address Query when a response message is sent to same destination from which the message was received
85  * earlier).
86  *
87  */
88 #ifndef OPENTHREAD_CONFIG_TMF_SNOOP_CACHE_ENTRY_TIMEOUT
89 #define OPENTHREAD_CONFIG_TMF_SNOOP_CACHE_ENTRY_TIMEOUT 3
90 #endif
91 
92 /**
93  * @def OPENTHREAD_CONFIG_TMF_ADDRESS_QUERY_TIMEOUT
94  *
95  * The timeout value (in seconds) waiting for a address notification response after sending an address query.
96  *
97  * Default: 3 seconds
98  *
99  */
100 #ifndef OPENTHREAD_CONFIG_TMF_ADDRESS_QUERY_TIMEOUT
101 #define OPENTHREAD_CONFIG_TMF_ADDRESS_QUERY_TIMEOUT 3
102 #endif
103 
104 /**
105  * @def OPENTHREAD_CONFIG_TMF_ADDRESS_QUERY_INITIAL_RETRY_DELAY
106  *
107  * Initial retry delay for address query (in seconds).
108  *
109  * Default: 15 seconds
110  *
111  */
112 #ifndef OPENTHREAD_CONFIG_TMF_ADDRESS_QUERY_INITIAL_RETRY_DELAY
113 #define OPENTHREAD_CONFIG_TMF_ADDRESS_QUERY_INITIAL_RETRY_DELAY 15
114 #endif
115 
116 /**
117  * @def OPENTHREAD_CONFIG_TMF_ADDRESS_QUERY_MAX_RETRY_DELAY
118  *
119  * Maximum retry delay for address query (in seconds).
120  *
121  * Default: 120 seconds
122  *
123  */
124 #ifndef OPENTHREAD_CONFIG_TMF_ADDRESS_QUERY_MAX_RETRY_DELAY
125 #define OPENTHREAD_CONFIG_TMF_ADDRESS_QUERY_MAX_RETRY_DELAY 120
126 #endif
127 
128 /**
129  * @def OPENTHREAD_CONFIG_TMF_ALLOW_ADDRESS_RESOLUTION_USING_NET_DATA_SERVICES
130  *
131  * Define as 1 to allow address resolution of on-mesh addresses using Thread Network Data DNS/SRP Service entries.
132  *
133  */
134 #ifndef OPENTHREAD_CONFIG_TMF_ALLOW_ADDRESS_RESOLUTION_USING_NET_DATA_SERVICES
135 #define OPENTHREAD_CONFIG_TMF_ALLOW_ADDRESS_RESOLUTION_USING_NET_DATA_SERVICES 1
136 #endif
137 
138 /**
139  * @def OPENTHREAD_CONFIG_TMF_PENDING_DATASET_MINIMUM_DELAY
140  *
141  * Minimum Delay Timer value for a Pending Operational Dataset (in ms).
142  *
143  * Thread specification defines this value as 30,000 ms. Changing from the specified value should be done for testing
144  * only.
145  *
146  */
147 #ifndef OPENTHREAD_CONFIG_TMF_PENDING_DATASET_MINIMUM_DELAY
148 #define OPENTHREAD_CONFIG_TMF_PENDING_DATASET_MINIMUM_DELAY 30000
149 #endif
150 
151 /**
152  * @def OPENTHREAD_CONFIG_TMF_PENDING_DATASET_DEFAULT_DELAY
153  *
154  * Default Delay Timer value for a Pending Operational Dataset (in ms).
155  *
156  * Thread specification defines this value as 300,000 ms. Changing from the specified value should be done for testing
157  * only.
158  *
159  */
160 #ifndef OPENTHREAD_CONFIG_TMF_PENDING_DATASET_DEFAULT_DELAY
161 #define OPENTHREAD_CONFIG_TMF_PENDING_DATASET_DEFAULT_DELAY 300000
162 #endif
163 
164 /**
165  * @def OPENTHREAD_CONFIG_TMF_ENERGY_SCAN_MAX_RESULTS
166  *
167  * The maximum number of Energy List entries.
168  *
169  */
170 #ifndef OPENTHREAD_CONFIG_TMF_ENERGY_SCAN_MAX_RESULTS
171 #define OPENTHREAD_CONFIG_TMF_ENERGY_SCAN_MAX_RESULTS 64
172 #endif
173 
174 /**
175  * @def OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE
176  *
177  * Define to 1 to support injecting Service entries into the Thread Network Data.
178  *
179  */
180 #ifndef OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE
181 #define OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE 0
182 #endif
183 
184 /**
185  * @def OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_MAX_ALOCS
186  *
187  * The maximum number of supported Service ALOCs registrations for this device.
188  *
189  */
190 #ifndef OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_MAX_ALOCS
191 #define OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_MAX_ALOCS 1
192 #endif
193 
194 /**
195  * @def OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE
196  *
197  * Define to 1 to enable TMF network diagnostics client.
198  *
199  * The network diagnostic client add API to send diagnostic requests and queries to other node and process the response.
200  * It is enabled by default on Border Routers.
201  *
202  */
203 #ifndef OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE
204 #define OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
205 #endif
206 
207 /**
208  * @def OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_ENABLE
209  *
210  * Define to 1 to enable TMF anycast locator functionality.
211  *
212  * This feature allows a device to determine the mesh local EID and RLOC16 of the closest destination of an anycast
213  * address (if any) through sending `TMF_ANYCAST_LOCATE` requests.
214  *
215  */
216 #ifndef OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_ENABLE
217 #define OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_ENABLE 0
218 #endif
219 
220 /**
221  * @def OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_SEND_RESPONSE
222  *
223  * Define to 1 to require the device to listen and respond to `TMF_ANYCAST_LOCATE` requests.
224  *
225  * This config is used only when `OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_ENABLE` is enabled. It is enabled by default.
226  *
227  */
228 #ifndef OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_SEND_RESPONSE
229 #define OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_SEND_RESPONSE 1
230 #endif
231 
232 /**
233  * @def OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE
234  *
235  * Define to 1 for Thread 1.2 FTD device to register DUA of its MTD children registered
236  * even if it doesn't enable DUA feature itself.
237  *
238  */
239 #ifndef OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE
240 #define OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
241 #endif
242 
243 #if OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE && OPENTHREAD_CONFIG_THREAD_VERSION < OT_THREAD_VERSION_1_2
244 #error "Thread 1.2 or higher version is required for OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE"
245 #endif
246 
247 /**
248  * @def OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE
249  *
250  * This setting configures the Multicast Listener Registration parent proxying in Thread 1.2.
251  *
252  */
253 #ifndef OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE
254 #define OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
255 #endif
256 
257 #if OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE && OPENTHREAD_CONFIG_THREAD_VERSION < OT_THREAD_VERSION_1_2
258 #error "Thread 1.2 or higher version is required for OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE"
259 #endif
260 
261 /**
262  * @}
263  *
264  */
265 
266 #endif // CONFIG_TMF_H_
267