init.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  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. {
  66. PACK_STRUCT_FLD_8(u8_t dummy1);
  67. PACK_STRUCT_FIELD(u32_t dummy2);
  68. } PACK_STRUCT_STRUCT;
  69. PACK_STRUCT_END
  70. #ifdef PACK_STRUCT_USE_INCLUDES
  71. # include "arch/epstruct.h"
  72. #endif
  73. #define PACKED_STRUCT_TEST_EXPECTED_SIZE 5
  74. #endif
  75. /* Compile-time sanity checks for configuration errors.
  76. * These can be done independently of LWIP_DEBUG, without penalty.
  77. */
  78. #ifndef BYTE_ORDER
  79. #error "BYTE_ORDER is not defined, you have to define it in your cc.h"
  80. #endif
  81. #if (!IP_SOF_BROADCAST && IP_SOF_BROADCAST_RECV)
  82. #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"
  83. #endif
  84. #if (!LWIP_UDP && LWIP_UDPLITE)
  85. #error "If you want to use UDP Lite, you have to define LWIP_UDP=1 in your lwipopts.h"
  86. #endif
  87. #if (!LWIP_UDP && LWIP_DHCP)
  88. #error "If you want to use DHCP, you have to define LWIP_UDP=1 in your lwipopts.h"
  89. #endif
  90. #if (!LWIP_UDP && LWIP_MULTICAST_TX_OPTIONS)
  91. #error "If you want to use IGMP/LWIP_MULTICAST_TX_OPTIONS, you have to define LWIP_UDP=1 in your lwipopts.h"
  92. #endif
  93. #if (!LWIP_UDP && LWIP_DNS)
  94. #error "If you want to use DNS, you have to define LWIP_UDP=1 in your lwipopts.h"
  95. #endif
  96. #if !MEMP_MEM_MALLOC /* MEMP_NUM_* checks are disabled when not using the pool allocator */
  97. #if (LWIP_ARP && ARP_QUEUEING && (MEMP_NUM_ARP_QUEUE<=0))
  98. #error "If you want to use ARP Queueing, you have to define MEMP_NUM_ARP_QUEUE>=1 in your lwipopts.h"
  99. #endif
  100. #if (LWIP_RAW && (MEMP_NUM_RAW_PCB<=0))
  101. #error "If you want to use RAW, you have to define MEMP_NUM_RAW_PCB>=1 in your lwipopts.h"
  102. #endif
  103. #if (LWIP_UDP && (MEMP_NUM_UDP_PCB<=0))
  104. #error "If you want to use UDP, you have to define MEMP_NUM_UDP_PCB>=1 in your lwipopts.h"
  105. #endif
  106. #if (LWIP_TCP && (MEMP_NUM_TCP_PCB<=0))
  107. #error "If you want to use TCP, you have to define MEMP_NUM_TCP_PCB>=1 in your lwipopts.h"
  108. #endif
  109. #if (LWIP_IGMP && (MEMP_NUM_IGMP_GROUP<=1))
  110. #error "If you want to use IGMP, you have to define MEMP_NUM_IGMP_GROUP>1 in your lwipopts.h"
  111. #endif
  112. #if (LWIP_IGMP && !LWIP_MULTICAST_TX_OPTIONS)
  113. #error "If you want to use IGMP, you have to define LWIP_MULTICAST_TX_OPTIONS==1 in your lwipopts.h"
  114. #endif
  115. #if (LWIP_IGMP && !LWIP_IPV4)
  116. #error "IGMP needs LWIP_IPV4 enabled in your lwipopts.h"
  117. #endif
  118. #if (LWIP_MULTICAST_TX_OPTIONS && !LWIP_IPV4)
  119. #error "LWIP_MULTICAST_TX_OPTIONS needs LWIP_IPV4 enabled in your lwipopts.h"
  120. #endif
  121. #if ((LWIP_NETCONN || LWIP_SOCKET) && (MEMP_NUM_TCPIP_MSG_API<=0))
  122. #error "If you want to use Sequential API, you have to define MEMP_NUM_TCPIP_MSG_API>=1 in your lwipopts.h"
  123. #endif
  124. /* There must be sufficient timeouts, taking into account requirements of the subsystems. */
  125. #if LWIP_TIMERS && (MEMP_NUM_SYS_TIMEOUT < (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + PPP_SUPPORT + (LWIP_IPV6 ? (1 + LWIP_IPV6_REASS + LWIP_IPV6_MLD) : 0)))
  126. #error "MEMP_NUM_SYS_TIMEOUT is too low to accomodate all required timeouts"
  127. #endif
  128. #if (IP_REASSEMBLY && (MEMP_NUM_REASSDATA > IP_REASS_MAX_PBUFS))
  129. #error "MEMP_NUM_REASSDATA > IP_REASS_MAX_PBUFS doesn't make sense since each struct ip_reassdata must hold 2 pbufs at least!"
  130. #endif
  131. #endif /* !MEMP_MEM_MALLOC */
  132. #if LWIP_WND_SCALE
  133. #if (LWIP_TCP && (TCP_WND > 0xffffffff))
  134. #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"
  135. #endif
  136. #if (LWIP_TCP && (TCP_RCV_SCALE > 14))
  137. #error "The maximum valid window scale value is 14!"
  138. #endif
  139. #if (LWIP_TCP && (TCP_WND > (0xFFFFU << TCP_RCV_SCALE)))
  140. #error "TCP_WND is bigger than the configured LWIP_WND_SCALE allows!"
  141. #endif
  142. #if (LWIP_TCP && ((TCP_WND >> TCP_RCV_SCALE) == 0))
  143. #error "TCP_WND is too small for the configured LWIP_WND_SCALE (results in zero window)!"
  144. #endif
  145. #else /* LWIP_WND_SCALE */
  146. #if (LWIP_TCP && (TCP_WND > 0xffff))
  147. #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)"
  148. #endif
  149. #endif /* LWIP_WND_SCALE */
  150. #if (LWIP_TCP && (TCP_SND_QUEUELEN > 0xffff))
  151. #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"
  152. #endif
  153. #if (LWIP_TCP && (TCP_SND_QUEUELEN < 2))
  154. #error "TCP_SND_QUEUELEN must be at least 2 for no-copy TCP writes to work"
  155. #endif
  156. #if (LWIP_TCP && ((TCP_MAXRTX > 12) || (TCP_SYNMAXRTX > 12)))
  157. #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"
  158. #endif
  159. #if (LWIP_TCP && TCP_LISTEN_BACKLOG && ((TCP_DEFAULT_LISTEN_BACKLOG < 0) || (TCP_DEFAULT_LISTEN_BACKLOG > 0xff)))
  160. #error "If you want to use TCP backlog, TCP_DEFAULT_LISTEN_BACKLOG must fit into an u8_t"
  161. #endif
  162. #if (LWIP_NETIF_API && (NO_SYS==1))
  163. #error "If you want to use NETIF API, you have to define NO_SYS=0 in your lwipopts.h"
  164. #endif
  165. #if ((LWIP_SOCKET || LWIP_NETCONN) && (NO_SYS==1))
  166. #error "If you want to use Sequential API, you have to define NO_SYS=0 in your lwipopts.h"
  167. #endif
  168. #if (LWIP_PPP_API && (NO_SYS==1))
  169. #error "If you want to use PPP API, you have to define NO_SYS=0 in your lwipopts.h"
  170. #endif
  171. #if (LWIP_PPP_API && (PPP_SUPPORT==0))
  172. #error "If you want to use PPP API, you have to enable PPP_SUPPORT in your lwipopts.h"
  173. #endif
  174. #if (((!LWIP_DHCP) || (!LWIP_AUTOIP)) && LWIP_DHCP_AUTOIP_COOP)
  175. #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"
  176. #endif
  177. #if (((!LWIP_DHCP) || (!LWIP_ARP)) && DHCP_DOES_ARP_CHECK)
  178. #error "If you want to use DHCP ARP checking, you have to define LWIP_DHCP=1 and LWIP_ARP=1 in your lwipopts.h"
  179. #endif
  180. #if (!LWIP_ARP && LWIP_AUTOIP)
  181. #error "If you want to use AUTOIP, you have to define LWIP_ARP=1 in your lwipopts.h"
  182. #endif
  183. #if (LWIP_TCP && ((LWIP_EVENT_API && LWIP_CALLBACK_API) || (!LWIP_EVENT_API && !LWIP_CALLBACK_API)))
  184. #error "One and exactly one of LWIP_EVENT_API and LWIP_CALLBACK_API has to be enabled in your lwipopts.h"
  185. #endif
  186. #if (MEM_LIBC_MALLOC && MEM_USE_POOLS)
  187. #error "MEM_LIBC_MALLOC and MEM_USE_POOLS may not both be simultaneously enabled in your lwipopts.h"
  188. #endif
  189. #if (MEM_USE_POOLS && !MEMP_USE_CUSTOM_POOLS)
  190. #error "MEM_USE_POOLS requires custom pools (MEMP_USE_CUSTOM_POOLS) to be enabled in your lwipopts.h"
  191. #endif
  192. #if (PBUF_POOL_BUFSIZE <= MEM_ALIGNMENT)
  193. #error "PBUF_POOL_BUFSIZE must be greater than MEM_ALIGNMENT or the offset may take the full first pbuf"
  194. #endif
  195. #if (DNS_LOCAL_HOSTLIST && !DNS_LOCAL_HOSTLIST_IS_DYNAMIC && !(defined(DNS_LOCAL_HOSTLIST_INIT)))
  196. #error "you have to define define DNS_LOCAL_HOSTLIST_INIT {{'host1', 0x123}, {'host2', 0x234}} to initialize DNS_LOCAL_HOSTLIST"
  197. #endif
  198. #if PPP_SUPPORT && !PPPOS_SUPPORT && !PPPOE_SUPPORT && !PPPOL2TP_SUPPORT
  199. #error "PPP_SUPPORT needs at least one of PPPOS_SUPPORT, PPPOE_SUPPORT or PPPOL2TP_SUPPORT turned on"
  200. #endif
  201. #if PPP_SUPPORT && !PPP_IPV4_SUPPORT && !PPP_IPV6_SUPPORT
  202. #error "PPP_SUPPORT needs PPP_IPV4_SUPPORT and/or PPP_IPV6_SUPPORT turned on"
  203. #endif
  204. #if PPP_SUPPORT && PPP_IPV4_SUPPORT && !LWIP_IPV4
  205. #error "PPP_IPV4_SUPPORT needs LWIP_IPV4 turned on"
  206. #endif
  207. #if PPP_SUPPORT && PPP_IPV6_SUPPORT && !LWIP_IPV6
  208. #error "PPP_IPV6_SUPPORT needs LWIP_IPV6 turned on"
  209. #endif
  210. #if !LWIP_ETHERNET && (LWIP_ARP || PPPOE_SUPPORT)
  211. #error "LWIP_ETHERNET needs to be turned on for LWIP_ARP or PPPOE_SUPPORT"
  212. #endif
  213. #if LWIP_TCPIP_CORE_LOCKING_INPUT && !LWIP_TCPIP_CORE_LOCKING
  214. #error "When using LWIP_TCPIP_CORE_LOCKING_INPUT, LWIP_TCPIP_CORE_LOCKING must be enabled, too"
  215. #endif
  216. #if LWIP_TCP && LWIP_NETIF_TX_SINGLE_PBUF && !TCP_OVERSIZE
  217. #error "LWIP_NETIF_TX_SINGLE_PBUF needs TCP_OVERSIZE enabled to create single-pbuf TCP packets"
  218. #endif
  219. #if LWIP_NETCONN && LWIP_TCP
  220. #if NETCONN_COPY != TCP_WRITE_FLAG_COPY
  221. #error "NETCONN_COPY != TCP_WRITE_FLAG_COPY"
  222. #endif
  223. #if NETCONN_MORE != TCP_WRITE_FLAG_MORE
  224. #error "NETCONN_MORE != TCP_WRITE_FLAG_MORE"
  225. #endif
  226. #endif /* LWIP_NETCONN && LWIP_TCP */
  227. #if LWIP_SOCKET
  228. /* Check that the SO_* socket options and SOF_* lwIP-internal flags match */
  229. #if SO_REUSEADDR != SOF_REUSEADDR
  230. #error "WARNING: SO_REUSEADDR != SOF_REUSEADDR"
  231. #endif
  232. #if SO_KEEPALIVE != SOF_KEEPALIVE
  233. #error "WARNING: SO_KEEPALIVE != SOF_KEEPALIVE"
  234. #endif
  235. #if SO_BROADCAST != SOF_BROADCAST
  236. #error "WARNING: SO_BROADCAST != SOF_BROADCAST"
  237. #endif
  238. #endif /* LWIP_SOCKET */
  239. /* Compile-time checks for deprecated options.
  240. */
  241. #ifdef MEMP_NUM_TCPIP_MSG
  242. #error "MEMP_NUM_TCPIP_MSG option is deprecated. Remove it from your lwipopts.h."
  243. #endif
  244. #ifdef TCP_REXMIT_DEBUG
  245. #error "TCP_REXMIT_DEBUG option is deprecated. Remove it from your lwipopts.h."
  246. #endif
  247. #ifdef RAW_STATS
  248. #error "RAW_STATS option is deprecated. Remove it from your lwipopts.h."
  249. #endif
  250. #ifdef ETHARP_QUEUE_FIRST
  251. #error "ETHARP_QUEUE_FIRST option is deprecated. Remove it from your lwipopts.h."
  252. #endif
  253. #ifdef ETHARP_ALWAYS_INSERT
  254. #error "ETHARP_ALWAYS_INSERT option is deprecated. Remove it from your lwipopts.h."
  255. #endif
  256. #if !NO_SYS && LWIP_TCPIP_CORE_LOCKING && LWIP_COMPAT_MUTEX && !defined(LWIP_COMPAT_MUTEX_ALLOWED)
  257. #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.)"
  258. #endif
  259. #ifndef LWIP_DISABLE_TCP_SANITY_CHECKS
  260. #define LWIP_DISABLE_TCP_SANITY_CHECKS 1
  261. #endif
  262. #ifndef LWIP_DISABLE_MEMP_SANITY_CHECKS
  263. #define LWIP_DISABLE_MEMP_SANITY_CHECKS 0
  264. #endif
  265. /* MEMP sanity checks */
  266. #if MEMP_MEM_MALLOC
  267. #if !LWIP_DISABLE_MEMP_SANITY_CHECKS
  268. #if LWIP_NETCONN || LWIP_SOCKET
  269. #if !MEMP_NUM_NETCONN && LWIP_SOCKET
  270. #error "lwip_sanity_check: WARNING: MEMP_NUM_NETCONN cannot be 0 when using sockets!"
  271. #endif
  272. #else /* MEMP_MEM_MALLOC */
  273. #if MEMP_NUM_NETCONN > (MEMP_NUM_TCP_PCB+MEMP_NUM_TCP_PCB_LISTEN+MEMP_NUM_UDP_PCB+MEMP_NUM_RAW_PCB)
  274. #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."
  275. #endif
  276. #endif /* LWIP_NETCONN || LWIP_SOCKET */
  277. #endif /* !LWIP_DISABLE_MEMP_SANITY_CHECKS */
  278. #if MEM_USE_POOLS
  279. #error "MEMP_MEM_MALLOC and MEM_USE_POOLS cannot be enabled at the same time"
  280. #endif
  281. #ifdef LWIP_HOOK_MEMP_AVAILABLE
  282. #error "LWIP_HOOK_MEMP_AVAILABLE doesn't make sense with MEMP_MEM_MALLOC"
  283. #endif
  284. #endif /* MEMP_MEM_MALLOC */
  285. /* TCP sanity checks */
  286. #if !LWIP_DISABLE_TCP_SANITY_CHECKS
  287. #if LWIP_TCP
  288. #if !MEMP_MEM_MALLOC && (MEMP_NUM_TCP_SEG < TCP_SND_QUEUELEN)
  289. #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."
  290. #endif
  291. #if TCP_SND_BUF < (2 * TCP_MSS)
  292. #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."
  293. #endif
  294. #if TCP_SND_QUEUELEN < (2 * (TCP_SND_BUF / TCP_MSS))
  295. #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."
  296. #endif
  297. #if TCP_SNDLOWAT >= TCP_SND_BUF
  298. #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."
  299. #endif
  300. #if TCP_SNDLOWAT >= (0xFFFF - (4 * TCP_MSS))
  301. #error "lwip_sanity_check: WARNING: TCP_SNDLOWAT must at least be 4*MSS below u16_t overflow!"
  302. #endif
  303. #if TCP_SNDQUEUELOWAT >= TCP_SND_QUEUELEN
  304. #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."
  305. #endif
  306. #if !MEMP_MEM_MALLOC && PBUF_POOL_SIZE && (PBUF_POOL_BUFSIZE <= (PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN))
  307. #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."
  308. #endif
  309. #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))))
  310. #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."
  311. #endif
  312. #if TCP_WND < TCP_MSS
  313. #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."
  314. #endif
  315. #endif /* LWIP_TCP */
  316. #endif /* !LWIP_DISABLE_TCP_SANITY_CHECKS */
  317. /**
  318. * @ingroup lwip_nosys
  319. * Initialize all modules.
  320. * Use this in NO_SYS mode. Use tcpip_init() otherwise.
  321. */
  322. void
  323. lwip_init(void)
  324. {
  325. #ifndef LWIP_SKIP_CONST_CHECK
  326. int a;
  327. LWIP_UNUSED_ARG(a);
  328. LWIP_ASSERT("LWIP_CONST_CAST not implemented correctly. Check your lwIP port.", LWIP_CONST_CAST(void*, &a) == &a);
  329. #endif
  330. #ifndef LWIP_SKIP_PACKING_CHECK
  331. LWIP_ASSERT("Struct packing not implemented correctly. Check your lwIP port.", sizeof(struct packed_struct_test) == PACKED_STRUCT_TEST_EXPECTED_SIZE);
  332. #endif
  333. /* Modules initialization */
  334. stats_init();
  335. #if !NO_SYS
  336. sys_init();
  337. #endif /* !NO_SYS */
  338. mem_init();
  339. memp_init();
  340. pbuf_init();
  341. netif_init();
  342. #if LWIP_IPV4
  343. ip_init();
  344. #if LWIP_ARP
  345. etharp_init();
  346. #endif /* LWIP_ARP */
  347. #endif /* LWIP_IPV4 */
  348. #if LWIP_RAW
  349. raw_init();
  350. #endif /* LWIP_RAW */
  351. #if LWIP_UDP
  352. udp_init();
  353. #endif /* LWIP_UDP */
  354. #if LWIP_TCP
  355. tcp_init();
  356. #endif /* LWIP_TCP */
  357. #if LWIP_IGMP
  358. igmp_init();
  359. #endif /* LWIP_IGMP */
  360. #if LWIP_DNS
  361. dns_init();
  362. #endif /* LWIP_DNS */
  363. #if PPP_SUPPORT
  364. ppp_init();
  365. #endif
  366. #if LWIP_TIMERS
  367. sys_timeouts_init();
  368. #endif /* LWIP_TIMERS */
  369. }