1 /** 2 ****************************************************************************** 3 * @file lwipopts.h 4 * @author MCD Application Team 5 * @version V1.0.0 6 * @date 11/20/2009 7 * @brief lwIP Options Configuration. 8 * This file is based on Utilities\lwip-1.3.1\src\include\lwip\opt.h 9 * and contains the lwIP configuration for the STM32F107 demonstration. 10 ****************************************************************************** 11 * @copy 12 * 13 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 14 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 15 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 16 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 17 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 18 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 19 * 20 * <h2><center>© COPYRIGHT 2009 STMicroelectronics</center></h2> 21 */ 22 23 #ifndef __LWIPOPTS_H__ 24 #define __LWIPOPTS_H__ 25 #include "cmsis_os.h" 26 27 // move from opt.h for bes adapter 28 #define LWIP_TCPIP_CORE_LOCKING 0 29 #define MEMP_NUM_SELECT_CB 8 30 #define MEMP_NUM_TCPIP_MSG_API 16 31 #define ETH_PAD_SIZE 2 32 #define LWIP_RAW 1 33 #define LWIP_DNS 1 34 #define SO_REUSE 1 35 #define SO_REUSE_RXTOALL 1 36 #define SNTP_SERVER_DNS 1 37 #define SNTP_STARTUP_DELAY 0 38 #define SNTP_RECV_TIMEOUT 5000 39 40 41 #define MAX_MSG_IN_LWIP_MBOX 50 42 43 /*----------------Thread Priority---------------------------------------------*/ 44 #define TCPIP_THREAD_PRIO osPriorityHigh 45 #define DEFAULT_THREAD_PRIO osPriorityNormal 46 47 /** 48 * SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain 49 * critical regions during buffer allocation, deallocation and memory 50 * allocation and deallocation. 51 */ 52 #define SYS_LIGHTWEIGHT_PROT 1 53 54 /** 55 * NO_SYS==1: Provides VERY minimal functionality. Otherwise, 56 * use lwIP facilities. 57 */ 58 #define NO_SYS 0 59 60 /* ---------- Memory options ---------- */ 61 #define MEM_LIBC_MALLOC 1 62 #if 0 63 extern void *rt_malloc(size_t size); 64 extern void *rt_calloc(size_t count, size_t size); 65 extern void rt_free(void *rmem); 66 #define mem_clib_free rt_free 67 #define mem_clib_malloc rt_malloc 68 #define mem_clib_calloc rt_calloc 69 #endif 70 71 #define MEMP_MEM_MALLOC 0 72 73 #define LWIP_COMPAT_MUTEX_ALLOWED (1) 74 75 /* MEM_ALIGNMENT: should be set to the alignment of the CPU for which 76 lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2 77 byte alignment -> define MEM_ALIGNMENT to 2. */ 78 #define MEM_ALIGNMENT 4 79 80 /* MEM_SIZE: the size of the heap memory. If the application will send 81 a lot of data that needs to be copied, this should be set high. */ 82 #define MEM_SIZE (20*1024) // used for Lwip malloc 83 84 #define MAX_SOCKETS_TCP 12 85 #define MAX_LISTENING_SOCKETS_TCP 4 86 #define MAX_SOCKETS_UDP 22 87 #define TCP_SND_BUF_COUNT 5 88 89 /* Value of TCP_SND_BUF_COUNT denotes the number of buffers and is set by 90 * CONFIG option available in the SDK 91 */ 92 /* Buffer size needed for TCP: Max. number of TCP sockets * Size of pbuf * 93 * Max. number of TCP sender buffers per socket 94 * 95 * Listening sockets for TCP servers do not require the same amount buffer 96 * space. Hence do not consider these sockets for memory computation 97 */ 98 #define TCP_MEM_SIZE (MAX_SOCKETS_TCP * \ 99 PBUF_POOL_BUFSIZE * (TCP_SND_BUF/TCP_MSS)) 100 101 /* Buffer size needed for UDP: Max. number of UDP sockets * Size of pbuf 102 */ 103 #define UDP_MEM_SIZE (MAX_SOCKETS_UDP * PBUF_POOL_BUFSIZE) 104 105 /* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application 106 sends a lot of data out of ROM (or other static memory), this 107 should be set high. */ 108 #define MEMP_NUM_PBUF 10 109 /* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One 110 per active UDP "connection". */ 111 #define MEMP_NUM_UDP_PCB (MAX_SOCKETS_UDP + 2) 112 /* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP 113 connections. */ 114 #define MEMP_NUM_TCP_PCB MAX_SOCKETS_TCP 115 /* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP 116 connections. */ 117 #define MEMP_NUM_TCP_PCB_LISTEN MAX_LISTENING_SOCKETS_TCP 118 /* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP 119 segments. */ 120 121 /** 122 * MEMP_NUM_SYS_TIMEOUT: the number of simulateously active timeouts. 123 * (requires NO_SYS==0) 124 */ 125 #define MEMP_NUM_SYS_TIMEOUT 12 126 127 /** 128 * MEMP_NUM_NETBUF: the number of struct netbufs. 129 * (only needed if you use the sequential API, like api_lib.c) 130 */ 131 132 #define MEMP_NUM_NETBUF 16 133 134 /** 135 * MEMP_NUM_NETCONN: the number of struct netconns. 136 * (only needed if you use the sequential API, like api_lib.c) 137 * 138 * This number corresponds to the maximum number of active sockets at any 139 * given point in time. This number must be sum of max. TCP sockets, max. TCP 140 * sockets used for listening, and max. number of UDP sockets 141 */ 142 #define MEMP_NUM_NETCONN (MAX_SOCKETS_TCP + \ 143 MAX_LISTENING_SOCKETS_TCP + MAX_SOCKETS_UDP) 144 145 /* ---------- Pbuf options ---------- */ 146 /* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */ 147 #define PBUF_POOL_SIZE 30 148 149 /* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */ 150 #define PBUF_POOL_BUFSIZE 1536 151 152 /* Enable IPv4 Auto IP */ 153 #ifdef CONFIG_AUTOIP 154 #define LWIP_AUTOIP 1 155 #define LWIP_DHCP_AUTOIP_COOP 1 156 #define LWIP_DHCP_AUTOIP_COOP_TRIES 5 157 #endif 158 159 #define DNS_TABLE_SIZE 2 // number of table entries, default 4 160 //#define DNS_MAX_NAME_LENGTH 64 // max. name length, default 256 161 #define DNS_MAX_SERVERS 2 // number of DNS servers, default 2 162 #define DNS_DOES_NAME_CHECK 1 // compare received name with given,def 0 163 #define DNS_MSG_SIZE 512 164 #define MDNS_MSG_SIZE 512 165 166 #define MDNS_TABLE_SIZE 1 // number of mDNS table entries 167 #define MDNS_MAX_SERVERS 1 // number of mDNS multicast addresses 168 /* TODO: Number of active UDP PCBs is equal to number of active UDP sockets plus 169 * two. Need to find the users of these 2 PCBs 170 */ 171 172 173 /* ---------- TCP options ---------- */ 174 #define LWIP_TCP 1 175 #define TCP_TTL 255 176 177 178 #define TCPIP_THREAD_STACKSIZE 25600 //8192 179 180 /* Controls if TCP should queue segments that arrive out of 181 order. Define to 0 if your device is low on memory. */ 182 #define TCP_QUEUE_OOSEQ 1 183 184 /** 185 * TCPIP_MBOX_SIZE: The mailbox size for the tcpip thread messages 186 * The queue size value itself is platform-dependent, but is passed to 187 * sys_mbox_new() when tcpip_init is called. 188 */ 189 #define MEMP_NUM_TCPIP_MSG_INPKT 64 190 #define TCPIP_MBOX_SIZE 64 191 192 /** 193 * DEFAULT_TCP_RECVMBOX_SIZE: The mailbox size for the incoming packets on a 194 * NETCONN_TCP. The queue size value itself is platform-dependent, but is passed 195 * to sys_mbox_new() when the recvmbox is created. 196 */ 197 #define DEFAULT_ACCEPTMBOX_SIZE 8 198 #define DEFAULT_RAW_RECVMBOX_SIZE 4 199 #define DEFAULT_UDP_RECVMBOX_SIZE 20 200 #define DEFAULT_TCP_RECVMBOX_SIZE 20 201 202 /* TCP Maximum segment size. */ 203 #define TCP_MSS (1500 - 40) /* TCP_MSS = (Ethernet MTU - IP header size - TCP header size) */ 204 205 /* TCP sender buffer space (bytes). */ 206 #define TCP_SND_BUF (44*TCP_MSS) 207 208 /* TCP sender buffer space (pbufs). This must be at least = 2 * 209 TCP_SND_BUF/TCP_MSS for things to work. */ 210 #define TCP_SND_QUEUELEN (4* TCP_SND_BUF/TCP_MSS) 211 212 /* TCP receive window. */ 213 #define TCP_WND (10*TCP_MSS) 214 215 /** 216 * Enable TCP_KEEPALIVE 217 */ 218 #define LWIP_TCP_KEEPALIVE 1 219 220 /** 221 * TCP_SYNMAXRTX: Maximum number of retransmissions of SYN segments. 222 */ 223 #define TCP_SYNMAXRTX 10 224 225 #define TCP_MAX_ACCEPT_CONN 5 226 #define MEMP_NUM_TCP_SEG (TCP_SND_QUEUELEN*2) 227 228 #define IP_REASS_MAX_PBUFS 0 229 #define IP_REASSEMBLY 0 230 #define IP_REASS_MAX_PBUFS 0 231 #define IP_REASSEMBLY 0 232 #define MEMP_NUM_REASSDATA 0 233 #define IP_FRAG 0 234 235 /* ---------- ICMP options ---------- */ 236 #define LWIP_ICMP 1 237 238 239 /* ---------- DHCP options ---------- */ 240 /* Define LWIP_DHCP to 1 if you want DHCP configuration of 241 interfaces. DHCP is not implemented in lwIP 0.5.1, however, so 242 turning this on does currently not work. */ 243 #define LWIP_DHCP 1 244 #define DHCP_DOES_ARP_CHECK 0 245 246 247 /* ---------- UDP options ---------- */ 248 #define LWIP_UDP 1 249 #define UDP_TTL 255 250 251 /* ---------- Statistics options ---------- */ 252 #define LWIP_STATS 0 253 254 #define LWIP_IGMP 1 255 #if LWIP_IGMP 256 extern uint32_t get_random(void); 257 #define LWIP_RAND get_random 258 #endif 259 260 #define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 1 261 262 #define IP_FORWARD 0 263 264 #define LWIP_NETIF_STATUS_CALLBACK 1 265 266 /* 267 -------------------------------------- 268 ---------- Checksum options ---------- 269 -------------------------------------- 270 */ 271 272 /* 273 The STM32F107 allows computing and verifying the IP, UDP, TCP and ICMP checksums by hardware: 274 - To use this feature let the following define uncommented. 275 - To disable it and process by CPU comment the the checksum. 276 */ 277 #if 1//ndef __HIGH_THRUPUT__ 278 #define CHECKSUM_BY_HARDWARE 279 #endif 280 281 #ifdef CHECKSUM_BY_HARDWARE 282 /* CHECKSUM_GEN_IP==0: Generate checksums by hardware for outgoing IP packets.*/ 283 #define CHECKSUM_GEN_IP 1 284 /* CHECKSUM_GEN_UDP==0: Generate checksums by hardware for outgoing UDP packets.*/ 285 #define CHECKSUM_GEN_UDP 0 286 /* CHECKSUM_GEN_TCP==0: Generate checksums by hardware for outgoing TCP packets.*/ 287 #define CHECKSUM_GEN_TCP 0 288 /* CHECKSUM_CHECK_IP==0: Check checksums by hardware for incoming IP packets.*/ 289 #define CHECKSUM_CHECK_IP 1 290 /* CHECKSUM_CHECK_UDP==0: Check checksums by hardware for incoming UDP packets.*/ 291 #define CHECKSUM_CHECK_UDP 0 292 /* CHECKSUM_CHECK_TCP==0: Check checksums by hardware for incoming TCP packets.*/ 293 #define CHECKSUM_CHECK_TCP 0 294 #else 295 /* CHECKSUM_GEN_IP==1: Generate checksums in software for outgoing IP packets.*/ 296 #define CHECKSUM_GEN_IP 1 297 /* CHECKSUM_GEN_UDP==1: Generate checksums in software for outgoing UDP packets.*/ 298 #define CHECKSUM_GEN_UDP 1 299 /* CHECKSUM_GEN_TCP==1: Generate checksums in software for outgoing TCP packets.*/ 300 #define CHECKSUM_GEN_TCP 1 301 /* CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets.*/ 302 #define CHECKSUM_CHECK_IP 1 303 /* CHECKSUM_CHECK_UDP==1: Check checksums in software for incoming UDP packets.*/ 304 #define CHECKSUM_CHECK_UDP 1 305 /* CHECKSUM_CHECK_TCP==1: Check checksums in software for incoming TCP packets.*/ 306 #define CHECKSUM_CHECK_TCP 1 307 #endif 308 309 310 /* 311 ---------------------------------------------- 312 ---------- Sequential layer options ---------- 313 ---------------------------------------------- 314 */ 315 /** 316 * LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c) 317 */ 318 #define LWIP_NETCONN 1 319 /* 320 ------------------------------------ 321 ---------- Socket options ---------- 322 ------------------------------------ 323 */ 324 /** 325 * LWIP_SOCKET==1: Enable Socket API (require to use sockets.c) 326 */ 327 #define LWIP_SOCKET 1 328 #define LWIP_NETIF_API 1 329 330 /** 331 * LWIP_RECV_CB==1: Enable callback when a socket receives data. 332 */ 333 #define LWIP_RECV_CB 1 334 /** 335 * SO_REUSE==1: Enable SO_REUSEADDR option. 336 */ 337 #define SO_REUSE 1 338 #define SO_REUSE_RXTOALL 1 339 340 #define LWIP_SO_RCVTIMEO 1 341 #define LWIP_SO_SNDTIMEO 1 342 343 #define ARP_QUEUEING 1 344 #define LWIP_DHCP_MAX_NTP_SERVERS 3 345 346 #if defined(LWIP_FULLDUPLEX_SUPPORT) 347 //#define LWIP_NETCONN_FULLDUPLEX 1 348 #define LWIP_NETCONN_SEM_PER_THREAD 1 349 #endif 350 351 #define LWIP_PROVIDE_ERRNO 1 352 #define LWIP_MAILBOX_QUEUE 1 353 #define LWIP_TIMEVAL_PRIVATE 0 354 355 #define LWIP_SO_RCVBUF 1 356 #define LWIP_SO_RCVTCPBUF 1 357 358 /** 359 * TCP_LISTEN_BACKLOG==1: Handle backlog connections. 360 */ 361 #define TCP_LISTEN_BACKLOG 1 362 363 // add for alios things compatible 364 #define LWIP_IPV6 0 365 366 /* 367 ------------------------------------ 368 --------- customize macros --------- 369 ------------------------------------ 370 */ 371 /** 372 * LWIP_THREAD_EXIT_HOOK==1: bes add for thread exit proc 373 */ 374 #define LWIP_THREAD_EXIT_HOOK 1 375 /** 376 * LWIP_NTP_HOOK==1: bes add for ntp maintain 377 */ 378 #define LWIP_NTP_HOOK 1 379 /** 380 * DHCP_REBIND_PRE_ADDR: bes add for DHCP 381 */ 382 /* uncommented below define to try to rebind last offerred address when link get reconnected*/ 383 //#define DHCP_REBIND_PRE_ADDR 384 #ifdef DHCP_REBIND_PRE_ADDR 385 /* dhcp retry interval ms */ 386 #define DHCP_RETRY_INTERVAL 500 387 #endif 388 /** 389 * LWIP_ARP_ENHANCEMENT==1: bes add for arp 390 */ 391 #define LWIP_ARP_ENHANCEMENT 1 392 /** 393 * LWIP_NET_STATUS==0: bes add for net flow customize 394 */ 395 #define LWIP_NET_STATUS 0 396 /** 397 * LWIP_PBUF_NEW_API==1: bes add new PBUF api 398 */ 399 #define LWIP_PBUF_NEW_API 1 400 /** 401 * LWIP_PBUF_NEW_MEMCPY==1: bes add for PBUF use mymemcpy 402 */ 403 #define LWIP_PBUF_NEW_MEMCPY 1 404 /** 405 * LWIP_IN_ADDR_TYPE_CSTM==1: bes add for in_addr use u32_t s_addr 406 */ 407 #define LWIP_IN_ADDR_TYPE_CSTM 1 408 409 /* 410 * LWIP_NETIF_HOSTNAME==1: use DHCP_OPTION_HOSTNAME with netif's hostname 411 * field. 412 */ 413 #define LWIP_NETIF_HOSTNAME 1 414 415 /** 416 * Loopback demo related options. 417 */ 418 #define LWIP_NETIF_LOOPBACK 1 419 #define LWIP_HAVE_LOOPIF 1 420 #define LWIP_NETIF_LOOPBACK_MULTITHREADING 1 421 #define LWIP_LOOPBACK_MAX_PBUFS 8 422 423 #define LWIP_TIMERS 1 424 #define LWIP_TCPIP_TIMEOUT 1 425 426 /** 427 * TCP_RESOURCE_FAIL_RETRY_LIMIT: limit for retrying sending of tcp segment 428 * on resource failure error returned by driver. 429 */ 430 #define TCP_RESOURCE_FAIL_RETRY_LIMIT 50 431 432 #endif /* __LWIPOPTS_H__ */ 433 434 /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/ 435