3 * Copyright (c) 2020 Project CHIP Authors
4 * Copyright (c) 2013-2018 Nest Labs, Inc.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
21 * This file defines default compile-time configuration constants
22 * for the CHIP InetLayer, an Internet Protocol communications
25 * Package integrators that wish to override these values should
26 * either use preprocessor definitions or create a project-
27 * specific InetProjectConfig.h header and then assert
28 * HAVE_INETPROJECTCONFIG_H via the package configuration tool
29 * via --with-chip-inet-project-includes=DIR where DIR is the
30 * directory that contains the header.
32 * NOTE WELL: On some platforms, this header is included by C-language programs.
38 #if CHIP_HAVE_CONFIG_H
39 #include <inet/InetBuildConfig.h>
42 /*--- Include configuration headers ---*/
43 #include <system/SystemConfig.h>
46 * If the CHIP_SYSTEM_CONFIG_TRANSFER_INETLAYER_PROJECT_CONFIGURATION option is not applicable, then the "InetProjectConfig.h"
47 * header was not included by <SystemLayer/SystemConfig.h> and therefore it must be included here.
49 #if !CHIP_SYSTEM_CONFIG_TRANSFER_INETLAYER_PROJECT_CONFIGURATION
51 /* Include a project-specific configuration file, if defined.
53 * An application or module that incorporates chip can define a project configuration
54 * file to override standard Inet Layer configuration with application-specific values.
55 * The project config file is typically located outside the Openchip source tree,
56 * alongside the source code for the application.
58 #ifdef INET_PROJECT_CONFIG_INCLUDE
59 #include INET_PROJECT_CONFIG_INCLUDE
60 #endif // INET_PROJECT_CONFIG_INCLUDE
62 #endif // !CHIP_SYSTEM_CONFIG_TRANSFER_INETLAYER_PROJECT_CONFIGURATION
64 /* Include a platform-specific configuration file, if defined.
66 * A platform configuration file contains overrides to standard Inet Layer configuration
67 * that are specific to the platform or OS on which chip is running. It is typically
68 * provided as apart of an adaptation layer that adapts Openchip to the target
69 * environment. This adaptation layer may be included in the Openchip source tree
70 * itself or implemented externally.
72 #ifdef INET_PLATFORM_CONFIG_INCLUDE
73 #include INET_PLATFORM_CONFIG_INCLUDE
79 * @def INET_CONFIG_MAX_IP_AND_UDP_HEADER_SIZE
82 * The maximum space required for IPv6 and UDP headers.
83 * Useful when ensuring a chip message will not exceed a UDP MTU.
86 #ifndef INET_CONFIG_MAX_IP_AND_UDP_HEADER_SIZE
87 #define INET_CONFIG_MAX_IP_AND_UDP_HEADER_SIZE (40 + 8)
88 #endif // INET_CONFIG_MAX_IP_AND_UDP_HEADER_SIZE
91 * @def INET_CONFIG_ERROR_TYPE
94 * This defines the data type used to represent errors for the
95 * InetLayer subsystem.
98 * By default, this parameter is a copy of CHIP_SYSTEM_CONFIG_ERROR_TYPE.
101 #ifndef INET_CONFIG_ERROR_TYPE
102 #define INET_CONFIG_ERROR_TYPE CHIP_SYSTEM_CONFIG_ERROR_TYPE
103 #endif // !defined(INET_CONFIG_ERROR_TYPE)
106 * @def INET_CONFIG_NO_ERROR
109 * This defines the InetLayer error code for no error or success.
112 * By default, this parameter is a copy of CHIP_SYSTEM_CONFIG_NO_ERROR.
115 #ifndef INET_CONFIG_NO_ERROR
116 #define INET_CONFIG_NO_ERROR CHIP_SYSTEM_CONFIG_NO_ERROR
117 #endif // !defined(INET_CONFIG_NO_ERROR)
120 * @def INET_CONFIG_ERROR_MIN
123 * This defines the base or minimum InetLayer error number range.
126 #ifndef INET_CONFIG_ERROR_MIN
127 #define INET_CONFIG_ERROR_MIN 1000
128 #endif // INET_CONFIG_ERROR_MIN
131 * @def INET_CONFIG_ERROR_MAX
134 * This defines the top or maximum InetLayer error number range.
137 #ifndef INET_CONFIG_ERROR_MAX
138 #define INET_CONFIG_ERROR_MAX 1999
139 #endif // INET_CONFIG_ERROR_MAX
142 * @def _INET_CONFIG_ERROR
145 * This defines a mapping function for InetLayer errors that allows
146 * mapping such errors into a platform- or system-specific range.
149 #ifndef _INET_CONFIG_ERROR
150 #define _INET_CONFIG_ERROR(e) (INET_ERROR_MIN + (e))
151 #endif // _INET_CONFIG_ERROR
154 * @def INET_CONFIG_WILL_OVERRIDE_OS_ERROR_FUNCS
157 * This defines whether (1) or not (0) your platform will override
158 * the platform- and system-specific INET_MapOSError,
159 * INET_DescribeOSError, and INET_IsOSError functions.
162 #ifndef INET_CONFIG_WILL_OVERRIDE_OS_ERROR_FUNCS
163 #define INET_CONFIG_WILL_OVERRIDE_OS_ERROR_FUNCS 0
164 #endif // INET_CONFIG_WILL_OVERRIDE_OS_ERROR_FUNCS
167 * @def INET_CONFIG_WILL_OVERRIDE_LWIP_ERROR_FUNCS
170 * This defines whether (1) or not (0) your platform will override
171 * the platform- and system-specific INET_MapLwIPError,
172 * INET_DescribeLwIPError, and INET_IsLwIPError functions.
175 #ifndef INET_CONFIG_WILL_OVERRIDE_LWIP_ERROR_FUNCS
176 #define INET_CONFIG_WILL_OVERRIDE_LWIP_ERROR_FUNCS 0
177 #endif // INET_CONFIG_WILL_OVERRIDE_LWIP_ERROR_FUNCS
180 * @def INET_CONFIG_WILL_OVERRIDE_PLATFORM_XTOR_FUNCS
183 * This defines whether (1) or not (0) your platform will override
184 * the platform- and system-specific InetLayer WillInit, DidInit,
185 * WillShutdown, and DidShutdown.
188 #ifndef INET_CONFIG_WILL_OVERRIDE_PLATFORM_XTOR_FUNCS
189 #define INET_CONFIG_WILL_OVERRIDE_PLATFORM_XTOR_FUNCS 0
190 #endif // INET_CONFIG_WILL_OVERRIDE_PLATFORM_XTOR_FUNCS
193 * @def INET_CONFIG_MAX_DROPPABLE_EVENTS
196 * This is the maximum number of UDP or raw network transport
197 * packet events / messages that may be dropped due to packet
200 * In some implementations, there may be a shared event / message
201 * queue for the InetLayer used by other system events / messages.
203 * If the length of that queue is considerably longer than the
204 * number of packet buffers available, it may lead to buffer
205 * exhaustion. As a result, using the queue itself to implement
206 * backpressure is insufficient, and we need an external mechanism
207 * to prevent buffer starvation in the rest of the system and
208 * getting into deadlock situations.
210 * For both UDP and raw network transport traffic we can easily
211 * drop incoming packets without impacting the correctness of
212 * higher level protocols.
215 #ifndef INET_CONFIG_MAX_DROPPABLE_EVENTS
216 #define INET_CONFIG_MAX_DROPPABLE_EVENTS 0
217 #endif // INET_CONFIG_MAX_DROPPABLE_EVENTS
220 * @def INET_CONFIG_NUM_RAW_ENDPOINTS
223 * This is the total number of "raw" (direct-IP, non-TCP/-UDP) end
224 * point context structures.
226 * Up to this many outstanding "raw" communication flows may be in
230 #ifndef INET_CONFIG_NUM_RAW_ENDPOINTS
231 #define INET_CONFIG_NUM_RAW_ENDPOINTS 8
232 #endif // INET_CONFIG_NUM_RAW_ENDPOINTS
235 * @def INET_CONFIG_NUM_TCP_ENDPOINTS
238 * This is the total number of TCP end point context structures.
240 * Up to this many outstanding TCP communication flows may be in
244 #ifndef INET_CONFIG_NUM_TCP_ENDPOINTS
245 #define INET_CONFIG_NUM_TCP_ENDPOINTS 64
246 #endif // INET_CONFIG_NUM_TCP_ENDPOINTS
249 * @def INET_CONFIG_NUM_UDP_ENDPOINTS
252 * This is the total number of UDP end point context structures.
254 * Up to this many outstanding UDP communication flows may be in
258 #ifndef INET_CONFIG_NUM_UDP_ENDPOINTS
259 #define INET_CONFIG_NUM_UDP_ENDPOINTS 64
260 #endif // INET_CONFIG_NUM_UDP_ENDPOINTS
263 * @def INET_CONFIG_NUM_DNS_RESOLVERS
266 * This is the total number of outstanding DNS resolution request
269 * Up to this many DNS resolution requests may be in in use.
272 #ifndef INET_CONFIG_NUM_DNS_RESOLVERS
273 #define INET_CONFIG_NUM_DNS_RESOLVERS 4
274 #endif // INET_CONFIG_NUM_DNS_RESOLVERS
277 * @def INET_CONFIG_MAX_DNS_ADDRS
280 * This is the maximum allowable number of addresses that may
281 * be returned in a single DNS hostname lookup.
284 #ifndef INET_CONFIG_MAX_DNS_ADDRS
285 #define INET_CONFIG_MAX_DNS_ADDRS 16
286 #endif // INET_CONFIG_MAX_DNS_ADDRS
289 * @def INET_TCP_IDLE_CHECK_INTERVAL
292 * This is the interval, in milliseconds, at which checks are made
293 * to detect idle TCP connections.
296 #ifndef INET_TCP_IDLE_CHECK_INTERVAL
297 #define INET_TCP_IDLE_CHECK_INTERVAL 100
298 #endif // INET_TCP_IDLE_CHECK_INTERVAL
301 * @def INET_CONFIG_ENABLE_DNS_RESOLVER
304 * Defines whether (1) or not (0) to enable the ability
305 * to instantiate the DNS resolver.
308 #ifndef INET_CONFIG_ENABLE_DNS_RESOLVER
309 #define INET_CONFIG_ENABLE_DNS_RESOLVER 0
310 #endif // INET_CONFIG_ENABLE_DNS_RESOLVER
313 * @def INET_CONFIG_ENABLE_RAW_ENDPOINT
316 * Defines whether (1) or not (0) to enable the ability
317 * to instantiate a Raw endpoint.
320 #ifndef INET_CONFIG_ENABLE_RAW_ENDPOINT
321 #define INET_CONFIG_ENABLE_RAW_ENDPOINT 0
322 #endif // INET_CONFIG_ENABLE_RAW_ENDPOINT
325 * @def INET_CONFIG_ENABLE_TCP_ENDPOINT
328 * Defines whether (1) or not (0) to enable the ability
329 * to instantiate a TCP endpoint.
332 #ifndef INET_CONFIG_ENABLE_TCP_ENDPOINT
333 #define INET_CONFIG_ENABLE_TCP_ENDPOINT 0
334 #endif // INET_CONFIG_ENABLE_TCP_ENDPOINT
337 * @def INET_CONFIG_ENABLE_UDP_ENDPOINT
340 * Defines whether (1) or not (0) to enable the ability
341 * to instantiate a UDP endpoint.
344 #ifndef INET_CONFIG_ENABLE_UDP_ENDPOINT
345 #define INET_CONFIG_ENABLE_UDP_ENDPOINT 0
346 #endif // INET_CONFIG_ENABLE_UDP_ENDPOINT
349 * @def INET_CONFIG_EVENT_RESERVED
352 * This defines the first number in the default chip System Layer event code space reserved for use by the Inet Layer.
353 * Event codes used by each layer must not overlap.
355 #ifndef INET_CONFIG_EVENT_RESERVED
356 #define INET_CONFIG_EVENT_RESERVED 1000
357 #endif /* INET_CONFIG_EVENT_RESERVED */
360 * @def _INET_CONFIG_EVENT
363 * This defines a mapping function for InetLayer event types that allows
364 * mapping such event types into a platform- or system-specific range.
367 * By default, this definition is a copy of _CHIP_SYSTEM_CONFIG_LWIP_EVENT.
370 #ifndef _INET_CONFIG_EVENT
371 #define _INET_CONFIG_EVENT(e) _CHIP_SYSTEM_CONFIG_LWIP_EVENT(INET_CONFIG_EVENT_RESERVED + (e))
372 #endif // _INET_CONFIG_EVENT
375 * @def INET_CONFIG_TEST
378 * Defines whether (1) or not (0) to enable testing aids
380 #ifndef INET_CONFIG_TEST
381 #define INET_CONFIG_TEST 0
385 * @def INET_CONFIG_ENABLE_ASYNC_DNS_SOCKETS
387 * @brief Enable asynchronous dns name resolution for Linux sockets.
389 #ifndef INET_CONFIG_ENABLE_ASYNC_DNS_SOCKETS
390 #define INET_CONFIG_ENABLE_ASYNC_DNS_SOCKETS 1
391 #endif // INET_CONFIG_ENABLE_ASYNC_DNS_SOCKETS
394 * @def INET_CONFIG_DNS_ASYNC_MAX_THREAD_COUNT
396 * @brief The maximum number of POSIX threads that would be performing
397 * asynchronous DNS resolution.
399 #ifndef INET_CONFIG_DNS_ASYNC_MAX_THREAD_COUNT
400 #define INET_CONFIG_DNS_ASYNC_MAX_THREAD_COUNT 2
401 #endif // INET_CONFIG_DNS_ASYNC_MAX_THREAD_COUNT
404 * @def INET_CONFIG_OVERRIDE_SYSTEM_TCP_USER_TIMEOUT
407 * When this flag is set, the InetLayer implements
408 * a mechanism that simulates the TCP_USER_TIMEOUT
409 * socket option for Linux sockets.
412 * The TCP_USER_TIMEOUT option specifies the maximum
413 * amount of time in milliseconds that transmitted
414 * data may remain unacknowledged before TCP will
415 * forcibly close the corresponding connection.
416 * See RFC 5482, for further details.
418 * This flag is set to override the usage of the system
419 * defined TCP_USER_TIMEOUT socket option for Linux.
420 * The reason for having this overriding feature
421 * was to overcome some limitations of the system
422 * socket option wherein the TCP_USER_TIMEOUT was
423 * not taking effect when
424 * 1) The IP address of the interface of the TCP
425 * connection was removed.
426 * 2) The interface of the TCP connection was
430 #ifndef INET_CONFIG_OVERRIDE_SYSTEM_TCP_USER_TIMEOUT
431 #define INET_CONFIG_OVERRIDE_SYSTEM_TCP_USER_TIMEOUT 1
432 #endif // INET_CONFIG_OVERRIDE_SYSTEM_TCP_USER_TIMEOUT
435 * @def INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS
438 * When this flag is set, the InetLayer enables
439 * callbacks to the upper layer notifying it when
440 * the send channel of the TCP connection changes
441 * between being idle or not idle.
444 * When enabled, the TCP send queue is actively
445 * polled to determine if sent data has been
449 #ifndef INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS
450 #define INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS 0
451 #endif // INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS
454 * @def INET_CONFIG_TCP_SEND_QUEUE_POLL_INTERVAL_MSEC
457 * The default polling interval to check the progress
458 * on the TCP SendQueue to determine if sent data is
459 * being acknowledged.
462 * If progress is being made, then the TCP UserTimeout
463 * period would be shifted further ahead by resetting
464 * the max poll count. If, however, progress is not made,
465 * then the next timer would still fire at the next poll
466 * interval without resetting the poll count. The
467 * connection would be torn down when the poll count
470 #ifndef INET_CONFIG_TCP_SEND_QUEUE_POLL_INTERVAL_MSEC
471 #define INET_CONFIG_TCP_SEND_QUEUE_POLL_INTERVAL_MSEC 500
472 #endif // INET_CONFIG_TCP_SEND_QUEUE_POLL_INTERVAL_MSEC
475 * @def INET_CONFIG_DEFAULT_TCP_USER_TIMEOUT_MSEC
478 * The default value of the TCP_USER_TIMEOUT in
479 * milliseconds. Set to equivalent of 5 minutes.
483 * This value specifies the maximum amount of
484 * time in milliseconds that transmitted data may remain
485 * unacknowledged before TCP will forcibly close the
486 * corresponding connection.
487 * See RFC 5482, for further details.
489 #ifndef INET_CONFIG_DEFAULT_TCP_USER_TIMEOUT_MSEC
490 #define INET_CONFIG_DEFAULT_TCP_USER_TIMEOUT_MSEC (5 * 60 * 1000)
491 #endif // INET_CONFIG_DEFAULT_TCP_USER_TIMEOUT_MSEC
494 * @def INET_CONFIG_IP_MULTICAST_HOP_LIMIT
497 * The default value of the Hop Limit field in
498 * the IP multicast packet.
502 * This value specifies the hop limit that could be set in the
503 * outgoing IP packet to override any default settings(made by
504 * the kernel) for the hop limit field in the IP header.
505 * On Linux platforms, the hoplimit field is set to 1 for
508 #ifndef INET_CONFIG_IP_MULTICAST_HOP_LIMIT
509 #define INET_CONFIG_IP_MULTICAST_HOP_LIMIT (64)
510 #endif // INET_CONFIG_IP_MULTICAST_HOP_LIMIT