ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

init.c
Go to the documentation of this file.
00001 
00007 /*
00008  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
00009  * All rights reserved. 
00010  * 
00011  * Redistribution and use in source and binary forms, with or without modification, 
00012  * are permitted provided that the following conditions are met:
00013  *
00014  * 1. Redistributions of source code must retain the above copyright notice,
00015  *    this list of conditions and the following disclaimer.
00016  * 2. Redistributions in binary form must reproduce the above copyright notice,
00017  *    this list of conditions and the following disclaimer in the documentation
00018  *    and/or other materials provided with the distribution.
00019  * 3. The name of the author may not be used to endorse or promote products
00020  *    derived from this software without specific prior written permission. 
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
00023  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
00024  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
00025  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
00026  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
00027  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
00028  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
00029  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
00030  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
00031  * OF SUCH DAMAGE.
00032  *
00033  * This file is part of the lwIP TCP/IP stack.
00034  * 
00035  * Author: Adam Dunkels <adam@sics.se>
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_impl.h"
00053 #include "lwip/snmp_msg.h"
00054 #include "lwip/autoip.h"
00055 #include "lwip/igmp.h"
00056 #include "lwip/dns.h"
00057 #include "lwip/timers.h"
00058 #include "netif/etharp.h"
00059 
00060 /* Compile-time sanity checks for configuration errors.
00061  * These can be done independently of LWIP_DEBUG, without penalty.
00062  */
00063 #ifndef BYTE_ORDER
00064   #error "BYTE_ORDER is not defined, you have to define it in your cc.h"
00065 #endif
00066 #if (!IP_SOF_BROADCAST && IP_SOF_BROADCAST_RECV)
00067   #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"
00068 #endif
00069 #if (!LWIP_ARP && ARP_QUEUEING)
00070   #error "If you want to use ARP Queueing, you have to define LWIP_ARP=1 in your lwipopts.h"
00071 #endif
00072 #if (!LWIP_UDP && LWIP_UDPLITE)
00073   #error "If you want to use UDP Lite, you have to define LWIP_UDP=1 in your lwipopts.h"
00074 #endif
00075 #if (!LWIP_UDP && LWIP_SNMP)
00076   #error "If you want to use SNMP, you have to define LWIP_UDP=1 in your lwipopts.h"
00077 #endif
00078 #if (!LWIP_UDP && LWIP_DHCP)
00079   #error "If you want to use DHCP, you have to define LWIP_UDP=1 in your lwipopts.h"
00080 #endif
00081 #if (!LWIP_UDP && LWIP_IGMP)
00082   #error "If you want to use IGMP, you have to define LWIP_UDP=1 in your lwipopts.h"
00083 #endif
00084 #if (!LWIP_UDP && LWIP_SNMP)
00085   #error "If you want to use SNMP, you have to define LWIP_UDP=1 in your lwipopts.h"
00086 #endif
00087 #if (!LWIP_UDP && LWIP_DNS)
00088   #error "If you want to use DNS, you have to define LWIP_UDP=1 in your lwipopts.h"
00089 #endif
00090 #if (LWIP_ARP && ARP_QUEUEING && (MEMP_NUM_ARP_QUEUE<=0))
00091   #error "If you want to use ARP Queueing, you have to define MEMP_NUM_ARP_QUEUE>=1 in your lwipopts.h"
00092 #endif
00093 #if (LWIP_RAW && (MEMP_NUM_RAW_PCB<=0))
00094   #error "If you want to use RAW, you have to define MEMP_NUM_RAW_PCB>=1 in your lwipopts.h"
00095 #endif
00096 #if (LWIP_UDP && (MEMP_NUM_UDP_PCB<=0))
00097   #error "If you want to use UDP, you have to define MEMP_NUM_UDP_PCB>=1 in your lwipopts.h"
00098 #endif
00099 #if (LWIP_TCP && (MEMP_NUM_TCP_PCB<=0))
00100   #error "If you want to use TCP, you have to define MEMP_NUM_TCP_PCB>=1 in your lwipopts.h"
00101 #endif
00102 #if (LWIP_TCP && (TCP_WND > 0xffff))
00103   #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"
00104 #endif
00105 #if (LWIP_TCP && (TCP_SND_QUEUELEN > 0xffff))
00106   #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"
00107 #endif
00108 #if (LWIP_TCP && (TCP_SND_QUEUELEN < 2))
00109   #error "TCP_SND_QUEUELEN must be at least 2 for no-copy TCP writes to work"
00110 #endif
00111 #if (LWIP_TCP && ((TCP_MAXRTX > 12) || (TCP_SYNMAXRTX > 12)))
00112   #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"
00113 #endif
00114 #if (LWIP_TCP && TCP_LISTEN_BACKLOG && (TCP_DEFAULT_LISTEN_BACKLOG < 0) || (TCP_DEFAULT_LISTEN_BACKLOG > 0xff))
00115   #error "If you want to use TCP backlog, TCP_DEFAULT_LISTEN_BACKLOG must fit into an u8_t"
00116 #endif
00117 #if (LWIP_IGMP && (MEMP_NUM_IGMP_GROUP<=1))
00118   #error "If you want to use IGMP, you have to define MEMP_NUM_IGMP_GROUP>1 in your lwipopts.h"
00119 #endif
00120 #if (LWIP_NETIF_API && (NO_SYS==1))
00121   #error "If you want to use NETIF API, you have to define NO_SYS=0 in your lwipopts.h"
00122 #endif
00123 #if ((LWIP_SOCKET || LWIP_NETCONN) && (NO_SYS==1))
00124   #error "If you want to use Sequential API, you have to define NO_SYS=0 in your lwipopts.h"
00125 #endif
00126 #if ((LWIP_NETCONN || LWIP_SOCKET) && (MEMP_NUM_TCPIP_MSG_API<=0))
00127   #error "If you want to use Sequential API, you have to define MEMP_NUM_TCPIP_MSG_API>=1 in your lwipopts.h"
00128 #endif
00129 #if (!LWIP_NETCONN && LWIP_SOCKET)
00130   #error "If you want to use Socket API, you have to define LWIP_NETCONN=1 in your lwipopts.h"
00131 #endif
00132 #if (((!LWIP_DHCP) || (!LWIP_AUTOIP)) && LWIP_DHCP_AUTOIP_COOP)
00133   #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"
00134 #endif
00135 #if (((!LWIP_DHCP) || (!LWIP_ARP)) && DHCP_DOES_ARP_CHECK)
00136   #error "If you want to use DHCP ARP checking, you have to define LWIP_DHCP=1 and LWIP_ARP=1 in your lwipopts.h"
00137 #endif
00138 #if (!LWIP_ARP && LWIP_AUTOIP)
00139   #error "If you want to use AUTOIP, you have to define LWIP_ARP=1 in your lwipopts.h"
00140 #endif
00141 #if (LWIP_SNMP && (SNMP_CONCURRENT_REQUESTS<=0))
00142   #error "If you want to use SNMP, you have to define SNMP_CONCURRENT_REQUESTS>=1 in your lwipopts.h"
00143 #endif
00144 #if (LWIP_SNMP && (SNMP_TRAP_DESTINATIONS<=0))
00145   #error "If you want to use SNMP, you have to define SNMP_TRAP_DESTINATIONS>=1 in your lwipopts.h"
00146 #endif
00147 #if (LWIP_TCP && ((LWIP_EVENT_API && LWIP_CALLBACK_API) || (!LWIP_EVENT_API && !LWIP_CALLBACK_API)))
00148   #error "One and exactly one of LWIP_EVENT_API and LWIP_CALLBACK_API has to be enabled in your lwipopts.h"
00149 #endif
00150 /* There must be sufficient timeouts, taking into account requirements of the subsystems. */
00151 #if LWIP_TIMERS && (MEMP_NUM_SYS_TIMEOUT < (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + PPP_SUPPORT))
00152   #error "MEMP_NUM_SYS_TIMEOUT is too low to accomodate all required timeouts"
00153 #endif
00154 #if (IP_REASSEMBLY && (MEMP_NUM_REASSDATA > IP_REASS_MAX_PBUFS))
00155   #error "MEMP_NUM_REASSDATA > IP_REASS_MAX_PBUFS doesn't make sense since each struct ip_reassdata must hold 2 pbufs at least!"
00156 #endif
00157 #if (MEM_LIBC_MALLOC && MEM_USE_POOLS)
00158   #error "MEM_LIBC_MALLOC and MEM_USE_POOLS may not both be simultaneously enabled in your lwipopts.h"
00159 #endif
00160 #if (MEM_USE_POOLS && !MEMP_USE_CUSTOM_POOLS)
00161   #error "MEM_USE_POOLS requires custom pools (MEMP_USE_CUSTOM_POOLS) to be enabled in your lwipopts.h"
00162 #endif
00163 #if (PBUF_POOL_BUFSIZE <= MEM_ALIGNMENT)
00164   #error "PBUF_POOL_BUFSIZE must be greater than MEM_ALIGNMENT or the offset may take the full first pbuf"
00165 #endif
00166 #if (TCP_QUEUE_OOSEQ && !LWIP_TCP)
00167   #error "TCP_QUEUE_OOSEQ requires LWIP_TCP"
00168 #endif
00169 #if (DNS_LOCAL_HOSTLIST && !DNS_LOCAL_HOSTLIST_IS_DYNAMIC && !(defined(DNS_LOCAL_HOSTLIST_INIT)))
00170   #error "you have to define define DNS_LOCAL_HOSTLIST_INIT {{'host1', 0x123}, {'host2', 0x234}} to initialize DNS_LOCAL_HOSTLIST"
00171 #endif
00172 #if PPP_SUPPORT && !PPPOS_SUPPORT & !PPPOE_SUPPORT
00173   #error "PPP_SUPPORT needs either PPPOS_SUPPORT or PPPOE_SUPPORT turned on"
00174 #endif
00175 #if !LWIP_ETHERNET && (LWIP_ARP || PPPOE_SUPPORT)
00176   #error "LWIP_ETHERNET needs to be turned on for LWIP_ARP or PPPOE_SUPPORT"
00177 #endif
00178 #if LWIP_IGMP && !defined(LWIP_RAND)
00179   #error "When using IGMP, LWIP_RAND() needs to be defined to a random-function returning an u32_t random value"
00180 #endif
00181 #if LWIP_TCPIP_CORE_LOCKING_INPUT && !LWIP_TCPIP_CORE_LOCKING
00182   #error "When using LWIP_TCPIP_CORE_LOCKING_INPUT, LWIP_TCPIP_CORE_LOCKING must be enabled, too"
00183 #endif
00184 #if LWIP_TCP && LWIP_NETIF_TX_SINGLE_PBUF && !TCP_OVERSIZE
00185   #error "LWIP_NETIF_TX_SINGLE_PBUF needs TCP_OVERSIZE enabled to create single-pbuf TCP packets"
00186 #endif
00187 #if IP_FRAG && IP_FRAG_USES_STATIC_BUF && LWIP_NETIF_TX_SINGLE_PBUF
00188   #error "LWIP_NETIF_TX_SINGLE_PBUF does not work with IP_FRAG_USES_STATIC_BUF==1 as that creates pbuf queues"
00189 #endif
00190 
00191 
00192 /* Compile-time checks for deprecated options.
00193  */
00194 #ifdef MEMP_NUM_TCPIP_MSG
00195   #error "MEMP_NUM_TCPIP_MSG option is deprecated. Remove it from your lwipopts.h."
00196 #endif
00197 #ifdef MEMP_NUM_API_MSG
00198   #error "MEMP_NUM_API_MSG option is deprecated. Remove it from your lwipopts.h."
00199 #endif
00200 #ifdef TCP_REXMIT_DEBUG
00201   #error "TCP_REXMIT_DEBUG option is deprecated. Remove it from your lwipopts.h."
00202 #endif
00203 #ifdef RAW_STATS
00204   #error "RAW_STATS option is deprecated. Remove it from your lwipopts.h."
00205 #endif
00206 #ifdef ETHARP_QUEUE_FIRST
00207   #error "ETHARP_QUEUE_FIRST option is deprecated. Remove it from your lwipopts.h."
00208 #endif
00209 #ifdef ETHARP_ALWAYS_INSERT
00210   #error "ETHARP_ALWAYS_INSERT option is deprecated. Remove it from your lwipopts.h."
00211 #endif
00212 
00213 #ifdef LWIP_DEBUG
00214 static void
00215 lwip_sanity_check(void)
00216 {
00217   /* Warnings */
00218 #if LWIP_NETCONN
00219   if (MEMP_NUM_NETCONN > (MEMP_NUM_TCP_PCB+MEMP_NUM_TCP_PCB_LISTEN+MEMP_NUM_UDP_PCB+MEMP_NUM_RAW_PCB))
00220     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"));
00221 #endif /* LWIP_NETCONN */
00222 #if LWIP_TCP
00223   if (MEMP_NUM_TCP_SEG < TCP_SND_QUEUELEN)
00224     LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: MEMP_NUM_TCP_SEG should be at least as big as TCP_SND_QUEUELEN\n"));
00225   if (TCP_SND_BUF < 2 * TCP_MSS)
00226     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"));
00227   if (TCP_SND_QUEUELEN < (2 * (TCP_SND_BUF/TCP_MSS)))
00228     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"));
00229   if (TCP_SNDLOWAT >= TCP_SND_BUF)
00230     LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: TCP_SNDLOWAT must be less than TCP_SND_BUF.\n"));
00231   if (TCP_SNDQUEUELOWAT >= TCP_SND_QUEUELEN)
00232     LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: TCP_SNDQUEUELOWAT must be less than TCP_SND_QUEUELEN.\n"));
00233   if (TCP_WND > (PBUF_POOL_SIZE*PBUF_POOL_BUFSIZE))
00234     LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: TCP_WND is larger than space provided by PBUF_POOL_SIZE*PBUF_POOL_BUFSIZE\n"));
00235   if (TCP_WND < TCP_MSS)
00236     LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: TCP_WND is smaller than MSS\n"));
00237 #endif /* LWIP_TCP */
00238 #if LWIP_SOCKET
00239   /* Check that the SO_* socket options and SOF_* lwIP-internal flags match */
00240   if (SO_ACCEPTCONN != SOF_ACCEPTCONN)
00241     LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: SO_ACCEPTCONN != SOF_ACCEPTCONN\n"));
00242   if (SO_REUSEADDR != SOF_REUSEADDR)
00243     LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: SO_REUSEADDR != SOF_REUSEADDR\n"));
00244   if (SO_KEEPALIVE != SOF_KEEPALIVE)
00245     LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: SO_KEEPALIVE != SOF_KEEPALIVE\n"));
00246   if (SO_BROADCAST != SOF_BROADCAST)
00247     LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: SO_BROADCAST != SOF_BROADCAST\n"));
00248   if (SO_LINGER != SOF_LINGER)
00249     LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: SO_LINGER != SOF_LINGER\n"));
00250 #endif /* LWIP_SOCKET */
00251 }
00252 #else  /* LWIP_DEBUG */
00253 #define lwip_sanity_check()
00254 #endif /* LWIP_DEBUG */
00255 
00259 void
00260 lwip_init(void)
00261 {
00262   /* Sanity check user-configurable values */
00263   lwip_sanity_check();
00264 
00265   /* Modules initialization */
00266   stats_init();
00267 #if !NO_SYS
00268   sys_init();
00269 #endif /* !NO_SYS */
00270   mem_init();
00271   memp_init();
00272   pbuf_init();
00273   netif_init();
00274 #if LWIP_SOCKET
00275   lwip_socket_init();
00276 #endif /* LWIP_SOCKET */
00277   ip_init();
00278 #if LWIP_ARP
00279   etharp_init();
00280 #endif /* LWIP_ARP */
00281 #if LWIP_RAW
00282   raw_init();
00283 #endif /* LWIP_RAW */
00284 #if LWIP_UDP
00285   udp_init();
00286 #endif /* LWIP_UDP */
00287 #if LWIP_TCP
00288   tcp_init();
00289 #endif /* LWIP_TCP */
00290 #if LWIP_SNMP
00291   snmp_init();
00292 #endif /* LWIP_SNMP */
00293 #if LWIP_AUTOIP
00294   autoip_init();
00295 #endif /* LWIP_AUTOIP */
00296 #if LWIP_IGMP
00297   igmp_init();
00298 #endif /* LWIP_IGMP */
00299 #if LWIP_DNS
00300   dns_init();
00301 #endif /* LWIP_DNS */
00302 
00303 #if LWIP_TIMERS
00304   sys_timeouts_init();
00305 #endif /* LWIP_TIMERS */
00306 }

Generated on Sun May 27 2012 04:23:32 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.