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