Example program with HTTPServer and sensor data streaming over TCPSockets, using Donatien Garnier's Net APIs and services code on top of LWIP. Files StreamServer.h and .cpp encapsulate streaming over TCPSockets. Broadcast is done by sendToAll(), and all incoming data is echoed back to the client. Echo code can be replaced with some remote control of the streaming interface. See main() that shows how to periodically send some data to all subscribed clients. To subscribe, a client should open a socket at <mbed_ip> port 123. I used few lines in TCL code to set up a quick sink for the data. HTTP files are served on port 80 concurrently to the streaming.

Dependencies:   mbed

Committer:
iva2k
Date:
Mon Jun 14 03:24:33 2010 +0000
Revision:
1:3ee499525aa5
Parent:
0:e614f7875b60

        

Who changed what in which revision?

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