-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
Copy pathInetConfig.h
298 lines (273 loc) · 9.14 KB
/
InetConfig.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
/*
*
* Copyright (c) 2020 Project CHIP Authors
* Copyright (c) 2013-2018 Nest Labs, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file
* This file defines default compile-time configuration constants
* for the CHIP InetLayer, an Internet Protocol communications
* abstraction layer.
*
* Package integrators that wish to override these values should
* either use preprocessor definitions or create a project-
* specific InetProjectConfig.h header and then assert
* HAVE_INETPROJECTCONFIG_H via the package configuration tool
* via --with-chip-inet-project-includes=DIR where DIR is the
* directory that contains the header.
*
* NOTE WELL: On some platforms, this header is included by C-language programs.
*
*/
#pragma once
#if CHIP_HAVE_CONFIG_H
#include <inet/InetBuildConfig.h>
#endif
/*--- Include configuration headers ---*/
#include <system/SystemConfig.h>
/*
* If the CHIP_SYSTEM_CONFIG_TRANSFER_INETLAYER_PROJECT_CONFIGURATION option is not applicable, then the "InetProjectConfig.h"
* header was not included by <system/SystemConfig.h> and therefore it must be included here.
*/
#if !CHIP_SYSTEM_CONFIG_TRANSFER_INETLAYER_PROJECT_CONFIGURATION
/* Include a project-specific configuration file, if defined.
*
* An application or module that incorporates chip can define a project configuration
* file to override standard Inet Layer configuration with application-specific values.
* The project config file is typically located outside the Openchip source tree,
* alongside the source code for the application.
*/
#ifdef INET_PROJECT_CONFIG_INCLUDE
#include INET_PROJECT_CONFIG_INCLUDE
#endif // INET_PROJECT_CONFIG_INCLUDE
#endif // !CHIP_SYSTEM_CONFIG_TRANSFER_INETLAYER_PROJECT_CONFIGURATION
/* Include a platform-specific configuration file, if defined.
*
* A platform configuration file contains overrides to standard Inet Layer configuration
* that are specific to the platform or OS on which chip is running. It is typically
* provided as apart of an adaptation layer that adapts Openchip to the target
* environment. This adaptation layer may be included in the Openchip source tree
* itself or implemented externally.
*/
#ifdef INET_PLATFORM_CONFIG_INCLUDE
#include INET_PLATFORM_CONFIG_INCLUDE
#endif
// clang-format off
/**
* @def INET_CONFIG_MAX_IP_AND_UDP_HEADER_SIZE
*
* @brief
* The maximum space required for IPv6 and UDP headers.
* Useful when ensuring a chip message will not exceed a UDP MTU.
*
*/
#ifndef INET_CONFIG_MAX_IP_AND_UDP_HEADER_SIZE
#define INET_CONFIG_MAX_IP_AND_UDP_HEADER_SIZE (40 + 8)
#endif // INET_CONFIG_MAX_IP_AND_UDP_HEADER_SIZE
/**
* @def INET_CONFIG_NUM_TCP_ENDPOINTS
*
* @brief
* This is the total number of TCP end point context structures.
*
* Up to this many outstanding TCP communication flows may be in
* use.
*
*/
#ifndef INET_CONFIG_NUM_TCP_ENDPOINTS
#define INET_CONFIG_NUM_TCP_ENDPOINTS 64
#endif // INET_CONFIG_NUM_TCP_ENDPOINTS
/**
* @def INET_CONFIG_NUM_UDP_ENDPOINTS
*
* @brief
* This is the total number of UDP end point context structures.
*
* Up to this many outstanding UDP communication flows may be in
* use.
*
*/
#ifndef INET_CONFIG_NUM_UDP_ENDPOINTS
#define INET_CONFIG_NUM_UDP_ENDPOINTS 64
#endif // INET_CONFIG_NUM_UDP_ENDPOINTS
/**
* @def INET_TCP_IDLE_CHECK_INTERVAL
*
* @brief
* This is the interval, in milliseconds, at which checks are made
* to detect idle TCP connections.
*
*/
#ifndef INET_TCP_IDLE_CHECK_INTERVAL
#define INET_TCP_IDLE_CHECK_INTERVAL 100
#endif // INET_TCP_IDLE_CHECK_INTERVAL
/**
* @def INET_CONFIG_ENABLE_TCP_ENDPOINT
*
* @brief
* Defines whether (1) or not (0) to enable the ability
* to instantiate a TCP endpoint.
*
*/
#ifndef INET_CONFIG_ENABLE_TCP_ENDPOINT
#define INET_CONFIG_ENABLE_TCP_ENDPOINT 0
#endif // INET_CONFIG_ENABLE_TCP_ENDPOINT
/**
* @def INET_CONFIG_ENABLE_UDP_ENDPOINT
*
* @brief
* Defines whether (1) or not (0) to enable the ability
* to instantiate a UDP endpoint.
*
*/
#ifndef INET_CONFIG_ENABLE_UDP_ENDPOINT
#define INET_CONFIG_ENABLE_UDP_ENDPOINT 0
#endif // INET_CONFIG_ENABLE_UDP_ENDPOINT
/**
* @def INET_CONFIG_TEST
*
* @brief
* Defines whether (1) or not (0) to enable testing aids
*/
#ifndef INET_CONFIG_TEST
#define INET_CONFIG_TEST 0
#endif
/**
* @def INET_CONFIG_OVERRIDE_SYSTEM_TCP_USER_TIMEOUT
*
* @brief
* When this flag is set, the InetLayer implements
* a mechanism that simulates the TCP_USER_TIMEOUT
* socket option for Linux sockets.
*
* @details
* The TCP_USER_TIMEOUT option specifies the maximum
* amount of time in milliseconds that transmitted
* data may remain unacknowledged before TCP will
* forcibly close the corresponding connection.
* See RFC 5482, for further details.
*
* This flag is set to override the usage of the system
* defined TCP_USER_TIMEOUT socket option for Linux.
* The reason for having this overriding feature
* was to overcome some limitations of the system
* socket option wherein the TCP_USER_TIMEOUT was
* not taking effect when
* 1) The IP address of the interface of the TCP
* connection was removed.
* 2) The interface of the TCP connection was
* brought down.
*
*/
#ifndef INET_CONFIG_OVERRIDE_SYSTEM_TCP_USER_TIMEOUT
#define INET_CONFIG_OVERRIDE_SYSTEM_TCP_USER_TIMEOUT 1
#endif // INET_CONFIG_OVERRIDE_SYSTEM_TCP_USER_TIMEOUT
/**
* @def INET_CONFIG_TCP_SEND_QUEUE_POLL_INTERVAL_MSEC
*
* @brief
* The default polling interval to check the progress
* on the TCP SendQueue to determine if sent data is
* being acknowledged.
*
* @details
* If progress is being made, then the TCP UserTimeout
* period would be shifted further ahead by resetting
* the max poll count. If, however, progress is not made,
* then the next timer would still fire at the next poll
* interval without resetting the poll count. The
* connection would be torn down when the poll count
* reaches zero.
*/
#ifndef INET_CONFIG_TCP_SEND_QUEUE_POLL_INTERVAL_MSEC
#define INET_CONFIG_TCP_SEND_QUEUE_POLL_INTERVAL_MSEC 500
#endif // INET_CONFIG_TCP_SEND_QUEUE_POLL_INTERVAL_MSEC
/**
* @def INET_CONFIG_DEFAULT_TCP_USER_TIMEOUT_MSEC
*
* @brief
* The default value of the TCP_USER_TIMEOUT in
* milliseconds. Set to equivalent of 5 minutes.
*
*
* @details
* This value specifies the maximum amount of
* time in milliseconds that transmitted data may remain
* unacknowledged before TCP will forcibly close the
* corresponding connection.
* See RFC 5482, for further details.
*/
#ifndef INET_CONFIG_DEFAULT_TCP_USER_TIMEOUT_MSEC
#define INET_CONFIG_DEFAULT_TCP_USER_TIMEOUT_MSEC (5 * 60 * 1000)
#endif // INET_CONFIG_DEFAULT_TCP_USER_TIMEOUT_MSEC
/**
* @def INET_CONFIG_IP_MULTICAST_HOP_LIMIT
*
* @brief
* The default value of the Hop Limit field in
* the IP multicast packet.
*
*
* @details
* This value specifies the hop limit that could be set in the
* outgoing IP packet to override any default settings(made by
* the kernel) for the hop limit field in the IP header.
* On Linux platforms, the hoplimit field is set to 1 for
* multicast packets.
*/
#ifndef INET_CONFIG_IP_MULTICAST_HOP_LIMIT
#define INET_CONFIG_IP_MULTICAST_HOP_LIMIT (64)
#endif // INET_CONFIG_IP_MULTICAST_HOP_LIMIT
/**
* @def INET_CONFIG_UDP_SOCKET_PKTINFO
*
* @brief
* Use IP_PKTINFO and IPV6_PKTINFO control messages to specify the network
* interface and the source address of a sent UDP packet.
*
* @details
* When this flag is set, the socket-based implementation of UDP endpoints
* requires that IP_PKTINFO and IPV6_PKTINFO be supported. Otherwise, it is
* left to the operating system to select the network interface and the
* source address.
*/
#ifndef INET_CONFIG_UDP_SOCKET_PKTINFO
#ifndef __ZEPHYR__
#define INET_CONFIG_UDP_SOCKET_PKTINFO 1
#else
#define INET_CONFIG_UDP_SOCKET_PKTINFO 0
#endif
#endif // INET_CONFIG_UDP_SOCKET_PKTINFO
/**
* @def HAVE_SO_BINDTODEVICE
*
* @brief
* Should be set to 1 if the SO_BINDTODEVICE option to setsockopt is
* available.
*/
#ifndef HAVE_SO_BINDTODEVICE
#define HAVE_SO_BINDTODEVICE 0
#endif
/**
* @def INET_CONFIG_UDP_SOCKET_MREQN
*
* @brief
* Should be set to 1 if your platform can handle struct ip_mreqn,
* mandatory in UDPEndPointSocket.cpp
*/
#ifndef INET_CONFIG_UDP_SOCKET_MREQN
#define INET_CONFIG_UDP_SOCKET_MREQN 0
#endif
// clang-format on