Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #include "lwip/opt.h"
00040
00041 #include "lwip/init.h"
00042 #include "lwip/stats.h"
00043 #include "lwip/sys.h"
00044 #include "lwip/mem.h"
00045 #include "lwip/memp.h"
00046 #include "lwip/pbuf.h"
00047 #include "lwip/netif.h"
00048 #include "lwip/sockets.h"
00049 #include "lwip/ip.h"
00050 #include "lwip/raw.h"
00051 #include "lwip/udp.h"
00052 #include "lwip/tcp.h"
00053 #include "lwip/snmp_msg.h"
00054 #include "lwip/autoip.h"
00055 #include "lwip/igmp.h"
00056 #include "lwip/dns.h"
00057 #include "netif/etharp.h"
00058
00059
00060
00061
00062 #ifndef BYTE_ORDER
00063 #error "BYTE_ORDER is not defined, you have to define it in your cc.h"
00064 #endif
00065 #if (!IP_SOF_BROADCAST && IP_SOF_BROADCAST_RECV)
00066 #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"
00067 #endif
00068 #if (!LWIP_ARP && ARP_QUEUEING)
00069 #error "If you want to use ARP Queueing, you have to define LWIP_ARP=1 in your lwipopts.h"
00070 #endif
00071 #if (!LWIP_UDP && LWIP_UDPLITE)
00072 #error "If you want to use UDP Lite, you have to define LWIP_UDP=1 in your lwipopts.h"
00073 #endif
00074 #if (!LWIP_UDP && LWIP_SNMP)
00075 #error "If you want to use SNMP, you have to define LWIP_UDP=1 in your lwipopts.h"
00076 #endif
00077 #if (!LWIP_UDP && LWIP_DHCP)
00078 #error "If you want to use DHCP, you have to define LWIP_UDP=1 in your lwipopts.h"
00079 #endif
00080 #if (!LWIP_UDP && LWIP_IGMP)
00081 #error "If you want to use IGMP, you have to define LWIP_UDP=1 in your lwipopts.h"
00082 #endif
00083 #if (!LWIP_UDP && LWIP_DNS)
00084 #error "If you want to use DNS, you have to define LWIP_UDP=1 in your lwipopts.h"
00085 #endif
00086 #if (LWIP_ARP && (ARP_TABLE_SIZE > 0x7f))
00087 #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"
00088 #endif
00089 #if (LWIP_ARP && ARP_QUEUEING && (MEMP_NUM_ARP_QUEUE<=0))
00090 #error "If you want to use ARP Queueing, you have to define MEMP_NUM_ARP_QUEUE>=1 in your lwipopts.h"
00091 #endif
00092 #if (LWIP_RAW && (MEMP_NUM_RAW_PCB<=0))
00093 #error "If you want to use RAW, you have to define MEMP_NUM_RAW_PCB>=1 in your lwipopts.h"
00094 #endif
00095 #if (LWIP_UDP && (MEMP_NUM_UDP_PCB<=0))
00096 #error "If you want to use UDP, you have to define MEMP_NUM_UDP_PCB>=1 in your lwipopts.h"
00097 #endif
00098 #if (LWIP_TCP && (MEMP_NUM_TCP_PCB<=0))
00099 #error "If you want to use TCP, you have to define MEMP_NUM_TCP_PCB>=1 in your lwipopts.h"
00100 #endif
00101 #if (LWIP_TCP && (TCP_WND > 0xffff))
00102 #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"
00103 #endif
00104 #if (LWIP_TCP && (TCP_SND_QUEUELEN > 0xffff))
00105 #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"
00106 #endif
00107 #if (LWIP_TCP && ((TCP_MAXRTX > 12) || (TCP_SYNMAXRTX > 12)))
00108 #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"
00109 #endif
00110 #if (LWIP_TCP && TCP_LISTEN_BACKLOG && (TCP_DEFAULT_LISTEN_BACKLOG < 0) || (TCP_DEFAULT_LISTEN_BACKLOG > 0xff))
00111 #error "If you want to use TCP backlog, TCP_DEFAULT_LISTEN_BACKLOG must fit into an u8_t"
00112 #endif
00113 #if (LWIP_IGMP && (MEMP_NUM_IGMP_GROUP<=1))
00114 #error "If you want to use IGMP, you have to define MEMP_NUM_IGMP_GROUP>1 in your lwipopts.h"
00115 #endif
00116 #if (PPP_SUPPORT && (NO_SYS==1))
00117 #error "If you want to use PPP, you have to define NO_SYS=0 in your lwipopts.h"
00118 #endif
00119 #if (LWIP_NETIF_API && (NO_SYS==1))
00120 #error "If you want to use NETIF API, you have to define NO_SYS=0 in your lwipopts.h"
00121 #endif
00122 #if ((LWIP_SOCKET || LWIP_NETCONN) && (NO_SYS==1))
00123 #error "If you want to use Sequential API, you have to define NO_SYS=0 in your lwipopts.h"
00124 #endif
00125 #if ((LWIP_NETCONN || LWIP_SOCKET) && (MEMP_NUM_TCPIP_MSG_API<=0))
00126 #error "If you want to use Sequential API, you have to define MEMP_NUM_TCPIP_MSG_API>=1 in your lwipopts.h"
00127 #endif
00128 #if (!LWIP_NETCONN && LWIP_SOCKET)
00129 #error "If you want to use Socket API, you have to define LWIP_NETCONN=1 in your lwipopts.h"
00130 #endif
00131 #if (((!LWIP_DHCP) || (!LWIP_AUTOIP)) && LWIP_DHCP_AUTOIP_COOP)
00132 #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"
00133 #endif
00134 #if (((!LWIP_DHCP) || (!LWIP_ARP)) && DHCP_DOES_ARP_CHECK)
00135 #error "If you want to use DHCP ARP checking, you have to define LWIP_DHCP=1 and LWIP_ARP=1 in your lwipopts.h"
00136 #endif
00137 #if (!LWIP_ARP && LWIP_AUTOIP)
00138 #error "If you want to use AUTOIP, you have to define LWIP_ARP=1 in your lwipopts.h"
00139 #endif
00140 #if (LWIP_SNMP && (SNMP_CONCURRENT_REQUESTS<=0))
00141 #error "If you want to use SNMP, you have to define SNMP_CONCURRENT_REQUESTS>=1 in your lwipopts.h"
00142 #endif
00143 #if (LWIP_SNMP && (SNMP_TRAP_DESTINATIONS<=0))
00144 #error "If you want to use SNMP, you have to define SNMP_TRAP_DESTINATIONS>=1 in your lwipopts.h"
00145 #endif
00146 #if (LWIP_TCP && ((LWIP_EVENT_API && LWIP_CALLBACK_API) || (!LWIP_EVENT_API && !LWIP_CALLBACK_API)))
00147 #error "One and exactly one of LWIP_EVENT_API and LWIP_CALLBACK_API has to be enabled in your lwipopts.h"
00148 #endif
00149
00150 #if ((NO_SYS==0) && (MEMP_NUM_SYS_TIMEOUT < (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + PPP_SUPPORT)))
00151 #error "MEMP_NUM_SYS_TIMEOUT is too low to accomodate all required timeouts"
00152 #endif
00153 #if (IP_REASSEMBLY && (MEMP_NUM_REASSDATA > IP_REASS_MAX_PBUFS))
00154 #error "MEMP_NUM_REASSDATA > IP_REASS_MAX_PBUFS doesn't make sense since each struct ip_reassdata must hold 2 pbufs at least!"
00155 #endif
00156 #if (MEM_LIBC_MALLOC && MEM_USE_POOLS)
00157 #error "MEM_LIBC_MALLOC and MEM_USE_POOLS may not both be simultaneously enabled in your lwipopts.h"
00158 #endif
00159 #if (MEM_USE_POOLS && !MEMP_USE_CUSTOM_POOLS)
00160 #error "MEM_USE_POOLS requires custom pools (MEMP_USE_CUSTOM_POOLS) to be enabled in your lwipopts.h"
00161 #endif
00162 #if (PBUF_POOL_BUFSIZE <= MEM_ALIGNMENT)
00163 #error "PBUF_POOL_BUFSIZE must be greater than MEM_ALIGNMENT or the offset may take the full first pbuf"
00164 #endif
00165 #if (TCP_QUEUE_OOSEQ && !LWIP_TCP)
00166 #error "TCP_QUEUE_OOSEQ requires LWIP_TCP"
00167 #endif
00168 #if (DNS_LOCAL_HOSTLIST && !DNS_LOCAL_HOSTLIST_IS_DYNAMIC && !(defined(DNS_LOCAL_HOSTLIST_INIT)))
00169 #error "you have to define define DNS_LOCAL_HOSTLIST_INIT {{'host1', 0x123}, {'host2', 0x234}} to initialize DNS_LOCAL_HOSTLIST"
00170 #endif
00171 #if PPP_SUPPORT && !PPPOS_SUPPORT & !PPPOE_SUPPORT
00172 #error "PPP_SUPPORT needs either PPPOS_SUPPORT or PPPOE_SUPPORT turned on"
00173 #endif
00174
00175
00176
00177
00178 #ifdef MEMP_NUM_TCPIP_MSG
00179 #error "MEMP_NUM_TCPIP_MSG option is deprecated. Remove it from your lwipopts.h."
00180 #endif
00181 #ifdef MEMP_NUM_API_MSG
00182 #error "MEMP_NUM_API_MSG option is deprecated. Remove it from your lwipopts.h."
00183 #endif
00184 #ifdef TCP_REXMIT_DEBUG
00185 #error "TCP_REXMIT_DEBUG option is deprecated. Remove it from your lwipopts.h."
00186 #endif
00187 #ifdef RAW_STATS
00188 #error "RAW_STATS option is deprecated. Remove it from your lwipopts.h."
00189 #endif
00190 #ifdef ETHARP_QUEUE_FIRST
00191 #error "ETHARP_QUEUE_FIRST option is deprecated. Remove it from your lwipopts.h."
00192 #endif
00193 #ifdef ETHARP_ALWAYS_INSERT
00194 #error "ETHARP_ALWAYS_INSERT option is deprecated. Remove it from your lwipopts.h."
00195 #endif
00196 #if SO_REUSE
00197
00198
00199 #error "SO_REUSE currently unavailable, this was a hack"
00200 #endif
00201
00202 #ifdef LWIP_DEBUG
00203 static void
00204 lwip_sanity_check(void)
00205 {
00206
00207 #if LWIP_NETCONN
00208 if (MEMP_NUM_NETCONN > (MEMP_NUM_TCP_PCB+MEMP_NUM_TCP_PCB_LISTEN+MEMP_NUM_UDP_PCB+MEMP_NUM_RAW_PCB))
00209 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"));
00210 #endif
00211 #if LWIP_TCP
00212 if (MEMP_NUM_TCP_SEG < TCP_SND_QUEUELEN)
00213 LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: MEMP_NUM_TCP_SEG should be at least as big as TCP_SND_QUEUELEN\n"));
00214 if (TCP_SND_BUF < 2 * TCP_MSS)
00215 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"));
00216 if (TCP_SND_QUEUELEN < (2 * (TCP_SND_BUF/TCP_MSS)))
00217 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"));
00218 if (TCP_SNDLOWAT > TCP_SND_BUF)
00219 LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: TCP_SNDLOWAT must be less than or equal to TCP_SND_BUF.\n"));
00220 if (TCP_WND > (PBUF_POOL_SIZE*PBUF_POOL_BUFSIZE))
00221 LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: TCP_WND is larger than space provided by PBUF_POOL_SIZE*PBUF_POOL_BUFSIZE\n"));
00222 if (TCP_WND < TCP_MSS)
00223 LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: TCP_WND is smaller than MSS\n"));
00224 #endif
00225 }
00226 #else
00227 #define lwip_sanity_check()
00228 #endif
00229
00230
00231
00232
00233 void
00234 lwip_init(void)
00235 {
00236
00237 lwip_sanity_check();
00238
00239
00240 stats_init();
00241 sys_init();
00242 mem_init();
00243 memp_init();
00244 pbuf_init();
00245 netif_init();
00246 #if LWIP_SOCKET
00247 lwip_socket_init();
00248 #endif
00249 ip_init();
00250 #if LWIP_ARP
00251 etharp_init();
00252 #endif
00253 #if LWIP_RAW
00254 raw_init();
00255 #endif
00256 #if LWIP_UDP
00257 udp_init();
00258 #endif
00259 #if LWIP_TCP
00260 tcp_init();
00261 #endif
00262 #if LWIP_SNMP
00263 snmp_init();
00264 #endif
00265 #if LWIP_AUTOIP
00266 autoip_init();
00267 #endif
00268 #if LWIP_IGMP
00269 igmp_init();
00270 #endif
00271 #if LWIP_DNS
00272 dns_init();
00273 #endif
00274 }