2007-08-29 08:11:06 +00:00
/**
* @ file
* Modules initialization
*
*/
/*
* Copyright ( c ) 2001 - 2004 Swedish Institute of Computer Science .
2015-10-06 19:13:15 +00:00
* All rights reserved .
*
* Redistribution and use in source and binary forms , with or without modification ,
2007-08-29 08:11:06 +00:00
* 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
2015-10-06 19:13:15 +00:00
* derived from this software without specific prior written permission .
2007-08-29 08:11:06 +00:00
*
2015-10-06 19:13:15 +00:00
* 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
2007-08-29 08:11:06 +00:00
* OF SUCH DAMAGE .
*
* This file is part of the lwIP TCP / IP stack .
2015-10-06 19:13:15 +00:00
*
2007-08-29 08:11:06 +00:00
* Author : Adam Dunkels < adam @ sics . se >
2016-07-26 14:53:27 +00:00
*/
2007-08-29 08:11:06 +00:00
# include "lwip/opt.h"
2007-09-07 23:01:59 +00:00
2007-09-04 13:51:48 +00:00
# include "lwip/init.h"
2007-08-29 08:11:06 +00:00
# include "lwip/stats.h"
# include "lwip/sys.h"
# include "lwip/mem.h"
# include "lwip/memp.h"
# include "lwip/pbuf.h"
# include "lwip/netif.h"
# include "lwip/sockets.h"
# include "lwip/ip.h"
# include "lwip/raw.h"
# include "lwip/udp.h"
2015-10-09 19:58:58 +00:00
# include "lwip/priv/tcp_priv.h"
2007-08-30 16:06:51 +00:00
# include "lwip/igmp.h"
2007-11-14 23:27:13 +00:00
# include "lwip/dns.h"
2016-07-19 10:44:12 +00:00
# include "lwip/timeouts.h"
2016-07-19 07:29:51 +00:00
# include "lwip/etharp.h"
2011-05-17 19:35:14 +00:00
# include "lwip/ip6.h"
# include "lwip/nd6.h"
# include "lwip/mld6.h"
2011-07-22 19:59:16 +00:00
# include "lwip/api.h"
2007-08-30 10:15:17 +00:00
2016-04-22 04:24:01 +00:00
# include "netif/ppp/ppp_opts.h"
2016-04-25 17:52:07 +00:00
# include "netif/ppp/ppp_impl.h"
2016-04-22 04:24:01 +00:00
2016-08-19 11:05:51 +00:00
# ifndef LWIP_SKIP_PACKING_CHECK
# ifdef PACK_STRUCT_USE_INCLUDES
# include "arch / bpstruct.h"
# endif
PACK_STRUCT_BEGIN
struct packed_struct_test
{
PACK_STRUCT_FLD_8 ( u8_t dummy1 ) ;
PACK_STRUCT_FIELD ( u32_t dummy2 ) ;
} PACK_STRUCT_STRUCT ;
PACK_STRUCT_END
# ifdef PACK_STRUCT_USE_INCLUDES
# include "arch / epstruct.h"
# endif
# define PACKED_STRUCT_TEST_EXPECTED_SIZE 5
# endif
2007-08-30 15:33:51 +00:00
/* Compile-time sanity checks for configuration errors.
* These can be done independently of LWIP_DEBUG , without penalty .
*/
2007-09-05 13:19:25 +00:00
# ifndef BYTE_ORDER
# error "BYTE_ORDER is not defined, you have to define it in your cc.h"
# endif
2009-04-29 12:42:43 +00:00
# if (!IP_SOF_BROADCAST && IP_SOF_BROADCAST_RECV)
# error "If you want to use broadcast filter per pcb on recv operations, you have to define IP_SOF_BROADCAST=1 in your lwipopts.h"
# endif
2007-08-30 15:33:51 +00:00
# if (!LWIP_UDP && LWIP_UDPLITE)
# error "If you want to use UDP Lite, you have to define LWIP_UDP=1 in your lwipopts.h"
# endif
# if (!LWIP_UDP && LWIP_DHCP)
# error "If you want to use DHCP, you have to define LWIP_UDP=1 in your lwipopts.h"
# endif
2015-09-17 20:19:37 +00:00
# if (!LWIP_UDP && LWIP_MULTICAST_TX_OPTIONS)
udp: add core-level multicast support for IPv6
So far, the UDP core module implemented only IPv4 multicast support.
This patch extends the module with the features necessary for socket
layers on top to implement IPv6 multicast support as well:
o If a UDP PCB is bound to an IPv6 multicast address, a unicast source
address is selected and used to send the packet instead, as is
required (and was the case for IPv4 multicast already).
o Unlike IPv4's IP_MULTICAST_IF socket option, which takes a source
IPv4 address, the IPV6_MULTICAST_IF socket option (from RFC 3493)
takes an interface identifier to denote the interface to use for
outgoing multicast-destined packets. A new pair of UDP PCB API
calls, udp_[gs]et_multicast_netif_index(), are added to support
this. The new definition "NETIF_NO_INDEX" may be used to indicate
that lwIP should pick an interface instead.
IPv4 socket implementations may now also choose to map the given
source address to an interface index immediately and use the new
facility instead of the old udp_[gs]et_multicast_netif_addr() one.
A side effect of limiting the old facility to IPv4 is that for dual-
stack configurations with multicast support, the UDP PCB size is
reduced by (up to) 16 bytes.
o For configurations that enable loopback interface support, the IPv6
code now also supports multicast loopback (IPV6_MULTICAST_LOOP).
o The LWIP_MULTICAST_TX_OPTIONS opt.h setting now covers both IPv4
and IPv6, and as such is no longer strictly linked to IGMP. It is
therefore placed in its own lwIP options subgroup in opt.h.
The IPV6_MULTICAST_HOPS socket option can already be implemented using
the existing IP_MULTICAST_TTL support, and thus requires no additional
changes. Overall, this patch should not break any existing code.
2017-02-06 14:12:37 +00:00
# error "If you want to use LWIP_MULTICAST_TX_OPTIONS, you have to define LWIP_UDP=1 in your lwipopts.h"
2007-08-30 15:33:51 +00:00
# endif
2007-11-14 23:27:13 +00:00
# if (!LWIP_UDP && LWIP_DNS)
# error "If you want to use DNS, you have to define LWIP_UDP=1 in your lwipopts.h"
# endif
2012-02-16 06:33:38 +00:00
# if !MEMP_MEM_MALLOC /* MEMP_NUM_* checks are disabled when not using the pool allocator */
2007-08-30 16:06:51 +00:00
# if (LWIP_ARP && ARP_QUEUEING && (MEMP_NUM_ARP_QUEUE<=0))
# error "If you want to use ARP Queueing, you have to define MEMP_NUM_ARP_QUEUE>=1 in your lwipopts.h"
# endif
# if (LWIP_RAW && (MEMP_NUM_RAW_PCB<=0))
# error "If you want to use RAW, you have to define MEMP_NUM_RAW_PCB>=1 in your lwipopts.h"
# endif
2007-08-30 15:33:51 +00:00
# if (LWIP_UDP && (MEMP_NUM_UDP_PCB<=0))
# error "If you want to use UDP, you have to define MEMP_NUM_UDP_PCB>=1 in your lwipopts.h"
# endif
# if (LWIP_TCP && (MEMP_NUM_TCP_PCB<=0))
# error "If you want to use TCP, you have to define MEMP_NUM_TCP_PCB>=1 in your lwipopts.h"
# endif
2012-02-16 06:33:38 +00:00
# if (LWIP_IGMP && (MEMP_NUM_IGMP_GROUP<=1))
# error "If you want to use IGMP, you have to define MEMP_NUM_IGMP_GROUP>1 in your lwipopts.h"
# endif
2015-08-05 20:52:23 +00:00
# if (LWIP_IGMP && !LWIP_MULTICAST_TX_OPTIONS)
# error "If you want to use IGMP, you have to define LWIP_MULTICAST_TX_OPTIONS==1 in your lwipopts.h"
# endif
2015-08-20 14:36:54 +00:00
# if (LWIP_IGMP && !LWIP_IPV4)
# error "IGMP needs LWIP_IPV4 enabled in your lwipopts.h"
# endif
2012-02-16 06:33:38 +00:00
# if ((LWIP_NETCONN || LWIP_SOCKET) && (MEMP_NUM_TCPIP_MSG_API<=0))
# error "If you want to use Sequential API, you have to define MEMP_NUM_TCPIP_MSG_API>=1 in your lwipopts.h"
# endif
/* There must be sufficient timeouts, taking into account requirements of the subsystems. */
# if LWIP_TIMERS && (MEMP_NUM_SYS_TIMEOUT < (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + PPP_SUPPORT + (LWIP_IPV6 ? (1 + LWIP_IPV6_REASS + LWIP_IPV6_MLD) : 0)))
# error "MEMP_NUM_SYS_TIMEOUT is too low to accomodate all required timeouts"
# endif
# if (IP_REASSEMBLY && (MEMP_NUM_REASSDATA > IP_REASS_MAX_PBUFS))
# error "MEMP_NUM_REASSDATA > IP_REASS_MAX_PBUFS doesn't make sense since each struct ip_reassdata must hold 2 pbufs at least!"
# endif
# endif /* !MEMP_MEM_MALLOC */
2014-02-06 21:34:06 +00:00
# if LWIP_WND_SCALE
# if (LWIP_TCP && (TCP_WND > 0xffffffff))
# error "If you want to use TCP, TCP_WND must fit in an u32_t, so, you have to reduce it in your lwipopts.h"
# endif
2016-11-11 21:59:03 +00:00
# if (LWIP_TCP && (TCP_RCV_SCALE > 14))
2014-02-06 21:34:06 +00:00
# error "The maximum valid window scale value is 14!"
# endif
# if (LWIP_TCP && (TCP_WND > (0xFFFFU << TCP_RCV_SCALE)))
# error "TCP_WND is bigger than the configured LWIP_WND_SCALE allows!"
# endif
# if (LWIP_TCP && ((TCP_WND >> TCP_RCV_SCALE) == 0))
# error "TCP_WND is too small for the configured LWIP_WND_SCALE (results in zero window)!"
# endif
# else /* LWIP_WND_SCALE */
2007-09-07 17:59:30 +00:00
# if (LWIP_TCP && (TCP_WND > 0xffff))
2014-02-06 21:34:06 +00:00
# error "If you want to use TCP, TCP_WND must fit in an u16_t, so, you have to reduce it in your lwipopts.h (or enable window scaling)"
2007-09-07 17:59:30 +00:00
# endif
2014-02-06 21:34:06 +00:00
# endif /* LWIP_WND_SCALE */
2007-10-07 17:41:21 +00:00
# if (LWIP_TCP && (TCP_SND_QUEUELEN > 0xffff))
2007-11-22 10:17:16 +00:00
# error "If you want to use TCP, TCP_SND_QUEUELEN must fit in an u16_t, so, you have to reduce it in your lwipopts.h"
2007-10-09 20:48:28 +00:00
# endif
2010-11-20 17:34:10 +00:00
# if (LWIP_TCP && (TCP_SND_QUEUELEN < 2))
# error "TCP_SND_QUEUELEN must be at least 2 for no-copy TCP writes to work"
# endif
2007-10-09 20:48:28 +00:00
# if (LWIP_TCP && ((TCP_MAXRTX > 12) || (TCP_SYNMAXRTX > 12)))
2007-11-22 10:17:16 +00:00
# error "If you want to use TCP, TCP_MAXRTX and TCP_SYNMAXRTX must less or equal to 12 (due to tcp_backoff table), so, you have to reduce them in your lwipopts.h"
2007-10-07 17:41:21 +00:00
# endif
2014-02-12 21:20:25 +00:00
# if (LWIP_TCP && TCP_LISTEN_BACKLOG && ((TCP_DEFAULT_LISTEN_BACKLOG < 0) || (TCP_DEFAULT_LISTEN_BACKLOG > 0xff)))
rawapi.txt, api.h, api_lib.c, api_msg.h, api_msg.c, sockets.c, tcp.h, tcp.c, tcp_in.c, init.c, opt.h: rename backlog options with TCP_ prefix, limit the "backlog" parameter in an u8_t, 0 is interpreted as "smallest queue", add documentation in the rawapi.txt file.
2008-01-04 22:18:27 +00:00
# error "If you want to use TCP backlog, TCP_DEFAULT_LISTEN_BACKLOG must fit into an u8_t"
# endif
2007-09-21 12:36:35 +00:00
# if (LWIP_NETIF_API && (NO_SYS==1))
# error "If you want to use NETIF API, you have to define NO_SYS=0 in your lwipopts.h"
# endif
2007-08-30 15:33:51 +00:00
# if ((LWIP_SOCKET || LWIP_NETCONN) && (NO_SYS==1))
# error "If you want to use Sequential API, you have to define NO_SYS=0 in your lwipopts.h"
# endif
2014-09-17 19:30:41 +00:00
# if (LWIP_PPP_API && (NO_SYS==1))
# error "If you want to use PPP API, you have to define NO_SYS=0 in your lwipopts.h"
# endif
2015-03-04 20:10:29 +00:00
# if (LWIP_PPP_API && (PPP_SUPPORT==0))
# error "If you want to use PPP API, you have to enable PPP_SUPPORT in your lwipopts.h"
# endif
2007-11-22 10:17:16 +00:00
# if (((!LWIP_DHCP) || (!LWIP_AUTOIP)) && LWIP_DHCP_AUTOIP_COOP)
2007-08-30 16:06:51 +00:00
# error "If you want to use DHCP / AUTOIP cooperation mode, you have to define LWIP_DHCP=1 and LWIP_AUTOIP=1 in your lwipopts.h"
2007-08-30 15:33:51 +00:00
# endif
# if (((!LWIP_DHCP) || (!LWIP_ARP)) && DHCP_DOES_ARP_CHECK)
2007-08-30 16:06:51 +00:00
# error "If you want to use DHCP ARP checking, you have to define LWIP_DHCP=1 and LWIP_ARP=1 in your lwipopts.h"
2007-08-30 15:33:51 +00:00
# endif
2007-09-05 13:19:25 +00:00
# if (!LWIP_ARP && LWIP_AUTOIP)
# error "If you want to use AUTOIP, you have to define LWIP_ARP=1 in your lwipopts.h"
# endif
2007-08-30 22:33:55 +00:00
# if (LWIP_TCP && ((LWIP_EVENT_API && LWIP_CALLBACK_API) || (!LWIP_EVENT_API && !LWIP_CALLBACK_API)))
2007-11-28 00:11:05 +00:00
# error "One and exactly one of LWIP_EVENT_API and LWIP_CALLBACK_API has to be enabled in your lwipopts.h"
2007-08-30 22:33:55 +00:00
# endif
2007-11-28 00:11:05 +00:00
# if (MEM_LIBC_MALLOC && MEM_USE_POOLS)
# error "MEM_LIBC_MALLOC and MEM_USE_POOLS may not both be simultaneously enabled in your lwipopts.h"
# endif
# if (MEM_USE_POOLS && !MEMP_USE_CUSTOM_POOLS)
# error "MEM_USE_POOLS requires custom pools (MEMP_USE_CUSTOM_POOLS) to be enabled in your lwipopts.h"
# endif
2009-02-18 16:50:40 +00:00
# if (PBUF_POOL_BUFSIZE <= MEM_ALIGNMENT)
2009-04-23 15:28:52 +00:00
# error "PBUF_POOL_BUFSIZE must be greater than MEM_ALIGNMENT or the offset may take the full first pbuf"
2009-02-18 16:50:40 +00:00
# endif
2009-04-23 16:54:30 +00:00
# if (DNS_LOCAL_HOSTLIST && !DNS_LOCAL_HOSTLIST_IS_DYNAMIC && !(defined(DNS_LOCAL_HOSTLIST_INIT)))
2009-04-21 18:35:18 +00:00
# error "you have to define define DNS_LOCAL_HOSTLIST_INIT {{'host1', 0x123}, {'host2', 0x234}} to initialize DNS_LOCAL_HOSTLIST"
# endif
2015-02-19 21:32:24 +00:00
# if PPP_SUPPORT && !PPPOS_SUPPORT && !PPPOE_SUPPORT && !PPPOL2TP_SUPPORT
# error "PPP_SUPPORT needs at least one of PPPOS_SUPPORT, PPPOE_SUPPORT or PPPOL2TP_SUPPORT turned on"
2009-12-01 20:46:14 +00:00
# endif
2015-02-22 13:30:24 +00:00
# if PPP_SUPPORT && !PPP_IPV4_SUPPORT && !PPP_IPV6_SUPPORT
# error "PPP_SUPPORT needs PPP_IPV4_SUPPORT and / or PPP_IPV6_SUPPORT turned on"
# endif
2015-04-09 23:00:08 +00:00
# if PPP_SUPPORT && PPP_IPV4_SUPPORT && !LWIP_IPV4
# error "PPP_IPV4_SUPPORT needs LWIP_IPV4 turned on"
# endif
# if PPP_SUPPORT && PPP_IPV6_SUPPORT && !LWIP_IPV6
# error "PPP_IPV6_SUPPORT needs LWIP_IPV6 turned on"
# endif
2009-12-27 11:40:48 +00:00
# if !LWIP_ETHERNET && (LWIP_ARP || PPPOE_SUPPORT)
# error "LWIP_ETHERNET needs to be turned on for LWIP_ARP or PPPOE_SUPPORT"
# endif
2011-06-26 17:51:55 +00:00
# if (LWIP_IGMP || LWIP_IPV6) && !defined(LWIP_RAND)
2016-08-08 07:14:50 +00:00
# error "When using IGMP or IPv6, LWIP_RAND() needs to be defined to a random-function returning an u32_t random value (in arch / cc.h)"
2010-01-10 10:47:27 +00:00
# endif
2010-03-06 11:32:40 +00:00
# if LWIP_TCPIP_CORE_LOCKING_INPUT && !LWIP_TCPIP_CORE_LOCKING
# error "When using LWIP_TCPIP_CORE_LOCKING_INPUT, LWIP_TCPIP_CORE_LOCKING must be enabled, too"
# endif
2010-03-26 16:54:15 +00:00
# if LWIP_TCP && LWIP_NETIF_TX_SINGLE_PBUF && !TCP_OVERSIZE
# error "LWIP_NETIF_TX_SINGLE_PBUF needs TCP_OVERSIZE enabled to create single-pbuf TCP packets"
2010-03-06 11:51:31 +00:00
# endif
2011-07-22 19:59:16 +00:00
# if LWIP_NETCONN && LWIP_TCP
# if NETCONN_COPY != TCP_WRITE_FLAG_COPY
# error "NETCONN_COPY != TCP_WRITE_FLAG_COPY"
# endif
# if NETCONN_MORE != TCP_WRITE_FLAG_MORE
# error "NETCONN_MORE != TCP_WRITE_FLAG_MORE"
# endif
2015-10-06 19:08:28 +00:00
# endif /* LWIP_NETCONN && LWIP_TCP */
2011-07-22 19:59:16 +00:00
# if LWIP_SOCKET
/* Check that the SO_* socket options and SOF_* lwIP-internal flags match */
# if SO_REUSEADDR != SOF_REUSEADDR
# error "WARNING: SO_REUSEADDR != SOF_REUSEADDR"
# endif
# if SO_KEEPALIVE != SOF_KEEPALIVE
# error "WARNING: SO_KEEPALIVE != SOF_KEEPALIVE"
# endif
# if SO_BROADCAST != SOF_BROADCAST
# error "WARNING: SO_BROADCAST != SOF_BROADCAST"
# endif
# endif /* LWIP_SOCKET */
2007-12-21 16:47:56 +00:00
2007-08-30 15:33:51 +00:00
2007-08-30 22:33:55 +00:00
/* Compile-time checks for deprecated options.
*/
# ifdef MEMP_NUM_TCPIP_MSG
2007-09-07 23:28:02 +00:00
# error "MEMP_NUM_TCPIP_MSG option is deprecated. Remove it from your lwipopts.h."
# endif
# ifdef TCP_REXMIT_DEBUG
# error "TCP_REXMIT_DEBUG option is deprecated. Remove it from your lwipopts.h."
# endif
# ifdef RAW_STATS
# error "RAW_STATS option is deprecated. Remove it from your lwipopts.h."
2007-08-30 22:33:55 +00:00
# endif
# ifdef ETHARP_QUEUE_FIRST
2007-09-07 23:28:02 +00:00
# error "ETHARP_QUEUE_FIRST option is deprecated. Remove it from your lwipopts.h."
2007-08-30 22:33:55 +00:00
# endif
# ifdef ETHARP_ALWAYS_INSERT
2007-09-07 23:28:02 +00:00
# error "ETHARP_ALWAYS_INSERT option is deprecated. Remove it from your lwipopts.h."
2007-08-30 22:33:55 +00:00
# endif
2016-07-02 19:53:24 +00:00
# if !NO_SYS && LWIP_TCPIP_CORE_LOCKING && LWIP_COMPAT_MUTEX && !defined(LWIP_COMPAT_MUTEX_ALLOWED)
2016-06-30 20:37:37 +00:00
# error "LWIP_COMPAT_MUTEX cannot prevent priority inversion. It is recommended to implement priority-aware mutexes. (Define LWIP_COMPAT_MUTEX_ALLOWED to disable this error.)"
# endif
2007-08-30 15:33:51 +00:00
2011-09-21 16:35:29 +00:00
# ifndef LWIP_DISABLE_TCP_SANITY_CHECKS
# define LWIP_DISABLE_TCP_SANITY_CHECKS 0
# endif
# ifndef LWIP_DISABLE_MEMP_SANITY_CHECKS
# define LWIP_DISABLE_MEMP_SANITY_CHECKS 0
# endif
/* MEMP sanity checks */
2012-02-16 06:33:38 +00:00
# if MEMP_MEM_MALLOC
2016-07-21 20:16:05 +00:00
# if !LWIP_DISABLE_MEMP_SANITY_CHECKS
# if LWIP_NETCONN || LWIP_SOCKET
2012-02-16 06:33:38 +00:00
# if !MEMP_NUM_NETCONN && LWIP_SOCKET
# error "lwip_sanity_check: WARNING: MEMP_NUM_NETCONN cannot be 0 when using sockets!"
# endif
# else /* MEMP_MEM_MALLOC */
2011-09-21 16:35:29 +00:00
# if MEMP_NUM_NETCONN > (MEMP_NUM_TCP_PCB+MEMP_NUM_TCP_PCB_LISTEN+MEMP_NUM_UDP_PCB+MEMP_NUM_RAW_PCB)
# error "lwip_sanity_check: WARNING: MEMP_NUM_NETCONN should be less than the sum of MEMP_NUM_{TCP,RAW,UDP}_PCB+MEMP_NUM_TCP_PCB_LISTEN. If you know what you are doing, define LWIP_DISABLE_MEMP_SANITY_CHECKS to 1 to disable this error."
# endif
2016-07-21 20:16:05 +00:00
# endif /* LWIP_NETCONN || LWIP_SOCKET */
2011-09-21 16:35:29 +00:00
# endif /* !LWIP_DISABLE_MEMP_SANITY_CHECKS */
2016-07-21 20:16:05 +00:00
# if MEM_USE_POOLS
# error "MEMP_MEM_MALLOC and MEM_USE_POOLS cannot be enabled at the same time"
# endif
# ifdef LWIP_HOOK_MEMP_AVAILABLE
# error "LWIP_HOOK_MEMP_AVAILABLE doesn't make sense with MEMP_MEM_MALLOC"
# endif
# endif /* MEMP_MEM_MALLOC */
2011-09-21 16:35:29 +00:00
/* TCP sanity checks */
# if !LWIP_DISABLE_TCP_SANITY_CHECKS
2007-08-30 15:33:51 +00:00
# if LWIP_TCP
2012-02-16 06:33:38 +00:00
# if !MEMP_MEM_MALLOC && (MEMP_NUM_TCP_SEG < TCP_SND_QUEUELEN)
2011-09-21 16:35:29 +00:00
# error "lwip_sanity_check: WARNING: MEMP_NUM_TCP_SEG should be at least as big as TCP_SND_QUEUELEN. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error."
# endif
# if TCP_SND_BUF < (2 * TCP_MSS)
# error "lwip_sanity_check: WARNING: TCP_SND_BUF must be at least as much as (2 * TCP_MSS) for things to work smoothly. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error."
# endif
# if TCP_SND_QUEUELEN < (2 * (TCP_SND_BUF / TCP_MSS))
# error "lwip_sanity_check: WARNING: TCP_SND_QUEUELEN must be at least as much as (2 * TCP_SND_BUF / TCP_MSS) for things to work. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error."
# endif
# if TCP_SNDLOWAT >= TCP_SND_BUF
# error "lwip_sanity_check: WARNING: TCP_SNDLOWAT must be less than TCP_SND_BUF. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error."
# endif
2016-02-18 08:36:55 +00:00
# if TCP_SNDLOWAT >= (0xFFFF - (4 * TCP_MSS))
# error "lwip_sanity_check: WARNING: TCP_SNDLOWAT must at least be 4*MSS below u16_t overflow!"
# endif
2011-09-21 16:35:29 +00:00
# if TCP_SNDQUEUELOWAT >= TCP_SND_QUEUELEN
# error "lwip_sanity_check: WARNING: TCP_SNDQUEUELOWAT must be less than TCP_SND_QUEUELEN. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error."
# endif
2016-09-01 15:29:06 +00:00
# if !MEMP_MEM_MALLOC && PBUF_POOL_SIZE && (PBUF_POOL_BUFSIZE <= (PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN))
2013-01-14 17:05:18 +00:00
# error "lwip_sanity_check: WARNING: PBUF_POOL_BUFSIZE does not provide enough space for protocol headers. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error."
# endif
2016-09-01 15:29:06 +00:00
# if !MEMP_MEM_MALLOC && PBUF_POOL_SIZE && (TCP_WND > (PBUF_POOL_SIZE * (PBUF_POOL_BUFSIZE - (PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN))))
2016-02-26 07:59:50 +00:00
# error "lwip_sanity_check: WARNING: TCP_WND is larger than space provided by PBUF_POOL_SIZE * (PBUF_POOL_BUFSIZE - protocol headers). If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error."
2011-09-21 16:35:29 +00:00
# endif
# if TCP_WND < TCP_MSS
# error "lwip_sanity_check: WARNING: TCP_WND is smaller than MSS. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error."
# endif
2007-08-30 15:33:51 +00:00
# endif /* LWIP_TCP */
2011-09-21 16:35:29 +00:00
# endif /* !LWIP_DISABLE_TCP_SANITY_CHECKS */
2007-08-30 10:15:17 +00:00
/**
2016-07-27 11:03:36 +00:00
* @ ingroup lwip_nosys
2015-08-27 19:35:18 +00:00
* Initialize all modules .
2016-07-26 16:39:53 +00:00
* Use this in NO_SYS mode . Use tcpip_init ( ) otherwise .
2007-08-30 10:15:17 +00:00
*/
2007-08-29 08:11:06 +00:00
void
lwip_init ( void )
{
2016-12-14 07:31:09 +00:00
# ifndef LWIP_SKIP_CONST_CHECK
int a ;
LWIP_UNUSED_ARG ( a ) ;
LWIP_ASSERT ( " LWIP_CONST_CAST not implemented correctly. Check your lwIP port. " , LWIP_CONST_CAST ( void * , & a ) = = & a ) ;
# endif
2016-08-19 11:05:51 +00:00
# ifndef LWIP_SKIP_PACKING_CHECK
LWIP_ASSERT ( " Struct packing not implemented correctly. Check your lwIP port. " , sizeof ( struct packed_struct_test ) = = PACKED_STRUCT_TEST_EXPECTED_SIZE ) ;
# endif
2007-08-30 10:15:17 +00:00
/* Modules initialization */
2007-08-29 08:11:06 +00:00
stats_init ( ) ;
2010-06-24 20:27:49 +00:00
# if !NO_SYS
2007-08-29 08:11:06 +00:00
sys_init ( ) ;
2010-06-24 20:27:49 +00:00
# endif /* !NO_SYS */
2007-08-29 08:11:06 +00:00
mem_init ( ) ;
memp_init ( ) ;
pbuf_init ( ) ;
netif_init ( ) ;
2015-04-09 20:21:15 +00:00
# if LWIP_IPV4
2007-08-29 08:11:06 +00:00
ip_init ( ) ;
# if LWIP_ARP
etharp_init ( ) ;
# endif /* LWIP_ARP */
2015-04-09 20:21:15 +00:00
# endif /* LWIP_IPV4 */
2007-08-29 08:11:06 +00:00
# if LWIP_RAW
raw_init ( ) ;
# endif /* LWIP_RAW */
# if LWIP_UDP
udp_init ( ) ;
# endif /* LWIP_UDP */
# if LWIP_TCP
tcp_init ( ) ;
# endif /* LWIP_TCP */
2007-08-29 21:12:32 +00:00
# if LWIP_IGMP
igmp_init ( ) ;
# endif /* LWIP_IGMP */
2007-11-14 23:27:13 +00:00
# if LWIP_DNS
dns_init ( ) ;
# endif /* LWIP_DNS */
2016-04-25 17:52:07 +00:00
# if PPP_SUPPORT
ppp_init ( ) ;
# endif
2010-06-24 20:27:49 +00:00
# if LWIP_TIMERS
2009-12-31 16:16:44 +00:00
sys_timeouts_init ( ) ;
2010-06-24 20:27:49 +00:00
# endif /* LWIP_TIMERS */
2007-08-29 08:11:06 +00:00
}