1195972f6Sopenharmony_ci/** 2195972f6Sopenharmony_ci * @file 3195972f6Sopenharmony_ci * Modules initialization 4195972f6Sopenharmony_ci * 5195972f6Sopenharmony_ci */ 6195972f6Sopenharmony_ci 7195972f6Sopenharmony_ci/* 8195972f6Sopenharmony_ci * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 9195972f6Sopenharmony_ci * All rights reserved. 10195972f6Sopenharmony_ci * 11195972f6Sopenharmony_ci * Redistribution and use in source and binary forms, with or without modification, 12195972f6Sopenharmony_ci * are permitted provided that the following conditions are met: 13195972f6Sopenharmony_ci * 14195972f6Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright notice, 15195972f6Sopenharmony_ci * this list of conditions and the following disclaimer. 16195972f6Sopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright notice, 17195972f6Sopenharmony_ci * this list of conditions and the following disclaimer in the documentation 18195972f6Sopenharmony_ci * and/or other materials provided with the distribution. 19195972f6Sopenharmony_ci * 3. The name of the author may not be used to endorse or promote products 20195972f6Sopenharmony_ci * derived from this software without specific prior written permission. 21195972f6Sopenharmony_ci * 22195972f6Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23195972f6Sopenharmony_ci * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24195972f6Sopenharmony_ci * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25195972f6Sopenharmony_ci * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26195972f6Sopenharmony_ci * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27195972f6Sopenharmony_ci * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28195972f6Sopenharmony_ci * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29195972f6Sopenharmony_ci * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30195972f6Sopenharmony_ci * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31195972f6Sopenharmony_ci * OF SUCH DAMAGE. 32195972f6Sopenharmony_ci * 33195972f6Sopenharmony_ci * This file is part of the lwIP TCP/IP stack. 34195972f6Sopenharmony_ci * 35195972f6Sopenharmony_ci * Author: Adam Dunkels <adam@sics.se> 36195972f6Sopenharmony_ci */ 37195972f6Sopenharmony_ci 38195972f6Sopenharmony_ci#include "lwip/opt.h" 39195972f6Sopenharmony_ci 40195972f6Sopenharmony_ci#include "lwip/init.h" 41195972f6Sopenharmony_ci#include "lwip/stats.h" 42195972f6Sopenharmony_ci#include "lwip/sys.h" 43195972f6Sopenharmony_ci#include "lwip/mem.h" 44195972f6Sopenharmony_ci#include "lwip/memp.h" 45195972f6Sopenharmony_ci#include "lwip/pbuf.h" 46195972f6Sopenharmony_ci#include "lwip/netif.h" 47195972f6Sopenharmony_ci#include "lwip/sockets.h" 48195972f6Sopenharmony_ci#include "lwip/ip.h" 49195972f6Sopenharmony_ci#include "lwip/raw.h" 50195972f6Sopenharmony_ci#include "lwip/udp.h" 51195972f6Sopenharmony_ci#include "lwip/priv/tcp_priv.h" 52195972f6Sopenharmony_ci#include "lwip/igmp.h" 53195972f6Sopenharmony_ci#include "lwip/dns.h" 54195972f6Sopenharmony_ci#include "lwip/timeouts.h" 55195972f6Sopenharmony_ci#include "lwip/etharp.h" 56195972f6Sopenharmony_ci#include "lwip/ip6.h" 57195972f6Sopenharmony_ci#include "lwip/nd6.h" 58195972f6Sopenharmony_ci#include "lwip/mld6.h" 59195972f6Sopenharmony_ci#include "lwip/api.h" 60195972f6Sopenharmony_ci#ifdef LOSCFG_NET_CONTAINER 61195972f6Sopenharmony_ci#include "lwip/net_group.h" 62195972f6Sopenharmony_ci#endif 63195972f6Sopenharmony_ci 64195972f6Sopenharmony_ci#include "netif/ppp/ppp_opts.h" 65195972f6Sopenharmony_ci#include "netif/ppp/ppp_impl.h" 66195972f6Sopenharmony_ci 67195972f6Sopenharmony_ci#ifndef LWIP_SKIP_PACKING_CHECK 68195972f6Sopenharmony_ci 69195972f6Sopenharmony_ci#ifdef PACK_STRUCT_USE_INCLUDES 70195972f6Sopenharmony_ci# include "arch/bpstruct.h" 71195972f6Sopenharmony_ci#endif 72195972f6Sopenharmony_ciPACK_STRUCT_BEGIN 73195972f6Sopenharmony_cistruct packed_struct_test { 74195972f6Sopenharmony_ci PACK_STRUCT_FLD_8(u8_t dummy1); 75195972f6Sopenharmony_ci PACK_STRUCT_FIELD(u32_t dummy2); 76195972f6Sopenharmony_ci} PACK_STRUCT_STRUCT; 77195972f6Sopenharmony_ciPACK_STRUCT_END 78195972f6Sopenharmony_ci#ifdef PACK_STRUCT_USE_INCLUDES 79195972f6Sopenharmony_ci# include "arch/epstruct.h" 80195972f6Sopenharmony_ci#endif 81195972f6Sopenharmony_ci#define PACKED_STRUCT_TEST_EXPECTED_SIZE 5 82195972f6Sopenharmony_ci 83195972f6Sopenharmony_ci#endif 84195972f6Sopenharmony_ci 85195972f6Sopenharmony_ci/* Compile-time sanity checks for configuration errors. 86195972f6Sopenharmony_ci * These can be done independently of LWIP_DEBUG, without penalty. 87195972f6Sopenharmony_ci */ 88195972f6Sopenharmony_ci#ifndef BYTE_ORDER 89195972f6Sopenharmony_ci#error "BYTE_ORDER is not defined, you have to define it in your cc.h" 90195972f6Sopenharmony_ci#endif 91195972f6Sopenharmony_ci#if (!IP_SOF_BROADCAST && IP_SOF_BROADCAST_RECV) 92195972f6Sopenharmony_ci#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" 93195972f6Sopenharmony_ci#endif 94195972f6Sopenharmony_ci#if (!LWIP_UDP && LWIP_UDPLITE) 95195972f6Sopenharmony_ci#error "If you want to use UDP Lite, you have to define LWIP_UDP=1 in your lwipopts.h" 96195972f6Sopenharmony_ci#endif 97195972f6Sopenharmony_ci#if (!LWIP_UDP && LWIP_DHCP) 98195972f6Sopenharmony_ci#error "If you want to use DHCP, you have to define LWIP_UDP=1 in your lwipopts.h" 99195972f6Sopenharmony_ci#endif 100195972f6Sopenharmony_ci#if (!LWIP_UDP && !LWIP_RAW && LWIP_MULTICAST_TX_OPTIONS) 101195972f6Sopenharmony_ci#error "If you want to use LWIP_MULTICAST_TX_OPTIONS, you have to define LWIP_UDP=1 and/or LWIP_RAW=1 in your lwipopts.h" 102195972f6Sopenharmony_ci#endif 103195972f6Sopenharmony_ci#if (!LWIP_UDP && LWIP_DNS) 104195972f6Sopenharmony_ci#error "If you want to use DNS, you have to define LWIP_UDP=1 in your lwipopts.h" 105195972f6Sopenharmony_ci#endif 106195972f6Sopenharmony_ci#if !MEMP_MEM_MALLOC /* MEMP_NUM_* checks are disabled when not using the pool allocator */ 107195972f6Sopenharmony_ci#if (LWIP_ARP && ARP_QUEUEING && (MEMP_NUM_ARP_QUEUE<=0)) 108195972f6Sopenharmony_ci#error "If you want to use ARP Queueing, you have to define MEMP_NUM_ARP_QUEUE>=1 in your lwipopts.h" 109195972f6Sopenharmony_ci#endif 110195972f6Sopenharmony_ci#if (LWIP_RAW && (MEMP_NUM_RAW_PCB<=0)) 111195972f6Sopenharmony_ci#error "If you want to use RAW, you have to define MEMP_NUM_RAW_PCB>=1 in your lwipopts.h" 112195972f6Sopenharmony_ci#endif 113195972f6Sopenharmony_ci#if (LWIP_UDP && (MEMP_NUM_UDP_PCB<=0)) 114195972f6Sopenharmony_ci#error "If you want to use UDP, you have to define MEMP_NUM_UDP_PCB>=1 in your lwipopts.h" 115195972f6Sopenharmony_ci#endif 116195972f6Sopenharmony_ci#if (LWIP_TCP && (MEMP_NUM_TCP_PCB<=0)) 117195972f6Sopenharmony_ci#error "If you want to use TCP, you have to define MEMP_NUM_TCP_PCB>=1 in your lwipopts.h" 118195972f6Sopenharmony_ci#endif 119195972f6Sopenharmony_ci#if (LWIP_IGMP && (MEMP_NUM_IGMP_GROUP<=1)) 120195972f6Sopenharmony_ci#error "If you want to use IGMP, you have to define MEMP_NUM_IGMP_GROUP>1 in your lwipopts.h" 121195972f6Sopenharmony_ci#endif 122195972f6Sopenharmony_ci#if (LWIP_IGMP && !LWIP_MULTICAST_TX_OPTIONS) 123195972f6Sopenharmony_ci#error "If you want to use IGMP, you have to define LWIP_MULTICAST_TX_OPTIONS==1 in your lwipopts.h" 124195972f6Sopenharmony_ci#endif 125195972f6Sopenharmony_ci#if (LWIP_IGMP && !LWIP_IPV4) 126195972f6Sopenharmony_ci#error "IGMP needs LWIP_IPV4 enabled in your lwipopts.h" 127195972f6Sopenharmony_ci#endif 128195972f6Sopenharmony_ci#if ((LWIP_NETCONN || LWIP_SOCKET) && (MEMP_NUM_TCPIP_MSG_API<=0)) 129195972f6Sopenharmony_ci#error "If you want to use Sequential API, you have to define MEMP_NUM_TCPIP_MSG_API>=1 in your lwipopts.h" 130195972f6Sopenharmony_ci#endif 131195972f6Sopenharmony_ci/* There must be sufficient timeouts, taking into account requirements of the subsystems. */ 132195972f6Sopenharmony_ci#if LWIP_TIMERS && (MEMP_NUM_SYS_TIMEOUT < LWIP_NUM_SYS_TIMEOUT_INTERNAL) 133195972f6Sopenharmony_ci#error "MEMP_NUM_SYS_TIMEOUT is too low to accomodate all required timeouts" 134195972f6Sopenharmony_ci#endif 135195972f6Sopenharmony_ci#if (IP_REASSEMBLY && (MEMP_NUM_REASSDATA > IP_REASS_MAX_PBUFS)) 136195972f6Sopenharmony_ci#error "MEMP_NUM_REASSDATA > IP_REASS_MAX_PBUFS doesn't make sense since each struct ip_reassdata must hold 2 pbufs at least!" 137195972f6Sopenharmony_ci#endif 138195972f6Sopenharmony_ci#endif /* !MEMP_MEM_MALLOC */ 139195972f6Sopenharmony_ci#if LWIP_WND_SCALE 140195972f6Sopenharmony_ci#if (LWIP_TCP && (TCP_WND > 0xffffffff)) 141195972f6Sopenharmony_ci#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" 142195972f6Sopenharmony_ci#endif 143195972f6Sopenharmony_ci#if (LWIP_TCP && (TCP_RCV_SCALE > 14)) 144195972f6Sopenharmony_ci#error "The maximum valid window scale value is 14!" 145195972f6Sopenharmony_ci#endif 146195972f6Sopenharmony_ci#if (LWIP_TCP && (TCP_WND > (0xFFFFU << TCP_RCV_SCALE))) 147195972f6Sopenharmony_ci#error "TCP_WND is bigger than the configured LWIP_WND_SCALE allows!" 148195972f6Sopenharmony_ci#endif 149195972f6Sopenharmony_ci#if (LWIP_TCP && ((TCP_WND >> TCP_RCV_SCALE) == 0)) 150195972f6Sopenharmony_ci#error "TCP_WND is too small for the configured LWIP_WND_SCALE (results in zero window)!" 151195972f6Sopenharmony_ci#endif 152195972f6Sopenharmony_ci#else /* LWIP_WND_SCALE */ 153195972f6Sopenharmony_ci#if (LWIP_TCP && (TCP_WND > 0xffff)) 154195972f6Sopenharmony_ci#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)" 155195972f6Sopenharmony_ci#endif 156195972f6Sopenharmony_ci#endif /* LWIP_WND_SCALE */ 157195972f6Sopenharmony_ci#if (LWIP_TCP && (TCP_SND_QUEUELEN > 0xffff)) 158195972f6Sopenharmony_ci#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" 159195972f6Sopenharmony_ci#endif 160195972f6Sopenharmony_ci#if (LWIP_TCP && (TCP_SND_QUEUELEN < 2)) 161195972f6Sopenharmony_ci#error "TCP_SND_QUEUELEN must be at least 2 for no-copy TCP writes to work" 162195972f6Sopenharmony_ci#endif 163195972f6Sopenharmony_ci#if (LWIP_TCP && ((TCP_MAXRTX > 12) || (TCP_SYNMAXRTX > 12))) 164195972f6Sopenharmony_ci#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" 165195972f6Sopenharmony_ci#endif 166195972f6Sopenharmony_ci#if (LWIP_TCP && TCP_LISTEN_BACKLOG && ((TCP_DEFAULT_LISTEN_BACKLOG < 0) || (TCP_DEFAULT_LISTEN_BACKLOG > 0xff))) 167195972f6Sopenharmony_ci#error "If you want to use TCP backlog, TCP_DEFAULT_LISTEN_BACKLOG must fit into an u8_t" 168195972f6Sopenharmony_ci#endif 169195972f6Sopenharmony_ci#if (LWIP_TCP && LWIP_TCP_SACK_OUT && !TCP_QUEUE_OOSEQ) 170195972f6Sopenharmony_ci#error "To use LWIP_TCP_SACK_OUT, TCP_QUEUE_OOSEQ needs to be enabled" 171195972f6Sopenharmony_ci#endif 172195972f6Sopenharmony_ci#if (LWIP_TCP && LWIP_TCP_SACK_OUT && (LWIP_TCP_MAX_SACK_NUM < 1)) 173195972f6Sopenharmony_ci#error "LWIP_TCP_MAX_SACK_NUM must be greater than 0" 174195972f6Sopenharmony_ci#endif 175195972f6Sopenharmony_ci#if (LWIP_NETIF_API && (NO_SYS==1)) 176195972f6Sopenharmony_ci#error "If you want to use NETIF API, you have to define NO_SYS=0 in your lwipopts.h" 177195972f6Sopenharmony_ci#endif 178195972f6Sopenharmony_ci#if ((LWIP_SOCKET || LWIP_NETCONN) && (NO_SYS==1)) 179195972f6Sopenharmony_ci#error "If you want to use Sequential API, you have to define NO_SYS=0 in your lwipopts.h" 180195972f6Sopenharmony_ci#endif 181195972f6Sopenharmony_ci#if (LWIP_PPP_API && (NO_SYS==1)) 182195972f6Sopenharmony_ci#error "If you want to use PPP API, you have to define NO_SYS=0 in your lwipopts.h" 183195972f6Sopenharmony_ci#endif 184195972f6Sopenharmony_ci#if (LWIP_PPP_API && (PPP_SUPPORT==0)) 185195972f6Sopenharmony_ci#error "If you want to use PPP API, you have to enable PPP_SUPPORT in your lwipopts.h" 186195972f6Sopenharmony_ci#endif 187195972f6Sopenharmony_ci#if (((!LWIP_DHCP) || (!LWIP_AUTOIP)) && LWIP_DHCP_AUTOIP_COOP) 188195972f6Sopenharmony_ci#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" 189195972f6Sopenharmony_ci#endif 190195972f6Sopenharmony_ci#if (((!LWIP_DHCP) || (!LWIP_ARP)) && DHCP_DOES_ARP_CHECK) 191195972f6Sopenharmony_ci#error "If you want to use DHCP ARP checking, you have to define LWIP_DHCP=1 and LWIP_ARP=1 in your lwipopts.h" 192195972f6Sopenharmony_ci#endif 193195972f6Sopenharmony_ci#if (!LWIP_ARP && LWIP_AUTOIP) 194195972f6Sopenharmony_ci#error "If you want to use AUTOIP, you have to define LWIP_ARP=1 in your lwipopts.h" 195195972f6Sopenharmony_ci#endif 196195972f6Sopenharmony_ci#if (LWIP_TCP && ((LWIP_EVENT_API && LWIP_CALLBACK_API) || (!LWIP_EVENT_API && !LWIP_CALLBACK_API))) 197195972f6Sopenharmony_ci#error "One and exactly one of LWIP_EVENT_API and LWIP_CALLBACK_API has to be enabled in your lwipopts.h" 198195972f6Sopenharmony_ci#endif 199195972f6Sopenharmony_ci#if (LWIP_ALTCP && LWIP_EVENT_API) 200195972f6Sopenharmony_ci#error "The application layered tcp API does not work with LWIP_EVENT_API" 201195972f6Sopenharmony_ci#endif 202195972f6Sopenharmony_ci#if (MEM_LIBC_MALLOC && MEM_USE_POOLS) 203195972f6Sopenharmony_ci#error "MEM_LIBC_MALLOC and MEM_USE_POOLS may not both be simultaneously enabled in your lwipopts.h" 204195972f6Sopenharmony_ci#endif 205195972f6Sopenharmony_ci#if (MEM_USE_POOLS && !MEMP_USE_CUSTOM_POOLS) 206195972f6Sopenharmony_ci#error "MEM_USE_POOLS requires custom pools (MEMP_USE_CUSTOM_POOLS) to be enabled in your lwipopts.h" 207195972f6Sopenharmony_ci#endif 208195972f6Sopenharmony_ci#if (PBUF_POOL_BUFSIZE <= MEM_ALIGNMENT) 209195972f6Sopenharmony_ci#error "PBUF_POOL_BUFSIZE must be greater than MEM_ALIGNMENT or the offset may take the full first pbuf" 210195972f6Sopenharmony_ci#endif 211195972f6Sopenharmony_ci#if (DNS_LOCAL_HOSTLIST && !DNS_LOCAL_HOSTLIST_IS_DYNAMIC && !(defined(DNS_LOCAL_HOSTLIST_INIT))) 212195972f6Sopenharmony_ci#error "you have to define define DNS_LOCAL_HOSTLIST_INIT {{'host1', 0x123}, {'host2', 0x234}} to initialize DNS_LOCAL_HOSTLIST" 213195972f6Sopenharmony_ci#endif 214195972f6Sopenharmony_ci#if PPP_SUPPORT && !PPPOS_SUPPORT && !PPPOE_SUPPORT && !PPPOL2TP_SUPPORT 215195972f6Sopenharmony_ci#error "PPP_SUPPORT needs at least one of PPPOS_SUPPORT, PPPOE_SUPPORT or PPPOL2TP_SUPPORT turned on" 216195972f6Sopenharmony_ci#endif 217195972f6Sopenharmony_ci#if PPP_SUPPORT && !PPP_IPV4_SUPPORT && !PPP_IPV6_SUPPORT 218195972f6Sopenharmony_ci#error "PPP_SUPPORT needs PPP_IPV4_SUPPORT and/or PPP_IPV6_SUPPORT turned on" 219195972f6Sopenharmony_ci#endif 220195972f6Sopenharmony_ci#if PPP_SUPPORT && PPP_IPV4_SUPPORT && !LWIP_IPV4 221195972f6Sopenharmony_ci#error "PPP_IPV4_SUPPORT needs LWIP_IPV4 turned on" 222195972f6Sopenharmony_ci#endif 223195972f6Sopenharmony_ci#if PPP_SUPPORT && PPP_IPV6_SUPPORT && !LWIP_IPV6 224195972f6Sopenharmony_ci#error "PPP_IPV6_SUPPORT needs LWIP_IPV6 turned on" 225195972f6Sopenharmony_ci#endif 226195972f6Sopenharmony_ci#if !LWIP_ETHERNET && (LWIP_ARP || PPPOE_SUPPORT) 227195972f6Sopenharmony_ci#error "LWIP_ETHERNET needs to be turned on for LWIP_ARP or PPPOE_SUPPORT" 228195972f6Sopenharmony_ci#endif 229195972f6Sopenharmony_ci#if LWIP_TCPIP_CORE_LOCKING_INPUT && !LWIP_TCPIP_CORE_LOCKING 230195972f6Sopenharmony_ci#error "When using LWIP_TCPIP_CORE_LOCKING_INPUT, LWIP_TCPIP_CORE_LOCKING must be enabled, too" 231195972f6Sopenharmony_ci#endif 232195972f6Sopenharmony_ci#if LWIP_TCP && LWIP_NETIF_TX_SINGLE_PBUF && !TCP_OVERSIZE 233195972f6Sopenharmony_ci#error "LWIP_NETIF_TX_SINGLE_PBUF needs TCP_OVERSIZE enabled to create single-pbuf TCP packets" 234195972f6Sopenharmony_ci#endif 235195972f6Sopenharmony_ci#if LWIP_NETCONN && LWIP_TCP 236195972f6Sopenharmony_ci#if NETCONN_COPY != TCP_WRITE_FLAG_COPY 237195972f6Sopenharmony_ci#error "NETCONN_COPY != TCP_WRITE_FLAG_COPY" 238195972f6Sopenharmony_ci#endif 239195972f6Sopenharmony_ci#if NETCONN_MORE != TCP_WRITE_FLAG_MORE 240195972f6Sopenharmony_ci#error "NETCONN_MORE != TCP_WRITE_FLAG_MORE" 241195972f6Sopenharmony_ci#endif 242195972f6Sopenharmony_ci#endif /* LWIP_NETCONN && LWIP_TCP */ 243195972f6Sopenharmony_ci// #if LWIP_NETCONN_FULLDUPLEX && !LWIP_NETCONN_SEM_PER_THREAD 244195972f6Sopenharmony_ci// #error "For LWIP_NETCONN_FULLDUPLEX to work, LWIP_NETCONN_SEM_PER_THREAD is required" 245195972f6Sopenharmony_ci// #endif 246195972f6Sopenharmony_ci 247195972f6Sopenharmony_ci 248195972f6Sopenharmony_ci/* Compile-time checks for deprecated options. 249195972f6Sopenharmony_ci */ 250195972f6Sopenharmony_ci#ifdef MEMP_NUM_TCPIP_MSG 251195972f6Sopenharmony_ci#error "MEMP_NUM_TCPIP_MSG option is deprecated. Remove it from your lwipopts.h." 252195972f6Sopenharmony_ci#endif 253195972f6Sopenharmony_ci#ifdef TCP_REXMIT_DEBUG 254195972f6Sopenharmony_ci#error "TCP_REXMIT_DEBUG option is deprecated. Remove it from your lwipopts.h." 255195972f6Sopenharmony_ci#endif 256195972f6Sopenharmony_ci#ifdef RAW_STATS 257195972f6Sopenharmony_ci#error "RAW_STATS option is deprecated. Remove it from your lwipopts.h." 258195972f6Sopenharmony_ci#endif 259195972f6Sopenharmony_ci#ifdef ETHARP_QUEUE_FIRST 260195972f6Sopenharmony_ci#error "ETHARP_QUEUE_FIRST option is deprecated. Remove it from your lwipopts.h." 261195972f6Sopenharmony_ci#endif 262195972f6Sopenharmony_ci#ifdef ETHARP_ALWAYS_INSERT 263195972f6Sopenharmony_ci#error "ETHARP_ALWAYS_INSERT option is deprecated. Remove it from your lwipopts.h." 264195972f6Sopenharmony_ci#endif 265195972f6Sopenharmony_ci#if !NO_SYS && LWIP_TCPIP_CORE_LOCKING && LWIP_COMPAT_MUTEX && !defined(LWIP_COMPAT_MUTEX_ALLOWED) 266195972f6Sopenharmony_ci#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.)" 267195972f6Sopenharmony_ci#endif 268195972f6Sopenharmony_ci 269195972f6Sopenharmony_ci#ifndef LWIP_DISABLE_TCP_SANITY_CHECKS 270195972f6Sopenharmony_ci#define LWIP_DISABLE_TCP_SANITY_CHECKS 0 271195972f6Sopenharmony_ci#endif 272195972f6Sopenharmony_ci#ifndef LWIP_DISABLE_MEMP_SANITY_CHECKS 273195972f6Sopenharmony_ci#define LWIP_DISABLE_MEMP_SANITY_CHECKS 0 274195972f6Sopenharmony_ci#endif 275195972f6Sopenharmony_ci 276195972f6Sopenharmony_ci/* MEMP sanity checks */ 277195972f6Sopenharmony_ci#if MEMP_MEM_MALLOC 278195972f6Sopenharmony_ci#if !LWIP_DISABLE_MEMP_SANITY_CHECKS 279195972f6Sopenharmony_ci#if LWIP_NETCONN || LWIP_SOCKET 280195972f6Sopenharmony_ci#if !MEMP_NUM_NETCONN && LWIP_SOCKET 281195972f6Sopenharmony_ci#error "lwip_sanity_check: WARNING: MEMP_NUM_NETCONN cannot be 0 when using sockets!" 282195972f6Sopenharmony_ci#endif 283195972f6Sopenharmony_ci#else /* MEMP_MEM_MALLOC */ 284195972f6Sopenharmony_ci#if MEMP_NUM_NETCONN > (MEMP_NUM_TCP_PCB+MEMP_NUM_TCP_PCB_LISTEN+MEMP_NUM_UDP_PCB+MEMP_NUM_RAW_PCB) 285195972f6Sopenharmony_ci#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." 286195972f6Sopenharmony_ci#endif 287195972f6Sopenharmony_ci#endif /* LWIP_NETCONN || LWIP_SOCKET */ 288195972f6Sopenharmony_ci#endif /* !LWIP_DISABLE_MEMP_SANITY_CHECKS */ 289195972f6Sopenharmony_ci#if MEM_USE_POOLS 290195972f6Sopenharmony_ci#error "MEMP_MEM_MALLOC and MEM_USE_POOLS cannot be enabled at the same time" 291195972f6Sopenharmony_ci#endif 292195972f6Sopenharmony_ci#ifdef LWIP_HOOK_MEMP_AVAILABLE 293195972f6Sopenharmony_ci#error "LWIP_HOOK_MEMP_AVAILABLE doesn't make sense with MEMP_MEM_MALLOC" 294195972f6Sopenharmony_ci#endif 295195972f6Sopenharmony_ci#endif /* MEMP_MEM_MALLOC */ 296195972f6Sopenharmony_ci 297195972f6Sopenharmony_ci/* TCP sanity checks */ 298195972f6Sopenharmony_ci#if !LWIP_DISABLE_TCP_SANITY_CHECKS 299195972f6Sopenharmony_ci#if LWIP_TCP 300195972f6Sopenharmony_ci#if !MEMP_MEM_MALLOC && (MEMP_NUM_TCP_SEG < TCP_SND_QUEUELEN) 301195972f6Sopenharmony_ci#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." 302195972f6Sopenharmony_ci#endif 303195972f6Sopenharmony_ci#if TCP_SND_BUF < (2 * TCP_MSS) 304195972f6Sopenharmony_ci#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." 305195972f6Sopenharmony_ci#endif 306195972f6Sopenharmony_ci#if TCP_SND_QUEUELEN < (2 * (TCP_SND_BUF / TCP_MSS)) 307195972f6Sopenharmony_ci#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." 308195972f6Sopenharmony_ci#endif 309195972f6Sopenharmony_ci#if TCP_SNDLOWAT >= TCP_SND_BUF 310195972f6Sopenharmony_ci#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." 311195972f6Sopenharmony_ci#endif 312195972f6Sopenharmony_ci#if TCP_SNDLOWAT >= (0xFFFF - (4 * TCP_MSS)) 313195972f6Sopenharmony_ci#error "lwip_sanity_check: WARNING: TCP_SNDLOWAT must at least be 4*MSS below u16_t overflow!" 314195972f6Sopenharmony_ci#endif 315195972f6Sopenharmony_ci#if TCP_SNDQUEUELOWAT >= TCP_SND_QUEUELEN 316195972f6Sopenharmony_ci#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." 317195972f6Sopenharmony_ci#endif 318195972f6Sopenharmony_ci#if !MEMP_MEM_MALLOC && PBUF_POOL_SIZE && (PBUF_POOL_BUFSIZE <= (PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN)) 319195972f6Sopenharmony_ci#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." 320195972f6Sopenharmony_ci#endif 321195972f6Sopenharmony_ci#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)))) 322195972f6Sopenharmony_ci#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." 323195972f6Sopenharmony_ci#endif 324195972f6Sopenharmony_ci#if TCP_WND < TCP_MSS 325195972f6Sopenharmony_ci#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." 326195972f6Sopenharmony_ci#endif 327195972f6Sopenharmony_ci#endif /* LWIP_TCP */ 328195972f6Sopenharmony_ci#endif /* !LWIP_DISABLE_TCP_SANITY_CHECKS */ 329195972f6Sopenharmony_ci 330195972f6Sopenharmony_ci/** 331195972f6Sopenharmony_ci * @ingroup lwip_nosys 332195972f6Sopenharmony_ci * Initialize all modules. 333195972f6Sopenharmony_ci * Use this in NO_SYS mode. Use tcpip_init() otherwise. 334195972f6Sopenharmony_ci */ 335195972f6Sopenharmony_civoid 336195972f6Sopenharmony_cilwip_init(void) 337195972f6Sopenharmony_ci{ 338195972f6Sopenharmony_ci#ifndef LWIP_SKIP_CONST_CHECK 339195972f6Sopenharmony_ci int a = 0; 340195972f6Sopenharmony_ci LWIP_UNUSED_ARG(a); 341195972f6Sopenharmony_ci LWIP_ASSERT("LWIP_CONST_CAST not implemented correctly. Check your lwIP port.", LWIP_CONST_CAST(void *, &a) == &a); 342195972f6Sopenharmony_ci#endif 343195972f6Sopenharmony_ci#ifndef LWIP_SKIP_PACKING_CHECK 344195972f6Sopenharmony_ci LWIP_ASSERT("Struct packing not implemented correctly. Check your lwIP port.", sizeof(struct packed_struct_test) == PACKED_STRUCT_TEST_EXPECTED_SIZE); 345195972f6Sopenharmony_ci#endif 346195972f6Sopenharmony_ci 347195972f6Sopenharmony_ci /* Modules initialization */ 348195972f6Sopenharmony_ci stats_init(); 349195972f6Sopenharmony_ci#if !NO_SYS 350195972f6Sopenharmony_ci sys_init(); 351195972f6Sopenharmony_ci#endif /* !NO_SYS */ 352195972f6Sopenharmony_ci mem_init(); 353195972f6Sopenharmony_ci memp_init(); 354195972f6Sopenharmony_ci pbuf_init(); 355195972f6Sopenharmony_ci#ifdef LOSCFG_NET_CONTAINER 356195972f6Sopenharmony_ci netif_init(get_root_net_group()); 357195972f6Sopenharmony_ci#else 358195972f6Sopenharmony_ci netif_init(); 359195972f6Sopenharmony_ci#endif 360195972f6Sopenharmony_ci#if LWIP_IPV4 361195972f6Sopenharmony_ci ip_init(); 362195972f6Sopenharmony_ci#if LWIP_ARP 363195972f6Sopenharmony_ci etharp_init(); 364195972f6Sopenharmony_ci#endif /* LWIP_ARP */ 365195972f6Sopenharmony_ci#endif /* LWIP_IPV4 */ 366195972f6Sopenharmony_ci#if LWIP_RAW 367195972f6Sopenharmony_ci raw_init(); 368195972f6Sopenharmony_ci#endif /* LWIP_RAW */ 369195972f6Sopenharmony_ci#if LWIP_UDP 370195972f6Sopenharmony_ci udp_init(); 371195972f6Sopenharmony_ci#endif /* LWIP_UDP */ 372195972f6Sopenharmony_ci#if LWIP_TCP 373195972f6Sopenharmony_ci tcp_init(); 374195972f6Sopenharmony_ci#endif /* LWIP_TCP */ 375195972f6Sopenharmony_ci#if LWIP_IGMP 376195972f6Sopenharmony_ci igmp_init(); 377195972f6Sopenharmony_ci#endif /* LWIP_IGMP */ 378195972f6Sopenharmony_ci#if LWIP_DNS 379195972f6Sopenharmony_ci dns_init(); 380195972f6Sopenharmony_ci#endif /* LWIP_DNS */ 381195972f6Sopenharmony_ci#if PPP_SUPPORT 382195972f6Sopenharmony_ci ppp_init(); 383195972f6Sopenharmony_ci#endif 384195972f6Sopenharmony_ci 385195972f6Sopenharmony_ci#if LWIP_TIMERS 386195972f6Sopenharmony_ci sys_timeouts_init(); 387195972f6Sopenharmony_ci#endif /* LWIP_TIMERS */ 388195972f6Sopenharmony_ci} 389