init.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. /**
  2. * @file
  3. * Modules initialization
  4. *
  5. */
  6. /*
  7. * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without modification,
  11. * are permitted provided that the following conditions are met:
  12. *
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. The name of the author may not be used to endorse or promote products
  19. * derived from this software without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
  22. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  23. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
  24. * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  25. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
  26. * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  27. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  28. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  29. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  30. * OF SUCH DAMAGE.
  31. *
  32. * This file is part of the lwIP TCP/IP stack.
  33. *
  34. * Author: Adam Dunkels <adam@sics.se>
  35. */
  36. #include "lwip/opt.h"
  37. #include "lwip/init.h"
  38. #include "lwip/stats.h"
  39. #include "lwip/sys.h"
  40. #include "lwip/mem.h"
  41. #include "lwip/memp.h"
  42. #include "lwip/pbuf.h"
  43. #include "lwip/netif.h"
  44. #include "lwip/sockets.h"
  45. #include "lwip/ip.h"
  46. #include "lwip/raw.h"
  47. #include "lwip/udp.h"
  48. #include "lwip/priv/tcp_priv.h"
  49. #include "lwip/igmp.h"
  50. #include "lwip/dns.h"
  51. #include "lwip/timeouts.h"
  52. #include "lwip/etharp.h"
  53. #include "lwip/ip6.h"
  54. #include "lwip/nd6.h"
  55. #include "lwip/mld6.h"
  56. #include "lwip/api.h"
  57. #include "netif/ppp/ppp_opts.h"
  58. #include "netif/ppp/ppp_impl.h"
  59. #ifndef LWIP_SKIP_PACKING_CHECK
  60. #ifdef PACK_STRUCT_USE_INCLUDES
  61. # include "arch/bpstruct.h"
  62. #endif
  63. PACK_STRUCT_BEGIN
  64. struct packed_struct_test {
  65. PACK_STRUCT_FLD_8(u8_t dummy1);
  66. PACK_STRUCT_FIELD(u32_t dummy2);
  67. } PACK_STRUCT_STRUCT;
  68. PACK_STRUCT_END
  69. #ifdef PACK_STRUCT_USE_INCLUDES
  70. # include "arch/epstruct.h"
  71. #endif
  72. #define PACKED_STRUCT_TEST_EXPECTED_SIZE 5
  73. #endif
  74. /* Compile-time sanity checks for configuration errors.
  75. * These can be done independently of LWIP_DEBUG, without penalty.
  76. */
  77. #ifndef BYTE_ORDER
  78. #error "BYTE_ORDER is not defined, you have to define it in your cc.h"
  79. #endif
  80. #if (!IP_SOF_BROADCAST && IP_SOF_BROADCAST_RECV)
  81. #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"
  82. #endif
  83. #if (!LWIP_UDP && LWIP_UDPLITE)
  84. #error "If you want to use UDP Lite, you have to define LWIP_UDP=1 in your lwipopts.h"
  85. #endif
  86. #if (!LWIP_UDP && LWIP_DHCP)
  87. #error "If you want to use DHCP, you have to define LWIP_UDP=1 in your lwipopts.h"
  88. #endif
  89. #if (!LWIP_UDP && !LWIP_RAW && LWIP_MULTICAST_TX_OPTIONS)
  90. #error "If you want to use LWIP_MULTICAST_TX_OPTIONS, you have to define LWIP_UDP=1 and/or LWIP_RAW=1 in your lwipopts.h"
  91. #endif
  92. #if (!LWIP_UDP && LWIP_DNS)
  93. #error "If you want to use DNS, you have to define LWIP_UDP=1 in your lwipopts.h"
  94. #endif
  95. #if !MEMP_MEM_MALLOC /* MEMP_NUM_* checks are disabled when not using the pool allocator */
  96. #if (LWIP_ARP && ARP_QUEUEING && (MEMP_NUM_ARP_QUEUE<=0))
  97. #error "If you want to use ARP Queueing, you have to define MEMP_NUM_ARP_QUEUE>=1 in your lwipopts.h"
  98. #endif
  99. #if (LWIP_RAW && (MEMP_NUM_RAW_PCB<=0))
  100. #error "If you want to use RAW, you have to define MEMP_NUM_RAW_PCB>=1 in your lwipopts.h"
  101. #endif
  102. #if (LWIP_UDP && (MEMP_NUM_UDP_PCB<=0))
  103. #error "If you want to use UDP, you have to define MEMP_NUM_UDP_PCB>=1 in your lwipopts.h"
  104. #endif
  105. #if (LWIP_TCP && (MEMP_NUM_TCP_PCB<=0))
  106. #error "If you want to use TCP, you have to define MEMP_NUM_TCP_PCB>=1 in your lwipopts.h"
  107. #endif
  108. #if (LWIP_IGMP && (MEMP_NUM_IGMP_GROUP<=1))
  109. #error "If you want to use IGMP, you have to define MEMP_NUM_IGMP_GROUP>1 in your lwipopts.h"
  110. #endif
  111. #if (LWIP_IGMP && !LWIP_MULTICAST_TX_OPTIONS)
  112. #error "If you want to use IGMP, you have to define LWIP_MULTICAST_TX_OPTIONS==1 in your lwipopts.h"
  113. #endif
  114. #if (LWIP_IGMP && !LWIP_IPV4)
  115. #error "IGMP needs LWIP_IPV4 enabled in your lwipopts.h"
  116. #endif
  117. #if ((LWIP_NETCONN || LWIP_SOCKET) && (MEMP_NUM_TCPIP_MSG_API<=0))
  118. #error "If you want to use Sequential API, you have to define MEMP_NUM_TCPIP_MSG_API>=1 in your lwipopts.h"
  119. #endif
  120. /* There must be sufficient timeouts, taking into account requirements of the subsystems. */
  121. #if LWIP_TIMERS && (MEMP_NUM_SYS_TIMEOUT < LWIP_NUM_SYS_TIMEOUT_INTERNAL)
  122. #error "MEMP_NUM_SYS_TIMEOUT is too low to accomodate all required timeouts"
  123. #endif
  124. #if (IP_REASSEMBLY && (MEMP_NUM_REASSDATA > IP_REASS_MAX_PBUFS))
  125. #error "MEMP_NUM_REASSDATA > IP_REASS_MAX_PBUFS doesn't make sense since each struct ip_reassdata must hold 2 pbufs at least!"
  126. #endif
  127. #endif /* !MEMP_MEM_MALLOC */
  128. #if LWIP_WND_SCALE
  129. #if (LWIP_TCP && (TCP_WND > 0xffffffff))
  130. #error "If you want to use TCP, TCP_WND must fit in an u32_t, so, you have to reduce it in your lwipopts.h"
  131. #endif
  132. #if (LWIP_TCP && (TCP_RCV_SCALE > 14))
  133. #error "The maximum valid window scale value is 14!"
  134. #endif
  135. #if (LWIP_TCP && (TCP_WND > (0xFFFFU << TCP_RCV_SCALE)))
  136. #error "TCP_WND is bigger than the configured LWIP_WND_SCALE allows!"
  137. #endif
  138. #if (LWIP_TCP && ((TCP_WND >> TCP_RCV_SCALE) == 0))
  139. #error "TCP_WND is too small for the configured LWIP_WND_SCALE (results in zero window)!"
  140. #endif
  141. #else /* LWIP_WND_SCALE */
  142. #if (LWIP_TCP && (TCP_WND > 0xffff))
  143. #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 (or enable window scaling)"
  144. #endif
  145. #endif /* LWIP_WND_SCALE */
  146. #if (LWIP_TCP && (TCP_SND_QUEUELEN > 0xffff))
  147. #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"
  148. #endif
  149. #if (LWIP_TCP && (TCP_SND_QUEUELEN < 2))
  150. #error "TCP_SND_QUEUELEN must be at least 2 for no-copy TCP writes to work"
  151. #endif
  152. #if (LWIP_TCP && ((TCP_MAXRTX > 12) || (TCP_SYNMAXRTX > 12)))
  153. #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"
  154. #endif
  155. #if (LWIP_TCP && TCP_LISTEN_BACKLOG && ((TCP_DEFAULT_LISTEN_BACKLOG < 0) || (TCP_DEFAULT_LISTEN_BACKLOG > 0xff)))
  156. #error "If you want to use TCP backlog, TCP_DEFAULT_LISTEN_BACKLOG must fit into an u8_t"
  157. #endif
  158. #if (LWIP_TCP && LWIP_TCP_SACK_OUT && !TCP_QUEUE_OOSEQ)
  159. #error "To use LWIP_TCP_SACK_OUT, TCP_QUEUE_OOSEQ needs to be enabled"
  160. #endif
  161. #if (LWIP_TCP && LWIP_TCP_SACK_OUT && (LWIP_TCP_MAX_SACK_NUM < 1))
  162. #error "LWIP_TCP_MAX_SACK_NUM must be greater than 0"
  163. #endif
  164. #if (LWIP_NETIF_API && (NO_SYS==1))
  165. #error "If you want to use NETIF API, you have to define NO_SYS=0 in your lwipopts.h"
  166. #endif
  167. #if ((LWIP_SOCKET || LWIP_NETCONN) && (NO_SYS==1))
  168. #error "If you want to use Sequential API, you have to define NO_SYS=0 in your lwipopts.h"
  169. #endif
  170. #if (LWIP_PPP_API && (NO_SYS==1))
  171. #error "If you want to use PPP API, you have to define NO_SYS=0 in your lwipopts.h"
  172. #endif
  173. #if (LWIP_PPP_API && (PPP_SUPPORT==0))
  174. #error "If you want to use PPP API, you have to enable PPP_SUPPORT in your lwipopts.h"
  175. #endif
  176. #if (((!LWIP_DHCP) || (!LWIP_AUTOIP)) && LWIP_DHCP_AUTOIP_COOP)
  177. #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"
  178. #endif
  179. #if (((!LWIP_DHCP) || (!LWIP_ARP) || (!LWIP_ACD)) && LWIP_DHCP_DOES_ACD_CHECK)
  180. #error "If you want to use DHCP ACD checking, you have to define LWIP_DHCP=1, LWIP_ARP=1 and LWIP_ACD=1 in your lwipopts.h"
  181. #endif
  182. #if (!LWIP_ARP && LWIP_AUTOIP)
  183. #error "If you want to use AUTOIP, you have to define LWIP_ARP=1 in your lwipopts.h"
  184. #endif
  185. #if (LWIP_TCP && ((LWIP_EVENT_API && LWIP_CALLBACK_API) || (!LWIP_EVENT_API && !LWIP_CALLBACK_API)))
  186. #error "One and exactly one of LWIP_EVENT_API and LWIP_CALLBACK_API has to be enabled in your lwipopts.h"
  187. #endif
  188. #if (LWIP_ALTCP && LWIP_EVENT_API)
  189. #error "The application layered tcp API does not work with LWIP_EVENT_API"
  190. #endif
  191. #if (MEM_LIBC_MALLOC && MEM_USE_POOLS)
  192. #error "MEM_LIBC_MALLOC and MEM_USE_POOLS may not both be simultaneously enabled in your lwipopts.h"
  193. #endif
  194. #if (MEM_USE_POOLS && !MEMP_USE_CUSTOM_POOLS)
  195. #error "MEM_USE_POOLS requires custom pools (MEMP_USE_CUSTOM_POOLS) to be enabled in your lwipopts.h"
  196. #endif
  197. #if (PBUF_POOL_BUFSIZE <= MEM_ALIGNMENT)
  198. #error "PBUF_POOL_BUFSIZE must be greater than MEM_ALIGNMENT or the offset may take the full first pbuf"
  199. #endif
  200. #if (DNS_LOCAL_HOSTLIST && !DNS_LOCAL_HOSTLIST_IS_DYNAMIC && !(defined(DNS_LOCAL_HOSTLIST_INIT)))
  201. #error "you have to define define DNS_LOCAL_HOSTLIST_INIT {{'host1', 0x123}, {'host2', 0x234}} to initialize DNS_LOCAL_HOSTLIST"
  202. #endif
  203. #if PPP_SUPPORT && !PPPOS_SUPPORT && !PPPOE_SUPPORT && !PPPOL2TP_SUPPORT
  204. #error "PPP_SUPPORT needs at least one of PPPOS_SUPPORT, PPPOE_SUPPORT or PPPOL2TP_SUPPORT turned on"
  205. #endif
  206. #if PPP_SUPPORT && !PPP_IPV4_SUPPORT && !PPP_IPV6_SUPPORT
  207. #error "PPP_SUPPORT needs PPP_IPV4_SUPPORT and/or PPP_IPV6_SUPPORT turned on"
  208. #endif
  209. #if PPP_SUPPORT && PPP_IPV4_SUPPORT && !LWIP_IPV4
  210. #error "PPP_IPV4_SUPPORT needs LWIP_IPV4 turned on"
  211. #endif
  212. #if PPP_SUPPORT && PPP_IPV6_SUPPORT && !LWIP_IPV6
  213. #error "PPP_IPV6_SUPPORT needs LWIP_IPV6 turned on"
  214. #endif
  215. #if !LWIP_ETHERNET && (LWIP_ARP || PPPOE_SUPPORT)
  216. #error "LWIP_ETHERNET needs to be turned on for LWIP_ARP or PPPOE_SUPPORT"
  217. #endif
  218. #if LWIP_TCPIP_CORE_LOCKING_INPUT && !LWIP_TCPIP_CORE_LOCKING
  219. #error "When using LWIP_TCPIP_CORE_LOCKING_INPUT, LWIP_TCPIP_CORE_LOCKING must be enabled, too"
  220. #endif
  221. #if LWIP_TCP && LWIP_NETIF_TX_SINGLE_PBUF && !TCP_OVERSIZE
  222. #error "LWIP_NETIF_TX_SINGLE_PBUF needs TCP_OVERSIZE enabled to create single-pbuf TCP packets"
  223. #endif
  224. #if LWIP_NETCONN && LWIP_TCP
  225. #if NETCONN_COPY != TCP_WRITE_FLAG_COPY
  226. #error "NETCONN_COPY != TCP_WRITE_FLAG_COPY"
  227. #endif
  228. #if NETCONN_MORE != TCP_WRITE_FLAG_MORE
  229. #error "NETCONN_MORE != TCP_WRITE_FLAG_MORE"
  230. #endif
  231. #endif /* LWIP_NETCONN && LWIP_TCP */
  232. #if LWIP_NETCONN_FULLDUPLEX && !LWIP_NETCONN_SEM_PER_THREAD
  233. #error "For LWIP_NETCONN_FULLDUPLEX to work, LWIP_NETCONN_SEM_PER_THREAD is required"
  234. #endif
  235. /* Compile-time checks for deprecated options.
  236. */
  237. #ifdef MEMP_NUM_TCPIP_MSG
  238. #error "MEMP_NUM_TCPIP_MSG option is deprecated. Remove it from your lwipopts.h."
  239. #endif
  240. #ifdef TCP_REXMIT_DEBUG
  241. #error "TCP_REXMIT_DEBUG option is deprecated. Remove it from your lwipopts.h."
  242. #endif
  243. #ifdef RAW_STATS
  244. #error "RAW_STATS option is deprecated. Remove it from your lwipopts.h."
  245. #endif
  246. #ifdef ETHARP_QUEUE_FIRST
  247. #error "ETHARP_QUEUE_FIRST option is deprecated. Remove it from your lwipopts.h."
  248. #endif
  249. #ifdef ETHARP_ALWAYS_INSERT
  250. #error "ETHARP_ALWAYS_INSERT option is deprecated. Remove it from your lwipopts.h."
  251. #endif
  252. #if !NO_SYS && LWIP_TCPIP_CORE_LOCKING && LWIP_COMPAT_MUTEX && !defined(LWIP_COMPAT_MUTEX_ALLOWED)
  253. #error "LWIP_COMPAT_MUTEX cannot prevent priority inversion. It is recommended to implement priority-aware mutexes. (Define LWIP_COMPAT_MUTEX_ALLOWED to disable this error.)"
  254. #endif
  255. #ifndef LWIP_DISABLE_TCP_SANITY_CHECKS
  256. #define LWIP_DISABLE_TCP_SANITY_CHECKS 0
  257. #endif
  258. #ifndef LWIP_DISABLE_MEMP_SANITY_CHECKS
  259. #define LWIP_DISABLE_MEMP_SANITY_CHECKS 0
  260. #endif
  261. /* MEMP sanity checks */
  262. #if MEMP_MEM_MALLOC
  263. #if !LWIP_DISABLE_MEMP_SANITY_CHECKS
  264. #if LWIP_NETCONN || LWIP_SOCKET
  265. #if !MEMP_NUM_NETCONN && LWIP_SOCKET
  266. #error "lwip_sanity_check: WARNING: MEMP_NUM_NETCONN cannot be 0 when using sockets!"
  267. #endif
  268. #else /* MEMP_MEM_MALLOC */
  269. #if MEMP_NUM_NETCONN > (MEMP_NUM_TCP_PCB+MEMP_NUM_TCP_PCB_LISTEN+MEMP_NUM_UDP_PCB+MEMP_NUM_RAW_PCB)
  270. #error "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. If you know what you are doing, define LWIP_DISABLE_MEMP_SANITY_CHECKS to 1 to disable this error."
  271. #endif
  272. #endif /* LWIP_NETCONN || LWIP_SOCKET */
  273. #endif /* !LWIP_DISABLE_MEMP_SANITY_CHECKS */
  274. #if MEM_USE_POOLS
  275. #error "MEMP_MEM_MALLOC and MEM_USE_POOLS cannot be enabled at the same time"
  276. #endif
  277. #ifdef LWIP_HOOK_MEMP_AVAILABLE
  278. #error "LWIP_HOOK_MEMP_AVAILABLE doesn't make sense with MEMP_MEM_MALLOC"
  279. #endif
  280. #endif /* MEMP_MEM_MALLOC */
  281. /* TCP sanity checks */
  282. #if !LWIP_DISABLE_TCP_SANITY_CHECKS
  283. #if LWIP_TCP
  284. #if !MEMP_MEM_MALLOC && (MEMP_NUM_TCP_SEG < TCP_SND_QUEUELEN)
  285. #error "lwip_sanity_check: WARNING: MEMP_NUM_TCP_SEG should be at least as big as TCP_SND_QUEUELEN. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error."
  286. #endif
  287. #if TCP_SND_BUF < (2 * TCP_MSS)
  288. #error "lwip_sanity_check: WARNING: TCP_SND_BUF must be at least as much as (2 * TCP_MSS) for things to work smoothly. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error."
  289. #endif
  290. #if TCP_SND_QUEUELEN < (2 * (TCP_SND_BUF / TCP_MSS))
  291. #error "lwip_sanity_check: WARNING: TCP_SND_QUEUELEN must be at least as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error."
  292. #endif
  293. #if TCP_SNDLOWAT >= TCP_SND_BUF
  294. #error "lwip_sanity_check: WARNING: TCP_SNDLOWAT must be less than TCP_SND_BUF. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error."
  295. #endif
  296. #if TCP_MSS >= ((16 * 1024) - 1)
  297. #error "lwip_sanity_check: WARNING: TCP_MSS must be <= 16382 to prevent u16_t underflow in TCP_SNDLOWAT calculation!"
  298. #endif
  299. #if TCP_SNDLOWAT >= (0xFFFF - (4 * TCP_MSS))
  300. #error "lwip_sanity_check: WARNING: TCP_SNDLOWAT must at least be 4*MSS below u16_t overflow!"
  301. #endif
  302. #if TCP_SNDQUEUELOWAT >= TCP_SND_QUEUELEN
  303. #error "lwip_sanity_check: WARNING: TCP_SNDQUEUELOWAT must be less than TCP_SND_QUEUELEN. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error."
  304. #endif
  305. #if !MEMP_MEM_MALLOC && PBUF_POOL_SIZE && (PBUF_POOL_BUFSIZE <= (PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN))
  306. #error "lwip_sanity_check: WARNING: PBUF_POOL_BUFSIZE does not provide enough space for protocol headers. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error."
  307. #endif
  308. #if !MEMP_MEM_MALLOC && PBUF_POOL_SIZE && (TCP_WND > (PBUF_POOL_SIZE * (PBUF_POOL_BUFSIZE - (PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN))))
  309. #error "lwip_sanity_check: WARNING: TCP_WND is larger than space provided by PBUF_POOL_SIZE * (PBUF_POOL_BUFSIZE - protocol headers). If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error."
  310. #endif
  311. #if TCP_WND < TCP_MSS
  312. #error "lwip_sanity_check: WARNING: TCP_WND is smaller than MSS. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error."
  313. #endif
  314. #endif /* LWIP_TCP */
  315. #endif /* !LWIP_DISABLE_TCP_SANITY_CHECKS */
  316. /**
  317. * @ingroup lwip_nosys
  318. * Initialize all modules.
  319. * Use this in NO_SYS mode. Use tcpip_init() otherwise.
  320. */
  321. void
  322. lwip_init(void)
  323. {
  324. #ifndef LWIP_SKIP_CONST_CHECK
  325. int a = 0;
  326. LWIP_UNUSED_ARG(a);
  327. LWIP_ASSERT("LWIP_CONST_CAST not implemented correctly. Check your lwIP port.", LWIP_CONST_CAST(void *, &a) == &a);
  328. #endif
  329. #ifndef LWIP_SKIP_PACKING_CHECK
  330. LWIP_ASSERT("Struct packing not implemented correctly. Check your lwIP port.", sizeof(struct packed_struct_test) == PACKED_STRUCT_TEST_EXPECTED_SIZE);
  331. #endif
  332. /* Modules initialization */
  333. stats_init();
  334. #if !NO_SYS
  335. sys_init();
  336. #endif /* !NO_SYS */
  337. mem_init();
  338. memp_init();
  339. pbuf_init();
  340. netif_init();
  341. #if LWIP_IPV4
  342. ip_init();
  343. #if LWIP_ARP
  344. etharp_init();
  345. #endif /* LWIP_ARP */
  346. #endif /* LWIP_IPV4 */
  347. #if LWIP_RAW
  348. raw_init();
  349. #endif /* LWIP_RAW */
  350. #if LWIP_UDP
  351. udp_init();
  352. #endif /* LWIP_UDP */
  353. #if LWIP_TCP
  354. tcp_init();
  355. #endif /* LWIP_TCP */
  356. #if LWIP_IGMP
  357. igmp_init();
  358. #endif /* LWIP_IGMP */
  359. #if LWIP_DNS
  360. dns_init();
  361. #endif /* LWIP_DNS */
  362. #if PPP_SUPPORT
  363. ppp_init();
  364. #endif
  365. #if LWIP_TIMERS
  366. sys_timeouts_init();
  367. #endif /* LWIP_TIMERS */
  368. }