Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
lwipopts.h
00001 /* Copyright (C) 2012 mbed.org, MIT License 00002 * 00003 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00004 * and associated documentation files (the "Software"), to deal in the Software without restriction, 00005 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 00006 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 00007 * furnished to do so, subject to the following conditions: 00008 * 00009 * The above copyright notice and this permission notice shall be included in all copies or 00010 * substantial portions of the Software. 00011 * 00012 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00013 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00014 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00015 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00016 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00017 */ 00018 00019 #ifndef LWIPOPTS_H 00020 #define LWIPOPTS_H 00021 00022 // Workaround for Linux timeval 00023 #if defined (TOOLCHAIN_GCC) 00024 #define LWIP_TIMEVAL_PRIVATE 0 00025 #include <sys/time.h> 00026 #endif 00027 00028 // Operating System 00029 #define NO_SYS 0 00030 00031 #if MBED_CONF_LWIP_IPV4_ENABLED 00032 #define LWIP_IPV4 1 00033 #else 00034 #define LWIP_IPV4 0 00035 #endif 00036 #if MBED_CONF_LWIP_IPV6_ENABLED 00037 #define LWIP_IPV6 1 00038 #else 00039 #define LWIP_IPV6 0 00040 #endif 00041 #if !MBED_CONF_LWIP_IPV4_ENABLED && !MBED_CONF_LWIP_IPV6_ENABLED 00042 #error "Either IPv4 or IPv6 must be enabled." 00043 #endif 00044 00045 // On dual stack configuration how long to wait for both or preferred stack 00046 // addresses before completing bring up. 00047 #if LWIP_IPV4 && LWIP_IPV6 00048 #if MBED_CONF_LWIP_ADDR_TIMEOUT_MODE 00049 #define BOTH_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT 00050 #define PREF_ADDR_TIMEOUT 0 00051 #else 00052 #define PREF_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT 00053 #define BOTH_ADDR_TIMEOUT 0 00054 #endif 00055 #else 00056 #define PREF_ADDR_TIMEOUT 0 00057 #define BOTH_ADDR_TIMEOUT 0 00058 #endif 00059 00060 #define DHCP_TIMEOUT 60 00061 00062 #define PREF_IPV4 1 00063 #define PREF_IPV6 2 00064 00065 #if MBED_CONF_LWIP_IP_VER_PREF == 4 00066 #define IP_VERSION_PREF PREF_IPV4 00067 #endif 00068 #if MBED_CONF_LWIP_IP_VER_PREF == 6 00069 #define IP_VERSION_PREF PREF_IPV6 00070 #endif 00071 #ifndef IP_VERSION_PREF 00072 #error "Either IPv4 or IPv6 must be preferred." 00073 #endif 00074 00075 #undef LWIP_DEBUG 00076 #if MBED_CONF_LWIP_DEBUG_ENABLED 00077 #define LWIP_DEBUG 1 00078 #endif 00079 00080 #if NO_SYS == 0 00081 #include "cmsis_os2.h" 00082 00083 #define SYS_LIGHTWEIGHT_PROT 1 00084 00085 #define LWIP_RAW 0 00086 00087 #define TCPIP_MBOX_SIZE 8 00088 #define DEFAULT_TCP_RECVMBOX_SIZE 8 00089 #define DEFAULT_UDP_RECVMBOX_SIZE 8 00090 #define DEFAULT_RAW_RECVMBOX_SIZE 8 00091 #define DEFAULT_ACCEPTMBOX_SIZE 8 00092 00093 // Thread stacks use 8-byte alignment 00094 #define LWIP_ALIGN_UP(pos, align) ((pos) % (align) ? (pos) + ((align) - (pos) % (align)) : (pos)) 00095 00096 // Thread stack size for lwip tcpip thread 00097 #ifndef MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE 00098 #define MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE 1200 00099 #endif 00100 00101 #ifdef LWIP_DEBUG 00102 // For LWIP debug, double the stack 00103 #define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE*2, 8) 00104 #elif MBED_DEBUG 00105 // When debug is enabled on the build increase stack 25 percent 00106 #define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE + MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE / 4, 8) 00107 #else 00108 #define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE, 8) 00109 #endif 00110 00111 #define TCPIP_THREAD_PRIO (osPriorityNormal) 00112 00113 // Thread stack size for lwip system threads 00114 #ifndef MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE 00115 #define MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE 512 00116 #endif 00117 00118 // Thread stack size for private PPP thread 00119 #ifndef MBED_CONF_LWIP_PPP_THREAD_STACKSIZE 00120 #define MBED_CONF_LWIP_PPP_THREAD_STACKSIZE 768 00121 #endif 00122 00123 #ifdef LWIP_DEBUG 00124 #define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE*2, 8) 00125 #define PPP_THREAD_STACK_SIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_PPP_THREAD_STACKSIZE*2, 8) 00126 #else 00127 #define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE, 8) 00128 #define PPP_THREAD_STACK_SIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_PPP_THREAD_STACKSIZE, 8) 00129 #endif 00130 00131 #define MEMP_NUM_SYS_TIMEOUT 16 00132 00133 #define sys_msleep(ms) sys_msleep(ms) 00134 00135 #endif 00136 00137 // 32-bit alignment 00138 #define MEM_ALIGNMENT 4 00139 00140 #define LWIP_RAM_HEAP_POINTER lwip_ram_heap 00141 00142 // Number of simultaneously queued TCP segments. 00143 #ifdef MBED_CONF_LWIP_MEMP_NUM_TCP_SEG 00144 #define MEMP_NUM_TCP_SEG MBED_CONF_LWIP_MEMP_NUM_TCP_SEG 00145 #endif 00146 00147 // TCP Maximum segment size. 00148 #ifdef MBED_CONF_LWIP_TCP_MSS 00149 #define TCP_MSS MBED_CONF_LWIP_TCP_MSS 00150 #endif 00151 00152 // TCP sender buffer space (bytes). 00153 #ifdef MBED_CONF_LWIP_TCP_SND_BUF 00154 #define TCP_SND_BUF MBED_CONF_LWIP_TCP_SND_BUF 00155 #endif 00156 00157 // TCP sender buffer space (bytes). 00158 #ifdef MBED_CONF_LWIP_TCP_WND 00159 #define TCP_WND MBED_CONF_LWIP_TCP_WND 00160 #endif 00161 00162 // Number of pool pbufs. 00163 // Each requires 684 bytes of RAM (if MSS=536 and PBUF_POOL_BUFSIZE defaulting to be based on MSS) 00164 #ifdef MBED_CONF_LWIP_PBUF_POOL_SIZE 00165 #undef PBUF_POOL_SIZE 00166 #define PBUF_POOL_SIZE MBED_CONF_LWIP_PBUF_POOL_SIZE 00167 #else 00168 #ifndef PBUF_POOL_SIZE 00169 #define PBUF_POOL_SIZE 5 00170 #endif 00171 #endif 00172 00173 #ifdef MBED_CONF_LWIP_PBUF_POOL_BUFSIZE 00174 #undef PBUF_POOL_BUFSIZE 00175 #define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(MBED_CONF_LWIP_PBUF_POOL_BUFSIZE) 00176 #else 00177 #ifndef PBUF_POOL_BUFSIZE 00178 #if LWIP_IPV6 00179 #define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) 00180 #elif LWIP_IPV4 00181 #define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+20+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) 00182 #endif 00183 #endif 00184 #endif 00185 00186 #ifdef MBED_CONF_LWIP_MEM_SIZE 00187 #undef MEM_SIZE 00188 #define MEM_SIZE MBED_CONF_LWIP_MEM_SIZE 00189 #endif 00190 00191 // One tcp_pcb_listen is needed for each TCPServer. 00192 // Each requires 72 bytes of RAM. 00193 #ifdef MBED_CONF_LWIP_TCP_SERVER_MAX 00194 #define MEMP_NUM_TCP_PCB_LISTEN MBED_CONF_LWIP_TCP_SERVER_MAX 00195 #else 00196 #define MEMP_NUM_TCP_PCB_LISTEN 4 00197 #endif 00198 00199 // One is tcp_pcb needed for each TCPSocket. 00200 // Each requires 196 bytes of RAM. 00201 #ifdef MBED_CONF_LWIP_TCP_SOCKET_MAX 00202 #define MEMP_NUM_TCP_PCB MBED_CONF_LWIP_TCP_SOCKET_MAX 00203 #else 00204 #define MEMP_NUM_TCP_PCB 4 00205 #endif 00206 00207 // One udp_pcb is needed for each UDPSocket. 00208 // Each requires 84 bytes of RAM (total rounded to multiple of 512). 00209 #ifdef MBED_CONF_LWIP_UDP_SOCKET_MAX 00210 #define MEMP_NUM_UDP_PCB MBED_CONF_LWIP_UDP_SOCKET_MAX 00211 #else 00212 #define MEMP_NUM_UDP_PCB 4 00213 #endif 00214 00215 // Number of non-pool pbufs. 00216 // Each requires 92 bytes of RAM. 00217 #ifndef MEMP_NUM_PBUF 00218 #define MEMP_NUM_PBUF 8 00219 #endif 00220 00221 // Each netbuf requires 64 bytes of RAM. 00222 #ifndef MEMP_NUM_NETBUF 00223 #define MEMP_NUM_NETBUF 8 00224 #endif 00225 00226 // One netconn is needed for each UDPSocket, TCPSocket or TCPServer. 00227 // Each requires 236 bytes of RAM (total rounded to multiple of 512). 00228 #ifdef MBED_CONF_LWIP_SOCKET_MAX 00229 #define MEMP_NUM_NETCONN MBED_CONF_LWIP_SOCKET_MAX 00230 #else 00231 #define MEMP_NUM_NETCONN 4 00232 #endif 00233 00234 #if MBED_CONF_LWIP_TCP_ENABLED 00235 #define LWIP_TCP 1 00236 #define TCP_OVERSIZE 0 00237 #define LWIP_TCP_KEEPALIVE 1 00238 #else 00239 #define LWIP_TCP 0 00240 #endif 00241 00242 #define LWIP_DNS 1 00243 // Only DNS address storage is enabled 00244 #define LWIP_FULL_DNS 0 00245 #define LWIP_SOCKET 0 00246 00247 #define SO_REUSE 1 00248 00249 // Support Multicast 00250 #include "stdlib.h" 00251 #define LWIP_IGMP LWIP_IPV4 00252 #define LWIP_RAND() lwip_get_random() 00253 00254 #define LWIP_COMPAT_SOCKETS 0 00255 #define LWIP_POSIX_SOCKETS_IO_NAMES 0 00256 #define LWIP_SO_RCVTIMEO 1 00257 00258 #define LWIP_BROADCAST_PING 1 00259 00260 // Fragmentation on, as per IPv4 default 00261 #define LWIP_IPV6_FRAG LWIP_IPV6 00262 00263 // Queuing "disabled", as per IPv4 default (so actually queues 1) 00264 #define LWIP_ND6_QUEUEING 0 00265 00266 // Debug Options 00267 #define NETIF_DEBUG LWIP_DBG_OFF 00268 #define PBUF_DEBUG LWIP_DBG_OFF 00269 #define API_LIB_DEBUG LWIP_DBG_OFF 00270 #define API_MSG_DEBUG LWIP_DBG_OFF 00271 #define SOCKETS_DEBUG LWIP_DBG_OFF 00272 #define ICMP_DEBUG LWIP_DBG_OFF 00273 #define IGMP_DEBUG LWIP_DBG_OFF 00274 #define INET_DEBUG LWIP_DBG_OFF 00275 #define IP_DEBUG LWIP_DBG_OFF 00276 #define IP_REASS_DEBUG LWIP_DBG_OFF 00277 #define RAW_DEBUG LWIP_DBG_OFF 00278 #define MEM_DEBUG LWIP_DBG_OFF 00279 #define MEMP_DEBUG LWIP_DBG_OFF 00280 #define SYS_DEBUG LWIP_DBG_OFF 00281 #define TIMERS_DEBUG LWIP_DBG_OFF 00282 #define TCP_DEBUG LWIP_DBG_OFF 00283 #define TCP_INPUT_DEBUG LWIP_DBG_OFF 00284 #define TCP_FR_DEBUG LWIP_DBG_OFF 00285 #define TCP_RTO_DEBUG LWIP_DBG_OFF 00286 #define TCP_CWND_DEBUG LWIP_DBG_OFF 00287 #define TCP_WND_DEBUG LWIP_DBG_OFF 00288 #define TCP_OUTPUT_DEBUG LWIP_DBG_OFF 00289 #define TCP_RST_DEBUG LWIP_DBG_OFF 00290 #define TCP_QLEN_DEBUG LWIP_DBG_OFF 00291 #define UDP_DEBUG LWIP_DBG_OFF 00292 #define TCPIP_DEBUG LWIP_DBG_OFF 00293 #define SLIP_DEBUG LWIP_DBG_OFF 00294 #define DHCP_DEBUG LWIP_DBG_OFF 00295 #define AUTOIP_DEBUG LWIP_DBG_OFF 00296 #define DNS_DEBUG LWIP_DBG_OFF 00297 #define IP6_DEBUG LWIP_DBG_OFF 00298 00299 #if MBED_CONF_LWIP_ENABLE_PPP_TRACE 00300 #define PPP_DEBUG LWIP_DBG_ON 00301 #else 00302 #define PPP_DEBUG LWIP_DBG_OFF 00303 #endif //MBED_CONF_LWIP_ENABLE_PPP_TRACE 00304 #define ETHARP_DEBUG LWIP_DBG_OFF 00305 #define UDP_LPC_EMAC LWIP_DBG_OFF 00306 00307 #ifdef LWIP_DEBUG 00308 #define MEMP_OVERFLOW_CHECK 1 00309 #define MEMP_SANITY_CHECK 1 00310 #define LWIP_DBG_TYPES_ON LWIP_DBG_ON 00311 #define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL 00312 #else 00313 #define LWIP_NOASSERT 1 00314 #define LWIP_STATS 0 00315 #endif 00316 00317 #define TRACE_TO_ASCII_HEX_DUMP 0 00318 00319 #define LWIP_PLATFORM_BYTESWAP 1 00320 00321 #define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 1 00322 00323 // Interface type configuration 00324 00325 #if MBED_CONF_LWIP_ETHERNET_ENABLED 00326 #define LWIP_ARP 1 00327 #define LWIP_ETHERNET 1 00328 #define LWIP_DHCP LWIP_IPV4 00329 #else 00330 #define LWIP_ARP 0 00331 #define LWIP_ETHERNET 0 00332 #endif // MBED_CONF_LWIP_ETHERNET_ENABLED 00333 00334 // Note generic macro name used rather than MBED_CONF_LWIP_PPP_ENABLED 00335 // to allow users like PPPCellularInterface to detect that nsapi_ppp.h is available. 00336 #if NSAPI_PPP_AVAILABLE 00337 #define PPP_SUPPORT 1 00338 #if MBED_CONF_LWIP_IPV6_ENABLED 00339 #define PPP_IPV6_SUPPORT 1 00340 // Disable DAD for PPP 00341 #define LWIP_IPV6_DUP_DETECT_ATTEMPTS 0 00342 #endif 00343 #define CHAP_SUPPORT 1 00344 #define PPP_INPROC_IRQ_SAFE 1 00345 // Save RAM 00346 #define PAP_SUPPORT 0 00347 #define VJ_SUPPORT 0 00348 #define PRINTPKT_SUPPORT 0 00349 00350 // Broadcast 00351 #define IP_SOF_BROADCAST 0 00352 #define IP_SOF_BROADCAST_RECV 0 00353 00354 #define MAXNAMELEN 64 /* max length of hostname or name for auth */ 00355 #define MAXSECRETLEN 64 00356 #endif // NSAPI_PPP_AVAILABLE 00357 00358 // Make sure we default these to off, so 00359 // LWIP doesn't default to on 00360 #ifndef LWIP_ARP 00361 #define LWIP_ARP 0 00362 #endif 00363 // Checksum-on-copy disabled due to https://savannah.nongnu.org/bugs/?50914 00364 #define LWIP_CHECKSUM_ON_COPY 0 00365 00366 #define LWIP_NETIF_HOSTNAME 1 00367 #define LWIP_NETIF_STATUS_CALLBACK 1 00368 #define LWIP_NETIF_LINK_CALLBACK 1 00369 00370 #define DNS_TABLE_SIZE 2 00371 #define DNS_MAX_NAME_LENGTH 128 00372 00373 #include "lwip_random.h" 00374 #include "lwip_tcp_isn.h" 00375 #define LWIP_HOOK_TCP_ISN lwip_hook_tcp_isn 00376 #ifdef MBEDTLS_MD5_C 00377 #include "mbedtls/inc/mbedtls/md5.h" 00378 #define LWIP_USE_EXTERNAL_MBEDTLS 1 00379 #endif 00380 00381 #endif /* LWIPOPTS_H_ */
Generated on Tue Aug 9 2022 00:37:12 by
 1.7.2
 1.7.2