net_initialize.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. /****************************************************************************
  2. * net/net_initialize.c
  3. *
  4. * Copyright (C) 2007-2009, 2011-2015, 2017-2018 Gregory Nutt. All rights
  5. * reserved.
  6. * Author: Gregory Nutt <gnutt@nuttx.org>
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in
  16. * the documentation and/or other materials provided with the
  17. * distribution.
  18. * 3. Neither the name NuttX nor the names of its contributors may be
  19. * used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  25. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  26. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  27. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  28. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  29. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  30. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  31. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  32. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  33. * POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ****************************************************************************/
  36. /****************************************************************************
  37. * Included Files
  38. ****************************************************************************/
  39. #include <nuttx/config.h>
  40. #ifdef CONFIG_NET
  41. #include <debug.h>
  42. #include <nuttx/net/net.h>
  43. #include "socket/socket.h"
  44. #include "devif/devif.h"
  45. #include "netdev/netdev.h"
  46. #include "ipforward/ipforward.h"
  47. #include "sixlowpan/sixlowpan.h"
  48. #include "icmp/icmp.h"
  49. #include "icmpv6/icmpv6.h"
  50. #include "mld/mld.h"
  51. #include "tcp/tcp.h"
  52. #include "udp/udp.h"
  53. #include "pkt/pkt.h"
  54. #include "bluetooth/bluetooth.h"
  55. #include "ieee802154/ieee802154.h"
  56. #include "local/local.h"
  57. #include "netlink/netlink.h"
  58. #include "igmp/igmp.h"
  59. #include "route/route.h"
  60. #include "usrsock/usrsock.h"
  61. #include "utils/utils.h"
  62. /****************************************************************************
  63. * Public Functions
  64. ****************************************************************************/
  65. /****************************************************************************
  66. * Name: net_initialize
  67. *
  68. * Description:
  69. * This is called from the OS initialization logic at power-up reset in
  70. * order to configure networking data structures. This is called prior
  71. * to platform-specific driver initialization so that the networking
  72. * subsystem is prepared to deal with network driver initialization
  73. * actions.
  74. *
  75. * Actions performed in this initialization phase assume that base OS
  76. * facilities such as semaphores are available but this logic cannot
  77. * depend upon OS resources such as interrupts or timers which are not
  78. * yet available.
  79. *
  80. * Input Parameters:
  81. * None
  82. *
  83. * Returned Value:
  84. * None
  85. *
  86. ****************************************************************************/
  87. void net_initialize(void)
  88. {
  89. /* Initialize the locking facility */
  90. net_lockinitialize();
  91. #ifdef CONFIG_NET_IPv6
  92. #ifdef CONFIG_NET_MLD
  93. /* Initialize ICMPv6 Multicast Listener Discovery (MLD) logic */
  94. mld_initialize();
  95. #endif
  96. #ifdef CONFIG_NET_6LOWPAN
  97. /* Initialize 6LoWPAN data structures */
  98. sixlowpan_initialize();
  99. #endif
  100. #endif /* CONFIG_NET_IPv6 */
  101. /* Initialize the device interface layer */
  102. devif_initialize();
  103. #ifdef HAVE_FWDALLOC
  104. /* Initialize IP forwarding support */
  105. ipfwd_initialize();
  106. #endif
  107. #ifdef CONFIG_NET_PKT
  108. /* Initialize packet socket support */
  109. pkt_initialize();
  110. #endif
  111. #ifdef CONFIG_NET_ICMP_SOCKET
  112. /* Initialize IPPPROTO_ICMP socket support */
  113. icmp_sock_initialize();
  114. #endif
  115. #ifdef CONFIG_NET_ICMPv6_SOCKET
  116. /* Initialize IPPPROTO_ICMP6 socket support */
  117. icmpv6_sock_initialize();
  118. #endif
  119. #ifdef CONFIG_NET_BLUETOOTH
  120. /* Initialize Bluetooth socket support */
  121. bluetooth_initialize();
  122. #endif
  123. #ifdef CONFIG_NET_IEEE802154
  124. /* Initialize IEEE 802.15.4 socket support */
  125. ieee802154_initialize();
  126. #endif
  127. #ifdef CONFIG_NET_LOCAL
  128. /* Initialize the local, "Unix domain" socket support */
  129. local_initialize();
  130. #endif
  131. #ifdef CONFIG_NET_NETLINK
  132. /* Initialize the Netlink IPC support */
  133. netlink_initialize();
  134. #endif
  135. #ifdef NET_TCP_HAVE_STACK
  136. /* Initialize the listening port structures */
  137. tcp_listen_initialize();
  138. /* Initialize the TCP/IP connection structures */
  139. tcp_initialize();
  140. /* Initialize the TCP/IP write buffering */
  141. #ifdef CONFIG_NET_TCP_WRITE_BUFFERS
  142. tcp_wrbuffer_initialize();
  143. #endif
  144. #endif /* CONFIG_NET_TCP */
  145. #ifdef NET_UDP_HAVE_STACK
  146. /* Initialize the UDP connection structures */
  147. udp_initialize();
  148. #ifdef CONFIG_NET_UDP_WRITE_BUFFERS
  149. udp_wrbuffer_initialize();
  150. #endif
  151. #endif
  152. #ifdef CONFIG_NET_IGMP
  153. /* Initialize IGMP support */
  154. igmp_initialize();
  155. #endif
  156. #ifdef CONFIG_NET_ROUTE
  157. /* Initialize the routing table */
  158. net_init_route();
  159. #endif
  160. #ifdef CONFIG_NET_USRSOCK
  161. /* Initialize the user-space socket API */
  162. usrsock_initialize();
  163. #endif
  164. }
  165. #endif /* CONFIG_NET */