Port to C027 (using AppShield and Ethernet)

Dependencies:   C12832 EthernetInterface LM75B MMA7660 MQTT mbed-rtos mbed

Fork of IBMIoTClientEthernetExample by IBM Watson IoT

Committer:
samdanbury
Date:
Wed Aug 20 12:45:14 2014 +0000
Revision:
6:37b6d0d56190
Code completely changed to improve the structure, flow and memory usage of the application

Who changed what in which revision?

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