Marco Zecchini
/
Example_RTOS
Rtos API example
Embed:
(wiki syntax)
Show/hide line numbers
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 #if MBED_CONF_LWIP_ETHERNET_ENABLED 00023 #include "lwipopts_conf.h" 00024 #endif 00025 00026 // Workaround for Linux timeval 00027 #if defined (TOOLCHAIN_GCC) 00028 #define LWIP_TIMEVAL_PRIVATE 0 00029 #include <sys/time.h> 00030 #endif 00031 00032 // Operating System 00033 #define NO_SYS 0 00034 00035 #if MBED_CONF_LWIP_IPV4_ENABLED 00036 #define LWIP_IPV4 1 00037 #else 00038 #define LWIP_IPV4 0 00039 #endif 00040 #if MBED_CONF_LWIP_IPV6_ENABLED 00041 #define LWIP_IPV6 1 00042 #else 00043 #define LWIP_IPV6 0 00044 #endif 00045 #if !MBED_CONF_LWIP_IPV4_ENABLED && !MBED_CONF_LWIP_IPV6_ENABLED 00046 #error "Either IPv4 or IPv6 must be enabled." 00047 #endif 00048 00049 // On dual stack configuration how long to wait for both or preferred stack 00050 // addresses before completing bring up. 00051 #if LWIP_IPV4 && LWIP_IPV6 00052 #if MBED_CONF_LWIP_ADDR_TIMEOUT_MODE 00053 #define BOTH_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT 00054 #define PREF_ADDR_TIMEOUT 0 00055 #else 00056 #define PREF_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT 00057 #define BOTH_ADDR_TIMEOUT 0 00058 #endif 00059 #else 00060 #define PREF_ADDR_TIMEOUT 0 00061 #define BOTH_ADDR_TIMEOUT 0 00062 #endif 00063 00064 #define DHCP_TIMEOUT 60 00065 00066 #define PREF_IPV4 1 00067 #define PREF_IPV6 2 00068 00069 #if MBED_CONF_LWIP_IP_VER_PREF == 4 00070 #define IP_VERSION_PREF PREF_IPV4 00071 #endif 00072 #if MBED_CONF_LWIP_IP_VER_PREF == 6 00073 #define IP_VERSION_PREF PREF_IPV6 00074 #endif 00075 #ifndef IP_VERSION_PREF 00076 #error "Either IPv4 or IPv6 must be preferred." 00077 #endif 00078 00079 #undef LWIP_DEBUG 00080 #if MBED_CONF_LWIP_DEBUG_ENABLED 00081 #define LWIP_DEBUG 1 00082 #endif 00083 00084 #if NO_SYS == 0 00085 #include "cmsis_os2.h" 00086 00087 #define SYS_LIGHTWEIGHT_PROT 1 00088 00089 #define LWIP_RAW 0 00090 00091 #define TCPIP_MBOX_SIZE 8 00092 #define DEFAULT_TCP_RECVMBOX_SIZE 8 00093 #define DEFAULT_UDP_RECVMBOX_SIZE 8 00094 #define DEFAULT_RAW_RECVMBOX_SIZE 8 00095 #define DEFAULT_ACCEPTMBOX_SIZE 8 00096 00097 // Thread stack size for lwip tcpip thread 00098 #ifndef MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE 00099 #define MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE 1200 00100 #endif 00101 00102 #ifdef LWIP_DEBUG 00103 #define TCPIP_THREAD_STACKSIZE MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE*2 00104 #else 00105 #define TCPIP_THREAD_STACKSIZE MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE 00106 #endif 00107 00108 #define TCPIP_THREAD_PRIO (osPriorityNormal) 00109 00110 // Thread stack size for lwip system threads 00111 #ifndef MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE 00112 #define MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE 512 00113 #endif 00114 00115 // Thread stack size for private PPP thread 00116 #ifndef MBED_CONF_LWIP_PPP_THREAD_STACKSIZE 00117 #define MBED_CONF_LWIP_PPP_THREAD_STACKSIZE 768 00118 #endif 00119 00120 #ifdef LWIP_DEBUG 00121 #define DEFAULT_THREAD_STACKSIZE MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE*2 00122 #define PPP_THREAD_STACK_SIZE MBED_CONF_LWIP_PPP_THREAD_STACKSIZE*2 00123 #else 00124 #define DEFAULT_THREAD_STACKSIZE MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE 00125 #define PPP_THREAD_STACK_SIZE MBED_CONF_LWIP_PPP_THREAD_STACKSIZE 00126 #endif 00127 00128 #define MEMP_NUM_SYS_TIMEOUT 16 00129 00130 #define sys_msleep(ms) sys_msleep(ms) 00131 00132 #endif 00133 00134 // 32-bit alignment 00135 #define MEM_ALIGNMENT 4 00136 00137 #define LWIP_RAM_HEAP_POINTER lwip_ram_heap 00138 00139 // Number of pool pbufs. 00140 // Each requires 684 bytes of RAM (if MSS=536 and PBUF_POOL_BUFSIZE defaulting to be based on MSS) 00141 #ifdef MBED_CONF_LWIP_PBUF_POOL_SIZE 00142 #undef PBUF_POOL_SIZE 00143 #define PBUF_POOL_SIZE MBED_CONF_LWIP_PBUF_POOL_SIZE 00144 #else 00145 #ifndef PBUF_POOL_SIZE 00146 #define PBUF_POOL_SIZE 5 00147 #endif 00148 #endif 00149 00150 #ifdef MBED_CONF_LWIP_PBUF_POOL_BUFSIZE 00151 #undef PBUF_POOL_BUFSIZE 00152 #define PBUF_POOL_BUFSIZE MBED_CONF_LWIP_PBUF_POOL_BUFSIZE 00153 #endif 00154 00155 #ifdef MBED_CONF_LWIP_MEM_SIZE 00156 #undef MEM_SIZE 00157 #define MEM_SIZE MBED_CONF_LWIP_MEM_SIZE 00158 #endif 00159 00160 // One tcp_pcb_listen is needed for each TCPServer. 00161 // Each requires 72 bytes of RAM. 00162 #ifdef MBED_CONF_LWIP_TCP_SERVER_MAX 00163 #define MEMP_NUM_TCP_PCB_LISTEN MBED_CONF_LWIP_TCP_SERVER_MAX 00164 #else 00165 #define MEMP_NUM_TCP_PCB_LISTEN 4 00166 #endif 00167 00168 // One is tcp_pcb needed for each TCPSocket. 00169 // Each requires 196 bytes of RAM. 00170 #ifdef MBED_CONF_LWIP_TCP_SOCKET_MAX 00171 #define MEMP_NUM_TCP_PCB MBED_CONF_LWIP_TCP_SOCKET_MAX 00172 #else 00173 #define MEMP_NUM_TCP_PCB 4 00174 #endif 00175 00176 // One udp_pcb is needed for each UDPSocket. 00177 // Each requires 84 bytes of RAM (total rounded to multiple of 512). 00178 #ifdef MBED_CONF_LWIP_UDP_SOCKET_MAX 00179 #define MEMP_NUM_UDP_PCB MBED_CONF_LWIP_UDP_SOCKET_MAX 00180 #else 00181 #define MEMP_NUM_UDP_PCB 4 00182 #endif 00183 00184 // Number of non-pool pbufs. 00185 // Each requires 92 bytes of RAM. 00186 #ifndef MEMP_NUM_PBUF 00187 #define MEMP_NUM_PBUF 8 00188 #endif 00189 00190 // Each netbuf requires 64 bytes of RAM. 00191 #ifndef MEMP_NUM_NETBUF 00192 #define MEMP_NUM_NETBUF 8 00193 #endif 00194 00195 // One netconn is needed for each UDPSocket, TCPSocket or TCPServer. 00196 // Each requires 236 bytes of RAM (total rounded to multiple of 512). 00197 #ifdef MBED_CONF_LWIP_SOCKET_MAX 00198 #define MEMP_NUM_NETCONN MBED_CONF_LWIP_SOCKET_MAX 00199 #else 00200 #define MEMP_NUM_NETCONN 4 00201 #endif 00202 00203 #if MBED_CONF_LWIP_TCP_ENABLED 00204 #define LWIP_TCP 1 00205 #define TCP_QUEUE_OOSEQ 0 00206 #define TCP_OVERSIZE 0 00207 #define LWIP_TCP_KEEPALIVE 1 00208 #else 00209 #define LWIP_TCP 0 00210 #endif 00211 00212 #define LWIP_DNS 1 00213 #define LWIP_SOCKET 0 00214 00215 #define SO_REUSE 1 00216 00217 // Support Multicast 00218 #include "stdlib.h" 00219 #define LWIP_IGMP LWIP_IPV4 00220 #define LWIP_RAND() lwip_get_random() 00221 00222 #define LWIP_COMPAT_SOCKETS 0 00223 #define LWIP_POSIX_SOCKETS_IO_NAMES 0 00224 #define LWIP_SO_RCVTIMEO 1 00225 00226 #define LWIP_BROADCAST_PING 1 00227 00228 // Fragmentation on, as per IPv4 default 00229 #define LWIP_IPV6_FRAG LWIP_IPV6 00230 00231 // Queuing "disabled", as per IPv4 default (so actually queues 1) 00232 #define LWIP_ND6_QUEUEING 0 00233 00234 // Debug Options 00235 #define NETIF_DEBUG LWIP_DBG_OFF 00236 #define PBUF_DEBUG LWIP_DBG_OFF 00237 #define API_LIB_DEBUG LWIP_DBG_OFF 00238 #define API_MSG_DEBUG LWIP_DBG_OFF 00239 #define SOCKETS_DEBUG LWIP_DBG_OFF 00240 #define ICMP_DEBUG LWIP_DBG_OFF 00241 #define IGMP_DEBUG LWIP_DBG_OFF 00242 #define INET_DEBUG LWIP_DBG_OFF 00243 #define IP_DEBUG LWIP_DBG_OFF 00244 #define IP_REASS_DEBUG LWIP_DBG_OFF 00245 #define RAW_DEBUG LWIP_DBG_OFF 00246 #define MEM_DEBUG LWIP_DBG_OFF 00247 #define MEMP_DEBUG LWIP_DBG_OFF 00248 #define SYS_DEBUG LWIP_DBG_OFF 00249 #define TIMERS_DEBUG LWIP_DBG_OFF 00250 #define TCP_DEBUG LWIP_DBG_OFF 00251 #define TCP_INPUT_DEBUG LWIP_DBG_OFF 00252 #define TCP_FR_DEBUG LWIP_DBG_OFF 00253 #define TCP_RTO_DEBUG LWIP_DBG_OFF 00254 #define TCP_CWND_DEBUG LWIP_DBG_OFF 00255 #define TCP_WND_DEBUG LWIP_DBG_OFF 00256 #define TCP_OUTPUT_DEBUG LWIP_DBG_OFF 00257 #define TCP_RST_DEBUG LWIP_DBG_OFF 00258 #define TCP_QLEN_DEBUG LWIP_DBG_OFF 00259 #define UDP_DEBUG LWIP_DBG_OFF 00260 #define TCPIP_DEBUG LWIP_DBG_OFF 00261 #define SLIP_DEBUG LWIP_DBG_OFF 00262 #define DHCP_DEBUG LWIP_DBG_OFF 00263 #define AUTOIP_DEBUG LWIP_DBG_OFF 00264 #define DNS_DEBUG LWIP_DBG_OFF 00265 #define IP6_DEBUG LWIP_DBG_OFF 00266 00267 #if MBED_CONF_LWIP_ENABLE_PPP_TRACE 00268 #define PPP_DEBUG LWIP_DBG_ON 00269 #else 00270 #define PPP_DEBUG LWIP_DBG_OFF 00271 #endif //MBED_CONF_LWIP_ENABLE_PPP_TRACE 00272 #define ETHARP_DEBUG LWIP_DBG_OFF 00273 #define UDP_LPC_EMAC LWIP_DBG_OFF 00274 00275 #ifdef LWIP_DEBUG 00276 #define MEMP_OVERFLOW_CHECK 1 00277 #define MEMP_SANITY_CHECK 1 00278 #define LWIP_DBG_TYPES_ON LWIP_DBG_ON 00279 #define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL 00280 #else 00281 #define LWIP_NOASSERT 1 00282 #define LWIP_STATS 0 00283 #endif 00284 00285 #define TRACE_TO_ASCII_HEX_DUMP 0 00286 00287 #define LWIP_PLATFORM_BYTESWAP 1 00288 00289 #define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 1 00290 00291 // Interface type configuration 00292 00293 #if MBED_CONF_LWIP_ETHERNET_ENABLED 00294 #define LWIP_ARP 1 00295 #define LWIP_ETHERNET 1 00296 #define LWIP_DHCP LWIP_IPV4 00297 #else 00298 #define LWIP_ARP 0 00299 #define LWIP_ETHERNET 0 00300 #endif // MBED_CONF_LWIP_ETHERNET_ENABLED 00301 00302 // Note generic macro name used rather than MBED_CONF_LWIP_PPP_ENABLED 00303 // to allow users like PPPCellularInterface to detect that nsapi_ppp.h is available. 00304 #if NSAPI_PPP_AVAILABLE 00305 #define PPP_SUPPORT 1 00306 #if MBED_CONF_LWIP_IPV6_ENABLED 00307 #define PPP_IPV6_SUPPORT 1 00308 // Disable DAD for PPP 00309 #define LWIP_IPV6_DUP_DETECT_ATTEMPTS 0 00310 #endif 00311 #define CHAP_SUPPORT 1 00312 #define PPP_INPROC_IRQ_SAFE 1 00313 // Save RAM 00314 #define PAP_SUPPORT 0 00315 #define VJ_SUPPORT 0 00316 #define PRINTPKT_SUPPORT 0 00317 00318 // Broadcast 00319 #define IP_SOF_BROADCAST 0 00320 #define IP_SOF_BROADCAST_RECV 0 00321 00322 #define MAXNAMELEN 64 /* max length of hostname or name for auth */ 00323 #define MAXSECRETLEN 64 00324 #endif // NSAPI_PPP_AVAILABLE 00325 00326 // Make sure we default these to off, so 00327 // LWIP doesn't default to on 00328 #ifndef LWIP_ARP 00329 #define LWIP_ARP 0 00330 #endif 00331 // Checksum-on-copy disabled due to https://savannah.nongnu.org/bugs/?50914 00332 #define LWIP_CHECKSUM_ON_COPY 0 00333 00334 #define LWIP_NETIF_HOSTNAME 1 00335 #define LWIP_NETIF_STATUS_CALLBACK 1 00336 #define LWIP_NETIF_LINK_CALLBACK 1 00337 00338 #define DNS_TABLE_SIZE 2 00339 #define DNS_MAX_NAME_LENGTH 128 00340 00341 #include "lwip_random.h" 00342 #include "lwip_tcp_isn.h" 00343 #define LWIP_HOOK_TCP_ISN lwip_hook_tcp_isn 00344 #ifdef MBEDTLS_MD5_C 00345 #include "mbedtls/inc/mbedtls/md5.h" 00346 #define LWIP_USE_EXTERNAL_MBEDTLS 1 00347 #endif 00348 00349 #endif /* LWIPOPTS_H_ */
Generated on Sun Jul 17 2022 08:25:25 by 1.7.2