Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / lwip / standalone / lwipopts.h
1 /*
2  *
3  *    Copyright (c) 2020 Project CHIP Authors
4  *    Copyright (c) 2019 Google LLC.
5  *    Copyright (c) 2014-2018 Nest Labs, Inc.
6  *    All rights reserved.
7  *
8  *    Licensed under the Apache License, Version 2.0 (the "License");
9  *    you may not use this file except in compliance with the License.
10  *    You may obtain a copy of the License at
11  *
12  *        http://www.apache.org/licenses/LICENSE-2.0
13  *
14  *    Unless required by applicable law or agreed to in writing, software
15  *    distributed under the License is distributed on an "AS IS" BASIS,
16  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  *    See the License for the specific language governing permissions and
18  *    limitations under the License.
19  */
20
21 /**
22  *    @file
23  *      This file describes compile-time constants for configuring LwIP
24  *      for use in standalone (desktop) environments.
25  *
26  */
27
28 #ifndef __LWIPOPTS_H__
29 #define __LWIPOPTS_H__
30
31 #if CHIP_HAVE_CONFIG_H
32 #include <lwip/lwip_buildconfig.h>
33 #endif
34
35 #include <stdlib.h>
36
37 /**
38  * NO_SYS==1: Provides VERY minimal functionality. Otherwise,
39  * use lwIP facilities.
40  */
41 #define NO_SYS 0
42
43 /**
44  * MEM_ALIGNMENT: should be set to the alignment of the CPU
45  *    4 byte alignment -> #define MEM_ALIGNMENT 4
46  *    2 byte alignment -> #define MEM_ALIGNMENT 2
47  */
48 #define MEM_ALIGNMENT (4)
49
50 /**
51  * MEM_SIZE: specify bigger memory size to pass LwIP-internal unit tests
52  * (only needed when building tests)
53  */
54 #ifdef CHIP_WITH_TESTS
55 #define MEM_SIZE (16000)
56 #endif
57
58 /**
59  * Use Malloc from LibC - saves code space
60  */
61 #define MEM_LIBC_MALLOC (0)
62
63 /**
64  * Do not use memory pools to create fixed, statically allocated pools of
65  * memory in lieu of the Standard C Library heap and APIs.
66  */
67 #define MEM_USE_POOLS (0)
68
69 /**
70  * Do not use custom memory pools for specific, named LwIP objects, sourced
71  * from lwippools.h.
72  */
73 #define MEM_USE_CUSTOM_POOLS (MEM_USE_POOLS)
74
75 /**
76  * MEMP_NUM_NETBUF: the number of struct netbufs.
77  * (only needed if you use the sequential API, like api_lib.c)
78  */
79 #define MEMP_NUM_NETBUF (PBUF_POOL_SIZE)
80
81 /**
82  * MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments.
83  * (requires the LWIP_TCP option)
84  */
85 #define MEMP_NUM_TCP_SEG (TCP_SND_QUEUELEN + 1)
86
87 /**
88  * PBUF_POOL_SIZE: the number of buffers in the pbuf pool.
89  *
90  * This is just a default designed to be overriden by the FreeRTOS.mk makefile
91  * To perform this override, define the makefile variable LWIP_NUM_PACKET_BUFFERS_IN_POOL
92  */
93 #ifndef PBUF_POOL_SIZE
94 #define PBUF_POOL_SIZE (10)
95 #endif
96
97 /*
98  * IP_REASS_MAX_PBUFS: Total maximum amount of pbufs waiting to be reassembled.
99  * Since the received pbufs are enqueued, be sure to configure
100  * PBUF_POOL_SIZE > IP_REASS_MAX_PBUFS so that the stack is still able to receive
101  * packets even if the maximum amount of fragments is enqueued for reassembly!
102  *
103  */
104 #if PBUF_POOL_SIZE > 2
105 #ifndef IP_REASS_MAX_PBUFS
106 #define IP_REASS_MAX_PBUFS (PBUF_POOL_SIZE - 2)
107 #endif
108 #else
109 #define IP_REASS_MAX_PBUFS 0
110 #define IP_REASSEMBLY 0
111 #endif
112
113 /**
114  * MEMP_NUM_REASSDATA: the number of IP packets simultaneously queued for
115  * reassembly (whole packets, not fragments!)
116  */
117 #if IP_REASS_MAX_PBUFS > 1
118 #ifndef MEMP_NUM_REASSDATA
119 #define MEMP_NUM_REASSDATA (IP_REASS_MAX_PBUFS - 1)
120 #endif
121 #else
122 #define MEMP_NUM_REASSDATA 0
123 #endif
124
125 #define PAYLOAD_MTU (1500)
126
127 /**
128  * TCP_MSS: TCP Maximum segment size. (default is 536, a conservative default,
129  * you might want to increase this.)
130  * For the receive side, this MSS is advertised to the remote side
131  * when opening a connection. For the transmit size, this MSS sets
132  * an upper limit on the MSS advertised by the remote host.
133  */
134 #define TCP_MSS (1152)
135
136 /**
137  * PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. The default is
138  * designed to accomodate single full size link-layer frame in one pbuf, including
139  * the link-layer header and any link-layer encapsulation header, and the pbuf
140  * structure itself.
141  */
142
143 #define PBUF_POOL_BUFSIZE                                                                                                          \
144     LWIP_MEM_ALIGN_SIZE(PAYLOAD_MTU + PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN) + LWIP_MEM_ALIGN_SIZE(sizeof(struct pbuf) + 1)
145
146 /**
147  * TCP_SND_BUF: TCP sender buffer space (bytes).
148  * must be at least as much as (2 * TCP_MSS) for things to work smoothly
149  */
150 #define TCP_SND_BUF (6 * TCP_MSS)
151
152 /**
153  * ETH_PAD_SIZE: the header space required preceeding the of each pbuf in the pbuf pool. The default is
154  * designed to accomodate single full size TCP frame in one pbuf, including
155  * TCP_MSS, IP header, and link header.
156  *
157  * This is zero since the role has been taken over by SUB_ETHERNET_HEADER_SPACE as ETH_PAD_SIZE was not always obeyed
158  */
159 #define ETH_PAD_SIZE (0)
160
161 /**
162  * LWIP_NETIF_TX_SINGLE_PBUF: if this is set to 1, lwIP tries to put all data
163  * to be sent into one single pbuf. This is for compatibility with DMA-enabled
164  * MACs that do not support scatter-gather.
165  * Beware that this might involve CPU-memcpy before transmitting that would not
166  * be needed without this flag! Use this only if you need to!
167  *
168  * @todo: TCP and IP-frag do not work with this, yet:
169  */
170 #define LWIP_NETIF_TX_SINGLE_PBUF (0)
171
172 /** Define LWIP_COMPAT_MUTEX if the port has no mutexes and binary semaphores
173  *  should be used instead
174  */
175 #define LWIP_COMPAT_MUTEX (1)
176
177 /** Define LWIP_COMPAT_MUTEX_ALLOWED if the platform concurrency model has no
178  * support for avoiding priority inversion deadlocks
179  */
180 #define LWIP_COMPAT_MUTEX_ALLOWED (1)
181
182 /**
183  * SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain
184  * critical regions during buffer allocation, deallocation and memory
185  * allocation and deallocation.
186  */
187 #define SYS_LIGHTWEIGHT_PROT (0)
188
189 /**
190  * TCPIP_THREAD_STACKSIZE: The stack size used by the main tcpip thread.
191  * The stack size value itself is platform-dependent, but is passed to
192  * sys_thread_new() when the thread is created.
193  */
194 #define TCPIP_THREAD_STACKSIZE (1300)
195
196 /**
197  * TCPIP_THREAD_PRIO: The priority assigned to the main tcpip thread.
198  * The priority value itself is platform-dependent, but is passed to
199  * sys_thread_new() when the thread is created.
200  */
201 #define TCPIP_THREAD_PRIO (7)
202
203 #define TCP_LISTEN_BACKLOG (1)
204
205 /**
206  * LWIP_DHCP==1: Enable DHCP module.
207  */
208 #define LWIP_DHCP (1)
209
210 /**
211  * Enable automatic IPv4 link-local address assignment.
212  */
213 #define LWIP_AUTOIP 1
214
215 /**
216  * Allow DHCP and automatic IPv4 link-local address assignment to
217  * work cooperatively.
218  */
219 #define LWIP_DHCP_AUTOIP_COOP 1
220
221 /**
222  * LWIP_PROVIDE_ERRNO: errno definitions from the Standard C Library.
223  */
224 #undef LWIP_PROVIDE_ERRNO
225
226 /**
227  * ERRNO: set errno on interface invocation failures
228  */
229 #define ERRNO (1)
230
231 /**
232  * MEMP_NUM_RAW_PCB: Number of raw connection PCBs
233  * (requires the LWIP_RAW option)
234  */
235 #ifndef MEMP_NUM_RAW_PCB
236 #define MEMP_NUM_RAW_PCB (5)
237 #endif
238
239 /**
240  * MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
241  * per active UDP "connection".
242  * (requires the LWIP_UDP option)
243  */
244 #ifndef MEMP_NUM_UDP_PCB
245 #define MEMP_NUM_UDP_PCB (6)
246 #endif
247
248 /**
249  * MEMP_NUM_SYS_TIMEOUT: the number of simulateously active timeouts.
250  * (requires NO_SYS==0)
251  * Must be larger than or equal to LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS +
252  * PPP_SUPPORT Since each InetTimer requires one matching LwIP timeout (if built with LwIP option), the number should be expanded to
253  * be (All LwIP needs) + (max number of InetTimers)
254  */
255 #define MEMP_NUM_SYS_TIMEOUT (48)
256
257 /* ARP before DHCP causes multi-second delay  - turn it off */
258 #define DHCP_DOES_ARP_CHECK (0)
259
260 /**
261  * LWIP_HAVE_LOOPIF==1: Support loop interface (127.0.0.1) and loopif.c
262  */
263 #define LWIP_HAVE_LOOPIF (1)
264
265 /**
266  * LWIP_NETIF_LOOPBACK==1: Support sending packets with a destination IP
267  * address equal to the netif IP address, looping them back up the stack.
268  */
269 #define LWIP_NETIF_LOOPBACK (0)
270
271 /**
272  * MEMP_NUM_NETCONN: the number of struct netconns.
273  * (only needed if you use the sequential API, like api_lib.c)
274  */
275 #define MEMP_NUM_NETCONN (8)
276
277 /**
278  * LWIP_SO_RCVTIMEO==1: Enable SO_RCVTIMEO processing.
279  */
280 #define LWIP_SO_RCVTIMEO (1)
281
282 /**
283  * LWIP_IGMP==1: Turn on IGMP module.
284  */
285 #define LWIP_IGMP (1)
286
287 /**
288  * SO_REUSE==1: Enable SO_REUSEADDR option.
289  * Required by IGMP for reuse of multicast address and port by other sockets
290  */
291 #define SO_REUSE (1)
292
293 /**
294  * LWIP_DNS==1: Turn on DNS module. UDP must be available for DNS
295  * transport.
296  */
297 #define LWIP_DNS (1)
298
299 /**
300  * LWIP_POSIX_SOCKETS_IO_NAMES==1: Enable POSIX-style sockets functions names.
301  * Disable this option if you use a POSIX operating system that uses the same
302  * names (read, write & close). (only used if you use sockets.c)
303  *
304  * We disable this because this otherwise collides with the Standard C
305  * Library where both LWIP and its headers are included.
306  */
307 #define LWIP_POSIX_SOCKETS_IO_NAMES (0)
308
309 #ifdef LWIP_SO_RCVBUF
310 #if (LWIP_SO_RCVBUF == 1)
311 #include <limits.h> /* Needed because RECV_BUFSIZE_DEFAULT is defined as INT_MAX */
312 #endif              /* if ( LWIP_SO_RCVBUF == 1 ) */
313 #endif              /* ifdef LWIP_SO_RCVBUF */
314
315 /**
316  * LWIP_STATS : Turn on statistics gathering
317  */
318 #define LWIP_STATS (1)
319
320 /**
321  * LWIP_IPV6==1: Enable IPv6
322  */
323 #ifndef LWIP_IPV6
324 #define LWIP_IPV6 1
325 #endif
326
327 /**
328  * LWIP_IPV6_DHCP6==1: enable DHCPv6 stateful address autoconfiguration.
329  */
330 #ifndef LWIP_IPV6_DHCP6
331 #define LWIP_IPV6_DHCP6 1
332 #endif
333
334 /**
335  * LWIP_IPV6_MLD==1: Enable multicast listener discovery protocol.
336  */
337 #ifndef LWIP_IPV6_MLD
338 #define LWIP_IPV6_MLD 1
339 #endif
340
341 /**
342  * MEMP_NUM_MLD6_GROUP: Maximum number of IPv6 multicast groups that
343  * can be joined. Allocate one (1) for the link local address
344  * solicited node multicast group, one (1) for the any/unspecified
345  * address solicited node multicast group (which seems to be used
346  * for/by DAD in this epoch of LwIP), and another four (4) for
347  * application groups.
348  */
349 #define MEMP_NUM_MLD6_GROUP ((1 + 1) + 4)
350
351 /**
352  * LWIP_IPV6_FORWARD==1: Enable IPv6 forwarding.
353  */
354 #ifndef LWIP_IPV6_FORWARD
355 #define LWIP_IPV6_FORWARD 1
356 #endif
357
358 /**
359  * LWIP_IPV6_ROUTE_TABLE_SUPPORT==1: Enable support for a routing table and refering these during forwarding.
360  */
361 #ifndef LWIP_IPV6_ROUTE_TABLE_SUPPORT
362 #define LWIP_IPV6_ROUTE_TABLE_SUPPORT 1
363 #endif
364
365 /**
366  * IPV6_FRAG_COPYHEADER==1: Enable copying of IPv6 fragment headers on 64-bit platforms.
367  */
368 #ifndef IPV6_FRAG_COPYHEADER
369 #if defined(__x86_64__)
370 #define IPV6_FRAG_COPYHEADER 1
371 #else
372 #define IPV6_FRAG_COPYHEADER 0
373 #endif
374 #endif
375
376 /**
377  * Debug printing
378  * By default enable debug printing for debug build, but set level to off
379  * This allows user to change any desired debug level to on.
380  */
381 #ifdef LWIP_DEBUG
382
383 #define MEMP_OVERFLOW_CHECK (1)
384 #define MEMP_SANITY_CHECK (1)
385
386 #define MEM_DEBUG LWIP_DBG_OFF
387 #define MEMP_DEBUG LWIP_DBG_OFF
388 #define PBUF_DEBUG LWIP_DBG_ON
389 #define API_LIB_DEBUG LWIP_DBG_ON
390 #define API_MSG_DEBUG LWIP_DBG_ON
391 #define TCPIP_DEBUG LWIP_DBG_ON
392 #define NETIF_DEBUG LWIP_DBG_ON
393 #define SOCKETS_DEBUG LWIP_DBG_ON
394 #define DEMO_DEBUG LWIP_DBG_ON
395 #define IP_DEBUG LWIP_DBG_ON
396 #define IP6_DEBUG LWIP_DBG_ON
397 #define IP_REASS_DEBUG LWIP_DBG_ON
398 #define RAW_DEBUG LWIP_DBG_ON
399 #define ICMP_DEBUG LWIP_DBG_ON
400 #define UDP_DEBUG LWIP_DBG_ON
401 #define TCP_DEBUG LWIP_DBG_ON
402 #define TCP_INPUT_DEBUG LWIP_DBG_ON
403 #define TCP_OUTPUT_DEBUG LWIP_DBG_ON
404 #define TCP_RTO_DEBUG LWIP_DBG_ON
405 #define TCP_CWND_DEBUG LWIP_DBG_ON
406 #define TCP_WND_DEBUG LWIP_DBG_ON
407 #define TCP_FR_DEBUG LWIP_DBG_ON
408 #define TCP_QLEN_DEBUG LWIP_DBG_ON
409 #define TCP_RST_DEBUG LWIP_DBG_ON
410 #define PPP_DEBUG LWIP_DBG_OFF
411
412 extern unsigned char gLwIP_DebugFlags;
413 #define LWIP_DBG_TYPES_ON gLwIP_DebugFlags
414
415 #endif
416
417 /**
418  * The WICED definition of PBUF_POOL_BUFSIZE includes a number of
419  * sizeof() instantiations which causes the C preprocessor to
420  * fail. Disable TCP configuration constant sanity checks to work
421  * around this.
422  */
423 #define LWIP_DISABLE_TCP_SANITY_CHECKS (1)
424
425 /**
426  * LwIP defaults the size of most mailboxes (i.e. message queues) to
427  * zero (0). That generally makes RTOSes such as FreeRTOS very
428  * unhappy. Specify reasonable defaults instead.
429  */
430 #define TCPIP_MBOX_SIZE 6
431
432 #define DEFAULT_RAW_RECVMBOX_SIZE 6
433
434 #define DEFAULT_UDP_RECVMBOX_SIZE 6
435
436 #define DEFAULT_TCP_RECVMBOX_SIZE 6
437
438 /*
439    ---------------------------------
440    ---------- RAW options ----------
441    ---------------------------------
442 */
443
444 /**
445  * LWIP_RAW==1: Enable application layer to hook into the IP layer itself.
446  */
447 #define LWIP_RAW 1
448
449 /*
450    ----------------------------------------------
451    ---------- Sequential layer options ----------
452    ----------------------------------------------
453 */
454
455 /**
456  * LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c)
457  */
458 #define LWIP_NETCONN 0
459
460 /*
461    ------------------------------------
462    ---------- Socket options ----------
463    ------------------------------------
464 */
465
466 /**
467  * LWIP_SOCKET==1: Enable Socket API (require to use sockets.c)
468  */
469 #define LWIP_SOCKET 0
470
471 /**
472  * Enable locking in the lwip (tcpip) thread.
473  */
474 #ifndef LWIP_TCPIP_CORE_LOCKING
475 #define LWIP_TCPIP_CORE_LOCKING 1
476 #endif
477
478 /**
479  * Enable support for TCP keepalives.
480  */
481 #ifndef LWIP_TCP_KEEPALIVE
482 #define LWIP_TCP_KEEPALIVE 1
483 #endif
484
485 /** LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS:
486  * Ensure compatibilty with platforms where LwIP is configured not to define the host/network byte-order conversion
487  * functions normally provided in <arpa/inet.h> on POSIX systems.
488  */
489 #ifndef LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS
490 #define LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS 1
491 #endif
492
493 #endif /* __LWIPOPTS_H__ */