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 pool pbufs. 00143 // Each requires 684 bytes of RAM (if MSS=536 and PBUF_POOL_BUFSIZE defaulting to be based on MSS) 00144 #ifdef MBED_CONF_LWIP_PBUF_POOL_SIZE 00145 #undef PBUF_POOL_SIZE 00146 #define PBUF_POOL_SIZE MBED_CONF_LWIP_PBUF_POOL_SIZE 00147 #else 00148 #ifndef PBUF_POOL_SIZE 00149 #define PBUF_POOL_SIZE 5 00150 #endif 00151 #endif 00152 00153 #ifdef MBED_CONF_LWIP_PBUF_POOL_BUFSIZE 00154 #undef PBUF_POOL_BUFSIZE 00155 #define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(MBED_CONF_LWIP_PBUF_POOL_BUFSIZE) 00156 #else 00157 #ifndef PBUF_POOL_BUFSIZE 00158 #if LWIP_IPV6 00159 #define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) 00160 #elif LWIP_IPV4 00161 #define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+20+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) 00162 #endif 00163 #endif 00164 #endif 00165 00166 #ifdef MBED_CONF_LWIP_MEM_SIZE 00167 #undef MEM_SIZE 00168 #define MEM_SIZE MBED_CONF_LWIP_MEM_SIZE 00169 #endif 00170 00171 // One tcp_pcb_listen is needed for each TCPServer. 00172 // Each requires 72 bytes of RAM. 00173 #ifdef MBED_CONF_LWIP_TCP_SERVER_MAX 00174 #define MEMP_NUM_TCP_PCB_LISTEN MBED_CONF_LWIP_TCP_SERVER_MAX 00175 #else 00176 #define MEMP_NUM_TCP_PCB_LISTEN 4 00177 #endif 00178 00179 // One is tcp_pcb needed for each TCPSocket. 00180 // Each requires 196 bytes of RAM. 00181 #ifdef MBED_CONF_LWIP_TCP_SOCKET_MAX 00182 #define MEMP_NUM_TCP_PCB MBED_CONF_LWIP_TCP_SOCKET_MAX 00183 #else 00184 #define MEMP_NUM_TCP_PCB 4 00185 #endif 00186 00187 // One udp_pcb is needed for each UDPSocket. 00188 // Each requires 84 bytes of RAM (total rounded to multiple of 512). 00189 #ifdef MBED_CONF_LWIP_UDP_SOCKET_MAX 00190 #define MEMP_NUM_UDP_PCB MBED_CONF_LWIP_UDP_SOCKET_MAX 00191 #else 00192 #define MEMP_NUM_UDP_PCB 4 00193 #endif 00194 00195 // Number of non-pool pbufs. 00196 // Each requires 92 bytes of RAM. 00197 #ifndef MEMP_NUM_PBUF 00198 #define MEMP_NUM_PBUF 8 00199 #endif 00200 00201 // Each netbuf requires 64 bytes of RAM. 00202 #ifndef MEMP_NUM_NETBUF 00203 #define MEMP_NUM_NETBUF 8 00204 #endif 00205 00206 // One netconn is needed for each UDPSocket, TCPSocket or TCPServer. 00207 // Each requires 236 bytes of RAM (total rounded to multiple of 512). 00208 #ifdef MBED_CONF_LWIP_SOCKET_MAX 00209 #define MEMP_NUM_NETCONN MBED_CONF_LWIP_SOCKET_MAX 00210 #else 00211 #define MEMP_NUM_NETCONN 4 00212 #endif 00213 00214 #if MBED_CONF_LWIP_TCP_ENABLED 00215 #define LWIP_TCP 1 00216 #define TCP_OVERSIZE 0 00217 #define LWIP_TCP_KEEPALIVE 1 00218 #else 00219 #define LWIP_TCP 0 00220 #endif 00221 00222 #define LWIP_DNS 1 00223 // Only DNS address storage is enabled 00224 #define LWIP_FULL_DNS 0 00225 #define LWIP_SOCKET 0 00226 00227 #define SO_REUSE 1 00228 00229 // Support Multicast 00230 #include "stdlib.h" 00231 #define LWIP_IGMP LWIP_IPV4 00232 #define LWIP_RAND() lwip_get_random() 00233 00234 #define LWIP_COMPAT_SOCKETS 0 00235 #define LWIP_POSIX_SOCKETS_IO_NAMES 0 00236 #define LWIP_SO_RCVTIMEO 1 00237 00238 #define LWIP_BROADCAST_PING 1 00239 00240 // Fragmentation on, as per IPv4 default 00241 #define LWIP_IPV6_FRAG LWIP_IPV6 00242 00243 // Queuing "disabled", as per IPv4 default (so actually queues 1) 00244 #define LWIP_ND6_QUEUEING 0 00245 00246 // Debug Options 00247 #define NETIF_DEBUG LWIP_DBG_OFF 00248 #define PBUF_DEBUG LWIP_DBG_OFF 00249 #define API_LIB_DEBUG LWIP_DBG_OFF 00250 #define API_MSG_DEBUG LWIP_DBG_OFF 00251 #define SOCKETS_DEBUG LWIP_DBG_OFF 00252 #define ICMP_DEBUG LWIP_DBG_OFF 00253 #define IGMP_DEBUG LWIP_DBG_OFF 00254 #define INET_DEBUG LWIP_DBG_OFF 00255 #define IP_DEBUG LWIP_DBG_OFF 00256 #define IP_REASS_DEBUG LWIP_DBG_OFF 00257 #define RAW_DEBUG LWIP_DBG_OFF 00258 #define MEM_DEBUG LWIP_DBG_OFF 00259 #define MEMP_DEBUG LWIP_DBG_OFF 00260 #define SYS_DEBUG LWIP_DBG_OFF 00261 #define TIMERS_DEBUG LWIP_DBG_OFF 00262 #define TCP_DEBUG LWIP_DBG_OFF 00263 #define TCP_INPUT_DEBUG LWIP_DBG_OFF 00264 #define TCP_FR_DEBUG LWIP_DBG_OFF 00265 #define TCP_RTO_DEBUG LWIP_DBG_OFF 00266 #define TCP_CWND_DEBUG LWIP_DBG_OFF 00267 #define TCP_WND_DEBUG LWIP_DBG_OFF 00268 #define TCP_OUTPUT_DEBUG LWIP_DBG_OFF 00269 #define TCP_RST_DEBUG LWIP_DBG_OFF 00270 #define TCP_QLEN_DEBUG LWIP_DBG_OFF 00271 #define UDP_DEBUG LWIP_DBG_OFF 00272 #define TCPIP_DEBUG LWIP_DBG_OFF 00273 #define SLIP_DEBUG LWIP_DBG_OFF 00274 #define DHCP_DEBUG LWIP_DBG_OFF 00275 #define AUTOIP_DEBUG LWIP_DBG_OFF 00276 #define DNS_DEBUG LWIP_DBG_OFF 00277 #define IP6_DEBUG LWIP_DBG_OFF 00278 00279 #if MBED_CONF_LWIP_ENABLE_PPP_TRACE 00280 #define PPP_DEBUG LWIP_DBG_ON 00281 #else 00282 #define PPP_DEBUG LWIP_DBG_OFF 00283 #endif //MBED_CONF_LWIP_ENABLE_PPP_TRACE 00284 #define ETHARP_DEBUG LWIP_DBG_OFF 00285 #define UDP_LPC_EMAC LWIP_DBG_OFF 00286 00287 #ifdef LWIP_DEBUG 00288 #define MEMP_OVERFLOW_CHECK 1 00289 #define MEMP_SANITY_CHECK 1 00290 #define LWIP_DBG_TYPES_ON LWIP_DBG_ON 00291 #define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL 00292 #else 00293 #define LWIP_NOASSERT 1 00294 #define LWIP_STATS 0 00295 #endif 00296 00297 #define TRACE_TO_ASCII_HEX_DUMP 0 00298 00299 #define LWIP_PLATFORM_BYTESWAP 1 00300 00301 #define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 1 00302 00303 // Interface type configuration 00304 00305 #if MBED_CONF_LWIP_ETHERNET_ENABLED 00306 #define LWIP_ARP 1 00307 #define LWIP_ETHERNET 1 00308 #define LWIP_DHCP LWIP_IPV4 00309 #else 00310 #define LWIP_ARP 0 00311 #define LWIP_ETHERNET 0 00312 #endif // MBED_CONF_LWIP_ETHERNET_ENABLED 00313 00314 // Note generic macro name used rather than MBED_CONF_LWIP_PPP_ENABLED 00315 // to allow users like PPPCellularInterface to detect that nsapi_ppp.h is available. 00316 #if NSAPI_PPP_AVAILABLE 00317 #define PPP_SUPPORT 1 00318 #if MBED_CONF_LWIP_IPV6_ENABLED 00319 #define PPP_IPV6_SUPPORT 1 00320 // Disable DAD for PPP 00321 #define LWIP_IPV6_DUP_DETECT_ATTEMPTS 0 00322 #endif 00323 #define CHAP_SUPPORT 1 00324 #define PPP_INPROC_IRQ_SAFE 1 00325 // Save RAM 00326 #define PAP_SUPPORT 0 00327 #define VJ_SUPPORT 0 00328 #define PRINTPKT_SUPPORT 0 00329 00330 // Broadcast 00331 #define IP_SOF_BROADCAST 0 00332 #define IP_SOF_BROADCAST_RECV 0 00333 00334 #define MAXNAMELEN 64 /* max length of hostname or name for auth */ 00335 #define MAXSECRETLEN 64 00336 #endif // NSAPI_PPP_AVAILABLE 00337 00338 // Make sure we default these to off, so 00339 // LWIP doesn't default to on 00340 #ifndef LWIP_ARP 00341 #define LWIP_ARP 0 00342 #endif 00343 // Checksum-on-copy disabled due to https://savannah.nongnu.org/bugs/?50914 00344 #define LWIP_CHECKSUM_ON_COPY 0 00345 00346 #define LWIP_NETIF_HOSTNAME 1 00347 #define LWIP_NETIF_STATUS_CALLBACK 1 00348 #define LWIP_NETIF_LINK_CALLBACK 1 00349 00350 #define DNS_TABLE_SIZE 2 00351 #define DNS_MAX_NAME_LENGTH 128 00352 00353 #include "lwip_random.h" 00354 #include "lwip_tcp_isn.h" 00355 #define LWIP_HOOK_TCP_ISN lwip_hook_tcp_isn 00356 #ifdef MBEDTLS_MD5_C 00357 #include "mbedtls/inc/mbedtls/md5.h" 00358 #define LWIP_USE_EXTERNAL_MBEDTLS 1 00359 #endif 00360 00361 #endif /* LWIPOPTS_H_ */
Generated on Tue Jul 12 2022 12:44:53 by
