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