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.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
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 #include "nsapi_types.h" 00028 #include "mbed_retarget.h" 00029 00030 // Operating System 00031 #define NO_SYS 0 00032 00033 #if !MBED_CONF_LWIP_IPV4_ENABLED && !MBED_CONF_LWIP_IPV6_ENABLED 00034 #error "Either IPv4 or IPv6 must be enabled." 00035 #endif 00036 00037 #define LWIP_IPV4 MBED_CONF_LWIP_IPV4_ENABLED 00038 00039 #define LWIP_IPV6 MBED_CONF_LWIP_IPV6_ENABLED 00040 00041 #define LWIP_PROVIDE_ERRNO 0 00042 00043 // On dual stack configuration how long to wait for both or preferred stack 00044 // addresses before completing bring up. 00045 #if LWIP_IPV4 && LWIP_IPV6 00046 #if MBED_CONF_LWIP_ADDR_TIMEOUT_MODE 00047 #define BOTH_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT 00048 #define PREF_ADDR_TIMEOUT 0 00049 #else 00050 #define PREF_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT 00051 #define BOTH_ADDR_TIMEOUT 0 00052 #endif 00053 #else 00054 #define PREF_ADDR_TIMEOUT 0 00055 #define BOTH_ADDR_TIMEOUT 0 00056 #endif 00057 00058 00059 #define DHCP_TIMEOUT MBED_CONF_LWIP_DHCP_TIMEOUT 00060 00061 #define LINK_TIMEOUT 60 00062 00063 #define PREF_IPV4 1 00064 #define PREF_IPV6 2 00065 00066 #if MBED_CONF_LWIP_IP_VER_PREF == 6 00067 #define IP_VERSION_PREF PREF_IPV6 00068 #elif MBED_CONF_LWIP_IP_VER_PREF == 4 00069 #define IP_VERSION_PREF PREF_IPV4 00070 #else 00071 #error "Either IPv4 or IPv6 must be preferred." 00072 #endif 00073 00074 #undef LWIP_DEBUG 00075 #if MBED_CONF_LWIP_DEBUG_ENABLED 00076 #define LWIP_DEBUG 1 00077 #endif 00078 00079 #if NO_SYS == 0 00080 #include "cmsis_os2.h" 00081 00082 #define SYS_LIGHTWEIGHT_PROT 1 00083 00084 #define LWIP_RAW MBED_CONF_LWIP_RAW_SOCKET_ENABLED 00085 00086 #define MEMP_NUM_TCPIP_MSG_INPKT MBED_CONF_LWIP_MEMP_NUM_TCPIP_MSG_INPKT 00087 00088 // Thread stacks use 8-byte alignment 00089 #define LWIP_ALIGN_UP(pos, align) ((pos) % (align) ? (pos) + ((align) - (pos) % (align)) : (pos)) 00090 00091 #ifdef LWIP_DEBUG 00092 // For LWIP debug, double the stack 00093 #define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE*2, 8) 00094 #elif MBED_DEBUG 00095 // When debug is enabled on the build increase stack 25 percent 00096 #define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE + MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE / 4, 8) 00097 #else 00098 #define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE, 8) 00099 #endif 00100 00101 // Thread priority (osPriorityNormal by default) 00102 #define TCPIP_THREAD_PRIO (MBED_CONF_LWIP_TCPIP_THREAD_PRIORITY) 00103 00104 #ifdef LWIP_DEBUG 00105 #define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE*2, 8) 00106 #else 00107 #define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE, 8) 00108 #endif 00109 00110 #define MEMP_NUM_SYS_TIMEOUT 16 00111 00112 #define sys_msleep(ms) sys_msleep(ms) 00113 00114 #endif 00115 00116 // 32-bit alignment 00117 #define MEM_ALIGNMENT 4 00118 00119 #define LWIP_RAM_HEAP_POINTER lwip_ram_heap 00120 00121 // Number of simultaneously queued TCP segments. 00122 #define MEMP_NUM_TCP_SEG MBED_CONF_LWIP_MEMP_NUM_TCP_SEG 00123 00124 // TCP Maximum segment size. 00125 #define TCP_MSS MBED_CONF_LWIP_TCP_MSS 00126 00127 // TCP sender buffer space (bytes). 00128 #define TCP_SND_BUF MBED_CONF_LWIP_TCP_SND_BUF 00129 00130 // TCP sender buffer space (bytes). 00131 #define TCP_WND MBED_CONF_LWIP_TCP_WND 00132 00133 #define TCP_MAXRTX MBED_CONF_LWIP_TCP_MAXRTX 00134 00135 #define TCP_SYNMAXRTX MBED_CONF_LWIP_TCP_SYNMAXRTX 00136 00137 // Number of pool pbufs. 00138 // Each requires 684 bytes of RAM (if MSS=536 and PBUF_POOL_BUFSIZE defaulting to be based on MSS) 00139 #define PBUF_POOL_SIZE MBED_CONF_LWIP_PBUF_POOL_SIZE 00140 00141 #ifdef MBED_CONF_LWIP_PBUF_POOL_BUFSIZE 00142 #undef PBUF_POOL_BUFSIZE 00143 #define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(MBED_CONF_LWIP_PBUF_POOL_BUFSIZE) 00144 #else 00145 #ifndef PBUF_POOL_BUFSIZE 00146 #if LWIP_IPV6 00147 #define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) 00148 #elif LWIP_IPV4 00149 #define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+20+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) 00150 #endif 00151 #endif 00152 #endif 00153 00154 #define MEM_SIZE MBED_CONF_LWIP_MEM_SIZE 00155 00156 // One tcp_pcb_listen is needed for each TCPServer. 00157 // Each requires 72 bytes of RAM. 00158 #define MEMP_NUM_TCP_PCB_LISTEN MBED_CONF_LWIP_TCP_SERVER_MAX 00159 00160 // One is tcp_pcb needed for each TCPSocket. 00161 // Each requires 196 bytes of RAM. 00162 #define MEMP_NUM_TCP_PCB MBED_CONF_LWIP_TCP_SOCKET_MAX 00163 00164 // One udp_pcb is needed for each UDPSocket. 00165 // Each requires 84 bytes of RAM (total rounded to multiple of 512). 00166 #define MEMP_NUM_UDP_PCB MBED_CONF_LWIP_UDP_SOCKET_MAX 00167 00168 // Number of non-pool pbufs. 00169 // Each requires 92 bytes of RAM. 00170 #define MEMP_NUM_PBUF MBED_CONF_LWIP_NUM_PBUF 00171 00172 // Each netbuf requires 64 bytes of RAM. 00173 #define MEMP_NUM_NETBUF MBED_CONF_LWIP_NUM_NETBUF 00174 00175 // One netconn is needed for each UDPSocket, TCPSocket or TCPServer. 00176 // Each requires 236 bytes of RAM (total rounded to multiple of 512). 00177 #define MEMP_NUM_NETCONN MBED_CONF_LWIP_SOCKET_MAX 00178 00179 #if MBED_CONF_LWIP_TCP_ENABLED 00180 #define LWIP_TCP 1 00181 #define TCP_OVERSIZE 0 00182 #define LWIP_TCP_KEEPALIVE 1 00183 00184 #define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT 00185 00186 #else 00187 #define LWIP_TCP 0 00188 #endif 00189 00190 #define LWIP_DNS 1 00191 // Only DNS address storage is enabled 00192 #define LWIP_FULL_DNS 0 00193 #define LWIP_SOCKET 0 00194 00195 #define SO_REUSE 1 00196 00197 // Support Multicast 00198 #include "stdlib.h" 00199 #define LWIP_IGMP LWIP_IPV4 00200 #define LWIP_RAND() lwip_get_random() 00201 00202 #define LWIP_COMPAT_SOCKETS 0 00203 #define LWIP_POSIX_SOCKETS_IO_NAMES 0 00204 #define LWIP_SO_RCVTIMEO 1 00205 00206 #define LWIP_BROADCAST_PING 1 00207 00208 // Fragmentation on, as per IPv4 default 00209 #define LWIP_IPV6_FRAG LWIP_IPV6 00210 00211 // Queuing "disabled", as per IPv4 default (so actually queues 1) 00212 #define LWIP_ND6_QUEUEING 0 00213 00214 // Debug Options 00215 #define NETIF_DEBUG LWIP_DBG_OFF 00216 #define PBUF_DEBUG LWIP_DBG_OFF 00217 #define API_LIB_DEBUG LWIP_DBG_OFF 00218 #define API_MSG_DEBUG LWIP_DBG_OFF 00219 #define SOCKETS_DEBUG LWIP_DBG_OFF 00220 #define ICMP_DEBUG LWIP_DBG_OFF 00221 #define IGMP_DEBUG LWIP_DBG_OFF 00222 #define INET_DEBUG LWIP_DBG_OFF 00223 #define IP_DEBUG LWIP_DBG_OFF 00224 #define IP_REASS_DEBUG LWIP_DBG_OFF 00225 #define RAW_DEBUG LWIP_DBG_OFF 00226 #define MEM_DEBUG LWIP_DBG_OFF 00227 #define MEMP_DEBUG LWIP_DBG_OFF 00228 #define SYS_DEBUG LWIP_DBG_OFF 00229 #define TIMERS_DEBUG LWIP_DBG_OFF 00230 #define TCP_DEBUG LWIP_DBG_OFF 00231 #define TCP_INPUT_DEBUG LWIP_DBG_OFF 00232 #define TCP_FR_DEBUG LWIP_DBG_OFF 00233 #define TCP_RTO_DEBUG LWIP_DBG_OFF 00234 #define TCP_CWND_DEBUG LWIP_DBG_OFF 00235 #define TCP_WND_DEBUG LWIP_DBG_OFF 00236 #define TCP_OUTPUT_DEBUG LWIP_DBG_OFF 00237 #define TCP_RST_DEBUG LWIP_DBG_OFF 00238 #define TCP_QLEN_DEBUG LWIP_DBG_OFF 00239 #define UDP_DEBUG LWIP_DBG_OFF 00240 #define TCPIP_DEBUG LWIP_DBG_OFF 00241 #define SLIP_DEBUG LWIP_DBG_OFF 00242 #define DHCP_DEBUG LWIP_DBG_OFF 00243 #define AUTOIP_DEBUG LWIP_DBG_OFF 00244 #define DNS_DEBUG LWIP_DBG_OFF 00245 #define IP6_DEBUG LWIP_DBG_OFF 00246 00247 #define ETHARP_DEBUG LWIP_DBG_OFF 00248 #define UDP_LPC_EMAC LWIP_DBG_OFF 00249 00250 #ifdef LWIP_DEBUG 00251 #define MEMP_OVERFLOW_CHECK 1 00252 #define MEMP_SANITY_CHECK 1 00253 #define LWIP_DBG_TYPES_ON LWIP_DBG_ON 00254 #define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL 00255 #else 00256 #define LWIP_NOASSERT 1 00257 #define LWIP_STATS 0 00258 #endif 00259 00260 #define TRACE_TO_ASCII_HEX_DUMP 0 00261 00262 #define LWIP_PLATFORM_BYTESWAP 1 00263 00264 #define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 1 00265 00266 // Interface type configuration 00267 00268 #if MBED_CONF_LWIP_ETHERNET_ENABLED 00269 #define LWIP_ARP 1 00270 #define LWIP_ETHERNET 1 00271 #define LWIP_DHCP LWIP_IPV4 00272 #else 00273 #define LWIP_ARP 0 00274 #define LWIP_ETHERNET 0 00275 #endif // MBED_CONF_LWIP_ETHERNET_ENABLED 00276 00277 #if MBED_CONF_LWIP_L3IP_ENABLED 00278 #define LWIP_L3IP 1 00279 #else 00280 #define LWIP_L3IP 0 00281 #endif 00282 00283 //Maximum size of network interface name 00284 #define INTERFACE_NAME_MAX_SIZE NSAPI_INTERFACE_NAME_MAX_SIZE 00285 // Note generic macro name used rather than MBED_CONF_LWIP_PPP_ENABLED 00286 // to allow users like PPPCellularInterface to detect that nsapi_ppp.h is available. 00287 00288 // Enable PPP for now either from lwIP PPP configuration (obsolete) or from PPP service configuration 00289 #if MBED_CONF_PPP_ENABLED || MBED_CONF_LWIP_PPP_ENABLED 00290 00291 #define PPP_SUPPORT 1 00292 00293 #if MBED_CONF_PPP_IPV4_ENABLED || MBED_CONF_LWIP_IPV4_ENABLED 00294 #define LWIP 0x11991199 00295 #if (MBED_CONF_NSAPI_DEFAULT_STACK == LWIP) && !MBED_CONF_LWIP_IPV4_ENABLED 00296 #error LWIP: IPv4 PPP enabled but not IPv4 00297 #endif 00298 #undef LWIP 00299 #define PPP_IPV4_SUPPORT 1 00300 #endif 00301 00302 #if MBED_CONF_PPP_IPV6_ENABLED || MBED_CONF_LWIP_IPV6_ENABLED 00303 #define LWIP 0x11991199 00304 #if (MBED_CONF_NSAPI_DEFAULT_STACK == LWIP) && !MBED_CONF_LWIP_IPV6_ENABLED 00305 #error LWIP: IPv6 PPP enabled but not IPv6 00306 #endif 00307 #undef LWIP 00308 #define PPP_IPV6_SUPPORT 1 00309 // Later to be dynamic for use for multiple interfaces 00310 #define LWIP_IPV6_DUP_DETECT_ATTEMPTS 0 00311 #endif 00312 00313 #endif 00314 00315 // Make sure we default these to off, so 00316 // LWIP doesn't default to on 00317 #ifndef LWIP_ARP 00318 #define LWIP_ARP 0 00319 #endif 00320 00321 // Checksum-on-copy disabled due to https://savannah.nongnu.org/bugs/?50914 00322 #define LWIP_CHECKSUM_ON_COPY 0 00323 00324 #define LWIP_NETIF_HOSTNAME 1 00325 #define LWIP_NETIF_STATUS_CALLBACK 1 00326 #define LWIP_NETIF_LINK_CALLBACK 1 00327 00328 #define DNS_TABLE_SIZE 2 00329 #define DNS_MAX_NAME_LENGTH 128 00330 00331 #include "lwip_random.h" 00332 #include "lwip_tcp_isn.h" 00333 #define LWIP_HOOK_TCP_ISN lwip_hook_tcp_isn 00334 #ifdef MBEDTLS_MD5_C 00335 #define LWIP_USE_EXTERNAL_MBEDTLS 1 00336 #else 00337 #define LWIP_USE_EXTERNAL_MBEDTLS 0 00338 #endif 00339 00340 #endif /* LWIPOPTS_H_ */
Generated on Tue Jul 12 2022 13:54:31 by
1.7.2