3 * Copyright (c) 2020 Project CHIP Authors
4 * Copyright (c) 2019 Google LLC.
5 * Copyright (c) 2014-2018 Nest Labs, Inc.
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 * This file describes compile-time constants for configuring LwIP
24 * for use in standalone (desktop) environments.
28 #ifndef __LWIPOPTS_H__
29 #define __LWIPOPTS_H__
31 #if CHIP_HAVE_CONFIG_H
32 #include <lwip/lwip_buildconfig.h>
38 * NO_SYS==1: Provides VERY minimal functionality. Otherwise,
39 * use lwIP facilities.
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
48 #define MEM_ALIGNMENT (4)
51 * MEM_SIZE: specify bigger memory size to pass LwIP-internal unit tests
52 * (only needed when building tests)
54 #ifdef CHIP_WITH_TESTS
55 #define MEM_SIZE (16000)
59 * Use Malloc from LibC - saves code space
61 #define MEM_LIBC_MALLOC (0)
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.
67 #define MEM_USE_POOLS (0)
70 * Do not use custom memory pools for specific, named LwIP objects, sourced
73 #define MEM_USE_CUSTOM_POOLS (MEM_USE_POOLS)
76 * MEMP_NUM_NETBUF: the number of struct netbufs.
77 * (only needed if you use the sequential API, like api_lib.c)
79 #define MEMP_NUM_NETBUF (PBUF_POOL_SIZE)
82 * MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments.
83 * (requires the LWIP_TCP option)
85 #define MEMP_NUM_TCP_SEG (TCP_SND_QUEUELEN + 1)
88 * PBUF_POOL_SIZE: the number of buffers in the pbuf pool.
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
93 #ifndef PBUF_POOL_SIZE
94 #define PBUF_POOL_SIZE (10)
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!
104 #if PBUF_POOL_SIZE > 2
105 #ifndef IP_REASS_MAX_PBUFS
106 #define IP_REASS_MAX_PBUFS (PBUF_POOL_SIZE - 2)
109 #define IP_REASS_MAX_PBUFS 0
110 #define IP_REASSEMBLY 0
114 * MEMP_NUM_REASSDATA: the number of IP packets simultaneously queued for
115 * reassembly (whole packets, not fragments!)
117 #if IP_REASS_MAX_PBUFS > 1
118 #ifndef MEMP_NUM_REASSDATA
119 #define MEMP_NUM_REASSDATA (IP_REASS_MAX_PBUFS - 1)
122 #define MEMP_NUM_REASSDATA 0
125 #define PAYLOAD_MTU (1500)
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.
134 #define TCP_MSS (1152)
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
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)
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
150 #define TCP_SND_BUF (6 * TCP_MSS)
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.
157 * This is zero since the role has been taken over by SUB_ETHERNET_HEADER_SPACE as ETH_PAD_SIZE was not always obeyed
159 #define ETH_PAD_SIZE (0)
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!
168 * @todo: TCP and IP-frag do not work with this, yet:
170 #define LWIP_NETIF_TX_SINGLE_PBUF (0)
172 /** Define LWIP_COMPAT_MUTEX if the port has no mutexes and binary semaphores
173 * should be used instead
175 #define LWIP_COMPAT_MUTEX (1)
177 /** Define LWIP_COMPAT_MUTEX_ALLOWED if the platform concurrency model has no
178 * support for avoiding priority inversion deadlocks
180 #define LWIP_COMPAT_MUTEX_ALLOWED (1)
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.
187 #define SYS_LIGHTWEIGHT_PROT (0)
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.
194 #define TCPIP_THREAD_STACKSIZE (1300)
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.
201 #define TCPIP_THREAD_PRIO (7)
203 #define TCP_LISTEN_BACKLOG (1)
206 * LWIP_DHCP==1: Enable DHCP module.
208 #define LWIP_DHCP (1)
211 * Enable automatic IPv4 link-local address assignment.
213 #define LWIP_AUTOIP 1
216 * Allow DHCP and automatic IPv4 link-local address assignment to
217 * work cooperatively.
219 #define LWIP_DHCP_AUTOIP_COOP 1
222 * LWIP_PROVIDE_ERRNO: errno definitions from the Standard C Library.
224 #undef LWIP_PROVIDE_ERRNO
227 * ERRNO: set errno on interface invocation failures
232 * MEMP_NUM_RAW_PCB: Number of raw connection PCBs
233 * (requires the LWIP_RAW option)
235 #ifndef MEMP_NUM_RAW_PCB
236 #define MEMP_NUM_RAW_PCB (5)
240 * MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
241 * per active UDP "connection".
242 * (requires the LWIP_UDP option)
244 #ifndef MEMP_NUM_UDP_PCB
245 #define MEMP_NUM_UDP_PCB (6)
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)
255 #define MEMP_NUM_SYS_TIMEOUT (48)
257 /* ARP before DHCP causes multi-second delay - turn it off */
258 #define DHCP_DOES_ARP_CHECK (0)
261 * LWIP_HAVE_LOOPIF==1: Support loop interface (127.0.0.1) and loopif.c
263 #define LWIP_HAVE_LOOPIF (1)
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.
269 #define LWIP_NETIF_LOOPBACK (0)
272 * MEMP_NUM_NETCONN: the number of struct netconns.
273 * (only needed if you use the sequential API, like api_lib.c)
275 #define MEMP_NUM_NETCONN (8)
278 * LWIP_SO_RCVTIMEO==1: Enable SO_RCVTIMEO processing.
280 #define LWIP_SO_RCVTIMEO (1)
283 * LWIP_IGMP==1: Turn on IGMP module.
285 #define LWIP_IGMP (1)
288 * SO_REUSE==1: Enable SO_REUSEADDR option.
289 * Required by IGMP for reuse of multicast address and port by other sockets
294 * LWIP_DNS==1: Turn on DNS module. UDP must be available for DNS
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)
304 * We disable this because this otherwise collides with the Standard C
305 * Library where both LWIP and its headers are included.
307 #define LWIP_POSIX_SOCKETS_IO_NAMES (0)
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 */
316 * LWIP_STATS : Turn on statistics gathering
318 #define LWIP_STATS (1)
321 * LWIP_IPV6==1: Enable IPv6
328 * LWIP_IPV6_DHCP6==1: enable DHCPv6 stateful address autoconfiguration.
330 #ifndef LWIP_IPV6_DHCP6
331 #define LWIP_IPV6_DHCP6 1
335 * LWIP_IPV6_MLD==1: Enable multicast listener discovery protocol.
337 #ifndef LWIP_IPV6_MLD
338 #define LWIP_IPV6_MLD 1
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.
349 #define MEMP_NUM_MLD6_GROUP ((1 + 1) + 4)
352 * LWIP_IPV6_FORWARD==1: Enable IPv6 forwarding.
354 #ifndef LWIP_IPV6_FORWARD
355 #define LWIP_IPV6_FORWARD 1
359 * LWIP_IPV6_ROUTE_TABLE_SUPPORT==1: Enable support for a routing table and refering these during forwarding.
361 #ifndef LWIP_IPV6_ROUTE_TABLE_SUPPORT
362 #define LWIP_IPV6_ROUTE_TABLE_SUPPORT 1
366 * IPV6_FRAG_COPYHEADER==1: Enable copying of IPv6 fragment headers on 64-bit platforms.
368 #ifndef IPV6_FRAG_COPYHEADER
369 #if defined(__x86_64__)
370 #define IPV6_FRAG_COPYHEADER 1
372 #define IPV6_FRAG_COPYHEADER 0
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.
383 #define MEMP_OVERFLOW_CHECK (1)
384 #define MEMP_SANITY_CHECK (1)
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
412 extern unsigned char gLwIP_DebugFlags;
413 #define LWIP_DBG_TYPES_ON gLwIP_DebugFlags
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
423 #define LWIP_DISABLE_TCP_SANITY_CHECKS (1)
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.
430 #define TCPIP_MBOX_SIZE 6
432 #define DEFAULT_RAW_RECVMBOX_SIZE 6
434 #define DEFAULT_UDP_RECVMBOX_SIZE 6
436 #define DEFAULT_TCP_RECVMBOX_SIZE 6
439 ---------------------------------
440 ---------- RAW options ----------
441 ---------------------------------
445 * LWIP_RAW==1: Enable application layer to hook into the IP layer itself.
450 ----------------------------------------------
451 ---------- Sequential layer options ----------
452 ----------------------------------------------
456 * LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c)
458 #define LWIP_NETCONN 0
461 ------------------------------------
462 ---------- Socket options ----------
463 ------------------------------------
467 * LWIP_SOCKET==1: Enable Socket API (require to use sockets.c)
469 #define LWIP_SOCKET 0
472 * Enable locking in the lwip (tcpip) thread.
474 #ifndef LWIP_TCPIP_CORE_LOCKING
475 #define LWIP_TCPIP_CORE_LOCKING 1
479 * Enable support for TCP keepalives.
481 #ifndef LWIP_TCP_KEEPALIVE
482 #define LWIP_TCP_KEEPALIVE 1
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.
489 #ifndef LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS
490 #define LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS 1
493 #endif /* __LWIPOPTS_H__ */