Library for Bert van Dam's book "ARM MICROCONTROLLERS" For all chapters with internet.

Dependencies:   mbed

Committer:
ICTFBI
Date:
Fri Oct 16 14:28:26 2015 +0000
Revision:
0:4edb816d21e1
Pre-update 16-10-15

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ICTFBI 0:4edb816d21e1 1 /**
ICTFBI 0:4edb816d21e1 2 * @file
ICTFBI 0:4edb816d21e1 3 * Modules initialization
ICTFBI 0:4edb816d21e1 4 *
ICTFBI 0:4edb816d21e1 5 */
ICTFBI 0:4edb816d21e1 6
ICTFBI 0:4edb816d21e1 7 /*
ICTFBI 0:4edb816d21e1 8 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
ICTFBI 0:4edb816d21e1 9 * All rights reserved.
ICTFBI 0:4edb816d21e1 10 *
ICTFBI 0:4edb816d21e1 11 * Redistribution and use in source and binary forms, with or without modification,
ICTFBI 0:4edb816d21e1 12 * are permitted provided that the following conditions are met:
ICTFBI 0:4edb816d21e1 13 *
ICTFBI 0:4edb816d21e1 14 * 1. Redistributions of source code must retain the above copyright notice,
ICTFBI 0:4edb816d21e1 15 * this list of conditions and the following disclaimer.
ICTFBI 0:4edb816d21e1 16 * 2. Redistributions in binary form must reproduce the above copyright notice,
ICTFBI 0:4edb816d21e1 17 * this list of conditions and the following disclaimer in the documentation
ICTFBI 0:4edb816d21e1 18 * and/or other materials provided with the distribution.
ICTFBI 0:4edb816d21e1 19 * 3. The name of the author may not be used to endorse or promote products
ICTFBI 0:4edb816d21e1 20 * derived from this software without specific prior written permission.
ICTFBI 0:4edb816d21e1 21 *
ICTFBI 0:4edb816d21e1 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
ICTFBI 0:4edb816d21e1 23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
ICTFBI 0:4edb816d21e1 24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
ICTFBI 0:4edb816d21e1 25 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
ICTFBI 0:4edb816d21e1 26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
ICTFBI 0:4edb816d21e1 27 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
ICTFBI 0:4edb816d21e1 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
ICTFBI 0:4edb816d21e1 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
ICTFBI 0:4edb816d21e1 30 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
ICTFBI 0:4edb816d21e1 31 * OF SUCH DAMAGE.
ICTFBI 0:4edb816d21e1 32 *
ICTFBI 0:4edb816d21e1 33 * This file is part of the lwIP TCP/IP stack.
ICTFBI 0:4edb816d21e1 34 *
ICTFBI 0:4edb816d21e1 35 * Author: Adam Dunkels <adam@sics.se>
ICTFBI 0:4edb816d21e1 36 *
ICTFBI 0:4edb816d21e1 37 */
ICTFBI 0:4edb816d21e1 38
ICTFBI 0:4edb816d21e1 39 #include "lwip/opt.h"
ICTFBI 0:4edb816d21e1 40
ICTFBI 0:4edb816d21e1 41 #include "lwip/init.h"
ICTFBI 0:4edb816d21e1 42 #include "lwip/stats.h"
ICTFBI 0:4edb816d21e1 43 #include "lwip/sys.h"
ICTFBI 0:4edb816d21e1 44 #include "lwip/mem.h"
ICTFBI 0:4edb816d21e1 45 #include "lwip/memp.h"
ICTFBI 0:4edb816d21e1 46 #include "lwip/pbuf.h"
ICTFBI 0:4edb816d21e1 47 #include "lwip/netif.h"
ICTFBI 0:4edb816d21e1 48 #include "lwip/sockets.h"
ICTFBI 0:4edb816d21e1 49 #include "lwip/ip.h"
ICTFBI 0:4edb816d21e1 50 #include "lwip/raw.h"
ICTFBI 0:4edb816d21e1 51 #include "lwip/udp.h"
ICTFBI 0:4edb816d21e1 52 #include "lwip/tcp_impl.h"
ICTFBI 0:4edb816d21e1 53 #include "lwip/snmp_msg.h"
ICTFBI 0:4edb816d21e1 54 #include "lwip/autoip.h"
ICTFBI 0:4edb816d21e1 55 #include "lwip/igmp.h"
ICTFBI 0:4edb816d21e1 56 #include "lwip/dns.h"
ICTFBI 0:4edb816d21e1 57 #include "lwip/timers.h"
ICTFBI 0:4edb816d21e1 58 #include "netif/etharp.h"
ICTFBI 0:4edb816d21e1 59
ICTFBI 0:4edb816d21e1 60 /* Compile-time sanity checks for configuration errors.
ICTFBI 0:4edb816d21e1 61 * These can be done independently of LWIP_DEBUG, without penalty.
ICTFBI 0:4edb816d21e1 62 */
ICTFBI 0:4edb816d21e1 63 #ifndef BYTE_ORDER
ICTFBI 0:4edb816d21e1 64 #error "BYTE_ORDER is not defined, you have to define it in your cc.h"
ICTFBI 0:4edb816d21e1 65 #endif
ICTFBI 0:4edb816d21e1 66 #if (!IP_SOF_BROADCAST && IP_SOF_BROADCAST_RECV)
ICTFBI 0:4edb816d21e1 67 #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"
ICTFBI 0:4edb816d21e1 68 #endif
ICTFBI 0:4edb816d21e1 69 #if (!LWIP_ARP && ARP_QUEUEING)
ICTFBI 0:4edb816d21e1 70 #error "If you want to use ARP Queueing, you have to define LWIP_ARP=1 in your lwipopts.h"
ICTFBI 0:4edb816d21e1 71 #endif
ICTFBI 0:4edb816d21e1 72 #if (!LWIP_UDP && LWIP_UDPLITE)
ICTFBI 0:4edb816d21e1 73 #error "If you want to use UDP Lite, you have to define LWIP_UDP=1 in your lwipopts.h"
ICTFBI 0:4edb816d21e1 74 #endif
ICTFBI 0:4edb816d21e1 75 #if (!LWIP_UDP && LWIP_SNMP)
ICTFBI 0:4edb816d21e1 76 #error "If you want to use SNMP, you have to define LWIP_UDP=1 in your lwipopts.h"
ICTFBI 0:4edb816d21e1 77 #endif
ICTFBI 0:4edb816d21e1 78 #if (!LWIP_UDP && LWIP_DHCP)
ICTFBI 0:4edb816d21e1 79 #error "If you want to use DHCP, you have to define LWIP_UDP=1 in your lwipopts.h"
ICTFBI 0:4edb816d21e1 80 #endif
ICTFBI 0:4edb816d21e1 81 #if (!LWIP_UDP && LWIP_IGMP)
ICTFBI 0:4edb816d21e1 82 #error "If you want to use IGMP, you have to define LWIP_UDP=1 in your lwipopts.h"
ICTFBI 0:4edb816d21e1 83 #endif
ICTFBI 0:4edb816d21e1 84 #if (!LWIP_UDP && LWIP_SNMP)
ICTFBI 0:4edb816d21e1 85 #error "If you want to use SNMP, you have to define LWIP_UDP=1 in your lwipopts.h"
ICTFBI 0:4edb816d21e1 86 #endif
ICTFBI 0:4edb816d21e1 87 #if (!LWIP_UDP && LWIP_DNS)
ICTFBI 0:4edb816d21e1 88 #error "If you want to use DNS, you have to define LWIP_UDP=1 in your lwipopts.h"
ICTFBI 0:4edb816d21e1 89 #endif
ICTFBI 0:4edb816d21e1 90 #if (LWIP_ARP && ARP_QUEUEING && (MEMP_NUM_ARP_QUEUE<=0))
ICTFBI 0:4edb816d21e1 91 #error "If you want to use ARP Queueing, you have to define MEMP_NUM_ARP_QUEUE>=1 in your lwipopts.h"
ICTFBI 0:4edb816d21e1 92 #endif
ICTFBI 0:4edb816d21e1 93 #if (LWIP_RAW && (MEMP_NUM_RAW_PCB<=0))
ICTFBI 0:4edb816d21e1 94 #error "If you want to use RAW, you have to define MEMP_NUM_RAW_PCB>=1 in your lwipopts.h"
ICTFBI 0:4edb816d21e1 95 #endif
ICTFBI 0:4edb816d21e1 96 #if (LWIP_UDP && (MEMP_NUM_UDP_PCB<=0))
ICTFBI 0:4edb816d21e1 97 #error "If you want to use UDP, you have to define MEMP_NUM_UDP_PCB>=1 in your lwipopts.h"
ICTFBI 0:4edb816d21e1 98 #endif
ICTFBI 0:4edb816d21e1 99 #if (LWIP_TCP && (MEMP_NUM_TCP_PCB<=0))
ICTFBI 0:4edb816d21e1 100 #error "If you want to use TCP, you have to define MEMP_NUM_TCP_PCB>=1 in your lwipopts.h"
ICTFBI 0:4edb816d21e1 101 #endif
ICTFBI 0:4edb816d21e1 102 #if (LWIP_TCP && (TCP_WND > 0xffff))
ICTFBI 0:4edb816d21e1 103 #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"
ICTFBI 0:4edb816d21e1 104 #endif
ICTFBI 0:4edb816d21e1 105 #if (LWIP_TCP && (TCP_SND_QUEUELEN > 0xffff))
ICTFBI 0:4edb816d21e1 106 #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"
ICTFBI 0:4edb816d21e1 107 #endif
ICTFBI 0:4edb816d21e1 108 #if (LWIP_TCP && ((TCP_MAXRTX > 12) || (TCP_SYNMAXRTX > 12)))
ICTFBI 0:4edb816d21e1 109 #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"
ICTFBI 0:4edb816d21e1 110 #endif
ICTFBI 0:4edb816d21e1 111 #if (LWIP_TCP && TCP_LISTEN_BACKLOG && (TCP_DEFAULT_LISTEN_BACKLOG < 0) || (TCP_DEFAULT_LISTEN_BACKLOG > 0xff))
ICTFBI 0:4edb816d21e1 112 #error "If you want to use TCP backlog, TCP_DEFAULT_LISTEN_BACKLOG must fit into an u8_t"
ICTFBI 0:4edb816d21e1 113 #endif
ICTFBI 0:4edb816d21e1 114 #if (LWIP_IGMP && (MEMP_NUM_IGMP_GROUP<=1))
ICTFBI 0:4edb816d21e1 115 #error "If you want to use IGMP, you have to define MEMP_NUM_IGMP_GROUP>1 in your lwipopts.h"
ICTFBI 0:4edb816d21e1 116 #endif
ICTFBI 0:4edb816d21e1 117 #if (LWIP_NETIF_API && (NO_SYS==1))
ICTFBI 0:4edb816d21e1 118 #error "If you want to use NETIF API, you have to define NO_SYS=0 in your lwipopts.h"
ICTFBI 0:4edb816d21e1 119 #endif
ICTFBI 0:4edb816d21e1 120 #if ((LWIP_SOCKET || LWIP_NETCONN) && (NO_SYS==1))
ICTFBI 0:4edb816d21e1 121 #error "If you want to use Sequential API, you have to define NO_SYS=0 in your lwipopts.h"
ICTFBI 0:4edb816d21e1 122 #endif
ICTFBI 0:4edb816d21e1 123 #if ((LWIP_NETCONN || LWIP_SOCKET) && (MEMP_NUM_TCPIP_MSG_API<=0))
ICTFBI 0:4edb816d21e1 124 #error "If you want to use Sequential API, you have to define MEMP_NUM_TCPIP_MSG_API>=1 in your lwipopts.h"
ICTFBI 0:4edb816d21e1 125 #endif
ICTFBI 0:4edb816d21e1 126 #if (!LWIP_NETCONN && LWIP_SOCKET)
ICTFBI 0:4edb816d21e1 127 #error "If you want to use Socket API, you have to define LWIP_NETCONN=1 in your lwipopts.h"
ICTFBI 0:4edb816d21e1 128 #endif
ICTFBI 0:4edb816d21e1 129 #if (((!LWIP_DHCP) || (!LWIP_AUTOIP)) && LWIP_DHCP_AUTOIP_COOP)
ICTFBI 0:4edb816d21e1 130 #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"
ICTFBI 0:4edb816d21e1 131 #endif
ICTFBI 0:4edb816d21e1 132 #if (((!LWIP_DHCP) || (!LWIP_ARP)) && DHCP_DOES_ARP_CHECK)
ICTFBI 0:4edb816d21e1 133 #error "If you want to use DHCP ARP checking, you have to define LWIP_DHCP=1 and LWIP_ARP=1 in your lwipopts.h"
ICTFBI 0:4edb816d21e1 134 #endif
ICTFBI 0:4edb816d21e1 135 #if (!LWIP_ARP && LWIP_AUTOIP)
ICTFBI 0:4edb816d21e1 136 #error "If you want to use AUTOIP, you have to define LWIP_ARP=1 in your lwipopts.h"
ICTFBI 0:4edb816d21e1 137 #endif
ICTFBI 0:4edb816d21e1 138 #if (LWIP_SNMP && (SNMP_CONCURRENT_REQUESTS<=0))
ICTFBI 0:4edb816d21e1 139 #error "If you want to use SNMP, you have to define SNMP_CONCURRENT_REQUESTS>=1 in your lwipopts.h"
ICTFBI 0:4edb816d21e1 140 #endif
ICTFBI 0:4edb816d21e1 141 #if (LWIP_SNMP && (SNMP_TRAP_DESTINATIONS<=0))
ICTFBI 0:4edb816d21e1 142 #error "If you want to use SNMP, you have to define SNMP_TRAP_DESTINATIONS>=1 in your lwipopts.h"
ICTFBI 0:4edb816d21e1 143 #endif
ICTFBI 0:4edb816d21e1 144 #if (LWIP_TCP && ((LWIP_EVENT_API && LWIP_CALLBACK_API) || (!LWIP_EVENT_API && !LWIP_CALLBACK_API)))
ICTFBI 0:4edb816d21e1 145 #error "One and exactly one of LWIP_EVENT_API and LWIP_CALLBACK_API has to be enabled in your lwipopts.h"
ICTFBI 0:4edb816d21e1 146 #endif
ICTFBI 0:4edb816d21e1 147 /* There must be sufficient timeouts, taking into account requirements of the subsystems. */
ICTFBI 0:4edb816d21e1 148 #if LWIP_TIMERS && (MEMP_NUM_SYS_TIMEOUT < (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + PPP_SUPPORT))
ICTFBI 0:4edb816d21e1 149 #error "MEMP_NUM_SYS_TIMEOUT is too low to accomodate all required timeouts"
ICTFBI 0:4edb816d21e1 150 #endif
ICTFBI 0:4edb816d21e1 151 #if (IP_REASSEMBLY && (MEMP_NUM_REASSDATA > IP_REASS_MAX_PBUFS))
ICTFBI 0:4edb816d21e1 152 #error "MEMP_NUM_REASSDATA > IP_REASS_MAX_PBUFS doesn't make sense since each struct ip_reassdata must hold 2 pbufs at least!"
ICTFBI 0:4edb816d21e1 153 #endif
ICTFBI 0:4edb816d21e1 154 #if (MEM_LIBC_MALLOC && MEM_USE_POOLS)
ICTFBI 0:4edb816d21e1 155 #error "MEM_LIBC_MALLOC and MEM_USE_POOLS may not both be simultaneously enabled in your lwipopts.h"
ICTFBI 0:4edb816d21e1 156 #endif
ICTFBI 0:4edb816d21e1 157 #if (MEM_USE_POOLS && !MEMP_USE_CUSTOM_POOLS)
ICTFBI 0:4edb816d21e1 158 #error "MEM_USE_POOLS requires custom pools (MEMP_USE_CUSTOM_POOLS) to be enabled in your lwipopts.h"
ICTFBI 0:4edb816d21e1 159 #endif
ICTFBI 0:4edb816d21e1 160 #if (PBUF_POOL_BUFSIZE <= MEM_ALIGNMENT)
ICTFBI 0:4edb816d21e1 161 #error "PBUF_POOL_BUFSIZE must be greater than MEM_ALIGNMENT or the offset may take the full first pbuf"
ICTFBI 0:4edb816d21e1 162 #endif
ICTFBI 0:4edb816d21e1 163 #if (TCP_QUEUE_OOSEQ && !LWIP_TCP)
ICTFBI 0:4edb816d21e1 164 #error "TCP_QUEUE_OOSEQ requires LWIP_TCP"
ICTFBI 0:4edb816d21e1 165 #endif
ICTFBI 0:4edb816d21e1 166 #if (DNS_LOCAL_HOSTLIST && !DNS_LOCAL_HOSTLIST_IS_DYNAMIC && !(defined(DNS_LOCAL_HOSTLIST_INIT)))
ICTFBI 0:4edb816d21e1 167 #error "you have to define define DNS_LOCAL_HOSTLIST_INIT {{'host1', 0x123}, {'host2', 0x234}} to initialize DNS_LOCAL_HOSTLIST"
ICTFBI 0:4edb816d21e1 168 #endif
ICTFBI 0:4edb816d21e1 169 #if PPP_SUPPORT && !PPPOS_SUPPORT & !PPPOE_SUPPORT
ICTFBI 0:4edb816d21e1 170 #error "PPP_SUPPORT needs either PPPOS_SUPPORT or PPPOE_SUPPORT turned on"
ICTFBI 0:4edb816d21e1 171 #endif
ICTFBI 0:4edb816d21e1 172 #if !LWIP_ETHERNET && (LWIP_ARP || PPPOE_SUPPORT)
ICTFBI 0:4edb816d21e1 173 #error "LWIP_ETHERNET needs to be turned on for LWIP_ARP or PPPOE_SUPPORT"
ICTFBI 0:4edb816d21e1 174 #endif
ICTFBI 0:4edb816d21e1 175 #if LWIP_IGMP && !defined(LWIP_RAND)
ICTFBI 0:4edb816d21e1 176 #error "When using IGMP, LWIP_RAND() needs to be defined to a random-function returning an u32_t random value"
ICTFBI 0:4edb816d21e1 177 #endif
ICTFBI 0:4edb816d21e1 178 #if LWIP_TCPIP_CORE_LOCKING_INPUT && !LWIP_TCPIP_CORE_LOCKING
ICTFBI 0:4edb816d21e1 179 #error "When using LWIP_TCPIP_CORE_LOCKING_INPUT, LWIP_TCPIP_CORE_LOCKING must be enabled, too"
ICTFBI 0:4edb816d21e1 180 #endif
ICTFBI 0:4edb816d21e1 181 #if LWIP_TCP && LWIP_NETIF_TX_SINGLE_PBUF && !TCP_OVERSIZE
ICTFBI 0:4edb816d21e1 182 #error "LWIP_NETIF_TX_SINGLE_PBUF needs TCP_OVERSIZE enabled to create single-pbuf TCP packets"
ICTFBI 0:4edb816d21e1 183 #endif
ICTFBI 0:4edb816d21e1 184 #if IP_FRAG && IP_FRAG_USES_STATIC_BUF && LWIP_NETIF_TX_SINGLE_PBUF
ICTFBI 0:4edb816d21e1 185 #error "LWIP_NETIF_TX_SINGLE_PBUF does not work with IP_FRAG_USES_STATIC_BUF==1 as that creates pbuf queues"
ICTFBI 0:4edb816d21e1 186 #endif
ICTFBI 0:4edb816d21e1 187
ICTFBI 0:4edb816d21e1 188
ICTFBI 0:4edb816d21e1 189 /* Compile-time checks for deprecated options.
ICTFBI 0:4edb816d21e1 190 */
ICTFBI 0:4edb816d21e1 191 #ifdef MEMP_NUM_TCPIP_MSG
ICTFBI 0:4edb816d21e1 192 #error "MEMP_NUM_TCPIP_MSG option is deprecated. Remove it from your lwipopts.h."
ICTFBI 0:4edb816d21e1 193 #endif
ICTFBI 0:4edb816d21e1 194 #ifdef MEMP_NUM_API_MSG
ICTFBI 0:4edb816d21e1 195 #error "MEMP_NUM_API_MSG option is deprecated. Remove it from your lwipopts.h."
ICTFBI 0:4edb816d21e1 196 #endif
ICTFBI 0:4edb816d21e1 197 #ifdef TCP_REXMIT_DEBUG
ICTFBI 0:4edb816d21e1 198 #error "TCP_REXMIT_DEBUG option is deprecated. Remove it from your lwipopts.h."
ICTFBI 0:4edb816d21e1 199 #endif
ICTFBI 0:4edb816d21e1 200 #ifdef RAW_STATS
ICTFBI 0:4edb816d21e1 201 #error "RAW_STATS option is deprecated. Remove it from your lwipopts.h."
ICTFBI 0:4edb816d21e1 202 #endif
ICTFBI 0:4edb816d21e1 203 #ifdef ETHARP_QUEUE_FIRST
ICTFBI 0:4edb816d21e1 204 #error "ETHARP_QUEUE_FIRST option is deprecated. Remove it from your lwipopts.h."
ICTFBI 0:4edb816d21e1 205 #endif
ICTFBI 0:4edb816d21e1 206 #ifdef ETHARP_ALWAYS_INSERT
ICTFBI 0:4edb816d21e1 207 #error "ETHARP_ALWAYS_INSERT option is deprecated. Remove it from your lwipopts.h."
ICTFBI 0:4edb816d21e1 208 #endif
ICTFBI 0:4edb816d21e1 209
ICTFBI 0:4edb816d21e1 210 #ifdef LWIP_DEBUG
ICTFBI 0:4edb816d21e1 211 static void
ICTFBI 0:4edb816d21e1 212 lwip_sanity_check(void)
ICTFBI 0:4edb816d21e1 213 {
ICTFBI 0:4edb816d21e1 214 /* Warnings */
ICTFBI 0:4edb816d21e1 215 #if LWIP_NETCONN
ICTFBI 0:4edb816d21e1 216 if (MEMP_NUM_NETCONN > (MEMP_NUM_TCP_PCB+MEMP_NUM_TCP_PCB_LISTEN+MEMP_NUM_UDP_PCB+MEMP_NUM_RAW_PCB))
ICTFBI 0:4edb816d21e1 217 LWIP_PLATFORM_DIAG(("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\n"));
ICTFBI 0:4edb816d21e1 218 #endif /* LWIP_NETCONN */
ICTFBI 0:4edb816d21e1 219 #if LWIP_TCP
ICTFBI 0:4edb816d21e1 220 if (MEMP_NUM_TCP_SEG < TCP_SND_QUEUELEN)
ICTFBI 0:4edb816d21e1 221 LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: MEMP_NUM_TCP_SEG should be at least as big as TCP_SND_QUEUELEN\n"));
ICTFBI 0:4edb816d21e1 222 if (TCP_SND_BUF < 2 * TCP_MSS)
ICTFBI 0:4edb816d21e1 223 LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: TCP_SND_BUF must be at least as much as (2 * TCP_MSS) for things to work smoothly\n"));
ICTFBI 0:4edb816d21e1 224 if (TCP_SND_QUEUELEN < (2 * (TCP_SND_BUF/TCP_MSS)))
ICTFBI 0:4edb816d21e1 225 LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: TCP_SND_QUEUELEN must be at least as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work\n"));
ICTFBI 0:4edb816d21e1 226 if (TCP_SNDLOWAT >= TCP_SND_BUF)
ICTFBI 0:4edb816d21e1 227 LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: TCP_SNDLOWAT must be less than TCP_SND_BUF.\n"));
ICTFBI 0:4edb816d21e1 228 if (TCP_SNDQUEUELOWAT >= TCP_SND_QUEUELEN)
ICTFBI 0:4edb816d21e1 229 LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: TCP_SNDQUEUELOWAT must be less than TCP_SND_QUEUELEN.\n"));
ICTFBI 0:4edb816d21e1 230 if (TCP_WND > (PBUF_POOL_SIZE*PBUF_POOL_BUFSIZE))
ICTFBI 0:4edb816d21e1 231 LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: TCP_WND is larger than space provided by PBUF_POOL_SIZE*PBUF_POOL_BUFSIZE\n"));
ICTFBI 0:4edb816d21e1 232 if (TCP_WND < TCP_MSS)
ICTFBI 0:4edb816d21e1 233 LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: TCP_WND is smaller than MSS\n"));
ICTFBI 0:4edb816d21e1 234 #endif /* LWIP_TCP */
ICTFBI 0:4edb816d21e1 235 #if LWIP_SOCKET
ICTFBI 0:4edb816d21e1 236 /* Check that the SO_* socket options and SOF_* lwIP-internal flags match */
ICTFBI 0:4edb816d21e1 237 if (SO_ACCEPTCONN != SOF_ACCEPTCONN)
ICTFBI 0:4edb816d21e1 238 LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: SO_ACCEPTCONN != SOF_ACCEPTCONN\n"));
ICTFBI 0:4edb816d21e1 239 if (SO_REUSEADDR != SOF_REUSEADDR)
ICTFBI 0:4edb816d21e1 240 LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: SO_REUSEADDR != SOF_REUSEADDR\n"));
ICTFBI 0:4edb816d21e1 241 if (SO_KEEPALIVE != SOF_KEEPALIVE)
ICTFBI 0:4edb816d21e1 242 LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: SO_KEEPALIVE != SOF_KEEPALIVE\n"));
ICTFBI 0:4edb816d21e1 243 if (SO_BROADCAST != SOF_BROADCAST)
ICTFBI 0:4edb816d21e1 244 LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: SO_BROADCAST != SOF_BROADCAST\n"));
ICTFBI 0:4edb816d21e1 245 if (SO_LINGER != SOF_LINGER)
ICTFBI 0:4edb816d21e1 246 LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: SO_LINGER != SOF_LINGER\n"));
ICTFBI 0:4edb816d21e1 247 #endif /* LWIP_SOCKET */
ICTFBI 0:4edb816d21e1 248 }
ICTFBI 0:4edb816d21e1 249 #else /* LWIP_DEBUG */
ICTFBI 0:4edb816d21e1 250 #define lwip_sanity_check()
ICTFBI 0:4edb816d21e1 251 #endif /* LWIP_DEBUG */
ICTFBI 0:4edb816d21e1 252
ICTFBI 0:4edb816d21e1 253 /**
ICTFBI 0:4edb816d21e1 254 * Perform Sanity check of user-configurable values, and initialize all modules.
ICTFBI 0:4edb816d21e1 255 */
ICTFBI 0:4edb816d21e1 256 void
ICTFBI 0:4edb816d21e1 257 lwip_init(void)
ICTFBI 0:4edb816d21e1 258 {
ICTFBI 0:4edb816d21e1 259 /* Sanity check user-configurable values */
ICTFBI 0:4edb816d21e1 260 lwip_sanity_check();
ICTFBI 0:4edb816d21e1 261
ICTFBI 0:4edb816d21e1 262 /* Modules initialization */
ICTFBI 0:4edb816d21e1 263 stats_init();
ICTFBI 0:4edb816d21e1 264 #if !NO_SYS
ICTFBI 0:4edb816d21e1 265 sys_init();
ICTFBI 0:4edb816d21e1 266 #endif /* !NO_SYS */
ICTFBI 0:4edb816d21e1 267 mem_init();
ICTFBI 0:4edb816d21e1 268 memp_init();
ICTFBI 0:4edb816d21e1 269 pbuf_init();
ICTFBI 0:4edb816d21e1 270 netif_init();
ICTFBI 0:4edb816d21e1 271 #if LWIP_SOCKET
ICTFBI 0:4edb816d21e1 272 lwip_socket_init();
ICTFBI 0:4edb816d21e1 273 #endif /* LWIP_SOCKET */
ICTFBI 0:4edb816d21e1 274 ip_init();
ICTFBI 0:4edb816d21e1 275 #if LWIP_ARP
ICTFBI 0:4edb816d21e1 276 etharp_init();
ICTFBI 0:4edb816d21e1 277 #endif /* LWIP_ARP */
ICTFBI 0:4edb816d21e1 278 #if LWIP_RAW
ICTFBI 0:4edb816d21e1 279 raw_init();
ICTFBI 0:4edb816d21e1 280 #endif /* LWIP_RAW */
ICTFBI 0:4edb816d21e1 281 #if LWIP_UDP
ICTFBI 0:4edb816d21e1 282 udp_init();
ICTFBI 0:4edb816d21e1 283 #endif /* LWIP_UDP */
ICTFBI 0:4edb816d21e1 284 #if LWIP_TCP
ICTFBI 0:4edb816d21e1 285 tcp_init();
ICTFBI 0:4edb816d21e1 286 #endif /* LWIP_TCP */
ICTFBI 0:4edb816d21e1 287 #if LWIP_SNMP
ICTFBI 0:4edb816d21e1 288 snmp_init();
ICTFBI 0:4edb816d21e1 289 #endif /* LWIP_SNMP */
ICTFBI 0:4edb816d21e1 290 #if LWIP_AUTOIP
ICTFBI 0:4edb816d21e1 291 autoip_init();
ICTFBI 0:4edb816d21e1 292 #endif /* LWIP_AUTOIP */
ICTFBI 0:4edb816d21e1 293 #if LWIP_IGMP
ICTFBI 0:4edb816d21e1 294 igmp_init();
ICTFBI 0:4edb816d21e1 295 #endif /* LWIP_IGMP */
ICTFBI 0:4edb816d21e1 296 #if LWIP_DNS
ICTFBI 0:4edb816d21e1 297 dns_init();
ICTFBI 0:4edb816d21e1 298 #endif /* LWIP_DNS */
ICTFBI 0:4edb816d21e1 299
ICTFBI 0:4edb816d21e1 300 #if LWIP_TIMERS
ICTFBI 0:4edb816d21e1 301 sys_timeouts_init();
ICTFBI 0:4edb816d21e1 302 #endif /* LWIP_TIMERS */
ICTFBI 0:4edb816d21e1 303 }