xref: /btstack/platform/lwip/port/lwipopts.h (revision 235be4f4c8186ae87e48b71d082326145296f408)
1*235be4f4SMatthias Ringwald #ifndef __LWIPOPTS_H__
2*235be4f4SMatthias Ringwald #define __LWIPOPTS_H__
3*235be4f4SMatthias Ringwald 
4*235be4f4SMatthias Ringwald /**
5*235be4f4SMatthias Ringwald  * NO_SYS==1: Bare metal lwIP
6*235be4f4SMatthias Ringwald  */
7*235be4f4SMatthias Ringwald #define NO_SYS 1
8*235be4f4SMatthias Ringwald /**
9*235be4f4SMatthias Ringwald  * LWIP_NETCONN==0: Disable Netconn API (require to use api_lib.c)
10*235be4f4SMatthias Ringwald  */
11*235be4f4SMatthias Ringwald #define LWIP_NETCONN 0
12*235be4f4SMatthias Ringwald /**
13*235be4f4SMatthias Ringwald  * LWIP_SOCKET==0: Disable Socket API (require to use sockets.c)
14*235be4f4SMatthias Ringwald  */
15*235be4f4SMatthias Ringwald #define LWIP_SOCKET 0
16*235be4f4SMatthias Ringwald 
17*235be4f4SMatthias Ringwald /**
18*235be4f4SMatthias Ringwald  * SYS_LIGHTWEIGHT_PROT==1: enable inter-task protection (and task-vs-interrupt
19*235be4f4SMatthias Ringwald  * protection) for certain critical regions during buffer allocation, deallocation
20*235be4f4SMatthias Ringwald  * and memory allocation and deallocation.
21*235be4f4SMatthias Ringwald  * ATTENTION: This is required when using lwIP from more than one context! If
22*235be4f4SMatthias Ringwald  * you disable this, you must be sure what you are doing!
23*235be4f4SMatthias Ringwald  */
24*235be4f4SMatthias Ringwald /**
25*235be4f4SMatthias Ringwald  * SYS_LIGHTWEIGHT_PROT==0:
26*235be4f4SMatthias Ringwald  */
27*235be4f4SMatthias Ringwald #define SYS_LIGHTWEIGHT_PROT 0
28*235be4f4SMatthias Ringwald 
29*235be4f4SMatthias Ringwald /* ---------- Memory options ---------- */
30*235be4f4SMatthias Ringwald /**
31*235be4f4SMatthias Ringwald  * MEM_ALIGNMENT: should be set to the alignment of the CPU
32*235be4f4SMatthias Ringwald  *    4 byte alignment -> #define MEM_ALIGNMENT 4
33*235be4f4SMatthias Ringwald  *    2 byte alignment -> #define MEM_ALIGNMENT 2
34*235be4f4SMatthias Ringwald  */
35*235be4f4SMatthias Ringwald #ifndef MEM_ALIGNMENT
36*235be4f4SMatthias Ringwald #define MEM_ALIGNMENT 4
37*235be4f4SMatthias Ringwald #endif
38*235be4f4SMatthias Ringwald 
39*235be4f4SMatthias Ringwald /**
40*235be4f4SMatthias Ringwald  * MEM_SIZE: the size of the heap memory. If the application will send
41*235be4f4SMatthias Ringwald  * a lot of data that needs to be copied, this should be set high.
42*235be4f4SMatthias Ringwald  */
43*235be4f4SMatthias Ringwald #ifndef MEM_SIZE
44*235be4f4SMatthias Ringwald #define MEM_SIZE (22 * 1024)
45*235be4f4SMatthias Ringwald #endif
46*235be4f4SMatthias Ringwald 
47*235be4f4SMatthias Ringwald /* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
48*235be4f4SMatthias Ringwald    sends a lot of data out of ROM (or other static memory), this
49*235be4f4SMatthias Ringwald    should be set high. */
50*235be4f4SMatthias Ringwald #ifndef MEMP_NUM_PBUF
51*235be4f4SMatthias Ringwald #define MEMP_NUM_PBUF 15
52*235be4f4SMatthias Ringwald #endif
53*235be4f4SMatthias Ringwald /* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
54*235be4f4SMatthias Ringwald    per active UDP "connection". */
55*235be4f4SMatthias Ringwald #ifndef MEMP_NUM_UDP_PCB
56*235be4f4SMatthias Ringwald #define MEMP_NUM_UDP_PCB 6
57*235be4f4SMatthias Ringwald #endif
58*235be4f4SMatthias Ringwald /* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
59*235be4f4SMatthias Ringwald    connections. */
60*235be4f4SMatthias Ringwald #ifndef MEMP_NUM_TCP_PCB
61*235be4f4SMatthias Ringwald #define MEMP_NUM_TCP_PCB 10
62*235be4f4SMatthias Ringwald #endif
63*235be4f4SMatthias Ringwald /* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
64*235be4f4SMatthias Ringwald    connections. */
65*235be4f4SMatthias Ringwald #ifndef MEMP_NUM_TCP_PCB_LISTEN
66*235be4f4SMatthias Ringwald #define MEMP_NUM_TCP_PCB_LISTEN 6
67*235be4f4SMatthias Ringwald #endif
68*235be4f4SMatthias Ringwald /* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
69*235be4f4SMatthias Ringwald    segments. */
70*235be4f4SMatthias Ringwald #ifndef MEMP_NUM_TCP_SEG
71*235be4f4SMatthias Ringwald #define MEMP_NUM_TCP_SEG 22
72*235be4f4SMatthias Ringwald #endif
73*235be4f4SMatthias Ringwald /* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
74*235be4f4SMatthias Ringwald    timeouts. */
75*235be4f4SMatthias Ringwald #ifndef MEMP_NUM_SYS_TIMEOUT
76*235be4f4SMatthias Ringwald #define MEMP_NUM_SYS_TIMEOUT 10
77*235be4f4SMatthias Ringwald #endif
78*235be4f4SMatthias Ringwald 
79*235be4f4SMatthias Ringwald /* ---------- Pbuf options ---------- */
80*235be4f4SMatthias Ringwald /* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
81*235be4f4SMatthias Ringwald #ifndef PBUF_POOL_SIZE
82*235be4f4SMatthias Ringwald #define PBUF_POOL_SIZE 9
83*235be4f4SMatthias Ringwald #endif
84*235be4f4SMatthias Ringwald 
85*235be4f4SMatthias Ringwald /* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
86*235be4f4SMatthias Ringwald /* Default value is defined in lwip\src\include\lwip\opt.h as
87*235be4f4SMatthias Ringwald  * LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN)*/
88*235be4f4SMatthias Ringwald 
89*235be4f4SMatthias Ringwald /* ---------- TCP options ---------- */
90*235be4f4SMatthias Ringwald #ifndef LWIP_TCP
91*235be4f4SMatthias Ringwald #define LWIP_TCP 1
92*235be4f4SMatthias Ringwald #endif
93*235be4f4SMatthias Ringwald 
94*235be4f4SMatthias Ringwald #ifndef TCP_TTL
95*235be4f4SMatthias Ringwald #define TCP_TTL 255
96*235be4f4SMatthias Ringwald #endif
97*235be4f4SMatthias Ringwald 
98*235be4f4SMatthias Ringwald /* Controls if TCP should queue segments that arrive out of
99*235be4f4SMatthias Ringwald    order. Define to 0 if your device is low on memory. */
100*235be4f4SMatthias Ringwald #ifndef TCP_QUEUE_OOSEQ
101*235be4f4SMatthias Ringwald #define TCP_QUEUE_OOSEQ 0
102*235be4f4SMatthias Ringwald #endif
103*235be4f4SMatthias Ringwald 
104*235be4f4SMatthias Ringwald /* TCP Maximum segment size. */
105*235be4f4SMatthias Ringwald #ifndef TCP_MSS
106*235be4f4SMatthias Ringwald #define TCP_MSS (1500 - 40) /* TCP_MSS = (Ethernet MTU - IP header size - TCP header size) */
107*235be4f4SMatthias Ringwald #endif
108*235be4f4SMatthias Ringwald 
109*235be4f4SMatthias Ringwald /* TCP sender buffer space (bytes). */
110*235be4f4SMatthias Ringwald #ifndef TCP_SND_BUF
111*235be4f4SMatthias Ringwald #define TCP_SND_BUF (6 * TCP_MSS) // 2
112*235be4f4SMatthias Ringwald #endif
113*235be4f4SMatthias Ringwald 
114*235be4f4SMatthias Ringwald /* TCP sender buffer space (pbufs). This must be at least = 2 *
115*235be4f4SMatthias Ringwald    TCP_SND_BUF/TCP_MSS for things to work. */
116*235be4f4SMatthias Ringwald #ifndef TCP_SND_QUEUELEN
117*235be4f4SMatthias Ringwald #define TCP_SND_QUEUELEN (3 * TCP_SND_BUF) / TCP_MSS // 6
118*235be4f4SMatthias Ringwald #endif
119*235be4f4SMatthias Ringwald 
120*235be4f4SMatthias Ringwald /* TCP receive window. */
121*235be4f4SMatthias Ringwald #ifndef TCP_WND
122*235be4f4SMatthias Ringwald #define TCP_WND (2 * TCP_MSS)
123*235be4f4SMatthias Ringwald #endif
124*235be4f4SMatthias Ringwald 
125*235be4f4SMatthias Ringwald /* Enable backlog*/
126*235be4f4SMatthias Ringwald #ifndef TCP_LISTEN_BACKLOG
127*235be4f4SMatthias Ringwald #define TCP_LISTEN_BACKLOG 1
128*235be4f4SMatthias Ringwald #endif
129*235be4f4SMatthias Ringwald 
130*235be4f4SMatthias Ringwald /* ---------- Network Interfaces options ---------- */
131*235be4f4SMatthias Ringwald /* Support netif api (in netifapi.c). */
132*235be4f4SMatthias Ringwald #ifndef LWIP_NETIF_API
133*235be4f4SMatthias Ringwald #define LWIP_NETIF_API 0
134*235be4f4SMatthias Ringwald #endif
135*235be4f4SMatthias Ringwald 
136*235be4f4SMatthias Ringwald /* ---------- ICMP options ---------- */
137*235be4f4SMatthias Ringwald #ifndef LWIP_ICMP
138*235be4f4SMatthias Ringwald #define LWIP_ICMP 1
139*235be4f4SMatthias Ringwald #endif
140*235be4f4SMatthias Ringwald 
141*235be4f4SMatthias Ringwald /* ---------- DHCP options ---------- */
142*235be4f4SMatthias Ringwald /* Define LWIP_DHCP to 1 if you want DHCP configuration of
143*235be4f4SMatthias Ringwald    interfaces. DHCP is not implemented in lwIP 0.5.1, however, so
144*235be4f4SMatthias Ringwald    turning this on does currently not work. */
145*235be4f4SMatthias Ringwald #ifndef LWIP_DHCP
146*235be4f4SMatthias Ringwald #define LWIP_DHCP 1
147*235be4f4SMatthias Ringwald #endif
148*235be4f4SMatthias Ringwald 
149*235be4f4SMatthias Ringwald /* ---------- UDP options ---------- */
150*235be4f4SMatthias Ringwald #ifndef LWIP_UDP
151*235be4f4SMatthias Ringwald #define LWIP_UDP 1
152*235be4f4SMatthias Ringwald #endif
153*235be4f4SMatthias Ringwald #ifndef UDP_TTL
154*235be4f4SMatthias Ringwald #define UDP_TTL 255
155*235be4f4SMatthias Ringwald #endif
156*235be4f4SMatthias Ringwald 
157*235be4f4SMatthias Ringwald /* ---------- Statistics options ---------- */
158*235be4f4SMatthias Ringwald #ifndef LWIP_STATS
159*235be4f4SMatthias Ringwald #define LWIP_STATS 0
160*235be4f4SMatthias Ringwald #endif
161*235be4f4SMatthias Ringwald #ifndef LWIP_PROVIDE_ERRNO
162*235be4f4SMatthias Ringwald #define LWIP_PROVIDE_ERRNO 1
163*235be4f4SMatthias Ringwald #endif
164*235be4f4SMatthias Ringwald 
165*235be4f4SMatthias Ringwald /*
166*235be4f4SMatthias Ringwald    --------------------------------------
167*235be4f4SMatthias Ringwald    ---------- Checksum options ----------
168*235be4f4SMatthias Ringwald    --------------------------------------
169*235be4f4SMatthias Ringwald */
170*235be4f4SMatthias Ringwald 
171*235be4f4SMatthias Ringwald /*
172*235be4f4SMatthias Ringwald Some MCU allow computing and verifying the IP, UDP, TCP and ICMP checksums by hardware:
173*235be4f4SMatthias Ringwald  - To use this feature let the following define uncommented.
174*235be4f4SMatthias Ringwald  - To disable it and process by CPU comment the  the checksum.
175*235be4f4SMatthias Ringwald */
176*235be4f4SMatthias Ringwald //#define CHECKSUM_BY_HARDWARE
177*235be4f4SMatthias Ringwald 
178*235be4f4SMatthias Ringwald #ifdef CHECKSUM_BY_HARDWARE
179*235be4f4SMatthias Ringwald /* CHECKSUM_GEN_IP==0: Generate checksums by hardware for outgoing IP packets.*/
180*235be4f4SMatthias Ringwald #define CHECKSUM_GEN_IP 0
181*235be4f4SMatthias Ringwald /* CHECKSUM_GEN_UDP==0: Generate checksums by hardware for outgoing UDP packets.*/
182*235be4f4SMatthias Ringwald #define CHECKSUM_GEN_UDP 0
183*235be4f4SMatthias Ringwald /* CHECKSUM_GEN_TCP==0: Generate checksums by hardware for outgoing TCP packets.*/
184*235be4f4SMatthias Ringwald #define CHECKSUM_GEN_TCP 0
185*235be4f4SMatthias Ringwald /* CHECKSUM_CHECK_IP==0: Check checksums by hardware for incoming IP packets.*/
186*235be4f4SMatthias Ringwald #define CHECKSUM_CHECK_IP 0
187*235be4f4SMatthias Ringwald /* CHECKSUM_CHECK_UDP==0: Check checksums by hardware for incoming UDP packets.*/
188*235be4f4SMatthias Ringwald #define CHECKSUM_CHECK_UDP 0
189*235be4f4SMatthias Ringwald /* CHECKSUM_CHECK_TCP==0: Check checksums by hardware for incoming TCP packets.*/
190*235be4f4SMatthias Ringwald #define CHECKSUM_CHECK_TCP 0
191*235be4f4SMatthias Ringwald #else
192*235be4f4SMatthias Ringwald /* CHECKSUM_GEN_IP==1: Generate checksums in software for outgoing IP packets.*/
193*235be4f4SMatthias Ringwald #define CHECKSUM_GEN_IP 1
194*235be4f4SMatthias Ringwald /* CHECKSUM_GEN_UDP==1: Generate checksums in software for outgoing UDP packets.*/
195*235be4f4SMatthias Ringwald #define CHECKSUM_GEN_UDP 1
196*235be4f4SMatthias Ringwald /* CHECKSUM_GEN_TCP==1: Generate checksums in software for outgoing TCP packets.*/
197*235be4f4SMatthias Ringwald #define CHECKSUM_GEN_TCP 1
198*235be4f4SMatthias Ringwald /* CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets.*/
199*235be4f4SMatthias Ringwald #define CHECKSUM_CHECK_IP 1
200*235be4f4SMatthias Ringwald /* CHECKSUM_CHECK_UDP==1: Check checksums in software for incoming UDP packets.*/
201*235be4f4SMatthias Ringwald #define CHECKSUM_CHECK_UDP 1
202*235be4f4SMatthias Ringwald /* CHECKSUM_CHECK_TCP==1: Check checksums in software for incoming TCP packets.*/
203*235be4f4SMatthias Ringwald #define CHECKSUM_CHECK_TCP 1
204*235be4f4SMatthias Ringwald #endif
205*235be4f4SMatthias Ringwald 
206*235be4f4SMatthias Ringwald /*
207*235be4f4SMatthias Ringwald    ------------------------------------
208*235be4f4SMatthias Ringwald    ---------- Debugging options ----------
209*235be4f4SMatthias Ringwald    ------------------------------------
210*235be4f4SMatthias Ringwald */
211*235be4f4SMatthias Ringwald 
212*235be4f4SMatthias Ringwald // #define LWIP_DEBUG
213*235be4f4SMatthias Ringwald 
214*235be4f4SMatthias Ringwald // TODO: map these to <stdint.h>
215*235be4f4SMatthias Ringwald 
216*235be4f4SMatthias Ringwald #ifdef LWIP_DEBUG
217*235be4f4SMatthias Ringwald #define U8_F "c"
218*235be4f4SMatthias Ringwald #define S8_F "c"
219*235be4f4SMatthias Ringwald #define X8_F "02x"
220*235be4f4SMatthias Ringwald #define U16_F "u"
221*235be4f4SMatthias Ringwald #define S16_F "d"
222*235be4f4SMatthias Ringwald #define X16_F "x"
223*235be4f4SMatthias Ringwald #define U32_F "u"
224*235be4f4SMatthias Ringwald #define S32_F "d"
225*235be4f4SMatthias Ringwald #define X32_F "x"
226*235be4f4SMatthias Ringwald #define SZT_F "u"
227*235be4f4SMatthias Ringwald #endif
228*235be4f4SMatthias Ringwald 
229*235be4f4SMatthias Ringwald #if (LWIP_DNS || LWIP_IGMP || LWIP_IPV6) && !defined(LWIP_RAND)
230*235be4f4SMatthias Ringwald /* When using IGMP or IPv6, LWIP_RAND() needs to be defined to a random-function returning an u32_t random value*/
231*235be4f4SMatthias Ringwald #include "lwip/arch.h"
232*235be4f4SMatthias Ringwald u32_t lwip_rand(void);
233*235be4f4SMatthias Ringwald #define LWIP_RAND() lwip_rand()
234*235be4f4SMatthias Ringwald #endif
235*235be4f4SMatthias Ringwald 
236*235be4f4SMatthias Ringwald #endif /* __LWIPOPTS_H__ */
237*235be4f4SMatthias Ringwald 
238*235be4f4SMatthias Ringwald /*****END OF FILE****/
239