1 /*
2  * SPDX-FileCopyrightText: 2001-2003 Swedish Institute of Computer Science
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  * SPDX-FileContributor: 2015-2021 Espressif Systems (Shanghai) CO LTD
7  */
8 
9 #ifndef __LWIPOPTS_H__
10 #define __LWIPOPTS_H__
11 
12 #include <stdlib.h>
13 #include <unistd.h>
14 #include <sys/fcntl.h>
15 #include <sys/ioctl.h>
16 #include <sys/types.h>
17 #include <sys/select.h>
18 #include "esp_task.h"
19 #include "esp_system.h"
20 #include "sdkconfig.h"
21 #include "netif/dhcp_state.h"
22 #include "sntp/sntp_get_set_time.h"
23 
24 /* Enable all Espressif-only options */
25 
26 /*
27    -----------------------------------------------
28    ---------- Platform specific locking ----------
29    -----------------------------------------------
30 */
31 /**
32  * SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain
33  * critical regions during buffer allocation, deallocation and memory
34  * allocation and deallocation.
35  */
36 #define SYS_LIGHTWEIGHT_PROT        1
37 
38 /**
39  * MEMCPY: override this if you have a faster implementation at hand than the
40  * one included in your C library
41  */
42 #define MEMCPY(dst,src,len)             memcpy(dst,src,len)
43 
44 /**
45  * SMEMCPY: override this with care! Some compilers (e.g. gcc) can inline a
46  * call to memcpy() if the length is known at compile time and is small.
47  */
48 #define SMEMCPY(dst,src,len)            memcpy(dst,src,len)
49 
50 #define LWIP_RAND       esp_random
51 
52 /*
53    ------------------------------------
54    ---------- Memory options ----------
55    ------------------------------------
56 */
57 /**
58  * MEM_LIBC_MALLOC==1: Use malloc/free/realloc provided by your C-library
59  * instead of the lwip internal allocator. Can save code size if you
60  * already use it.
61  */
62 #define MEM_LIBC_MALLOC        1
63 
64 /**
65 * MEMP_MEM_MALLOC==1: Use mem_malloc/mem_free instead of the lwip pool allocator.
66 * Especially useful with MEM_LIBC_MALLOC but handle with care regarding execution
67 * speed and usage from interrupts!
68 */
69 #define MEMP_MEM_MALLOC                 1
70 
71 /**
72  * MEM_ALIGNMENT: should be set to the alignment of the CPU
73  *    4 byte alignment -> #define MEM_ALIGNMENT 4
74  *    2 byte alignment -> #define MEM_ALIGNMENT 2
75  */
76 #define MEM_ALIGNMENT           4
77 
78 /*
79    ------------------------------------------------
80    ---------- Internal Memory Pool Sizes ----------
81    ------------------------------------------------
82 */
83 
84 /**
85  * MEMP_NUM_NETCONN: the number of struct netconns.
86  * (only needed if you use the sequential API, like api_lib.c)
87  */
88 #define MEMP_NUM_NETCONN                CONFIG_LWIP_MAX_SOCKETS
89 
90 /**
91  * MEMP_NUM_RAW_PCB: Number of raw connection PCBs
92  * (requires the LWIP_RAW option)
93  */
94 #define MEMP_NUM_RAW_PCB                CONFIG_LWIP_MAX_RAW_PCBS
95 
96 /**
97  * MEMP_NUM_TCP_PCB: the number of simultaneously active TCP connections.
98  * (requires the LWIP_TCP option)
99  */
100 #define MEMP_NUM_TCP_PCB                CONFIG_LWIP_MAX_ACTIVE_TCP
101 
102 /**
103  * MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP connections.
104  * (requires the LWIP_TCP option)
105  */
106 #define MEMP_NUM_TCP_PCB_LISTEN         CONFIG_LWIP_MAX_LISTENING_TCP
107 
108 /**
109  * MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
110  * per active UDP "connection".
111  * (requires the LWIP_UDP option)
112  */
113 #define MEMP_NUM_UDP_PCB                CONFIG_LWIP_MAX_UDP_PCBS
114 
115 /*
116    --------------------------------
117    ---------- ARP options -------
118    --------------------------------
119 */
120 /**
121  * ARP_QUEUEING==1: Multiple outgoing packets are queued during hardware address
122  * resolution. By default, only the most recent packet is queued per IP address.
123  * This is sufficient for most protocols and mainly reduces TCP connection
124  * startup time. Set this to 1 if you know your application sends more than one
125  * packet in a row to an IP address that is not in the ARP cache.
126  */
127 #define ARP_QUEUEING                    1
128 
129 /*
130    --------------------------------
131    ---------- IP options ----------
132    --------------------------------
133 */
134 /**
135  * IP_REASSEMBLY==1: Reassemble incoming fragmented IP4 packets. Note that
136  * this option does not affect outgoing packet sizes, which can be controlled
137  * via IP_FRAG.
138  */
139 #define IP_REASSEMBLY                   CONFIG_LWIP_IP4_REASSEMBLY
140 
141 /**
142  * LWIP_IPV6_REASS==1: reassemble incoming IP6 packets that fragmented. Note that
143  * this option does not affect outgoing packet sizes, which can be controlled
144  * via LWIP_IPV6_FRAG.
145  */
146 #define LWIP_IPV6_REASS                 CONFIG_LWIP_IP6_REASSEMBLY
147 
148 /**
149  * IP_FRAG==1: Fragment outgoing IP4 packets if their size exceeds MTU. Note
150  * that this option does not affect incoming packet sizes, which can be
151  * controlled via IP_REASSEMBLY.
152  */
153 #define IP_FRAG                         CONFIG_LWIP_IP4_FRAG
154 
155 /**
156  * LWIP_IPV6_FRAG==1: Fragment outgoing IP6 packets if their size exceeds MTU. Note
157  * that this option does not affect incoming packet sizes, which can be
158  * controlled via IP_REASSEMBLY.
159  */
160 #define LWIP_IPV6_FRAG                  CONFIG_LWIP_IP6_FRAG
161 
162 /**
163  * IP_REASS_MAXAGE: Maximum time (in multiples of IP_TMR_INTERVAL - so seconds, normally)
164  * a fragmented IP packet waits for all fragments to arrive. If not all fragments arrived
165  * in this time, the whole packet is discarded.
166  */
167 #define IP_REASS_MAXAGE                 3
168 
169 /**
170  * IP_REASS_MAX_PBUFS: Total maximum amount of pbufs waiting to be reassembled.
171  * Since the received pbufs are enqueued, be sure to configure
172  * PBUF_POOL_SIZE > IP_REASS_MAX_PBUFS so that the stack is still able to receive
173  * packets even if the maximum amount of fragments is enqueued for reassembly!
174  */
175 #define IP_REASS_MAX_PBUFS              10
176 
177 /**
178  * IP_FORWARD==1: Enables the ability to forward IP packets across network
179  * interfaces. If you are going to run lwIP on a device with only one network
180  * interface, define this to 0.
181  */
182 #define IP_FORWARD                      CONFIG_LWIP_IP_FORWARD
183 
184 /**
185  * IP_NAPT==1: Enables IPv4 Network Address and Port Translation.
186  * Note that both CONFIG_LWIP_IP_FORWARD and CONFIG_LWIP_L2_TO_L3_COPY options
187  * need to be enabled in system configuration for the NAPT to work on ESP platform
188  */
189 #define IP_NAPT                         CONFIG_LWIP_IPV4_NAPT
190 
191 /*
192    ----------------------------------
193    ---------- ICMP options ----------
194    ----------------------------------
195 */
196 #define LWIP_ICMP  CONFIG_LWIP_ICMP
197 
198 #define LWIP_BROADCAST_PING CONFIG_LWIP_BROADCAST_PING
199 
200 #define LWIP_MULTICAST_PING CONFIG_LWIP_MULTICAST_PING
201 
202 /*
203    ---------------------------------
204    ---------- RAW options ----------
205    ---------------------------------
206 */
207 /**
208  * LWIP_RAW==1: Enable application layer to hook into the IP layer itself.
209  */
210 #define LWIP_RAW                        1
211 
212 /*
213    ----------------------------------
214    ---------- DHCP options ----------
215    ----------------------------------
216 */
217 /**
218  * LWIP_DHCP==1: Enable DHCP module.
219  */
220 #define LWIP_DHCP                       1
221 
222 #define DHCP_MAXRTX                     0
223 
224 /**
225  * DHCP_DOES_ARP_CHECK==1: Do an ARP check on the offered address.
226  */
227 #define DHCP_DOES_ARP_CHECK             CONFIG_LWIP_DHCP_DOES_ARP_CHECK
228 
229 /**
230  * LWIP_DHCP_DISABLE_CLIENT_ID==1: Do not add option 61 (client-id) to DHCP packets
231  */
232 #define ESP_DHCP_DISABLE_CLIENT_ID      CONFIG_LWIP_DHCP_DISABLE_CLIENT_ID
233 
234 /**
235  * CONFIG_LWIP_DHCP_RESTORE_LAST_IP==1: Last valid IP address obtained from DHCP server
236  * is restored after reset/power-up.
237  */
238 #if CONFIG_LWIP_DHCP_RESTORE_LAST_IP
239 
240 #define LWIP_DHCP_IP_ADDR_RESTORE()     dhcp_ip_addr_restore(netif)
241 #define LWIP_DHCP_IP_ADDR_STORE()       dhcp_ip_addr_store(netif)
242 #define LWIP_DHCP_IP_ADDR_ERASE(esp_netif)       dhcp_ip_addr_erase(esp_netif)
243 
244 #endif
245 
246 /**
247  * CONFIG_LWIP_DHCP_OPTIONS_LEN: The total length of outgoing DHCP option msg. If you have many options
248  * and options value is too long, you can configure the length according to your requirements
249  */
250 #define DHCP_OPTIONS_LEN                CONFIG_LWIP_DHCP_OPTIONS_LEN
251 
252 /**
253  * LWIP_DHCP_DISABLE_VENDOR_CLASS_ID==1: Do not add option 60 (Vendor Class Identifier) to DHCP packets
254  */
255 #define ESP_DHCP_DISABLE_VENDOR_CLASS_IDENTIFIER       CONFIG_LWIP_DHCP_DISABLE_VENDOR_CLASS_ID
256 
257 /*
258    ------------------------------------
259    ---------- AUTOIP options ----------
260    ------------------------------------
261 */
262 #ifdef CONFIG_LWIP_AUTOIP
263 #define LWIP_AUTOIP                     1
264 
265 /**
266 * LWIP_DHCP_AUTOIP_COOP==1: Allow DHCP and AUTOIP to be both enabled on
267 * the same interface at the same time.
268 */
269 #define LWIP_DHCP_AUTOIP_COOP           1
270 
271 /**
272 * LWIP_DHCP_AUTOIP_COOP_TRIES: Set to the number of DHCP DISCOVER probes
273 * that should be sent before falling back on AUTOIP. This can be set
274 * as low as 1 to get an AutoIP address very quickly, but you should
275 * be prepared to handle a changing IP address when DHCP overrides
276 * AutoIP.
277 */
278 #define LWIP_DHCP_AUTOIP_COOP_TRIES     CONFIG_LWIP_AUTOIP_TRIES
279 
280 #define LWIP_AUTOIP_MAX_CONFLICTS CONFIG_LWIP_AUTOIP_MAX_CONFLICTS
281 
282 #define LWIP_AUTOIP_RATE_LIMIT_INTERVAL CONFIG_LWIP_AUTOIP_RATE_LIMIT_INTERVAL
283 
284 #endif /* CONFIG_LWIP_AUTOIP */
285 
286 /*
287    ----------------------------------
288    ---------- SNMP options ----------
289    ----------------------------------
290 */
291 /*
292    ----------------------------------
293    ---------- IGMP options ----------
294    ----------------------------------
295 */
296 /**
297  * LWIP_IGMP==1: Turn on IGMP module.
298  */
299 #define LWIP_IGMP                       1
300 
301 /*
302    ----------------------------------
303    ---------- DNS options -----------
304    ----------------------------------
305 */
306 /**
307  * LWIP_DNS==1: Turn on DNS module. UDP must be available for DNS
308  * transport.
309  */
310 #define LWIP_DNS                        1
311 
312 #define DNS_MAX_SERVERS                 3
313 #define DNS_FALLBACK_SERVER_INDEX        (DNS_MAX_SERVERS - 1)
314 
315 /*
316    ---------------------------------
317    ---------- UDP options ----------
318    ---------------------------------
319 */
320 /*
321    ---------------------------------
322    ---------- TCP options ----------
323    ---------------------------------
324 */
325 
326 
327 /**
328  * TCP_QUEUE_OOSEQ==1: TCP will queue segments that arrive out of order.
329  * Define to 0 if your device is low on memory.
330  */
331 #define TCP_QUEUE_OOSEQ                 CONFIG_LWIP_TCP_QUEUE_OOSEQ
332 
333 /**
334  * LWIP_TCP_SACK_OUT==1: TCP will support sending selective acknowledgements (SACKs).
335  */
336 #define LWIP_TCP_SACK_OUT               CONFIG_LWIP_TCP_SACK_OUT
337 
338 /**
339  * ESP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES==1: Keep TCP connection when IP changed
340  * scenario happens: 192.168.0.2 -> 0.0.0.0 -> 192.168.0.2 or 192.168.0.2 -> 0.0.0.0
341  */
342 
343 #define ESP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES  CONFIG_LWIP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES
344 /*
345  *     LWIP_EVENT_API==1: The user defines lwip_tcp_event() to receive all
346  *         events (accept, sent, etc) that happen in the system.
347  *     LWIP_CALLBACK_API==1: The PCB callback function is called directly
348  *         for the event. This is the default.
349 */
350 #define TCP_MSS                         CONFIG_LWIP_TCP_MSS
351 
352 /**
353  * TCP_TMR_INTERVAL: TCP timer interval
354  */
355 #define TCP_TMR_INTERVAL                CONFIG_LWIP_TCP_TMR_INTERVAL
356 
357 /**
358  * TCP_MSL: The maximum segment lifetime in milliseconds
359  */
360 #define TCP_MSL                         CONFIG_LWIP_TCP_MSL
361 
362 /**
363  * TCP_MAXRTX: Maximum number of retransmissions of data segments.
364  */
365 #define TCP_MAXRTX                      CONFIG_LWIP_TCP_MAXRTX
366 
367 /**
368  * TCP_SYNMAXRTX: Maximum number of retransmissions of SYN segments.
369  */
370 #define TCP_SYNMAXRTX                   CONFIG_LWIP_TCP_SYNMAXRTX
371 
372 /**
373  * TCP_LISTEN_BACKLOG: Enable the backlog option for tcp listen pcb.
374  */
375 #define TCP_LISTEN_BACKLOG              1
376 
377 
378 /**
379  * TCP_OVERSIZE: The maximum number of bytes that tcp_write may
380  * allocate ahead of time
381  */
382 #ifdef CONFIG_LWIP_TCP_OVERSIZE_MSS
383 #define TCP_OVERSIZE                    TCP_MSS
384 #endif
385 #ifdef CONFIG_LWIP_TCP_OVERSIZE_QUARTER_MSS
386 #define TCP_OVERSIZE                    (TCP_MSS/4)
387 #endif
388 #ifdef CONFIG_LWIP_TCP_OVERSIZE_DISABLE
389 #define TCP_OVERSIZE                    0
390 #endif
391 #ifndef TCP_OVERSIZE
392 #error "One of CONFIG_TCP_OVERSIZE_xxx options should be set by sdkconfig"
393 #endif
394 
395 /**
396  * LWIP_WND_SCALE and TCP_RCV_SCALE:
397  * Set LWIP_WND_SCALE to 1 to enable window scaling.
398  * Set TCP_RCV_SCALE to the desired scaling factor (shift count in the
399  * range of [0..14]).
400  * When LWIP_WND_SCALE is enabled but TCP_RCV_SCALE is 0, we can use a large
401  * send window while having a small receive window only.
402  */
403 #ifdef CONFIG_LWIP_WND_SCALE
404 #define LWIP_WND_SCALE                  1
405 #define TCP_RCV_SCALE                   CONFIG_LWIP_TCP_RCV_SCALE
406 #endif
407 
408 /**
409  * LWIP_TCP_RTO_TIME: TCP rto time.
410  * Default is 3 second.
411  */
412 #define LWIP_TCP_RTO_TIME             CONFIG_LWIP_TCP_RTO_TIME
413 
414 /*
415    ----------------------------------
416    ---------- Pbuf options ----------
417    ----------------------------------
418 */
419 
420 /*
421    ------------------------------------------------
422    ---------- Network Interfaces options ----------
423    ------------------------------------------------
424 */
425 
426 /**
427  * LWIP_NETIF_HOSTNAME==1: use DHCP_OPTION_HOSTNAME with netif's hostname
428  * field.
429  */
430 #define LWIP_NETIF_HOSTNAME             1
431 
432 /**
433  * LWIP_NETIF_TX_SINGLE_PBUF: if this is set to 1, lwIP tries to put all data
434  * to be sent into one single pbuf. This is for compatibility with DMA-enabled
435  * MACs that do not support scatter-gather.
436  * Beware that this might involve CPU-memcpy before transmitting that would not
437  * be needed without this flag! Use this only if you need to!
438  *
439  * @todo: TCP and IP-frag do not work with this, yet:
440  */
441 #define LWIP_NETIF_TX_SINGLE_PBUF             1
442 
443 /**
444  * LWIP_NETIF_API==1: Enable usage of standard POSIX APIs in LWIP.
445  */
446 #define LWIP_NETIF_API                      CONFIG_LWIP_NETIF_API
447 
448 #define LWIP_NETIF_STATUS_CALLBACK      CONFIG_LWIP_NETIF_STATUS_CALLBACK
449 
450 /*
451    ------------------------------------
452    ---------- LOOPIF options ----------
453    ------------------------------------
454 */
455 #ifdef CONFIG_LWIP_NETIF_LOOPBACK
456 /**
457  * LWIP_NETIF_LOOPBACK==1: Support sending packets with a destination IP
458  * address equal to the netif IP address, looping them back up the stack.
459  */
460 #define LWIP_NETIF_LOOPBACK             1
461 
462 /**
463  * LWIP_LOOPBACK_MAX_PBUFS: Maximum number of pbufs on queue for loopback
464  * sending for each netif (0 = disabled)
465  */
466 #define LWIP_LOOPBACK_MAX_PBUFS         CONFIG_LWIP_LOOPBACK_MAX_PBUFS
467 #endif
468 
469 /*
470    ------------------------------------
471    ---------- SLIPIF options ----------
472    ------------------------------------
473 */
474 
475 #ifdef CONFIG_LWIP_SLIP_SUPPORT
476 
477 /**
478  * Enable SLIP receive from ISR functions and disable Rx thread
479  *
480  * This is the only supported mode of lwIP SLIP interface, so that
481  * - incoming packets are queued into pbufs
482  * - no thread is created from lwIP
483  * meaning it is the application responsibility to read data
484  * from IO driver and feed them to the slip interface
485  */
486 #define SLIP_RX_FROM_ISR                 1
487 #define SLIP_USE_RX_THREAD               0
488 
489 /**
490  * PPP_DEBUG: Enable debugging for PPP.
491  */
492 #define SLIP_DEBUG_ON                    CONFIG_LWIP_SLIP_DEBUG_ON
493 
494 #if SLIP_DEBUG_ON
495 #define SLIP_DEBUG                       LWIP_DBG_ON
496 #else
497 #define SLIP_DEBUG                       LWIP_DBG_OFF
498 #endif
499 
500 
501 #endif
502 
503 /*
504    ------------------------------------
505    ---------- Thread options ----------
506    ------------------------------------
507 */
508 /**
509  * TCPIP_THREAD_NAME: The name assigned to the main tcpip thread.
510  */
511 #define TCPIP_THREAD_NAME              "tiT"
512 
513 /**
514  * TCPIP_THREAD_STACKSIZE: The stack size used by the main tcpip thread.
515  * The stack size value itself is platform-dependent, but is passed to
516  * sys_thread_new() when the thread is created.
517  */
518 #define TCPIP_THREAD_STACKSIZE          ESP_TASK_TCPIP_STACK
519 
520 /**
521  * TCPIP_THREAD_PRIO: The priority assigned to the main tcpip thread.
522  * The priority value itself is platform-dependent, but is passed to
523  * sys_thread_new() when the thread is created.
524  */
525 #define TCPIP_THREAD_PRIO               ESP_TASK_TCPIP_PRIO
526 
527 /**
528  * TCPIP_MBOX_SIZE: The mailbox size for the tcpip thread messages
529  * The queue size value itself is platform-dependent, but is passed to
530  * sys_mbox_new() when tcpip_init is called.
531  */
532 #define TCPIP_MBOX_SIZE                 CONFIG_LWIP_TCPIP_RECVMBOX_SIZE
533 
534 /**
535  * DEFAULT_UDP_RECVMBOX_SIZE: The mailbox size for the incoming packets on a
536  * NETCONN_UDP. The queue size value itself is platform-dependent, but is passed
537  * to sys_mbox_new() when the recvmbox is created.
538  */
539 #define DEFAULT_UDP_RECVMBOX_SIZE       CONFIG_LWIP_UDP_RECVMBOX_SIZE
540 
541 /**
542  * DEFAULT_TCP_RECVMBOX_SIZE: The mailbox size for the incoming packets on a
543  * NETCONN_TCP. The queue size value itself is platform-dependent, but is passed
544  * to sys_mbox_new() when the recvmbox is created.
545  */
546 #define DEFAULT_TCP_RECVMBOX_SIZE       CONFIG_LWIP_TCP_RECVMBOX_SIZE
547 
548 /**
549  * DEFAULT_ACCEPTMBOX_SIZE: The mailbox size for the incoming connections.
550  * The queue size value itself is platform-dependent, but is passed to
551  * sys_mbox_new() when the acceptmbox is created.
552  */
553 #define DEFAULT_ACCEPTMBOX_SIZE         6
554 
555 /**
556  * DEFAULT_THREAD_STACKSIZE: The stack size used by any other lwIP thread.
557  * The stack size value itself is platform-dependent, but is passed to
558  * sys_thread_new() when the thread is created.
559  */
560 #define DEFAULT_THREAD_STACKSIZE        TCPIP_THREAD_STACKSIZE
561 
562 /**
563  * DEFAULT_THREAD_PRIO: The priority assigned to any other lwIP thread.
564  * The priority value itself is platform-dependent, but is passed to
565  * sys_thread_new() when the thread is created.
566  */
567 #define DEFAULT_THREAD_PRIO             TCPIP_THREAD_PRIO
568 
569 /**
570  * DEFAULT_RAW_RECVMBOX_SIZE: The mailbox size for the incoming packets on a
571  * NETCONN_RAW. The queue size value itself is platform-dependent, but is passed
572  * to sys_mbox_new() when the recvmbox is created.
573  */
574 #define DEFAULT_RAW_RECVMBOX_SIZE       6
575 
576 /*
577    ----------------------------------------------
578    ---------- Sequential layer options ----------
579    ----------------------------------------------
580 */
581 /**
582  * LWIP_TCPIP_CORE_LOCKING: (EXPERIMENTAL!)
583  * Don't use it if you're not an active lwIP project member
584  */
585 #define LWIP_TCPIP_CORE_LOCKING         CONFIG_LWIP_TCPIP_CORE_LOCKING
586 
587 /*
588    ------------------------------------
589    ---------- Socket options ----------
590    ------------------------------------
591 */
592 /**
593  * LWIP_SO_SNDTIMEO==1: Enable send timeout for sockets/netconns and
594  * SO_SNDTIMEO processing.
595  */
596 #define LWIP_SO_SNDTIMEO                1
597 
598 /**
599  * LWIP_SO_RCVTIMEO==1: Enable receive timeout for sockets/netconns and
600  * SO_RCVTIMEO processing.
601  */
602 #define LWIP_SO_RCVTIMEO                1
603 
604 /**
605  * LWIP_TCP_KEEPALIVE==1: Enable TCP_KEEPIDLE, TCP_KEEPINTVL and TCP_KEEPCNT
606  * options processing. Note that TCP_KEEPIDLE and TCP_KEEPINTVL have to be set
607  * in seconds. (does not require sockets.c, and will affect tcp.c)
608  */
609 #define LWIP_TCP_KEEPALIVE              1
610 
611 /**
612  * LWIP_SO_LINGER==1: Enable SO_LINGER processing.
613  */
614 #define LWIP_SO_LINGER                  CONFIG_LWIP_SO_LINGER
615 
616 /**
617  * LWIP_SO_RCVBUF==1: Enable SO_RCVBUF processing.
618  */
619 #define LWIP_SO_RCVBUF                  CONFIG_LWIP_SO_RCVBUF
620 
621 /**
622  * SO_REUSE==1: Enable SO_REUSEADDR option.
623  * This option is set via menuconfig.
624  */
625 #define SO_REUSE                        CONFIG_LWIP_SO_REUSE
626 
627 
628 /**
629  * LWIP_DNS_SUPPORT_MDNS_QUERIES==1: Enable mDNS queries in hostname resolution.
630  * This option is set via menuconfig.
631  */
632 #define LWIP_DNS_SUPPORT_MDNS_QUERIES   CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES
633 /**
634  * SO_REUSE_RXTOALL==1: Pass a copy of incoming broadcast/multicast packets
635  * to all local matches if SO_REUSEADDR is turned on.
636  * WARNING: Adds a memcpy for every packet if passing to more than one pcb!
637  */
638 #define SO_REUSE_RXTOALL                CONFIG_LWIP_SO_REUSE_RXTOALL
639 
640 /**
641  * LWIP_NETBUF_RECVINFO==1: Enable IP_PKTINFO option.
642  * This option is set via menuconfig.
643  */
644 #define LWIP_NETBUF_RECVINFO            CONFIG_LWIP_NETBUF_RECVINFO
645 
646 /*
647    ----------------------------------------
648    ---------- Statistics options ----------
649    ----------------------------------------
650 */
651 
652 /**
653  * LWIP_STATS==1: Enable statistics collection in lwip_stats.
654  */
655 #define LWIP_STATS                      CONFIG_LWIP_STATS
656 
657 #if LWIP_STATS
658 
659 /**
660  * LWIP_STATS_DISPLAY==1: Compile in the statistics output functions.
661  */
662 #define LWIP_STATS_DISPLAY              CONFIG_LWIP_STATS
663 #endif
664 
665 
666 /*
667    ---------------------------------
668    ---------- PPP options ----------
669    ---------------------------------
670 */
671 
672 /**
673  * PPP_SUPPORT==1: Enable PPP.
674  */
675 #define PPP_SUPPORT                     CONFIG_LWIP_PPP_SUPPORT
676 
677 #if PPP_SUPPORT
678 
679 /**
680  * PPP_IPV6_SUPPORT == 1: Enable IPV6 support for local link
681  * between modem and lwIP stack.
682  * Some modems do not support IPV6 addressing in local link and
683  * the only option available is to disable IPV6 address negotiation.
684  */
685 #define PPP_IPV6_SUPPORT                               CONFIG_LWIP_PPP_ENABLE_IPV6
686 
687 /**
688  * PPP_NOTIFY_PHASE==1: Support PPP notify phase.
689  */
690 #define PPP_NOTIFY_PHASE                CONFIG_LWIP_PPP_NOTIFY_PHASE_SUPPORT
691 
692 /**
693  * PAP_SUPPORT==1: Support PAP.
694  */
695 #define PAP_SUPPORT                     CONFIG_LWIP_PPP_PAP_SUPPORT
696 
697 /**
698  * CHAP_SUPPORT==1: Support CHAP.
699  */
700 #define CHAP_SUPPORT                    CONFIG_LWIP_PPP_CHAP_SUPPORT
701 
702 /**
703  * MSCHAP_SUPPORT==1: Support MSCHAP.
704  */
705 #define MSCHAP_SUPPORT                  CONFIG_LWIP_PPP_MSCHAP_SUPPORT
706 
707 /**
708  * CCP_SUPPORT==1: Support CCP.
709  */
710 #define MPPE_SUPPORT                    CONFIG_LWIP_PPP_MPPE_SUPPORT
711 
712 /**
713  * PPP_MAXIDLEFLAG: Max Xmit idle time (in ms) before resend flag char.
714  * TODO: If PPP_MAXIDLEFLAG > 0 and next package is send during PPP_MAXIDLEFLAG time,
715  *       then 0x7E is not added at the begining of PPP package but 0x7E termination
716  *       is always at the end. This behaviour brokes PPP dial with GSM (PPPoS).
717  *       The PPP package should always start and end with 0x7E.
718  */
719 
720 #define PPP_MAXIDLEFLAG                 0
721 
722 /**
723  * PPP_DEBUG: Enable debugging for PPP.
724  */
725 #define PPP_DEBUG_ON                    CONFIG_LWIP_PPP_DEBUG_ON
726 
727 #if PPP_DEBUG_ON
728 #define PPP_DEBUG                       LWIP_DBG_ON
729 #define PRINTPKT_SUPPORT                1
730 #define PPP_PROTOCOLNAME                1
731 #else
732 #define PPP_DEBUG                       LWIP_DBG_OFF
733 #endif
734 
735 #endif  /* PPP SUPPORT */
736 
737 /*
738    ------------------------------------
739    --------- LCP Echo options ---------
740    ------------------------------------
741 */
742 #if CONFIG_LWIP_ENABLE_LCP_ECHO
743 /**
744  * LCP_ECHOINTERVAL: Interval in seconds between keepalive LCP echo requests, 0 to disable.
745  */
746 #define LCP_ECHOINTERVAL                CONFIG_LWIP_LCP_ECHOINTERVAL
747 
748 /**
749  * LCP_MAXECHOFAILS: Number of consecutive unanswered echo requests before failure is indicated.
750  */
751 #define LCP_MAXECHOFAILS                CONFIG_LWIP_LCP_MAXECHOFAILS
752 #endif /* CONFIG_LWIP_ENABLE_LCP_ECHO */
753 
754 /*
755    --------------------------------------
756    ---------- Checksum options ----------
757    --------------------------------------
758 */
759 
760 /*
761    ---------------------------------------
762    ---------- IPv6 options ---------------
763    ---------------------------------------
764 */
765 /**
766  * LWIP_IPV6==1: Enable IPv6
767  */
768 #define LWIP_IPV6                       CONFIG_LWIP_IPV6
769 
770 /**
771  * MEMP_NUM_ND6_QUEUE: Max number of IPv6 packets to queue during MAC resolution.
772  */
773 #define MEMP_NUM_ND6_QUEUE              CONFIG_LWIP_IPV6_MEMP_NUM_ND6_QUEUE
774 
775 /**
776  * LWIP_ND6_NUM_NEIGHBORS: Number of entries in IPv6 neighbor cache
777  */
778 #define LWIP_ND6_NUM_NEIGHBORS          CONFIG_LWIP_IPV6_ND6_NUM_NEIGHBORS
779 
780 /*
781    ---------------------------------------
782    ---------- Hook options ---------------
783    ---------------------------------------
784 */
785 #ifdef LWIP_HOOK_FILENAME
786 #warning LWIP_HOOK_FILENAME is used for IDF default hooks. Please use ESP_IDF_LWIP_HOOK_FILENAME to insert additional hook
787 #endif
788 #define LWIP_HOOK_FILENAME              "lwip_default_hooks.h"
789 #define LWIP_HOOK_IP4_ROUTE_SRC         ip4_route_src_hook
790 
791 /*
792    ---------------------------------------
793    ---------- Debugging options ----------
794    ---------------------------------------
795 */
796 /**
797  * ETHARP_DEBUG: Enable debugging in etharp.c.
798  */
799 #ifdef CONFIG_LWIP_ETHARP_DEBUG
800 #define ETHARP_DEBUG                     LWIP_DBG_ON
801 #else
802 #define ETHARP_DEBUG                     LWIP_DBG_OFF
803 #endif
804 
805 
806 /**
807  * NETIF_DEBUG: Enable debugging in netif.c.
808  */
809 #ifdef CONFIG_LWIP_NETIF_DEBUG
810 #define NETIF_DEBUG                     LWIP_DBG_ON
811 #else
812 #define NETIF_DEBUG                     LWIP_DBG_OFF
813 #endif
814 
815 /**
816  * PBUF_DEBUG: Enable debugging in pbuf.c.
817  */
818 #ifdef CONFIG_LWIP_PBUF_DEBUG
819 #define PBUF_DEBUG                     LWIP_DBG_ON
820 #else
821 #define PBUF_DEBUG                     LWIP_DBG_OFF
822 #endif
823 
824 /**
825  * API_LIB_DEBUG: Enable debugging in api_lib.c.
826  */
827 #ifdef CONFIG_LWIP_API_LIB_DEBUG
828 #define API_LIB_DEBUG                     LWIP_DBG_ON
829 #else
830 #define API_LIB_DEBUG                     LWIP_DBG_OFF
831 #endif
832 
833 
834 /**
835  * SOCKETS_DEBUG: Enable debugging in sockets.c.
836  */
837 #ifdef CONFIG_LWIP_SOCKETS_DEBUG
838 #define SOCKETS_DEBUG                   LWIP_DBG_ON
839 #else
840 #define SOCKETS_DEBUG                   LWIP_DBG_OFF
841 #endif
842 
843 /**
844  * ICMP_DEBUG: Enable debugging in icmp.c.
845  */
846 #ifdef CONFIG_LWIP_ICMP_DEBUG
847 #define ICMP_DEBUG                      LWIP_DBG_ON
848 #else
849 #define ICMP_DEBUG                      LWIP_DBG_OFF
850 #endif
851 
852 #ifdef CONFIG_LWIP_ICMP6_DEBUG
853 #define ICMP6_DEBUG                      LWIP_DBG_ON
854 #else
855 #define ICMP6_DEBUG                      LWIP_DBG_OFF
856 #endif
857 
858 /**
859  * DHCP_DEBUG: Enable debugging in dhcp.c.
860  */
861 #ifdef CONFIG_LWIP_DHCP_DEBUG
862 #define DHCP_DEBUG                      LWIP_DBG_ON
863 #else
864 #define DHCP_DEBUG                      LWIP_DBG_OFF
865 #endif
866 
867 #ifdef CONFIG_LWIP_DHCP_STATE_DEBUG
868 #define ESP_DHCP_DEBUG                  LWIP_DBG_ON
869 #else
870 #define ESP_DHCP_DEBUG                  LWIP_DBG_OFF
871 #endif
872 
873 /**
874  * IP_DEBUG: Enable debugging for IP.
875  */
876 #ifdef CONFIG_LWIP_IP_DEBUG
877 #define IP_DEBUG                        LWIP_DBG_ON
878 #else
879 #define IP_DEBUG                        LWIP_DBG_OFF
880 #endif
881 
882 /**
883  * IP6_DEBUG: Enable debugging for IP6.
884  */
885 #ifdef CONFIG_LWIP_IP6_DEBUG
886 #define IP6_DEBUG                        LWIP_DBG_ON
887 #else
888 #define IP6_DEBUG                        LWIP_DBG_OFF
889 #endif
890 
891 /**
892  * TCP_DEBUG: Enable debugging for TCP.
893  */
894 #ifdef CONFIG_LWIP_TCP_DEBUG
895 #define TCP_DEBUG                        LWIP_DBG_ON
896 #else
897 #define TCP_DEBUG                        LWIP_DBG_OFF
898 #endif
899 
900 /**
901  * SNTP_DEBUG: Enable debugging for SNTP.
902  */
903 #ifdef CONFIG_LWIP_SNTP_DEBUG
904 #define SNTP_DEBUG                       LWIP_DBG_ON
905 #else
906 #define SNTP_DEBUG                       LWIP_DBG_OFF
907 #endif
908 
909 /**
910  * MEMP_DEBUG: Enable debugging in memp.c.
911  */
912 #define MEMP_DEBUG                      LWIP_DBG_OFF
913 
914 /**
915  * TCP_INPUT_DEBUG: Enable debugging in tcp_in.c for incoming debug.
916  */
917 #define TCP_INPUT_DEBUG                 LWIP_DBG_OFF
918 
919 /**
920  * TCP_OUTPUT_DEBUG: Enable debugging in tcp_out.c output functions.
921  */
922 #define TCP_OUTPUT_DEBUG                LWIP_DBG_OFF
923 
924 /**
925  * TCPIP_DEBUG: Enable debugging in tcpip.c.
926  */
927 #define TCPIP_DEBUG                     LWIP_DBG_OFF
928 
929 /**
930  * TCP_OOSEQ_DEBUG: Enable debugging in tcpin.c for OOSEQ.
931  */
932 #define TCP_OOSEQ_DEBUG                 LWIP_DBG_OFF
933 
934 /**
935  * ETHARP_TRUST_IP_MAC==1: Incoming IP packets cause the ARP table to be
936  * updated with the source MAC and IP addresses supplied in the packet.
937  * You may want to disable this if you do not trust LAN peers to have the
938  * correct addresses, or as a limited approach to attempt to handle
939  * spoofing. If disabled, lwIP will need to make a new ARP request if
940  * the peer is not already in the ARP table, adding a little latency.
941  * The peer *is* in the ARP table if it requested our address before.
942  * Also notice that this slows down input processing of every IP packet!
943  */
944 #define ETHARP_TRUST_IP_MAC             CONFIG_LWIP_ETHARP_TRUST_IP_MAC
945 
946 
947 /**
948  * POSIX I/O functions are mapped to LWIP via the VFS layer
949  * (see port/vfs_lwip.c)
950  */
951 #define LWIP_POSIX_SOCKETS_IO_NAMES     0
952 
953 /**
954  * FD_SETSIZE from sys/types.h is the maximum number of supported file
955  * descriptors and CONFIG_LWIP_MAX_SOCKETS defines the number of sockets;
956  * LWIP_SOCKET_OFFSET is configured to use the largest numbers of file
957  * descriptors for sockets. File descriptors from 0 to LWIP_SOCKET_OFFSET-1
958  * are non-socket descriptors and from LWIP_SOCKET_OFFSET to FD_SETSIZE are
959  * socket descriptors.
960  */
961 #define LWIP_SOCKET_OFFSET              (FD_SETSIZE - CONFIG_LWIP_MAX_SOCKETS)
962 
963 #define LWIP_IPV6_FORWARD               CONFIG_LWIP_IPV6_FORWARD
964 
965 #define LWIP_IPV6_NUM_ADDRESSES         CONFIG_LWIP_IPV6_NUM_ADDRESSES
966 
967 #define LWIP_ND6_RDNSS_MAX_DNS_SERVERS  CONFIG_LWIP_IPV6_RDNSS_MAX_DNS_SERVERS
968 
969 #define LWIP_IPV6_DHCP6                 CONFIG_LWIP_IPV6_DHCP6
970 
971 /* Enable all Espressif-only options */
972 
973 #define ESP_LWIP                        1
974 #define ESP_LWIP_ARP                    1
975 #define ESP_PER_SOC_TCP_WND             0
976 #define ESP_THREAD_SAFE                 1
977 #define ESP_THREAD_SAFE_DEBUG           LWIP_DBG_OFF
978 #define ESP_DHCP                        1
979 #define ESP_DNS                         1
980 #define ESP_PERF                        0
981 #define ESP_RANDOM_TCP_PORT             1
982 #define ESP_IP4_ATON                    1
983 #define ESP_LIGHT_SLEEP                 1
984 #define ESP_L2_TO_L3_COPY               CONFIG_LWIP_L2_TO_L3_COPY
985 #define LWIP_NETIF_API                  CONFIG_LWIP_NETIF_API
986 #define ESP_STATS_MEM                   CONFIG_LWIP_STATS
987 #define ESP_STATS_DROP                  CONFIG_LWIP_STATS
988 #define ESP_STATS_TCP                   0
989 #ifdef CONFIG_LWIP_DHCPS
990 #define ESP_DHCPS                       1
991 #define ESP_DHCPS_TIMER                 1
992 #else
993 #define ESP_DHCPS                       0
994 #define ESP_DHCPS_TIMER                 0
995 #endif /* CONFIG_LWIP_DHCPS */
996 #define ESP_LWIP_LOGI(...)              ESP_LOGI("lwip", __VA_ARGS__)
997 #define ESP_PING                        1
998 #define ESP_HAS_SELECT                  1
999 #define ESP_AUTO_RECV                   1
1000 #define ESP_GRATUITOUS_ARP              CONFIG_LWIP_ESP_GRATUITOUS_ARP
1001 #define ESP_IP4_ROUTE                   1
1002 #define ESP_AUTO_IP                     1
1003 #define ESP_PBUF                        1
1004 #define ESP_PPP                         1
1005 #define ESP_IPV6                        LWIP_IPV6
1006 #define ESP_SOCKET                      1
1007 #define ESP_LWIP_SELECT                 1
1008 #define ESP_LWIP_LOCK                   1
1009 #define ESP_THREAD_PROTECTION           1
1010 
1011 #ifdef CONFIG_LWIP_IPV6_AUTOCONFIG
1012 #define ESP_IPV6_AUTOCONFIG             CONFIG_LWIP_IPV6_AUTOCONFIG
1013 #endif
1014 
1015 #ifdef ESP_IRAM_ATTR
1016 #undef ESP_IRAM_ATTR
1017 #endif
1018 #define ESP_IRAM_ATTR
1019 
1020 #ifdef CONFIG_LWIP_TIMERS_ONDEMAND
1021 #define ESP_LWIP_IGMP_TIMERS_ONDEMAND            1
1022 #define ESP_LWIP_MLD6_TIMERS_ONDEMAND            1
1023 #else
1024 #define ESP_LWIP_IGMP_TIMERS_ONDEMAND            0
1025 #define ESP_LWIP_MLD6_TIMERS_ONDEMAND            0
1026 #endif
1027 
1028 #define TCP_SND_BUF                     CONFIG_LWIP_TCP_SND_BUF_DEFAULT
1029 #define TCP_WND                         CONFIG_LWIP_TCP_WND_DEFAULT
1030 
1031 /**
1032  * LWIP_DEBUG: Enable lwip debugging in other modules.
1033  */
1034 #ifdef CONFIG_LWIP_DEBUG
1035 #define LWIP_DEBUG                      LWIP_DBG_ON
1036 #else
1037 #undef LWIP_DEBUG
1038 #endif
1039 
1040 #define CHECKSUM_CHECK_UDP              CONFIG_LWIP_CHECKSUM_CHECK_UDP
1041 #define CHECKSUM_CHECK_IP               CONFIG_LWIP_CHECKSUM_CHECK_IP
1042 #define CHECKSUM_CHECK_ICMP             CONFIG_LWIP_CHECKSUM_CHECK_ICMP
1043 
1044 #define LWIP_NETCONN_FULLDUPLEX         1
1045 #if LWIP_TCPIP_CORE_LOCKING
1046 #define LWIP_NETCONN_SEM_PER_THREAD     0
1047 #else
1048 #define LWIP_NETCONN_SEM_PER_THREAD     1
1049 #endif /* LWIP_TCPIP_CORE_LOCKING */
1050 
1051 #define LWIP_DHCP_MAX_NTP_SERVERS       CONFIG_LWIP_DHCP_MAX_NTP_SERVERS
1052 #define LWIP_TIMEVAL_PRIVATE            0
1053 
1054 /*
1055    --------------------------------------
1056    ------------ SNTP options ------------
1057    --------------------------------------
1058 */
1059 
1060 // Max number of SNTP servers handled (default equal to LWIP_DHCP_MAX_NTP_SERVERS)
1061 #if defined CONFIG_LWIP_SNTP_MAX_SERVERS
1062 #define SNTP_MAX_SERVERS                CONFIG_LWIP_SNTP_MAX_SERVERS
1063 #endif // CONFIG_LWIP_SNTP_MAX_SERVERS
1064 
1065 #ifdef CONFIG_LWIP_DHCP_GET_NTP_SRV
1066 #define LWIP_DHCP_GET_NTP_SRV           CONFIG_LWIP_DHCP_GET_NTP_SRV
1067 #endif // CONFIG_LWIP_DHCP_GET_NTP_SRV
1068 
1069 /** Set this to 1 to support DNS names (or IP address strings) to set sntp servers
1070  * One server address/name can be defined as default if SNTP_SERVER_DNS == 1:
1071  * \#define SNTP_SERVER_ADDRESS "pool.ntp.org"
1072  */
1073 #define SNTP_SERVER_DNS            1
1074 
1075 // It disables a check of SNTP_UPDATE_DELAY it is done in sntp_set_sync_interval
1076 #define SNTP_SUPPRESS_DELAY_CHECK
1077 
1078 #define SNTP_UPDATE_DELAY                 (sntp_get_sync_interval())
1079 #define SNTP_SET_SYSTEM_TIME_US(sec, us)  (sntp_set_system_time(sec, us))
1080 #define SNTP_GET_SYSTEM_TIME(sec, us)     (sntp_get_system_time(&(sec), &(us)))
1081 
1082 #define SOC_SEND_LOG //printf
1083 
1084 #endif /* __LWIPOPTS_H__ */
1085