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