From d390ca7056588c919463a39a4f874d4658bab65b Mon Sep 17 00:00:00 2001 From: jani Date: Mon, 24 Feb 2003 10:49:05 +0000 Subject: [PATCH] cleaned up opt.h a bit, added more option defaults ad changed SYS_LIGHTWEIGHT_PROT to be a 0/1 define.The same for COMPAT_SOCKET --- src/core/memp.c | 12 +- src/core/pbuf.c | 18 +-- src/include/lwip/opt.h | 275 +++++++++++++++++++++---------------- src/include/lwip/sockets.h | 2 +- src/netif/etharp.c | 7 +- 5 files changed, 178 insertions(+), 136 deletions(-) diff --git a/src/core/memp.c b/src/core/memp.c index 4b917cba..70991347 100644 --- a/src/core/memp.c +++ b/src/core/memp.c @@ -110,7 +110,7 @@ static u8_t memp_memory[(MEMP_NUM_PBUF * sizeof(struct memp)))]; /*-----------------------------------------------------------------------------------*/ -#ifndef SYS_LIGHTWEIGHT_PROT +#if !SYS_LIGHTWEIGHT_PROT static sys_sem_t mutex; #endif /*-----------------------------------------------------------------------------------*/ @@ -170,7 +170,7 @@ memp_init(void) } } -#ifndef SYS_LIGHTWEIGHT_PROT +#if !SYS_LIGHTWEIGHT_PROT mutex = sys_sem_new(1); #endif @@ -216,7 +216,7 @@ void * memp_mallocp(memp_t type) { void *mem; -#ifdef SYS_LIGHTWEIGHT_PROT +#if SYS_LIGHTWEIGHT_PROT SYS_ARCH_DECL_PROTECT(old_level); SYS_ARCH_PROTECT(old_level); #else /* SYS_LIGHTWEIGHT_PROT */ @@ -225,7 +225,7 @@ memp_mallocp(memp_t type) mem = memp_malloc(type); -#ifdef SYS_LIGHTWEIGHT_PROT +#if SYS_LIGHTWEIGHT_PROT SYS_ARCH_UNPROTECT(old_level); #else /* SYS_LIGHTWEIGHT_PROT */ sys_sem_signal(mutex); @@ -258,7 +258,7 @@ memp_free(memp_t type, void *mem) void memp_freep(memp_t type, void *mem) { -#ifdef SYS_LIGHTWEIGHT_PROT +#if SYS_LIGHTWEIGHT_PROT SYS_ARCH_DECL_PROTECT(old_level); SYS_ARCH_PROTECT(old_level); #else /* SYS_LIGHTWEIGHT_PROT */ @@ -267,7 +267,7 @@ memp_freep(memp_t type, void *mem) memp_free(type, mem); -#ifdef SYS_LIGHTWEIGHT_PROT +#if SYS_LIGHTWEIGHT_PROT SYS_ARCH_UNPROTECT(old_level); #else /* SYS_LIGHTWEIGHT_PROT */ sys_sem_signal(mutex); diff --git a/src/core/pbuf.c b/src/core/pbuf.c index e4c56d65..fb638508 100644 --- a/src/core/pbuf.c +++ b/src/core/pbuf.c @@ -53,7 +53,7 @@ static u8_t pbuf_pool_memory[(PBUF_POOL_SIZE * MEM_ALIGN_SIZE(PBUF_POOL_BUFSIZE + sizeof(struct pbuf)))]; -#ifndef SYS_LIGHTWEIGHT_PROT +#if !SYS_LIGHTWEIGHT_PROT static volatile u8_t pbuf_pool_free_lock, pbuf_pool_alloc_lock; static sys_sem_t pbuf_pool_free_sem; #endif @@ -103,7 +103,7 @@ pbuf_init(void) are no more pbufs in the pool. */ q->next = NULL; -#ifndef SYS_LIGHTWEIGHT_PROT +#if !SYS_LIGHTWEIGHT_PROT pbuf_pool_alloc_lock = 0; pbuf_pool_free_lock = 0; pbuf_pool_free_sem = sys_sem_new(1); @@ -126,7 +126,7 @@ pbuf_pool_alloc(void) pbuf_pool_alloc_cache = p->next; } } else { -#ifndef SYS_LIGHTWEIGHT_PROT +#if !SYS_LIGHTWEIGHT_PROT /* Next, check the actual pbuf pool, but if the pool is locked, we pretend to be out of buffers and return NULL. */ if(pbuf_pool_free_lock) { @@ -142,7 +142,7 @@ pbuf_pool_alloc(void) if(p) { pbuf_pool = p->next; } -#ifndef SYS_LIGHTWEIGHT_PROT +#if !SYS_LIGHTWEIGHT_PROT #ifdef PBUF_STATS } else { ++lwip_stats.pbuf.alloc_locked; @@ -331,12 +331,12 @@ pbuf_refresh(void) SYS_ARCH_DECL_PROTECT(old_level); SYS_ARCH_PROTECT(old_level); -#ifndef SYS_LIGHTWEIGHT_PROT +#if !SYS_LIGHTWEIGHT_PROT sys_sem_wait(pbuf_pool_free_sem); #endif /* else SYS_LIGHTWEIGHT_PROT */ if(pbuf_pool_free_cache != NULL) { -#ifndef SYS_LIGHTWEIGHT_PROT +#if !SYS_LIGHTWEIGHT_PROT pbuf_pool_free_lock = 1; if(!pbuf_pool_alloc_lock) { #endif /* SYS_LIGHTWEIGHT_PROT */ @@ -347,7 +347,7 @@ pbuf_refresh(void) p->next = pbuf_pool_free_cache; } pbuf_pool_free_cache = NULL; -#ifndef SYS_LIGHTWEIGHT_PROT +#if !SYS_LIGHTWEIGHT_PROT #ifdef PBUF_STATS } else { ++lwip_stats.pbuf.refresh_locked; @@ -358,7 +358,7 @@ pbuf_refresh(void) #endif /* SYS_LIGHTWEIGHT_PROT */ } SYS_ARCH_UNPROTECT(old_level); -#ifndef SYS_LIGHTWEIGHT_PROT +#if !SYS_LIGHTWEIGHT_PROT sys_sem_signal(pbuf_pool_free_sem); #endif /* SYS_LIGHTWEIGHT_PROT */ } @@ -375,7 +375,7 @@ pbuf_refresh(void) DEC_PBUF_STATS; \ } while (0) -#ifdef SYS_LIGHTWEIGHT_PROT +#if SYS_LIGHTWEIGHT_PROT #define PBUF_POOL_FREE(p) do { \ SYS_ARCH_DECL_PROTECT(old_level); \ SYS_ARCH_PROTECT(old_level); \ diff --git a/src/include/lwip/opt.h b/src/include/lwip/opt.h index 49e9a4dc..ea0ea2a8 100644 --- a/src/include/lwip/opt.h +++ b/src/include/lwip/opt.h @@ -36,117 +36,132 @@ /* Include user options which override defaults */ #include "lwipopts.h" -/* Define some handy default values for configuration parameters. */ +/* Define default values for all configuration parameters. */ +/* Platform specific locking */ -/*FIXME These were taken from unixsim lwipopts.More sensitive values should be here - * nicely documented and categorized - **/ +/* + * enable SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection + * for certain critical regions during buffer allocation, deallocation and memory + * allocation and deallocation. + */ +#ifndef SYS_LIGHTWEIGHT_PROT +#define SYS_LIGHTWEIGHT_PROT 0 +#endif + +#ifndef SYS_ARCH_DECL_PROTECT +#define SYS_ARCH_DECL_PROTECT(lock) +#endif + +#ifndef SYS_ARCH_PROTECT +#define SYS_ARCH_PROTECT(lock) +#endif + +#ifndef SYS_ARCH_UNPROTECT +#define SYS_ARCH_UNPROTECT(lock) +#endif -#define LWIP_COMPAT_SOCKETS /* ---------- Memory options ---------- */ /* MEM_ALIGNMENT: should be set to the alignment of the CPU for which lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2 byte alignment -> define MEM_ALIGNMENT to 2. */ + +#ifndef MEM_ALIGNMENT #define MEM_ALIGNMENT 1 +#endif /* MEM_SIZE: the size of the heap memory. If the application will send a lot of data that needs to be copied, this should be set high. */ +#ifndef MEM_SIZE #define MEM_SIZE 1600 +#endif /* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application sends a lot of data out of ROM (or other static memory), this should be set high. */ +#ifndef MEMP_NUM_PBUF #define MEMP_NUM_PBUF 16 +#endif + /* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One per active UDP "connection". */ +#ifndef MEMP_NUM_UDP_PCB #define MEMP_NUM_UDP_PCB 4 +#endif /* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP connections. */ +#ifndef MEMP_NUM_TCP_PCB #define MEMP_NUM_TCP_PCB 5 +#endif /* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP connections. */ +#ifndef MEMP_NUM_TCP_PCB_LISTEN #define MEMP_NUM_TCP_PCB_LISTEN 8 +#endif /* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments. */ +#ifndef MEMP_NUM_TCP_SEG #define MEMP_NUM_TCP_SEG 16 +#endif /* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active timeouts. */ +#ifndef MEMP_NUM_SYS_TIMEOUT #define MEMP_NUM_SYS_TIMEOUT 3 +#endif /* The following four are used only with the sequential API and can be set to 0 if the application only will use the raw API. */ /* MEMP_NUM_NETBUF: the number of struct netbufs. */ +#ifndef MEMP_NUM_NETBUF #define MEMP_NUM_NETBUF 2 +#endif /* MEMP_NUM_NETCONN: the number of struct netconns. */ +#ifndef MEMP_NUM_NETCONN #define MEMP_NUM_NETCONN 4 +#endif /* MEMP_NUM_APIMSG: the number of struct api_msg, used for communication between the TCP/IP stack and the sequential programs. */ +#ifndef MEMP_NUM_API_MSG #define MEMP_NUM_API_MSG 8 +#endif /* MEMP_NUM_TCPIPMSG: the number of struct tcpip_msg, which is used for sequential API communication and incoming packets. Used in src/api/tcpip.c. */ +#ifndef MEMP_NUM_TCPIP_MSG #define MEMP_NUM_TCPIP_MSG 8 - -/* These two control is reclaimer functions should be compiled - in. Should always be turned on (1). */ -#define MEM_RECLAIM 1 -#define MEMP_RECLAIM 1 +#endif /* ---------- Pbuf options ---------- */ /* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */ -#define PBUF_POOL_SIZE 100 + +#ifndef PBUF_POOL_SIZE +#define PBUF_POOL_SIZE 16 +#endif /* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */ + +#ifndef PBUF_POOL_BUFSIZE #define PBUF_POOL_BUFSIZE 128 +#endif /* PBUF_LINK_HLEN: the number of bytes that should be allocated for a link level header. */ -#define PBUF_LINK_HLEN 16 -/** SYS_LIGHTWEIGHT_PROT - * define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection - * for certain critical regions during buffer allocation, deallocation and memory - * allocation and deallocation. - */ -/*#define SYS_LIGHTWEIGHT_PROT 1*/ +#ifndef PBUF_LINK_HLEN +#define PBUF_LINK_HLEN 0 +#endif -/* ---------- TCP options ---------- */ -#define LWIP_TCP 1 -#define TCP_TTL 255 -/* Controls if TCP should queue segments that arrive out of - order. Define to 0 if your device is low on memory. */ -#define TCP_QUEUE_OOSEQ 1 - -/* TCP Maximum segment size. */ -#define TCP_MSS 128 - -/* TCP sender buffer space (bytes). */ -#define TCP_SND_BUF 256 - -/* TCP sender buffer space (pbufs). This must be at least = 2 * - TCP_SND_BUF/TCP_MSS for things to work. */ -#define TCP_SND_QUEUELEN 4 * TCP_SND_BUF/TCP_MSS - -/* TCP receive window. */ -#define TCP_WND 1024 - -/* Maximum number of retransmissions of data segments. */ -#define TCP_MAXRTX 12 - -/* Maximum number of retransmissions of SYN segments. */ -#define TCP_SYNMAXRTX 4 - -/* TCP writable space (bytes). This must be less than or equal - to TCP_SND_BUF. It is the amount of space which must be - available in the tcp snd_buf for select to return writable */ -#define TCP_SNDLOWAT TCP_SND_BUF/2 /* ---------- ARP options ---------- */ +#ifndef ARP_TABLE_SIZE #define ARP_TABLE_SIZE 10 +#endif + +#ifndef ARP_QUEUEING #define ARP_QUEUEING 1 +#endif /** * - If enabled, cache entries are generated for every kind of ARP traffic or * broadcast IP traffic. This enhances behaviour for sending to a dynamic set @@ -155,41 +170,133 @@ a lot of data that needs to be copied, this should be set high. */ * in use by lwIP or applications. This enhances performance if sending to a small, * reasonably static number of hosts. Typically for embedded devices. */ + +#ifndef ETHARP_ALWAYS_INSERT #define ETHARP_ALWAYS_INSERT 1 +#endif /* ---------- IP options ---------- */ /* Define IP_FORWARD to 1 if you wish to have the ability to forward IP packets across network interfaces. If you are going to run lwIP on a device with only one network interface, define this to 0. */ +#ifndef IP_FORWARD #define IP_FORWARD 1 +#endif /* If defined to 1, IP options are allowed (but not parsed). If defined to 0, all packets with IP options are dropped. */ +#ifndef IP_OPTIONS #define IP_OPTIONS 1 +#endif /* IP reassembly and segmentation.These are orthogonal even * if they both deal with IP fragments */ +#ifndef IP_REASSEMBLY #define IP_REASSEMBLY 1 +#endif + +#ifndef IP_FRAG #define IP_FRAG 1 +#endif /* ---------- ICMP options ---------- */ + +#ifndef ICMP_TTL #define ICMP_TTL 255 +#endif /* ---------- DHCP options ---------- */ -/* Define LWIP_DHCP to 1 if you want DHCP configuration of - interfaces. DHCP is not implemented in lwIP 0.5.1, however, so - turning this on does currently not work. */ + +#ifndef LWIP_DHCP #define LWIP_DHCP 0 +#endif /* 1 if you want to do an ARP check on the offered address (recommended). */ +#ifndef DHCP_DOES_ARP_CHECK #define DHCP_DOES_ARP_CHECK 1 +#endif /* ---------- UDP options ---------- */ +#ifndef LWIP_UDP #define LWIP_UDP 1 -#define UDP_TTL 255 +#endif +#ifndef UDP_TTL +#define UDP_TTL 255 +#endif + +/* ---------- TCP options ---------- */ +#ifndef LWIP_TCP +#define LWIP_TCP 1 +#endif + +#ifndef TCP_TTL +#define TCP_TTL 255 +#endif + +#ifndef TCP_WND +#define TCP_WND 2048 +#endif + +#ifndef TCP_MAXRTX +#define TCP_MAXRTX 12 +#endif + +#ifndef TCP_SYNMAXRTX +#define TCP_SYNMAXRTX 6 +#endif + + +/* Controls if TCP should queue segments that arrive out of + order. Define to 0 if your device is low on memory. */ +#ifndef TCP_QUEUE_OOSEQ +#define TCP_QUEUE_OOSEQ 1 +#endif + +/* TCP Maximum segment size. */ +#ifndef TCP_MSS +#define TCP_MSS 128 /* A *very* conservative default. */ +#endif + +/* TCP sender buffer space (bytes). */ +#ifndef TCP_SND_BUF +#define TCP_SND_BUF 256 +#endif + +/* TCP sender buffer space (pbufs). This must be at least = 2 * + TCP_SND_BUF/TCP_MSS for things to work. */ +#ifndef TCP_SND_QUEUELEN +#define TCP_SND_QUEUELEN 4 * TCP_SND_BUF/TCP_MSS +#endif + + +/* Maximum number of retransmissions of data segments. */ + +/* Maximum number of retransmissions of SYN segments. */ + +/* TCP writable space (bytes). This must be less than or equal + to TCP_SND_BUF. It is the amount of space which must be + available in the tcp snd_buf for select to return writable */ +#ifndef TCP_SNDLOWAT +#define TCP_SNDLOWAT TCP_SND_BUF/2 +#endif + + + + +#ifndef LWIP_EVENT_API +#define LWIP_EVENT_API 0 +#define LWIP_CALLBACK_API 1 +#else +#define LWIP_EVENT_API 1 +#define LWIP_CALLBACK_API 0 +#endif + +#ifndef LWIP_COMPAT_SOCKETS +#define LWIP_COMPAT_SOCKETS 1 +#endif /* ---------- Statistics options ---------- */ #define STATS @@ -206,70 +313,6 @@ a lot of data that needs to be copied, this should be set high. */ #define SYS_STATS #endif /* STATS */ - -/*FIXME*/ - - -#ifndef ICMP_TTL -#define ICMP_TTL 255 -#endif - -#ifndef UDP_TTL -#define UDP_TTL 255 -#endif - -#ifndef TCP_TTL -#define TCP_TTL 255 -#endif - -#ifndef TCP_MSS -#define TCP_MSS 128 /* A *very* conservative default. */ -#endif - -#ifndef TCP_WND -#define TCP_WND 2048 -#endif - -#ifndef TCP_MAXRTX -#define TCP_MAXRTX 12 -#endif - -#ifndef TCP_SYNMAXRTX -#define TCP_SYNMAXRTX 6 -#endif - -#ifndef MEM_ALIGNMENT -#define MEM_ALIGNMENT 1 -#endif - -#ifndef PBUF_POOL_SIZE -#define PBUF_POOL_SIZE 16 -#endif - -#ifndef PBUF_POOL_BUFSIZE -#define PBUF_POOL_BUFSIZE 128 -#endif - -#ifndef PBUF_LINK_HLEN -#define PBUF_LINK_HLEN 0 -#endif - -#ifndef LWIP_UDP -#define LWIP_UDP 1 -#endif - -#ifndef LWIP_TCP -#define LWIP_TCP 1 -#endif - -#ifndef LWIP_EVENT_API -#define LWIP_EVENT_API 0 -#define LWIP_CALLBACK_API 1 -#else -#define LWIP_EVENT_API 1 -#define LWIP_CALLBACK_API 0 -#endif /* LWIP_CALLBACK_API */ - /* Debugging options all default to off */ #ifndef DEMO_DEBUG diff --git a/src/include/lwip/sockets.h b/src/include/lwip/sockets.h index adbefe81..fbe47ecc 100644 --- a/src/include/lwip/sockets.h +++ b/src/include/lwip/sockets.h @@ -206,7 +206,7 @@ int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptse struct timeval *timeout); int lwip_ioctl(int s, long cmd, void *argp); -#ifdef LWIP_COMPAT_SOCKETS +#if LWIP_COMPAT_SOCKETS #define accept(a,b,c) lwip_accept(a,b,c) #define bind(a,b,c) lwip_bind(a,b,c) #define shutdown(a,b) lwip_shutdown(a,b) diff --git a/src/netif/etharp.c b/src/netif/etharp.c index 94f2e268..091cc2a4 100644 --- a/src/netif/etharp.c +++ b/src/netif/etharp.c @@ -3,6 +3,9 @@ * Address Resolution Protocol module for IP over Ethernet * * $Log: etharp.c,v $ + * Revision 1.29 2003/02/24 10:49:05 jani + * cleaned up opt.h a bit, added more option defaults ad changed SYS_LIGHTWEIGHT_PROT to be a 0/1 define.The same for COMPAT_SOCKET + * * Revision 1.28 2003/02/21 16:43:46 jani * byte-order handling functions are in inet.c now and the uperrcase counterparts are gone. opt.h has all the * configurable items debug does not need to be directly included. @@ -175,10 +178,6 @@ RFC 3220 4.6 IP Mobility Support for IPv4 January 2002 /** the time an ARP entry stays pending after first request, (2 * 10) seconds = 20 seconds. */ #define ARP_MAXPENDING 2 -#ifndef ETHARP_ALWAYS_INSERT -# define ETHARP_ALWAYS_INSERT 1 -#endif - #define HWTYPE_ETHERNET 1 /** ARP message types */