mbed-os/features/lwipstack/lwipopts.h

407 lines
13 KiB
C
Raw Normal View History

2016-04-05 14:36:06 +00:00
/* Copyright (C) 2012 mbed.org, MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute,
* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef LWIPOPTS_H
#define LWIPOPTS_H
// Workaround for Linux timeval
#if defined (TOOLCHAIN_GCC)
#define LWIP_TIMEVAL_PRIVATE 0
#include <sys/time.h>
#endif
#include "nsapi_types.h"
2018-10-30 15:02:01 +00:00
// Operating System
2016-04-05 14:36:06 +00:00
#define NO_SYS 0
#if MBED_CONF_LWIP_IPV4_ENABLED
#define LWIP_IPV4 1
#else
#define LWIP_IPV4 0
#endif
#if MBED_CONF_LWIP_IPV6_ENABLED
#define LWIP_IPV6 1
#else
#define LWIP_IPV6 0
#endif
#if !MBED_CONF_LWIP_IPV4_ENABLED && !MBED_CONF_LWIP_IPV6_ENABLED
#error "Either IPv4 or IPv6 must be enabled."
#endif
// On dual stack configuration how long to wait for both or preferred stack
// addresses before completing bring up.
#if LWIP_IPV4 && LWIP_IPV6
#if MBED_CONF_LWIP_ADDR_TIMEOUT_MODE
#define BOTH_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT
#define PREF_ADDR_TIMEOUT 0
#else
#define PREF_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT
#define BOTH_ADDR_TIMEOUT 0
#endif
#else
#define PREF_ADDR_TIMEOUT 0
#define BOTH_ADDR_TIMEOUT 0
#endif
#define DHCP_TIMEOUT 60
#define LINK_TIMEOUT 60
#define PREF_IPV4 1
#define PREF_IPV6 2
#if MBED_CONF_LWIP_IP_VER_PREF == 4
#define IP_VERSION_PREF PREF_IPV4
#endif
#if MBED_CONF_LWIP_IP_VER_PREF == 6
#define IP_VERSION_PREF PREF_IPV6
#endif
#ifndef IP_VERSION_PREF
#error "Either IPv4 or IPv6 must be preferred."
#endif
#undef LWIP_DEBUG
#if MBED_CONF_LWIP_DEBUG_ENABLED
#define LWIP_DEBUG 1
#endif
2016-04-05 14:36:06 +00:00
#if NO_SYS == 0
#include "cmsis_os2.h"
2016-04-05 14:36:06 +00:00
#define SYS_LIGHTWEIGHT_PROT 1
2019-04-26 15:22:00 +00:00
#ifndef LWIP_RAW
2016-04-05 14:36:06 +00:00
#define LWIP_RAW 0
2019-04-26 15:22:00 +00:00
#endif
2016-04-05 14:36:06 +00:00
#define TCPIP_MBOX_SIZE 8
#define DEFAULT_TCP_RECVMBOX_SIZE 8
#define DEFAULT_UDP_RECVMBOX_SIZE 8
#define DEFAULT_RAW_RECVMBOX_SIZE 8
#define DEFAULT_ACCEPTMBOX_SIZE 8
// Thread stacks use 8-byte alignment
#define LWIP_ALIGN_UP(pos, align) ((pos) % (align) ? (pos) + ((align) - (pos) % (align)) : (pos))
// Thread stack size for lwip tcpip thread
#ifndef MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE
#define MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE 1200
#endif
#ifdef LWIP_DEBUG
// For LWIP debug, double the stack
#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE*2, 8)
#elif MBED_DEBUG
// When debug is enabled on the build increase stack 25 percent
#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE + MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE / 4, 8)
#else
#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE, 8)
#endif
// Thread priority (osPriorityNormal by default)
#define TCPIP_THREAD_PRIO (MBED_CONF_LWIP_TCPIP_THREAD_PRIORITY)
2016-04-05 14:36:06 +00:00
// Thread stack size for lwip system threads
#ifndef MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE
#define MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE 512
#endif
// Thread stack size for private PPP thread
#ifndef MBED_CONF_LWIP_PPP_THREAD_STACKSIZE
#define MBED_CONF_LWIP_PPP_THREAD_STACKSIZE 768
#endif
#ifdef LWIP_DEBUG
#define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE*2, 8)
#define PPP_THREAD_STACK_SIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_PPP_THREAD_STACKSIZE*2, 8)
#else
#define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE, 8)
#define PPP_THREAD_STACK_SIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_PPP_THREAD_STACKSIZE, 8)
#endif
2016-04-05 14:36:06 +00:00
#define MEMP_NUM_SYS_TIMEOUT 16
#define sys_msleep(ms) sys_msleep(ms)
2016-04-05 14:36:06 +00:00
#endif
// 32-bit alignment
#define MEM_ALIGNMENT 4
#define LWIP_RAM_HEAP_POINTER lwip_ram_heap
// Number of simultaneously queued TCP segments.
#ifdef MBED_CONF_LWIP_MEMP_NUM_TCP_SEG
#define MEMP_NUM_TCP_SEG MBED_CONF_LWIP_MEMP_NUM_TCP_SEG
#endif
// TCP Maximum segment size.
#ifdef MBED_CONF_LWIP_TCP_MSS
#define TCP_MSS MBED_CONF_LWIP_TCP_MSS
#endif
// TCP sender buffer space (bytes).
#ifdef MBED_CONF_LWIP_TCP_SND_BUF
#define TCP_SND_BUF MBED_CONF_LWIP_TCP_SND_BUF
#endif
// TCP sender buffer space (bytes).
#ifdef MBED_CONF_LWIP_TCP_WND
#define TCP_WND MBED_CONF_LWIP_TCP_WND
#endif
#ifdef MBED_CONF_LWIP_TCP_MAXRTX
#define TCP_MAXRTX MBED_CONF_LWIP_TCP_MAXRTX
#endif
#ifdef MBED_CONF_LWIP_TCP_SYNMAXRTX
#define TCP_SYNMAXRTX MBED_CONF_LWIP_TCP_SYNMAXRTX
#endif
// Number of pool pbufs.
// Each requires 684 bytes of RAM (if MSS=536 and PBUF_POOL_BUFSIZE defaulting to be based on MSS)
#ifdef MBED_CONF_LWIP_PBUF_POOL_SIZE
#undef PBUF_POOL_SIZE
#define PBUF_POOL_SIZE MBED_CONF_LWIP_PBUF_POOL_SIZE
#else
#ifndef PBUF_POOL_SIZE
2016-04-05 14:36:06 +00:00
#define PBUF_POOL_SIZE 5
#endif
#endif
#ifdef MBED_CONF_LWIP_PBUF_POOL_BUFSIZE
#undef PBUF_POOL_BUFSIZE
#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(MBED_CONF_LWIP_PBUF_POOL_BUFSIZE)
#else
#ifndef PBUF_POOL_BUFSIZE
#if LWIP_IPV6
#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN)
#elif LWIP_IPV4
#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+20+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN)
#endif
#endif
#endif
#ifdef MBED_CONF_LWIP_MEM_SIZE
#undef MEM_SIZE
#define MEM_SIZE MBED_CONF_LWIP_MEM_SIZE
#endif
// One tcp_pcb_listen is needed for each TCPServer.
// Each requires 72 bytes of RAM.
#ifdef MBED_CONF_LWIP_TCP_SERVER_MAX
#define MEMP_NUM_TCP_PCB_LISTEN MBED_CONF_LWIP_TCP_SERVER_MAX
#else
2016-04-05 14:36:06 +00:00
#define MEMP_NUM_TCP_PCB_LISTEN 4
#endif
// One is tcp_pcb needed for each TCPSocket.
// Each requires 196 bytes of RAM.
#ifdef MBED_CONF_LWIP_TCP_SOCKET_MAX
#define MEMP_NUM_TCP_PCB MBED_CONF_LWIP_TCP_SOCKET_MAX
#else
2016-04-05 14:36:06 +00:00
#define MEMP_NUM_TCP_PCB 4
#endif
// One udp_pcb is needed for each UDPSocket.
// Each requires 84 bytes of RAM (total rounded to multiple of 512).
#ifdef MBED_CONF_LWIP_UDP_SOCKET_MAX
#define MEMP_NUM_UDP_PCB MBED_CONF_LWIP_UDP_SOCKET_MAX
#else
2016-04-05 14:36:06 +00:00
#define MEMP_NUM_UDP_PCB 4
#endif
// Number of non-pool pbufs.
// Each requires 92 bytes of RAM.
#ifndef MEMP_NUM_PBUF
2016-04-05 14:36:06 +00:00
#define MEMP_NUM_PBUF 8
#endif
// Each netbuf requires 64 bytes of RAM.
#ifndef MEMP_NUM_NETBUF
2016-04-05 14:36:06 +00:00
#define MEMP_NUM_NETBUF 8
#endif
// One netconn is needed for each UDPSocket, TCPSocket or TCPServer.
// Each requires 236 bytes of RAM (total rounded to multiple of 512).
#ifdef MBED_CONF_LWIP_SOCKET_MAX
#define MEMP_NUM_NETCONN MBED_CONF_LWIP_SOCKET_MAX
#else
#define MEMP_NUM_NETCONN 4
#endif
2016-04-05 14:36:06 +00:00
#if MBED_CONF_LWIP_TCP_ENABLED
#define LWIP_TCP 1
2016-04-05 14:36:06 +00:00
#define TCP_OVERSIZE 0
#define LWIP_TCP_KEEPALIVE 1
#ifdef MBED_CONF_TCP_CLOSE_TIMEOUT
#define TCP_CLOSE_TIMEOUT MBED_CONF_TCP_CLOSE_TIMEOUT
#else
#define TCP_CLOSE_TIMEOUT 1000
#endif
#else
#define LWIP_TCP 0
#endif
2016-04-05 14:36:06 +00:00
#define LWIP_DNS 1
// Only DNS address storage is enabled
#define LWIP_FULL_DNS 0
#define LWIP_SOCKET 0
2016-04-05 14:36:06 +00:00
#define SO_REUSE 1
2016-04-05 14:36:06 +00:00
// Support Multicast
#include "stdlib.h"
#define LWIP_IGMP LWIP_IPV4
#define LWIP_RAND() lwip_get_random()
2016-04-05 14:36:06 +00:00
#define LWIP_COMPAT_SOCKETS 0
#define LWIP_POSIX_SOCKETS_IO_NAMES 0
#define LWIP_SO_RCVTIMEO 1
#define LWIP_BROADCAST_PING 1
2016-04-05 14:36:06 +00:00
// Fragmentation on, as per IPv4 default
#define LWIP_IPV6_FRAG LWIP_IPV6
// Queuing "disabled", as per IPv4 default (so actually queues 1)
#define LWIP_ND6_QUEUEING 0
2016-04-05 14:36:06 +00:00
// Debug Options
#define NETIF_DEBUG LWIP_DBG_OFF
2016-04-05 14:36:06 +00:00
#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
2016-04-05 14:36:06 +00:00
#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
2016-04-05 14:36:06 +00:00
#define DHCP_DEBUG LWIP_DBG_OFF
#define AUTOIP_DEBUG LWIP_DBG_OFF
#define DNS_DEBUG LWIP_DBG_OFF
#define IP6_DEBUG LWIP_DBG_OFF
#if MBED_CONF_LWIP_ENABLE_PPP_TRACE
#define PPP_DEBUG LWIP_DBG_ON
#else
#define PPP_DEBUG LWIP_DBG_OFF
#endif //MBED_CONF_LWIP_ENABLE_PPP_TRACE
#define ETHARP_DEBUG LWIP_DBG_OFF
#define UDP_LPC_EMAC LWIP_DBG_OFF
2016-04-05 14:36:06 +00:00
#ifdef LWIP_DEBUG
2016-04-05 14:36:06 +00:00
#define MEMP_OVERFLOW_CHECK 1
#define MEMP_SANITY_CHECK 1
#define LWIP_DBG_TYPES_ON LWIP_DBG_ON
#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL
2016-04-05 14:36:06 +00:00
#else
#define LWIP_NOASSERT 1
#define LWIP_STATS 0
#endif
#define TRACE_TO_ASCII_HEX_DUMP 0
2016-04-05 14:36:06 +00:00
#define LWIP_PLATFORM_BYTESWAP 1
#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 1
2016-04-05 14:36:06 +00:00
// Interface type configuration
2016-04-05 14:36:06 +00:00
#if MBED_CONF_LWIP_ETHERNET_ENABLED
#define LWIP_ARP 1
#define LWIP_ETHERNET 1
#define LWIP_DHCP LWIP_IPV4
#else
#define LWIP_ARP 0
#define LWIP_ETHERNET 0
#endif // MBED_CONF_LWIP_ETHERNET_ENABLED
#if MBED_CONF_LWIP_L3IP_ENABLED
#define LWIP_L3IP 1
#else
#define LWIP_L3IP 0
#endif
//Maximum size of network interface name
#define INTERFACE_NAME_MAX_SIZE NSAPI_INTERFACE_NAME_MAX_SIZE
Major Refactoring & extensions For keep supporting external APIs with the same name (supposedly there are a larger number of users of those APIs), BufferedSerial and ATParser are being renamed. BufferedSerial becomes UARTSerial, will complement a future USBSerial etc. ATParser becomes ATCmdParser. * UARTSerial moves to /drivers * APN_db.h is moved from platform to cellular/util/. * Original CellularInterface is restored for backward compatability (again, supposedly there are users of that). * A new file, CellularBase is added which will now servce as the base class for all upcoming drivers. * Special restructuring for the driver has been undertaken. This makes a clear cut distinction between an on-board or an off-board implementation. - PPPCellularInterface is a generic network interface that works with a generic FileHandle and PPP. A derived class is needed to pass that FileHandle. - PPPCellularInterface provides some base functionality like network registration, AT setup, PPP connection etc. Lower level job is delegated to the derived classes and various modem specific APIs are provided which are supposed to be overridden. - UARTCellularInterface is derived from PPPCellularInterface. It constructs a FileHandle and passes it back to PPPCellularInterface as well as provides modem hangupf functionality. In future we could proive a USBInterface that would derive from PPPCellularInterface and could pass the FileHandle back. - OnboardCellularInterface is derived from UARTCellularInterfae and provides hooks to the target provided implementation of onbard_modem_api.h. An off-board modem, i.e, a modem on a shield has to override the modem_init(), modem_power_up() etc as it cannot use onboard_modem_api.h.
2017-05-23 17:07:24 +00:00
// Note generic macro name used rather than MBED_CONF_LWIP_PPP_ENABLED
// to allow users like PPPCellularInterface to detect that nsapi_ppp.h is available.
#if NSAPI_PPP_AVAILABLE
#define PPP_SUPPORT 1
#if MBED_CONF_LWIP_IPV6_ENABLED
#define PPP_IPV6_SUPPORT 1
// Disable DAD for PPP
#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 0
#endif
#define CHAP_SUPPORT 1
#define PPP_INPROC_IRQ_SAFE 1
// Save RAM
#define PAP_SUPPORT 0
#define VJ_SUPPORT 0
#define PRINTPKT_SUPPORT 0
2016-04-05 14:36:06 +00:00
// Broadcast
#define IP_SOF_BROADCAST 0
#define IP_SOF_BROADCAST_RECV 0
2016-04-05 14:36:06 +00:00
#define MAXNAMELEN 64 /* max length of hostname or name for auth */
#define MAXSECRETLEN 64
Major Refactoring & extensions For keep supporting external APIs with the same name (supposedly there are a larger number of users of those APIs), BufferedSerial and ATParser are being renamed. BufferedSerial becomes UARTSerial, will complement a future USBSerial etc. ATParser becomes ATCmdParser. * UARTSerial moves to /drivers * APN_db.h is moved from platform to cellular/util/. * Original CellularInterface is restored for backward compatability (again, supposedly there are users of that). * A new file, CellularBase is added which will now servce as the base class for all upcoming drivers. * Special restructuring for the driver has been undertaken. This makes a clear cut distinction between an on-board or an off-board implementation. - PPPCellularInterface is a generic network interface that works with a generic FileHandle and PPP. A derived class is needed to pass that FileHandle. - PPPCellularInterface provides some base functionality like network registration, AT setup, PPP connection etc. Lower level job is delegated to the derived classes and various modem specific APIs are provided which are supposed to be overridden. - UARTCellularInterface is derived from PPPCellularInterface. It constructs a FileHandle and passes it back to PPPCellularInterface as well as provides modem hangupf functionality. In future we could proive a USBInterface that would derive from PPPCellularInterface and could pass the FileHandle back. - OnboardCellularInterface is derived from UARTCellularInterfae and provides hooks to the target provided implementation of onbard_modem_api.h. An off-board modem, i.e, a modem on a shield has to override the modem_init(), modem_power_up() etc as it cannot use onboard_modem_api.h.
2017-05-23 17:07:24 +00:00
#endif // NSAPI_PPP_AVAILABLE
2016-04-05 14:36:06 +00:00
// Make sure we default these to off, so
// LWIP doesn't default to on
#ifndef LWIP_ARP
#define LWIP_ARP 0
#endif
// Checksum-on-copy disabled due to https://savannah.nongnu.org/bugs/?50914
#define LWIP_CHECKSUM_ON_COPY 0
2016-04-05 14:36:06 +00:00
#define LWIP_NETIF_HOSTNAME 1
#define LWIP_NETIF_STATUS_CALLBACK 1
#define LWIP_NETIF_LINK_CALLBACK 1
#define DNS_TABLE_SIZE 2
#define DNS_MAX_NAME_LENGTH 128
#include "lwip_random.h"
#include "lwip_tcp_isn.h"
#define LWIP_HOOK_TCP_ISN lwip_hook_tcp_isn
#ifdef MBEDTLS_MD5_C
#include "mbedtls/md5.h"
#define LWIP_USE_EXTERNAL_MBEDTLS 1
#endif
2016-04-05 14:36:06 +00:00
#endif /* LWIPOPTS_H_ */