Notes on lwIP TCP/IP stack II: Configuration file opt.h & lwipopts.h

Catalog

1. introduction

2. Configuration opt.h description

2.1 Infrastructure

NO_SYS

Timers

memcpy

Core locking and MPU

Heap and memory pools

Internal memory pools

SNMP MIB2 callbacks

Multicast

Threading

Checksum

Hooks (hook option)

2.2 IPv4

ARP

IP

ICMP

DHCP

AUTOIP

IGMP

2.3 Callback-style APIs

RAW

DNS

UDP

TCP

2.4 PBUF

2.5 NETIF

2.6 IPv6

2.7 Thread-safe APIs

Netconn

Sockets

2.8 Debugging

Assertion handling

Statistics (status information)

Debug messages (debugging information)

Performance (Performance Testing)

1. introduction

From the introduction of lwIP protocol stack, it can be seen that lwIP protocol stack can be tailored according to need. The specific tailoring configuration is embodied in its option configuration file, opt.h.

In order to maintain the source code independence in the lwIP TCP/IP stack, opt.h will not be changed directly, but a user-defined file will be added to indicate the user's own configuration, that is lwipopts.h. The above-mentioned method does not destroy the source files, but is also used many times in lwIP applications according to the way that users define files separately.

In lwIP routines, or applications, you can find the lwipopts.h file, which has been customized, so the user-defined configuration is here.

The reference files of lwipopts.h can be clipped from official routines, but the access is not limited to this.

2. Configuration opt.h description

2.1 Infrastructure

  • NO_SYS

/*
    NO_SYS == 1: No operating system, no thread security related API, only callback-style raw API
                 Note that lwIP functions/structures cannot be accessed from multiple contexts at once 
    NO_SYS == 0: Operating system
*/
#define NO_SYS        0

  • Timers

/*
    LWIP_TIMEERS == 0:    Delete support for sys_timeout and lwip internal loop timers. 
                            (Still provide an array of lwip internal loop timers)
    (Check whether NO_SYS_NO_TIMERS is compatible with older versions
*/
#define 	LWIP_TIMERS   1

/*
    LWIP_TIMERS_CUSTOM == 1: Provide custom timer implementation, function prototype in timeouts.h and the following
                             sys_timeouts_init(), sys_timeout(), 
                             sys_untimeout(), sys_timeouts_mbox_fetch() 
*/ 
#define 	LWIP_TIMERS_CUSTOM   0
/**
 * @defgroup lwip_opts_memcpy memcpy
 * @ingroup lwip_opts_infrastructure
 * @{
 */

/* If the implementation speed is faster than that contained in the C library, this item is overridden. */
#define 	MEMCPY(dst, src, len)   memcpy(dst,src,len)
 
/* Careful coverage! If the length is known at compile time and is small, some compilers (such as gcc) can inline calls to memcpy (). */
#define 	SMEMCPY(dst, src, len)   memcpy(dst,src,len)
 
/* If the implementation speed is faster than that contained in the C library, this item is overwritten. lwIP uses MEMMOVE only when IPv6 subsection support is enabled. */
#define 	MEMMOVE(dst, src, len)   memmove(dst,src,len)
 

/* Use default configuration */
/*
   ----------- Core locking -----------
*/
/* 
   MPU(Memory protection unit) compatible:
   Enable special memory management mechanism to enable lwip to work on MPU systems by not passing stack pointers to other threads
  (This reduces performance because memory is allocated from the pool rather than kept on the stack.
 */
#define 	LWIP_MPU_COMPATIBLE   0

/*
    Create a global mutex reserved during TCPIP thread operations.
    Client code locks can be used to perform lwIP operations without requiring callbacks to be changed to TCPIP threads.
    See LOCK_TCPIP_CORE() and UNLOCK_TCPIP_CORE().
    Your system should provide mutexes that support priority inversion to use it
*/ 
#define 	LWIP_TCPIP_CORE_LOCKING   1

/*
    LWIP_TCPIP_CORE_LOCKING == 1
    So that tcpip_input() can also acquire the mutex of the input packet, instead of assigning the message and passing it to tcpip_thread
    Note: This does not work when tcpip_input() is called from the interrupt context!
*/ 
#define 	LWIP_TCPIP_CORE_LOCKING_INPUT   0

/* 
    SYS_LIGHTWEIGHT_PROT   == 1    
    During buffer allocation, release and memory allocation, and de-allocation, inter-task protection (and task and interrupt protection) is enabled for certain critical areas. 
    Note: This is what you need to do when using lwIP from multiple contexts! If you disable it, you must be sure what you are doing! */ 
#define 	SYS_LIGHTWEIGHT_PROT   1

/* 
    Macro/function, used to check whether the thread/lock requirements of lwIP are met during the current function call. 
    This macro typically calls functions implemented in the OS-dependent sys layer and performs the following checks:
    Not in ISR (this should also check NO_SYS = 1!)
     If LWIP_TCPIP_CORE_LOCKING = 1: Keep the TCPIP core locked
     If LWIP_TCPIP_CORE_LOCKING = 0: Call a function from a TCPIP thread
*/ 
#define 	LWIP_ASSERT_CORE_LOCKED()

/* 
    First call in lwIP TCPIP thread. It can be used with LWIP_ASSERT_CORE_LOCKED to check for kernel locking.
    Handles that actually identify TCPIP threads
*/ 
#define 	LWIP_MARK_TCPIP_THREAD()
  • Heap and memory pools

/*
   ---------- Memory options ----------
*/
/*
    heap allocation strategy
    MEM_LIBC_MALLOC==1: Use malloc / free / realloc provided by the C library instead of the lwip internal allocator.
    Generally speaking, the allocation strategy of C library is fragmented and not suitable for embedded system.    
*/
#define 	MEM_LIBC_MALLOC   0

/*
    Memory pool allocation policy (whether to use memory heap allocation policy to achieve memory pool allocation)
    MEMP_MEM_MALLOC == 1: Use mem_malloc/mem_free instead of lwip memory pool allocator.
    (Heap allocation may be much slower than pool allocation.
    With MEM_USE_POOLS, only one can be chosen.
*/ 
#define 	MEMP_MEM_MALLOC   0

/*
    MEMP_MEM_INIT == 1: 
    Forces the use of memset to initialize pool memory. It is useful if the pool moves in an uninitialized memory portion.
    This will ensure that the default values in the pcbs structure are well initialized under all conditions.
*/ 
#define 	MEMP_MEM_INIT   0

/* byte alignment*/ 
#define 	MEM_ALIGNMENT   4

/*
    MEM_SIZE: The size of heap memory. If the application will send a large amount of data that needs to be replicated, it should be set to high.
*/ 
#define 	MEM_SIZE   1600

/* 
    Memory pool overflow check
    0:  No check
    1:  Inspection at release
    2: Calling memp_malloc() or memp_free() checks is useful, but slow
*/ 
#define 	MEMP_OVERFLOW_CHECK   0

/*
    Memory pool health check
    MEMP_SANITY_CHECK == 1: Run a sanity check after each memp_free() to ensure that there are no loops in the list.
*/ 
#define 	MEMP_SANITY_CHECK   0

/* 
    Heap memory overflow check
    0: No check
    1:  Inspection at release
    2: Calling mem_malloc() or mem_free() checks is useful, but slow
 */ 
#define 	MEM_OVERFLOW_CHECK   0

/* Heap memory integrity check */ 
#define 	MEM_SANITY_CHECK   0

/* 
    Memory heap allocation strategy (whether to use memory pool allocation strategy to achieve memory heap allocation) 
    MEM_USE_POOLS==1: With the memory pool approach, MEMP_USE_CUSTOM_POOLS must also be enabled.
    With MEMP_MEM_MALLOC, only one can be chosen.
*/ 
#define 	MEM_USE_POOLS   0

/* 
    MEM_USE_POOLS_TRY_BIGGER_POOL== 1: 
    If a malloc_pool is empty, try the next larger pool- 
    Warning: This may be a waste memory, but it can make the system more reliable.
 */ 
#define 	MEM_USE_POOLS_TRY_BIGGER_POOL   0

/*
    MEMP_USE_CUSTOM_POOLS== 1: 
    Does it contain the user file lwippools.h, which defines pools other than the "standard" required by lwIP?
    If it is set to 1, lwippools.h must be used somewhere in the containing path.
*/ 
#define 	MEMP_USE_CUSTOM_POOLS   0

/*
    Other contexts release memory
*/ 
#define 	LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT   0

Refer to the blogger's article:

https://blog.csdn.net/ZCShouCSDN/article/details/80282907

  • Internal memory pools

/*
    Number of Packet Buffers PBUF
   (Used for PBUF_ROM and PBUF_REF. If the application sends a large amount of data from ROM (or other static memory), it should be set to high.
*/
#define 	MEMP_NUM_PBUF   16

/*
    Raw Number of protocol control blocks (LWIP_RAW option required)
*/ 
#define 	MEMP_NUM_RAW_PCB   4

/* UDP The number of protocol control blocks. Each activity UDP "connects" one. (LWIP_UDP option is required)*/ 
#define 	MEMP_NUM_UDP_PCB   4

/* Number of concurrent TCP connections. (LWIP_TCP option is required) */ 
#define 	MEMP_NUM_TCP_PCB   5

/* Number of listening TCP connections. (LWIP_TCP option is required) */ 
#define 	MEMP_NUM_TCP_PCB_LISTEN   8

/* The number of TCP segments queued at the same time. (LWIP_TCP option is required) */ 
#define 	MEMP_NUM_TCP_SEG   16

/*
    The number of altcp layer control blocks that are active at the same time.
  (The LWIP_ALTCP option is required) Connections with multiple layers require multiple altcp_pcbs (for example, TLS over TCP requires two altcp_pcbs, one for TLS and one for TCP).
*/ 
#define 	MEMP_NUM_ALTCP_PCB   MEMP_NUM_TCP_PCB

/*   The number of IP packets queuing for reorganization (whole packet, not fragments!) */ 
#define 	MEMP_NUM_REASSDATA   5

/*
    The number of IP fragments sent at the same time (fragments, not the entire packet!).
    This is only for LWIP_NETIF_TX_SINGLE_PBUF== 0 and must be > 1 only when DMA MAC is enabled, where no packets are sent when netif-> output returns.
*/ 
#define 	MEMP_NUM_FRAG_PBUF   15

/*
    ARP Number of queues (ARP_QUEUEING option required)
*/ 
#define 	MEMP_NUM_ARP_QUEUE   30

/*  Number of Multicast Network Interfaces */ 
#define 	MEMP_NUM_IGMP_GROUP   8

/* 
    The protocol stack kernel uses the number of timeouts (excluding APP) where the default timeouts are calculated for all enabled modules.
*/ 
#define 	LWIP_NUM_SYS_TIMEOUT_INTERNAL   (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + PPP_NUM_TIMEOUTS + (LWIP_IPV6 * (1 + LWIP_IPV6_REASS + LWIP_IPV6_MLD)))

/* Overtime of simultaneous activity. The default timeout is calculated here for all enabled modules. Formula requirements are set to "0" or "1". */ 
#define 	MEMP_NUM_SYS_TIMEOUT   LWIP_NUM_SYS_TIMEOUT_INTERNAL

/* 
    netbuf Number of structures. (Only when using the sequential API, such as api_lib.c) 
*/ 
#define 	MEMP_NUM_NETBUF   2

/*
    netconns Number of structures. (Only when using sequential APIs, such as api_lib.c)
*/ 
#define 	MEMP_NUM_NETCONN   4

/*
  lwip_select_cb Number of structures. 
(Only if you have LWIP_MPU_COMPATIBLE== 1 and use the socket API. In this case, each thread needs to call lwip_select.)
*/ 
#define 	MEMP_NUM_SELECT_CB   4

/*
 struct tcpip_msg Number for callback/timeout API communications. (Only when using tcpip.c)
*/ 
#define 	MEMP_NUM_TCPIP_MSG_API   8

/* 
    struct tcpip_msg Number of incoming packets. (Only when using tcpip.c)
*/ 
#define 	MEMP_NUM_TCPIP_MSG_INPKT   8

/* Number of lwip_addrinfo() calls run concurrently (before releasing the corresponding memory using lwip_freeaddrinfo(). */ 
#define 	MEMP_NUM_NETDB   1

/* DNS_LOCAL_HOSTLIST_IS_DYNAMIC == 1 The number of host entries in the local host list. */ 
#define 	MEMP_NUM_LOCALHOSTLIST   1

/* pbuf Number of buffers in the pool. */ 
#define 	PBUF_POOL_SIZE   16

/* The number of concurrent active calls to various socket, netconn and tcpip functions */ 
#define 	MEMP_NUM_API_MSG   MEMP_NUM_TCPIP_MSG_API

/* netconn_gethostbyname Number of concurrent activity calls */ 
#define 	MEMP_NUM_DNS_API_MSG   MEMP_NUM_TCPIP_MSG_API

/*   getsockopt / setsockopt Number of concurrent activity calls */ 
#define 	MEMP_NUM_SOCKET_SETGETSOCKOPT_DATA   MEMP_NUM_TCPIP_MSG_API

/* netifapi Number of simultaneous calls to functions */ 
#define 	MEMP_NUM_NETIFAPI_MSG   MEMP_NUM_TCPIP_MSG_API
/*
    LWIP_MIB2_CALLBACKS == 1: 
    Open the SNMP MIB2 callback. Open it to get the callbacks needed to implement MIB2. MIB2_STATS should also be enabled in general.
*/
#define 	LWIP_MIB2_CALLBACKS   0
  • Multicast

/* 
    Enable multicast TX support.
    For example, the socket option IP_MULTICAST_TTL/IP_MULTICAST_IF/IP_MULTICAST_LOOP,
    And (currently only supported) core support for the corresponding IPv6 options. 
*/
#define 	LWIP_MULTICAST_TX_OPTIONS   ((LWIP_IGMP || LWIP_IPV6_MLD) && (LWIP_UDP || LWIP_RAW))
  • Threading

/* TCPIP Main thread name */
#define 	TCPIP_THREAD_NAME   "tcpip_thread"

/* TCPIP Main thread stack size */ 
#define 	TCPIP_THREAD_STACKSIZE   0
 
/* TCPIP Priority of main thread */ 
#define 	TCPIP_THREAD_PRIO   1

/* TCPIP Mailbox size of main thread messages */ 
#define 	TCPIP_MBOX_SIZE   0

/* TCPIP It is defined as the content of the trigger monitor. */ 
#define 	LWIP_TCPIP_THREAD_ALIVE()

/* SLIPIF Thread name */ 
#define 	SLIPIF_THREAD_NAME   "slipif_loop"

/* SLIPIF Thread stack size */ 
#define 	SLIPIF_THREAD_STACKSIZE   0

/* SLIPIF Thread priority */ 
#define 	SLIPIF_THREAD_PRIO   1

/* Default thread name */ 
#define 	DEFAULT_THREAD_NAME   "lwIP"

/* Default thread stack size */ 
#define 	DEFAULT_THREAD_STACKSIZE   0

/* Default Thread Priority */ 
#define 	DEFAULT_THREAD_PRIO   1

/* Default the mailbox size of NETCONN_RAW incoming packets. */ 
#define 	DEFAULT_RAW_RECVMBOX_SIZE   0

/* Default the mailbox size of the incoming NETCONN_UDP packet. */ 
#define 	DEFAULT_UDP_RECVMBOX_SIZE   0

/* Default the mailbox size of the incoming NETCONN_TCP packet. */  
#define 	DEFAULT_TCP_RECVMBOX_SIZE   0

/* Default mailbox size for incoming connections */ 
#define 	DEFAULT_ACCEPTMBOX_SIZE   0
  • Checksum

/* 
    LWIP_CHECKSUM_CTRL_PER_NETIF== 1: 
    netif Enable/Disable Check and Generate/Check
    Note: If enabled, CHECKSUM_GEN_* and CHECKSUM_CHECK_* definitions must be enabled!
 */
#define 	LWIP_CHECKSUM_CTRL_PER_NETIF   0

/* Generate checksum for outgoing IP packets*/ 
#define 	CHECKSUM_GEN_IP   1


/* Generate checksum for outgoing UDP data packets*/  
#define 	CHECKSUM_GEN_UDP   1

/* Generate checksum for outgoing TCP packets*/  
#define 	CHECKSUM_GEN_TCP   1

/* Generate checksum for outgoing ICMP data packets*/  
#define 	CHECKSUM_GEN_ICMP   1

/* Generate Checksum for Outgoing ICMP6 Packets*/  
#define 	CHECKSUM_GEN_ICMP6   1

/* Check and check incoming IP packets */ 
#define 	CHECKSUM_CHECK_IP   1

/* Check and check for incoming UDP packets */  
#define 	CHECKSUM_CHECK_UDP   1

/* Check and check incoming TCP packets */  
#define 	CHECKSUM_CHECK_TCP   1

/* Check and check incoming ICMP packets */  
#define 	CHECKSUM_CHECK_ICMP   1

/* Check and check incoming ICMP6 packets */  
#define 	CHECKSUM_CHECK_ICMP6   1

/* Calculate the checksum when the data is copied from the application buffer to pbuf. */  
#define 	LWIP_CHECKSUM_ON_COPY   0
  • Hooks (hook option)

/* Hooks are not defined by default and can be defined as functions if necessary. */
#define 	LWIP_HOOK_FILENAME   "path/to/my/lwip_hooks.h"
 
#define 	LWIP_HOOK_TCP_ISN(local_ip, local_port, remote_ip, remote_port)
 
#define 	LWIP_HOOK_TCP_INPACKET_PCB(pcb, hdr, optlen, opt1len, opt2, p)
 
#define 	LWIP_HOOK_TCP_OUT_TCPOPT_LENGTH(pcb, internal_len)
 
#define 	LWIP_HOOK_TCP_OUT_ADD_TCPOPTS(p, hdr, pcb, opts)
 
#define 	LWIP_HOOK_IP4_INPUT(pbuf, input_netif)
 
#define 	LWIP_HOOK_IP4_ROUTE()
 
#define 	LWIP_HOOK_IP4_ROUTE_SRC(src, dest)
 
#define 	LWIP_HOOK_IP4_CANFORWARD(src, dest)
 
#define 	LWIP_HOOK_ETHARP_GET_GW(netif, dest)
 
#define 	LWIP_HOOK_IP6_INPUT(pbuf, input_netif)
 
#define 	LWIP_HOOK_IP6_ROUTE(src, dest)
 
#define 	LWIP_HOOK_ND6_GET_GW(netif, dest)
 
#define 	LWIP_HOOK_VLAN_CHECK(netif, eth_hdr, vlan_hdr)
 
#define 	LWIP_HOOK_VLAN_SET(netif, p, src, dst, eth_type)
 
#define 	LWIP_HOOK_MEMP_AVAILABLE(memp_t_type)
 
#define 	LWIP_HOOK_UNKNOWN_ETH_PROTOCOL(pbuf, netif)
 
#define 	LWIP_HOOK_DHCP_APPEND_OPTIONS(netif, dhcp, state, msg, msg_type, options_len_ptr)
 
#define 	LWIP_HOOK_DHCP_PARSE_OPTION(netif, dhcp, state, msg, msg_type, option, len, pbuf, offset)
 
#define 	LWIP_HOOK_DHCP6_APPEND_OPTIONS(netif, dhcp6, state, msg, msg_type, options_len_ptr, max_len)
 
#define 	LWIP_HOOK_SOCKETS_SETSOCKOPT(s, sock, level, optname, optval, optlen, err)
 
#define 	LWIP_HOOK_SOCKETS_GETSOCKOPT(s, sock, level, optname, optval, optlen, err)
 
#define 	LWIP_HOOK_NETCONN_EXTERNAL_RESOLVE(name, addr, addrtype, err)

2.2 IPv4

  • ARP

/*
    LWIP_ARP == 1 : Enabling ARP function
*/
#define 	LWIP_ARP   1

/* MAC-IP Address cache size*/ 
#define 	ARP_TABLE_SIZE   10

/* ARP Entries remain valid after last update */ 
#define 	ARP_MAXAGE   300

/*
    ARP_QUEUEING== 1: 
    During hardware address resolution, multiple outgoing packets are queued. By default, each IP address queues only the latest packets. 
    This is enough for most protocols, mainly to reduce the start-up time of TCP connections.
*/ 

#define 	ARP_QUEUEING   0

/* 
    Other network layers may queue the maximum number of packets for each unresolved address.
    Default 3,0 means disabled. Discard old data packets and queue up new ones.
 */ 
#define 	ARP_QUEUE_LEN   3

/*
    ETHARP_SUPPORT_VLAN == 1: Support the use of VLAN header to receive and send Ethernet packets
*/ 
#define 	ETHARP_SUPPORT_VLAN   0

/*
    LWIP_ETHERNET== 1: Enabling Ethernet Support
*/ 
#define 	LWIP_ETHERNET   LWIP_ARP

/* The number of bytes added before the Ethernet header to ensure that the payload is aligned after the header. */ 
#define 	ETH_PAD_SIZE   0

/*
    ETHARP_SUPPORT_STATIC_ENTRIES== 1: 
    Enable support for static ARP table entries (using etharp_add_static_entry/etharp_remove_static_entry).
*/ 
#define 	ETHARP_SUPPORT_STATIC_ENTRIES   0

/*
    ETHARP_TABLE_MATCH_NETIF== 1: 
    Match the ARP table entry of netif. If disabled, duplicate IP addresses on multiple netif are not supported (but only for AutoIP)
*/ 
#define 	ETHARP_TABLE_MATCH_NETIF   !LWIP_SINGLE_NETIF
 
  • IP

/* Enabling IPv4 */
#define 	LWIP_IPV4   1

/*
    IP_FORWARD== 1: 
    Enable the function of forwarding IP packets across network interfaces. If you want to run lwIP on a device with only one network interface, define it as 0.
*/ 
#define 	IP_FORWARD   0

/*
    IP_REASSEMBLY== 1: Reassemble incoming fragmented IP packets. 
*/ 
#define 	IP_REASSEMBLY   1

/*
    IP_FRAG== 1: If the outgoing IP packet size exceeds MTU, it is segmented.
*/ 
#define 	IP_FRAG   1

/*
    Define the behavior of IP options.
    IP_OPTIONS_ALLOWED == 0: Discard all packets with IP options. 
    IP_OPTIONS_ALLOWED == 1: Allow IP options (but not parsed)
*/ 
#define 	IP_OPTIONS_ALLOWED   1

/* 
    The longest time a fragmented IP packet waits for all fragments to arrive. 
    If not all fragments arrive at this time, the entire packet is discarded. 
    second
*/ 
#define 	IP_REASS_MAXAGE   15

/*
    The maximum number of pbuf s awaiting reassembly.
    Since the received pbuf is on the queue, be sure to configure PBUF_POOL_SIZE> IP_REASS_MAX_PBUFS.
    So that even if the largest number of fragments are reassembled into the queue, the stack can still receive data packets! 
    When IPv4 and IPv6 are enabled, it will even change to (PBUF_POOL_SIZE > 2 * IP_REASS_MAX_PBUFS)!
*/ 
#define 	IP_REASS_MAX_PBUFS   10

/* The default lifetime used by the transport layer. */ 
#define 	IP_DEFAULT_TTL   255

/*
    IP_SOF_BROADCAST= 1: 
    Send in udp and raw using SOF_BROADCAST field
*/ 
#define 	IP_SOF_BROADCAST   0

/*
    IP_SOF_BROADCAST_RECV==1:
    (IP_SOF_BROADCAST = 1) is required to enable receive filtering.
*/ 
#define 	IP_SOF_BROADCAST_RECV   0

/*
    IP_FORWARD_ALLOW_TX_ON_RX_NETIF== 1: 
    Allow ip_forward() to send back packets on netif that received it. For wireless networks only.
    Note: When it is 1, make sure that your netif driver correctly marks incoming link-layer broadcast/multicast packets with corresponding pbuf tags!
*/ 
#define 	IP_FORWARD_ALLOW_TX_ON_RX_NETIF   0
  • ICMP

/* Protocol stack enabled ICMP module*/
#define 	LWIP_ICMP   1

/* ICMP Packet Lifetime */ 
#define 	ICMP_TTL   IP_DEFAULT_TTL

/*  LWIP_BROADCAST_PING== 1: Response broadcast ping (unicast only by default)*/ 
#define 	LWIP_BROADCAST_PING   0
 
/* LWIP_MULTICAST_PING == 1: Response multicast ping (default unicast) */
#define 	LWIP_MULTICAST_PING   0
  • DHCP

/* Enabling DHCP function */
#define 	LWIP_DHCP   0

/* DHCP_DOES_ARP_CHECK== 1: ARP check the address provided.*/ 
#define 	DHCP_DOES_ARP_CHECK   (LWIP_DHCP && LWIP_ARP)

/* LWIP_DHCP_BOOTP_FILE== 1: Store provided_si_addr and boot_file_name.*/ 
#define 	LWIP_DHCP_BOOTP_FILE   0

/*
    LWIP_DHCP_GETS_NTP== 1: 
    Request NTP server by discovery/selection. For each response packet, a callback is invoked, which must be provided by the port:
    void dhcp_set_ntp_servers(u8_t num_ntp_servers,ip_addr_t * ntp_server_addrs);
*/ 
#define 	LWIP_DHCP_GET_NTP_SRV   0

/* NTP Maximum number of requests for services */ 
#define 	LWIP_DHCP_MAX_NTP_SERVERS   1
 
#define 	LWIP_DHCP_MAX_DNS_SERVERS   DNS_MAX_SERVERS
  • AUTOIP

/* Enabling AUTOIP module*/
#define 	LWIP_AUTOIP   0

/*
    LWIP_DHCP_AUTOIP_COOP == 1: It allows both DHCP and AUTOIP to be enabled on the same interface.
*/ 
#define 	LWIP_DHCP_AUTOIP_COOP   0

/* DHCP Times of discovery */ 
#define 	LWIP_DHCP_AUTOIP_COOP_TRIES   9
  • IGMP

/* Enabling IGMP module */
#define 	LWIP_IGMP   0

2.3 Callback-style APIs

  • RAW

/* LWIP_RAW == 1: Enable application layer hooking to the IP layer itself. */
#define 	LWIP_RAW   0
 
#define 	RAW_TTL   IP_DEFAULT_TTL
 
  • DNS

/* DNS Modular */
#define 	LWIP_DNS   0

/* DNS Maximum number of entries maintained locally. */ 
#define 	DNS_TABLE_SIZE   4

/* The maximum host name length of DNS supported in the name table. */ 
#define 	DNS_MAX_NAME_LENGTH   256

/* DNS Maximum number of servers. */ 
#define 	DNS_MAX_SERVERS   2

/* The maximum number of DNS retries at request name before "timeout". */ 
#define 	DNS_MAX_RETRIES   4

/* DNS Name checking between queries and responses. */ 
#define 	DNS_DOES_NAME_CHECK   1

/* Control the security level of DNS implementation and use all DNS security functions by default. */ 
#define 	LWIP_DNS_SECURE   (LWIP_DNS_SECURE_RAND_XID | LWIP_DNS_SECURE_NO_MULTIPLE_OUTSTANDING | LWIP_DNS_SECURE_RAND_SRC_PORT)

/* DNS Address list. */ 
#define 	DNS_LOCAL_HOSTLIST   0

/* DNS Dynamic Address List */ 
#define 	DNS_LOCAL_HOSTLIST_IS_DYNAMIC   0

/* MDNS Query support*/ 
#define 	LWIP_DNS_SUPPORT_MDNS_QUERIES   0
  • UDP

/* Enabling UDP */
#define 	LWIP_UDP   1
 
#define 	LWIP_UDPLITE   0

/* survival time */ 
#define 	UDP_TTL   IP_DEFAULT_TTL

/*
    LWIP_NETBUF_RECVINFO == 1: Attach the destination address and port to each netbuf.
*/ 
#define 	LWIP_NETBUF_RECVINFO   0
  • TCP

/* Enabling TCP */
#define 	LWIP_TCP   1
 
#define 	TCP_TTL   IP_DEFAULT_TTL

/* TCP Window size: Must be at least (2 * TCP_MSS)*/ 
#define 	TCP_WND   (4 * TCP_MSS)

/* Maximum number of retransmissions of data segments */ 
#define 	TCP_MAXRTX   12

/* SYN Segment Maximum Retransmit Number */ 
#define 	TCP_SYNMAXRTX   6

/*
    TCP_QUEUE_OOSEQ==1: 
    TCP Queues will be queued for segments arriving in disorder. If the device has insufficient memory, define it as 0.
*/ 
#define 	TCP_QUEUE_OOSEQ   LWIP_TCP

/*
    LWIP_TCP_SACK_OUT== 1: 
    TCP Sending Selective Confirmation (SACK) will be supported
*/ 
#define 	LWIP_TCP_SACK_OUT   0
 
#define 	LWIP_TCP_MAX_SACK_NUM   4

/* TCP_MSS: TCP Maximum segment size */ 
#define 	TCP_MSS   536

/* tcp The expected length of the segment to be sent is 1, which is allocated according to the size of the window. */ 
#define 	TCP_CALCULATE_EFF_SEND_MSS   1

/* Send Buffer (bytes)*/ 
#define 	TCP_SND_BUF   (2 * TCP_MSS)

/* TCP Sender Buffer Space (pbufs), Queue Length */ 
#define 	TCP_SND_QUEUELEN   ((4 * (TCP_SND_BUF) + (TCP_MSS - 1))/(TCP_MSS))

/* TCP Writable space (bytes). This must be less than TCP_SND_BUF */ 
#define 	TCP_SNDLOWAT   LWIP_MIN(LWIP_MAX(((TCP_SND_BUF)/2), (2 * TCP_MSS) + 1), (TCP_SND_BUF) - 1)

/*
    TCP Writable bufs (pbuf count). This must be less than TCP_SND_QUEUELEN. 
    If the number of pbuf s queued on the pcb is less than this number, select returns writable (used in conjunction with TCP_SNDLOWAT)
*/ 
#define 	TCP_SNDQUEUELOWAT   LWIP_MAX(((TCP_SND_QUEUELEN)/2), 5)

/* Default maximum number of bytes queued on ooseq */ 
#define 	TCP_OOSEQ_MAX_BYTES   0

/* Default maximum number of pbufs queued on ooseq */ 
#define 	TCP_OOSEQ_MAX_PBUFS   0

/* Enable the backlog option */ 
#define 	TCP_LISTEN_BACKLOG   0

/* TCP Listening for the maximum backlog allowed by netconns */ 
#define 	TCP_DEFAULT_LISTEN_BACKLOG   0xff

/*
    tcp_write The maximum number of bytes can be allocated in advance to try to create shorter pbuf chains for transmission.
    The meaningful range is 0 to TCP_MSS.
*/ 
#define 	TCP_OVERSIZE   TCP_MSS

/* Support TCP timestamp options */ 
#define 	LWIP_TCP_TIMESTAMPS   0

/* Differences in Windows trigger explicit window updates */ 
#define 	TCP_WND_UPDATE_THRESHOLD   LWIP_MIN((TCP_WND / 4), (TCP_MSS * 4))

/* Either event or callback, default callback */ 
#define 	LWIP_EVENT_API   0
#defin          LWIP_CALLBACK_API 1

/* TCP Window Scale Option (WSopt):   Kind: 3 Length: 3 bytes  */ 
#define 	LWIP_WND_SCALE   0
#define         TCP_RCV_SCALE    0

/* Number of extended entries */ 
#define 	LWIP_TCP_PCB_NUM_EXT_ARGS   0

/*
    Application layered TCP
    LWIP_ALTCP == 1: 
        Enable altcp API. Altcp is an abstraction layer that prevents applications from linking to tcp.h functions, but provides the same functionality.
    LWIP_ALTCP == 0:
        Applications written for the altcp API can still be compiled, but directly linked to the tcp.h callback API, and then the layered protocol cannot be used.
*/ 
#define 	LWIP_ALTCP   0

/* LWIP_ALTCP_TLS== 1: altcp API Enable TLS (Secure Transport Protocol) support */ 
#define 	LWIP_ALTCP_TLS   0

2.4 PBUF

/* The number of bytes allocated by the link header. The default value is 14, which is the standard value of ethernet. */
#define 	PBUF_LINK_HLEN   (14 + ETH_PAD_SIZE)

/* The number of bytes that should be allocated to other encapsulation headers before the Ethernet header */ 
#define 	PBUF_LINK_ENCAPSULATION_HLEN   0

/*
    pbuf The size of each pbuf in the pool.
    The default design is used to accommodate a single full size TCP frame in a pbuf, including TCP_MSS, IP header and link header.
*/ 
#define 	PBUF_POOL_BUFSIZE   LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN)

/* pbuf Refcount type in. If 255 refs is not enough, the default width of u8_t can be increased. */ 
#define 	LWIP_PBUF_REF_T   u8_t

2.5 NETIF

/* 
    LWIP_SINGLE_NETIF== 1: 
    Use only one netif. This is a common occurrence of small real-life goals. You can omit some code like routing.
*/
#define 	LWIP_SINGLE_NETIF   0

/*
    LWIP_NETIF_HOSTNAME== 1: 
    Use DHCP? Option? Hostname with the host name field of netif.
*/ 
#define 	LWIP_NETIF_HOSTNAME   0

/* 
    LWIP_NETIF_API == 1: Support netif api (in netifapi.c) 
    (to be used from non-TCPIP threads)
*/ 
#define 	LWIP_NETIF_API   0

/* 
    LWIP_NETIF_STATUS_CALLBACK== 1: 
    Callback function is supported whenever the interface changes its upper/lower state (i.e., due to DHCP IP acquisition). 
*/ 
#define 	LWIP_NETIF_STATUS_CALLBACK   0

/*
    LWIP_NETIF_EXT_STATUS_CALLBACK== 1: 
    Extended callback functions that support multiple netif-related events that support multiple subscribers.
*/ 
#define 	LWIP_NETIF_EXT_STATUS_CALLBACK   0

/*
    LWIP_NETIF_LINK_CALLBACK== 1: 
    Callback functions are supported from the interface whenever the link changes (i.e., the link is disconnected).
*/ 
#define 	LWIP_NETIF_LINK_CALLBACK   0

/*
    LWIP_NETIF_REMOVE_CALLBACK== 1: 
    Supports callback functions called when netif is deleted
*/ 
#define 	LWIP_NETIF_REMOVE_CALLBACK   0

/*
    LWIP_NETIF_HWADDRHINT== 1: Cache link layer address hints (such as table indexes) in struct netif.
    TCP UDP and UDP can use it to prevent scanning ARP tables for each sent packet. Although this is faster for large ARP tables or multiple concurrent connections, it may backfire if you have a small ARP table or never have concurrent connections.
*/ 
#define 	LWIP_NETIF_HWADDRHINT   0

/* 
    Single PBUF Send 
    LWIP_NETIF_TX_SINGLE_PBUF== 1
    lwIP Attempts are made to send all data to a pbuf. This is for compatibility with MAC that does not support decentralized-aggregated support for DMA.
*/ 
#define 	LWIP_NETIF_TX_SINGLE_PBUF   0

/* The number of clients (up to 256) that can store data in the client_data member array of struct netif. */ 
#define 	LWIP_NUM_NETIF_CLIENT_DATA   0

2.6 IPv6

For the time being

2.7 Thread-safe APIs

  • Netconn

/* LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c)  */
#define 	LWIP_NETCONN   1

/*
    LWIP_TCPIP_TIMEOUT== 1: 
    Enable tcpip_timeout/tcpip_untimeout to create a timer running in tcpip_thread from another thread.
*/
#define 	LWIP_TCPIP_TIMEOUT   0

/*
    LWIP_NETCONN_SEM_PER_THREAD== 1: 
    Each thread invokes the socket / netconn function with a semaphore (local thread), rather than assigning a semaphore (and each selection, etc.) to each netconn.
*/ 
#define 	LWIP_NETCONN_SEM_PER_THREAD   0

/*
    LWIP_NETCONN_FULLDUPLEX == 1: 
    Enabling code that allows reading from one thread, writing from the second thread and closing from the third thread at the same time.
*/ 
#define 	LWIP_NETCONN_FULLDUPLEX   0
  • Sockets

/* LWIP_SOCKET==1: Enable Socket API (require to use sockets.c)  */
#define 	LWIP_SOCKET   1

/* 
    LWIP_COMPAT_SOCKETS== 1: Enable BSD-style socket function name.
 */ 
#define 	LWIP_COMPAT_SOCKETS   1

/*
    LWIP_POSIX_SOCKETS_IO_NAMES== 1: Name of socket function with POSIX style enabled
*/ 
#define 	LWIP_POSIX_SOCKETS_IO_NAMES   1

/* Add the file descriptor number created by LwIP */ 
#define 	LWIP_SOCKET_OFFSET   0
 
#define 	LWIP_TCP_KEEPALIVE   0

/* Enable send timeout for socket / netconns and SO_SNDTIMEO processing. */ 
#define 	LWIP_SO_SNDTIMEO   0

/* Enable receive timeout for socket / netconns and SO_SNDTIMEO processing. */ 
#define 	LWIP_SO_RCVTIMEO   0
 
#define 	LWIP_SO_SNDRCVTIMEO_NONSTANDARD   0

/* LWIP_SO_RCVBUF == 1: Enable SO_RCVBUF processing. */ 
#define 	LWIP_SO_RCVBUF   0

/* LWIP_SO_LINGER == 1: Enable SO_LINGER processing. */ 
#define 	LWIP_SO_LINGER   0

/* If LWIP_SO_RCVBUF is used, this is the default value of recv_bufsize. */ 
#define 	RECV_BUFSIZE_DEFAULT   INT_MAX

/* Turn off the default timeout value */ 
#define 	LWIP_TCP_CLOSE_TIMEOUT_MS_DEFAULT   20000
 
/* SO_REUSE==1: Enable SO_REUSEADDR option. */
#define 	SO_REUSE   0
 
#define 	SO_REUSE_RXTOALL   0

/*  Data schema selection: 0 win 1:linux*/ 
#define 	LWIP_FIONREAD_LINUXMODE   0

/*
    LWIP_SOCKET_SELECT == 1(Default: Enable select () (using netconn callbacks to track events) for sockets. This saves RAM (counter per slot) and code (netconn event callback), which improves performance.
*/ 
#define 	LWIP_SOCKET_SELECT   1

/*
    LWIP_SOCKET_POLL == 1(Default values:
    Enable poll () (including struct pollfd, nfds_t and constants) for sockets
*/ 
#define 	LWIP_SOCKET_POLL   1

2.8 Debugging

  • Assertion handling

/* Disable LWIP_ASSERT checking: To disable assertions, define LWIP_NOASSERT in arch/cc.h. */
#define 	LWIP_NOASSERT
 
  • Statistics (status information)

/* 
    LWIP_STATS== 1: 
    Enable statistics collection in lwip_stats. 
    Debugging helps
*/
#define 	LWIP_STATS   1

/*
    LWIP_STATS_DISPLAY== 1: 
    Compile statistical output functions.
*/ 
#define 	LWIP_STATS_DISPLAY   0

/* Connection state */ 
#define 	LINK_STATS   1
 
#define 	ETHARP_STATS   (LWIP_ARP)
 
#define 	IP_STATS   1
 
#define 	IPFRAG_STATS   (IP_REASSEMBLY || IP_FRAG)
 
#define 	ICMP_STATS   1
 
#define 	IGMP_STATS   (LWIP_IGMP)
 
#define 	UDP_STATS   (LWIP_UDP)
 
#define 	TCP_STATS   (LWIP_TCP)
 
#define 	MEM_STATS   ((MEM_LIBC_MALLOC == 0) && (MEM_USE_POOLS == 0))
 
#define 	MEMP_STATS   (MEMP_MEM_MALLOC == 0)
 
#define 	SYS_STATS   (NO_SYS == 0)
 
#define 	IP6_STATS   (LWIP_IPV6)
 
#define 	ICMP6_STATS   (LWIP_IPV6 && LWIP_ICMP6)
 
#define 	IP6_FRAG_STATS   (LWIP_IPV6 && (LWIP_IPV6_FRAG || LWIP_IPV6_REASS))
 
#define 	MLD6_STATS   (LWIP_IPV6 && LWIP_IPV6_MLD)
 
#define 	ND6_STATS   (LWIP_IPV6)
 
#define 	MIB2_STATS   0
  • Debug messages (debugging information)

/* Debugging Information Configuration */
#define 	LWIP_DBG_MIN_LEVEL   LWIP_DBG_LEVEL_ALL
 
#define 	LWIP_DBG_TYPES_ON   LWIP_DBG_ON
 
#define 	ETHARP_DEBUG   LWIP_DBG_OFF
 
#define 	NETIF_DEBUG   LWIP_DBG_OFF
 
#define 	PBUF_DEBUG   LWIP_DBG_OFF
 
#define 	API_LIB_DEBUG   LWIP_DBG_OFF
 
#define 	API_MSG_DEBUG   LWIP_DBG_OFF
 
#define 	SOCKETS_DEBUG   LWIP_DBG_OFF
 
#define 	ICMP_DEBUG   LWIP_DBG_OFF
 
#define 	IGMP_DEBUG   LWIP_DBG_OFF
 
#define 	INET_DEBUG   LWIP_DBG_OFF
 
#define 	IP_DEBUG   LWIP_DBG_OFF
 
#define 	IP_REASS_DEBUG   LWIP_DBG_OFF
 
#define 	RAW_DEBUG   LWIP_DBG_OFF
 
#define 	MEM_DEBUG   LWIP_DBG_OFF
 
#define 	MEMP_DEBUG   LWIP_DBG_OFF
 
#define 	SYS_DEBUG   LWIP_DBG_OFF
 
#define 	TIMERS_DEBUG   LWIP_DBG_OFF
 
#define 	TCP_DEBUG   LWIP_DBG_OFF
 
#define 	TCP_INPUT_DEBUG   LWIP_DBG_OFF
 
#define 	TCP_FR_DEBUG   LWIP_DBG_OFF
 
#define 	TCP_RTO_DEBUG   LWIP_DBG_OFF
 
#define 	TCP_CWND_DEBUG   LWIP_DBG_OFF
 
#define 	TCP_WND_DEBUG   LWIP_DBG_OFF
 
#define 	TCP_OUTPUT_DEBUG   LWIP_DBG_OFF
 
#define 	TCP_RST_DEBUG   LWIP_DBG_OFF
 
#define 	TCP_QLEN_DEBUG   LWIP_DBG_OFF
 
#define 	UDP_DEBUG   LWIP_DBG_OFF
 
#define 	TCPIP_DEBUG   LWIP_DBG_OFF
 
#define 	SLIP_DEBUG   LWIP_DBG_OFF
 
#define 	DHCP_DEBUG   LWIP_DBG_OFF
 
#define 	AUTOIP_DEBUG   LWIP_DBG_OFF
 
#define 	DNS_DEBUG   LWIP_DBG_OFF
 
#define 	IP6_DEBUG   LWIP_DBG_OFF
 
#define 	DHCP6_DEBUG   LWIP_DBG_OFF
  • Performance (Performance Testing)

/* LWIP_PERF: Enable performance testing for lwIP (if enabled, arch/perf.h is included)  */
#define 	LWIP_PERF   0

 

Tags: DNS socket network Mac

Posted on Fri, 11 Oct 2019 11:38:00 -0700 by ywickham