Mistake on this page?
Report an issue in GitHub or email us
include/lwipstack/lwipopts.h
1 /* Copyright (C) 2012 mbed.org, MIT License
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
4  * and associated documentation files (the "Software"), to deal in the Software without restriction,
5  * including without limitation the rights to use, copy, modify, merge, publish, distribute,
6  * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
7  * furnished to do so, subject to the following conditions:
8  *
9  * The above copyright notice and this permission notice shall be included in all copies or
10  * substantial portions of the Software.
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
13  * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
14  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
15  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17  */
18 
19 #ifndef LWIPOPTS_H
20 #define LWIPOPTS_H
21 
22 // Workaround for Linux timeval
23 #if defined (TOOLCHAIN_GCC)
24 #define LWIP_TIMEVAL_PRIVATE 0
25 #include <sys/time.h>
26 #endif
27 #include "nsapi_types.h"
28 #include "mbed_retarget.h"
29 
30 // Operating System
31 #define NO_SYS 0
32 
33 #if !MBED_CONF_LWIP_IPV4_ENABLED && !MBED_CONF_LWIP_IPV6_ENABLED
34 #error "Either IPv4 or IPv6 must be enabled."
35 #endif
36 
37 #define LWIP_IPV4 MBED_CONF_LWIP_IPV4_ENABLED
38 
39 #define LWIP_IPV6 MBED_CONF_LWIP_IPV6_ENABLED
40 
41 #define LWIP_PROVIDE_ERRNO 0
42 
43 // On dual stack configuration how long to wait for both or preferred stack
44 // addresses before completing bring up.
45 #if LWIP_IPV4 && LWIP_IPV6
46 #if MBED_CONF_LWIP_ADDR_TIMEOUT_MODE
47 #define BOTH_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT
48 #define PREF_ADDR_TIMEOUT 0
49 #else
50 #define PREF_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT
51 #define BOTH_ADDR_TIMEOUT 0
52 #endif
53 #else
54 #define PREF_ADDR_TIMEOUT 0
55 #define BOTH_ADDR_TIMEOUT 0
56 #endif
57 
58 
59 #define DHCP_TIMEOUT MBED_CONF_LWIP_DHCP_TIMEOUT
60 
61 #define LINK_TIMEOUT 60
62 
63 #define PREF_IPV4 1
64 #define PREF_IPV6 2
65 
66 #if MBED_CONF_LWIP_IP_VER_PREF == 6
67 #define IP_VERSION_PREF PREF_IPV6
68 #elif MBED_CONF_LWIP_IP_VER_PREF == 4
69 #define IP_VERSION_PREF PREF_IPV4
70 #else
71 #error "Either IPv4 or IPv6 must be preferred."
72 #endif
73 
74 #undef LWIP_DEBUG
75 #if MBED_CONF_LWIP_DEBUG_ENABLED
76 #define LWIP_DEBUG 1
77 #endif
78 
79 #if NO_SYS == 0
80 #include "cmsis_os2.h"
81 
82 #define SYS_LIGHTWEIGHT_PROT 1
83 
84 #define LWIP_RAW MBED_CONF_LWIP_RAW_SOCKET_ENABLED
85 
86 #define MEMP_NUM_TCPIP_MSG_INPKT MBED_CONF_LWIP_MEMP_NUM_TCPIP_MSG_INPKT
87 
88 // Thread stacks use 8-byte alignment
89 #define LWIP_ALIGN_UP(pos, align) ((pos) % (align) ? (pos) + ((align) - (pos) % (align)) : (pos))
90 
91 #ifdef LWIP_DEBUG
92 // For LWIP debug, double the stack
93 #define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE*2, 8)
94 #elif MBED_DEBUG
95 // When debug is enabled on the build increase stack 25 percent
96 #define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE + MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE / 4, 8)
97 #else
98 #define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE, 8)
99 #endif
100 
101 // Thread priority (osPriorityNormal by default)
102 #define TCPIP_THREAD_PRIO (MBED_CONF_LWIP_TCPIP_THREAD_PRIORITY)
103 
104 #ifdef LWIP_DEBUG
105 #define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE*2, 8)
106 #else
107 #define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE, 8)
108 #endif
109 
110 #define MEMP_NUM_SYS_TIMEOUT 16
111 
112 #define sys_msleep(ms) sys_msleep(ms)
113 
114 #endif
115 
116 // 32-bit alignment
117 #define MEM_ALIGNMENT 4
118 
119 #define LWIP_RAM_HEAP_POINTER lwip_ram_heap
120 
121 // Number of simultaneously queued TCP segments.
122 #define MEMP_NUM_TCP_SEG MBED_CONF_LWIP_MEMP_NUM_TCP_SEG
123 
124 // TCP Maximum segment size.
125 #define TCP_MSS MBED_CONF_LWIP_TCP_MSS
126 
127 // TCP sender buffer space (bytes).
128 #define TCP_SND_BUF MBED_CONF_LWIP_TCP_SND_BUF
129 
130 // TCP sender buffer space (bytes).
131 #define TCP_WND MBED_CONF_LWIP_TCP_WND
132 
133 #define TCP_MAXRTX MBED_CONF_LWIP_TCP_MAXRTX
134 
135 #define TCP_SYNMAXRTX MBED_CONF_LWIP_TCP_SYNMAXRTX
136 
137 // Number of pool pbufs.
138 // Each requires 684 bytes of RAM (if MSS=536 and PBUF_POOL_BUFSIZE defaulting to be based on MSS)
139 #define PBUF_POOL_SIZE MBED_CONF_LWIP_PBUF_POOL_SIZE
140 
141 #ifdef MBED_CONF_LWIP_PBUF_POOL_BUFSIZE
142 #undef PBUF_POOL_BUFSIZE
143 #define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(MBED_CONF_LWIP_PBUF_POOL_BUFSIZE)
144 #else
145 #ifndef PBUF_POOL_BUFSIZE
146 #if LWIP_IPV6
147 #define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN)
148 #elif LWIP_IPV4
149 #define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+20+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN)
150 #endif
151 #endif
152 #endif
153 
154 #define MEM_SIZE MBED_CONF_LWIP_MEM_SIZE
155 
156 // One tcp_pcb_listen is needed for each TCP server.
157 // Each requires 72 bytes of RAM.
158 #define MEMP_NUM_TCP_PCB_LISTEN MBED_CONF_LWIP_TCP_SERVER_MAX
159 
160 // One is tcp_pcb needed for each TCPSocket.
161 // Each requires 196 bytes of RAM.
162 #define MEMP_NUM_TCP_PCB MBED_CONF_LWIP_TCP_SOCKET_MAX
163 
164 // One udp_pcb is needed for each UDPSocket.
165 // Each requires 84 bytes of RAM (total rounded to multiple of 512).
166 #define MEMP_NUM_UDP_PCB MBED_CONF_LWIP_UDP_SOCKET_MAX
167 
168 // Number of non-pool pbufs.
169 // Each requires 92 bytes of RAM.
170 #define MEMP_NUM_PBUF MBED_CONF_LWIP_NUM_PBUF
171 
172 // Each netbuf requires 64 bytes of RAM.
173 #define MEMP_NUM_NETBUF MBED_CONF_LWIP_NUM_NETBUF
174 
175 // One netconn is needed for each UDPSocket or TCPSocket.
176 // Each requires 236 bytes of RAM (total rounded to multiple of 512).
177 #define MEMP_NUM_NETCONN MBED_CONF_LWIP_SOCKET_MAX
178 
179 #if MBED_CONF_LWIP_TCP_ENABLED
180 #define LWIP_TCP 1
181 #define TCP_OVERSIZE 0
182 #define LWIP_TCP_KEEPALIVE 1
183 
184 #define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT
185 
186 #else
187 #define LWIP_TCP 0
188 #endif
189 
190 #define LWIP_DNS 1
191 // Only DNS address storage is enabled
192 #define LWIP_FULL_DNS 0
193 #define LWIP_SOCKET 0
194 
195 #define SO_REUSE 1
196 
197 // Support Multicast
198 #include "stdlib.h"
199 #define LWIP_IGMP LWIP_IPV4
200 #define LWIP_RAND() lwip_get_random()
201 
202 #define LWIP_COMPAT_SOCKETS 0
203 #define LWIP_POSIX_SOCKETS_IO_NAMES 0
204 
205 #define LWIP_BROADCAST_PING 1
206 
207 // Fragmentation on, as per IPv4 default
208 #define LWIP_IPV6_FRAG LWIP_IPV6
209 
210 // Queuing, default is "disabled", as per IPv4 default (so actually queues 1)
211 #define LWIP_ND6_QUEUEING MBED_CONF_ND6_QUEUEING
212 
213 // Debug Options
214 #define NETIF_DEBUG LWIP_DBG_OFF
215 #define PBUF_DEBUG LWIP_DBG_OFF
216 #define API_LIB_DEBUG LWIP_DBG_OFF
217 #define API_MSG_DEBUG LWIP_DBG_OFF
218 #define SOCKETS_DEBUG LWIP_DBG_OFF
219 #define ICMP_DEBUG LWIP_DBG_OFF
220 #define IGMP_DEBUG LWIP_DBG_OFF
221 #define INET_DEBUG LWIP_DBG_OFF
222 #define IP_DEBUG LWIP_DBG_OFF
223 #define IP_REASS_DEBUG LWIP_DBG_OFF
224 #define RAW_DEBUG LWIP_DBG_OFF
225 #define MEM_DEBUG LWIP_DBG_OFF
226 #define MEMP_DEBUG LWIP_DBG_OFF
227 #define SYS_DEBUG LWIP_DBG_OFF
228 #define TIMERS_DEBUG LWIP_DBG_OFF
229 #define TCP_DEBUG LWIP_DBG_OFF
230 #define TCP_INPUT_DEBUG LWIP_DBG_OFF
231 #define TCP_FR_DEBUG LWIP_DBG_OFF
232 #define TCP_RTO_DEBUG LWIP_DBG_OFF
233 #define TCP_CWND_DEBUG LWIP_DBG_OFF
234 #define TCP_WND_DEBUG LWIP_DBG_OFF
235 #define TCP_OUTPUT_DEBUG LWIP_DBG_OFF
236 #define TCP_RST_DEBUG LWIP_DBG_OFF
237 #define TCP_QLEN_DEBUG LWIP_DBG_OFF
238 #define UDP_DEBUG LWIP_DBG_OFF
239 #define TCPIP_DEBUG LWIP_DBG_OFF
240 #define SLIP_DEBUG LWIP_DBG_OFF
241 #define DHCP_DEBUG LWIP_DBG_OFF
242 #define AUTOIP_DEBUG LWIP_DBG_OFF
243 #define DNS_DEBUG LWIP_DBG_OFF
244 #define IP6_DEBUG LWIP_DBG_OFF
245 
246 #define ETHARP_DEBUG LWIP_DBG_OFF
247 #define UDP_LPC_EMAC LWIP_DBG_OFF
248 
249 #ifdef LWIP_DEBUG
250 #define MEMP_OVERFLOW_CHECK 1
251 #define MEMP_SANITY_CHECK 1
252 #define LWIP_DBG_TYPES_ON LWIP_DBG_ON
253 #define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL
254 #else
255 #define LWIP_NOASSERT 1
256 #define LWIP_STATS 0
257 #endif
258 
259 #define TRACE_TO_ASCII_HEX_DUMP 0
260 
261 #define LWIP_PLATFORM_BYTESWAP 1
262 
263 #define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 1
264 
265 // Interface type configuration
266 
267 #if MBED_CONF_LWIP_ETHERNET_ENABLED
268 #define LWIP_ARP 1
269 #define LWIP_ETHERNET 1
270 #define LWIP_DHCP LWIP_IPV4
271 #else
272 #define LWIP_ARP 0
273 #define LWIP_ETHERNET 0
274 #endif // MBED_CONF_LWIP_ETHERNET_ENABLED
275 
276 #if MBED_CONF_LWIP_L3IP_ENABLED
277 #define LWIP_L3IP 1
278 #else
279 #define LWIP_L3IP 0
280 #endif
281 
282 //Maximum size of network interface name
283 #define INTERFACE_NAME_MAX_SIZE NSAPI_INTERFACE_NAME_MAX_SIZE
284 // Note generic macro name used rather than MBED_CONF_LWIP_PPP_ENABLED
285 // to allow users like PPPCellularInterface to detect that nsapi_ppp.h is available.
286 
287 // Enable PPP for now either from lwIP PPP configuration (obsolete) or from PPP service configuration
288 #if MBED_CONF_PPP_ENABLED || MBED_CONF_LWIP_PPP_ENABLED
289 
290 #define PPP_SUPPORT 1
291 
292 #if MBED_CONF_PPP_IPV4_ENABLED || MBED_CONF_LWIP_IPV4_ENABLED
293 #define LWIP 0x11991199
294 #if (MBED_CONF_NSAPI_DEFAULT_STACK == LWIP) && !MBED_CONF_LWIP_IPV4_ENABLED
295 #error LWIP: IPv4 PPP enabled but not IPv4
296 #endif
297 #undef LWIP
298 #define PPP_IPV4_SUPPORT 1
299 #endif
300 
301 #if MBED_CONF_PPP_IPV6_ENABLED || MBED_CONF_LWIP_IPV6_ENABLED
302 #define LWIP 0x11991199
303 #if (MBED_CONF_NSAPI_DEFAULT_STACK == LWIP) && !MBED_CONF_LWIP_IPV6_ENABLED
304 #error LWIP: IPv6 PPP enabled but not IPv6
305 #endif
306 #undef LWIP
307 #define PPP_IPV6_SUPPORT 1
308 // Later to be dynamic for use for multiple interfaces
309 #define LWIP_IPV6_DUP_DETECT_ATTEMPTS 0
310 #endif
311 
312 #endif
313 
314 // Make sure we default these to off, so
315 // LWIP doesn't default to on
316 #ifndef LWIP_ARP
317 #define LWIP_ARP 0
318 #endif
319 
320 // Checksum-on-copy disabled due to https://savannah.nongnu.org/bugs/?50914
321 #define LWIP_CHECKSUM_ON_COPY 0
322 
323 #define LWIP_NETIF_HOSTNAME 1
324 #define LWIP_NETIF_STATUS_CALLBACK 1
325 #define LWIP_NETIF_LINK_CALLBACK 1
326 
327 #define DNS_TABLE_SIZE 2
328 #define DNS_MAX_NAME_LENGTH 128
329 
330 #include "lwip_random.h"
331 #include "lwip_tcp_isn.h"
332 #define LWIP_HOOK_TCP_ISN lwip_hook_tcp_isn
333 #ifdef MBEDTLS_MD5_C
334 #define LWIP_USE_EXTERNAL_MBEDTLS 1
335 #else
336 #define LWIP_USE_EXTERNAL_MBEDTLS 0
337 #endif
338 
339 #define LWIP_ND6_RDNSS_MAX_DNS_SERVERS MBED_CONF_LWIP_ND6_RDNSS_MAX_DNS_SERVERS
340 
341 #endif /* LWIPOPTS_H_ */
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.