📄 opt.h
字号:
/** * @file * * lwIP Options Configuration *//* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels <adam@sics.se> * */#ifndef __LWIP_OPT_H__#define __LWIP_OPT_H__/* * Include user defined options first. Anything not defined in these files * will be set to standard values. Override anything you dont like! */#include "lwipopts.h"#include "lwip/debug.h"/* ----------------------------------------------- ---------- Platform specific locking ---------- -----------------------------------------------*//** * SYS_LIGHTWEIGHT_PROT==1: 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/** * NO_SYS==1: Provides VERY minimal functionality. Otherwise, * use lwIP facilities. */#ifndef NO_SYS#define NO_SYS 0#endif/** * NO_SYS_NO_TIMERS==1: Drop support for sys_timeout when NO_SYS==1 * Mainly for compatibility to old versions. */#ifndef NO_SYS_NO_TIMERS#define NO_SYS_NO_TIMERS 0#endif/** * MEMCPY: override this if you have a faster implementation at hand than the * one included in your C library */#ifndef MEMCPY#define MEMCPY(dst,src,len) memcpy(dst,src,len)#endif/** * SMEMCPY: override this with care! Some compilers (e.g. gcc) can inline a * call to memcpy() if the length is known at compile time and is small. */#ifndef SMEMCPY#define SMEMCPY(dst,src,len) memcpy(dst,src,len)#endif/* ------------------------------------ ---------- Memory options ---------- ------------------------------------*//** * MEM_LIBC_MALLOC==1: Use malloc/free/realloc provided by your C-library * instead of the lwip internal allocator. Can save code size if you * already use it. */#ifndef MEM_LIBC_MALLOC#define MEM_LIBC_MALLOC 0#endif/*** MEMP_MEM_MALLOC==1: Use mem_malloc/mem_free instead of the lwip pool allocator.* Especially useful with MEM_LIBC_MALLOC but handle with care regarding execution* speed and usage from interrupts!*/#ifndef MEMP_MEM_MALLOC#define MEMP_MEM_MALLOC 0#endif/** * MEM_ALIGNMENT: should be set to the alignment of the CPU * 4 byte alignment -> #define MEM_ALIGNMENT 4 * 2 byte alignment -> #define MEM_ALIGNMENT 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_SEPARATE_POOLS: if defined to 1, each pool is placed in its own array. * This can be used to individually change the location of each pool. * Default is one big array for all pools */#ifndef MEMP_SEPARATE_POOLS#define MEMP_SEPARATE_POOLS 0#endif/** * MEMP_OVERFLOW_CHECK: memp overflow protection reserves a configurable * amount of bytes before and after each memp element in every pool and fills * it with a prominent default value. * MEMP_OVERFLOW_CHECK == 0 no checking * MEMP_OVERFLOW_CHECK == 1 checks each element when it is freed * MEMP_OVERFLOW_CHECK >= 2 checks each element in every pool every time * memp_malloc() or memp_free() is called (useful but slow!) */#ifndef MEMP_OVERFLOW_CHECK#define MEMP_OVERFLOW_CHECK 0#endif/** * MEMP_SANITY_CHECK==1: run a sanity check after each memp_free() to make * sure that there are no cycles in the linked lists. */#ifndef MEMP_SANITY_CHECK#define MEMP_SANITY_CHECK 0#endif/** * MEM_USE_POOLS==1: Use an alternative to malloc() by allocating from a set * of memory pools of various sizes. When mem_malloc is called, an element of * the smallest pool that can provide the length needed is returned. * To use this, MEMP_USE_CUSTOM_POOLS also has to be enabled. */#ifndef MEM_USE_POOLS#define MEM_USE_POOLS 0#endif/** * MEM_USE_POOLS_TRY_BIGGER_POOL==1: if one malloc-pool is empty, try the next * bigger pool - WARNING: THIS MIGHT WASTE MEMORY but it can make a system more * reliable. */#ifndef MEM_USE_POOLS_TRY_BIGGER_POOL#define MEM_USE_POOLS_TRY_BIGGER_POOL 0#endif/** * MEMP_USE_CUSTOM_POOLS==1: whether to include a user file lwippools.h * that defines additional pools beyond the "standard" ones required * by lwIP. If you set this to 1, you must have lwippools.h in your * inlude path somewhere. */#ifndef MEMP_USE_CUSTOM_POOLS#define MEMP_USE_CUSTOM_POOLS 0#endif/** * Set this to 1 if you want to free PBUF_RAM pbufs (or call mem_free()) from * interrupt context (or another context that doesn't allow waiting for a * semaphore). * If set to 1, mem_malloc will be protected by a semaphore and SYS_ARCH_PROTECT, * while mem_free will only use SYS_ARCH_PROTECT. mem_malloc SYS_ARCH_UNPROTECTs * with each loop so that mem_free can run. * * ATTENTION: As you can see from the above description, this leads to dis-/ * enabling interrupts often, which can be slow! Also, on low memory, mem_malloc * can need longer. * * If you don't want that, at least for NO_SYS=0, you can still use the following * functions to enqueue a deallocation call which then runs in the tcpip_thread * context: * - pbuf_free_callback(p); * - mem_free_callback(m); */#ifndef LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 0#endif/* ------------------------------------------------ ---------- Internal Memory Pool Sizes ---------- ------------------------------------------------*//** * MEMP_NUM_PBUF: the number of memp struct pbufs (used for PBUF_ROM and PBUF_REF). * 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_RAW_PCB: Number of raw connection PCBs * (requires the LWIP_RAW option) */#ifndef MEMP_NUM_RAW_PCB#define MEMP_NUM_RAW_PCB 4#endif/** * MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One * per active UDP "connection". * (requires the LWIP_UDP option) */#ifndef MEMP_NUM_UDP_PCB#define MEMP_NUM_UDP_PCB 4#endif/** * MEMP_NUM_TCP_PCB: the number of simulatenously active TCP connections. * (requires the LWIP_TCP option) */#ifndef MEMP_NUM_TCP_PCB#define MEMP_NUM_TCP_PCB 5#endif/** * MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP connections. * (requires the LWIP_TCP option) */#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. * (requires the LWIP_TCP option) */#ifndef MEMP_NUM_TCP_SEG#define MEMP_NUM_TCP_SEG 16#endif/** * MEMP_NUM_REASSDATA: the number of IP packets simultaneously queued for * reassembly (whole packets, not fragments!) */#ifndef MEMP_NUM_REASSDATA#define MEMP_NUM_REASSDATA 5#endif/** * MEMP_NUM_FRAG_PBUF: the number of IP fragments simultaneously sent * (fragments, not whole packets!). * This is only used with IP_FRAG_USES_STATIC_BUF==0 and * LWIP_NETIF_TX_SINGLE_PBUF==0 and only has to be > 1 with DMA-enabled MACs * where the packet is not yet sent when netif->output returns. */#ifndef MEMP_NUM_FRAG_PBUF#define MEMP_NUM_FRAG_PBUF 15#endif/** * MEMP_NUM_ARP_QUEUE: the number of simulateously queued outgoing * packets (pbufs) that are waiting for an ARP request (to resolve * their destination address) to finish. * (requires the ARP_QUEUEING option) */#ifndef MEMP_NUM_ARP_QUEUE#define MEMP_NUM_ARP_QUEUE 30#endif/** * MEMP_NUM_IGMP_GROUP: The number of multicast groups whose network interfaces * can be members et the same time (one per netif - allsystems group -, plus one * per netif membership). * (requires the LWIP_IGMP option) */#ifndef MEMP_NUM_IGMP_GROUP#define MEMP_NUM_IGMP_GROUP 8#endif/** * MEMP_NUM_SYS_TIMEOUT: the number of simulateously active timeouts. * (requires NO_SYS==0) */#ifndef MEMP_NUM_SYS_TIMEOUT#define MEMP_NUM_SYS_TIMEOUT 3#endif/** * MEMP_NUM_NETBUF: the number of struct netbufs. * (only needed if you use the sequential API, like api_lib.c) */#ifndef MEMP_NUM_NETBUF#define MEMP_NUM_NETBUF 2#endif/** * MEMP_NUM_NETCONN: the number of struct netconns. * (only needed if you use the sequential API, like api_lib.c) */#ifndef MEMP_NUM_NETCONN#define MEMP_NUM_NETCONN 4#endif/** * MEMP_NUM_TCPIP_MSG_API: the number of struct tcpip_msg, which are used * for callback/timeout API communication. * (only needed if you use tcpip.c) */#ifndef MEMP_NUM_TCPIP_MSG_API#define MEMP_NUM_TCPIP_MSG_API 8#endif/** * MEMP_NUM_TCPIP_MSG_INPKT: the number of struct tcpip_msg, which are used * for incoming packets. * (only needed if you use tcpip.c) */#ifndef MEMP_NUM_TCPIP_MSG_INPKT#define MEMP_NUM_TCPIP_MSG_INPKT 8#endif/** * MEMP_NUM_SNMP_NODE: the number of leafs in the SNMP tree. */#ifndef MEMP_NUM_SNMP_NODE#define MEMP_NUM_SNMP_NODE 50#endif/** * MEMP_NUM_SNMP_ROOTNODE: the number of branches in the SNMP tree. * Every branch has one leaf (MEMP_NUM_SNMP_NODE) at least! */#ifndef MEMP_NUM_SNMP_ROOTNODE#define MEMP_NUM_SNMP_ROOTNODE 30#endif/** * MEMP_NUM_SNMP_VARBIND: the number of concurrent requests (does not have to * be changed normally) - 2 of these are used per request (1 for input, * 1 for output) */#ifndef MEMP_NUM_SNMP_VARBIND#define MEMP_NUM_SNMP_VARBIND 2#endif/** * MEMP_NUM_SNMP_VALUE: the number of OID or values concurrently used * (does not have to be changed normally) - 3 of these are used per request * (1 for the value read and 2 for OIDs - input and output) */#ifndef MEMP_NUM_SNMP_VALUE#define MEMP_NUM_SNMP_VALUE 3#endif/** * MEMP_NUM_NETDB: the number of concurrently running lwip_addrinfo() calls * (before freeing the corresponding memory using lwip_freeaddrinfo()). */#ifndef MEMP_NUM_NETDB#define MEMP_NUM_NETDB 1#endif/** * MEMP_NUM_LOCALHOSTLIST: the number of host entries in the local host list * if DNS_LOCAL_HOSTLIST_IS_DYNAMIC==1. */#ifndef MEMP_NUM_LOCALHOSTLIST#define MEMP_NUM_LOCALHOSTLIST 1#endif/** * MEMP_NUM_PPPOE_INTERFACES: the number of concurrently active PPPoE * interfaces (only used with PPPOE_SUPPORT==1) */#ifndef MEMP_NUM_PPPOE_INTERFACES#define MEMP_NUM_PPPOE_INTERFACES 1#endif/** * PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */#ifndef PBUF_POOL_SIZE#define PBUF_POOL_SIZE 16#endif/* --------------------------------- ---------- ARP options ---------- ---------------------------------*//** * LWIP_ARP==1: Enable ARP functionality. */#ifndef LWIP_ARP#define LWIP_ARP 1#endif/** * ARP_TABLE_SIZE: Number of active MAC-IP address pairs cached. */#ifndef ARP_TABLE_SIZE#define ARP_TABLE_SIZE 10#endif/** * ARP_QUEUEING==1: Multiple outgoing packets are queued during hardware address * resolution. By default, only the most recent packet is queued per IP address. * This is sufficient for most protocols and mainly reduces TCP connection * startup time. Set this to 1 if you know your application sends more than one * packet in a row to an IP address that is not in the ARP cache. */#ifndef ARP_QUEUEING#define ARP_QUEUEING 0#endif/** * ETHARP_TRUST_IP_MAC==1: Incoming IP packets cause the ARP table to be * updated with the source MAC and IP addresses supplied in the packet. * You may want to disable this if you do not trust LAN peers to have the * correct addresses, or as a limited approach to attempt to handle * spoofing. If disabled, lwIP will need to make a new ARP request if * the peer is not already in the ARP table, adding a little latency. * The peer *is* in the ARP table if it requested our address before. * Also notice that this slows down input processing of every IP packet! */#ifndef ETHARP_TRUST_IP_MAC#define ETHARP_TRUST_IP_MAC 0#endif/** * ETHARP_SUPPORT_VLAN==1: support receiving ethernet packets with VLAN header. * Additionally, you can define ETHARP_VLAN_CHECK to an u16_t VLAN ID to check. * If ETHARP_VLAN_CHECK is defined, only VLAN-traffic for this VLAN is accepted. * If ETHARP_VLAN_CHECK is not defined, all traffic is accepted. */#ifndef ETHARP_SUPPORT_VLAN#define ETHARP_SUPPORT_VLAN 0#endif/** LWIP_ETHERNET==1: enable ethernet support for PPPoE even though ARP * might be disabled */#ifndef LWIP_ETHERNET#define LWIP_ETHERNET (LWIP_ARP || PPPOE_SUPPORT)#endif/** ETH_PAD_SIZE: number of bytes added before the ethernet header to ensure * alignment of payload after that header. Since the header is 14 bytes long, * without this padding e.g. addresses in the IP header will not be aligned * on a 32-bit boundary, so setting this to 2 can speed up 32-bit-platforms. */#ifndef ETH_PAD_SIZE#define ETH_PAD_SIZE 0#endif/** ETHARP_SUPPORT_STATIC_ENTRIES==1: enable code to support static ARP table * entries (using etharp_add_static_entry/etharp_remove_static_entry). */#ifndef ETHARP_SUPPORT_STATIC_ENTRIES#define ETHARP_SUPPORT_STATIC_ENTRIES 0#endif/* -------------------------------- ---------- IP options ---------- --------------------------------*//** * IP_FORWARD==1: Enables 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 0#endif/** * IP_OPTIONS_ALLOWED: Defines the behavior for IP options. * IP_OPTIONS_ALLOWED==0: All packets with IP options are dropped. * IP_OPTIONS_ALLOWED==1: IP options are allowed (but not parsed). */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -