2014-06-27 04:36:24 +08:00
|
|
|
/****************************************************************************
|
2017-03-28 23:32:52 +08:00
|
|
|
* net/net_initialize.c
|
2014-06-27 04:36:24 +08:00
|
|
|
*
|
2024-09-11 20:39:39 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
2021-02-19 19:45:37 +08:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2014-06-27 04:36:24 +08:00
|
|
|
*
|
2021-02-19 19:45:37 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2014-06-27 04:36:24 +08:00
|
|
|
*
|
2021-02-19 19:45:37 +08:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2014-06-27 04:36:24 +08:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
#ifdef CONFIG_NET
|
|
|
|
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
#include <nuttx/net/net.h>
|
|
|
|
|
2014-06-29 07:25:18 +08:00
|
|
|
#include "socket/socket.h"
|
2014-06-29 08:07:02 +08:00
|
|
|
#include "devif/devif.h"
|
2014-06-27 23:56:45 +08:00
|
|
|
#include "netdev/netdev.h"
|
2017-07-08 08:45:58 +08:00
|
|
|
#include "ipforward/ipforward.h"
|
2017-03-28 23:32:52 +08:00
|
|
|
#include "sixlowpan/sixlowpan.h"
|
2017-10-23 22:45:12 +08:00
|
|
|
#include "icmp/icmp.h"
|
2017-10-25 01:23:08 +08:00
|
|
|
#include "icmpv6/icmpv6.h"
|
2014-06-27 04:36:24 +08:00
|
|
|
#include "tcp/tcp.h"
|
|
|
|
#include "udp/udp.h"
|
|
|
|
#include "pkt/pkt.h"
|
2018-04-01 04:55:03 +08:00
|
|
|
#include "bluetooth/bluetooth.h"
|
2017-08-19 22:48:52 +08:00
|
|
|
#include "ieee802154/ieee802154.h"
|
2020-06-15 16:23:25 +08:00
|
|
|
#include "can/can.h"
|
2018-08-04 03:22:36 +08:00
|
|
|
#include "netlink/netlink.h"
|
2014-06-27 04:36:24 +08:00
|
|
|
#include "route/route.h"
|
2017-03-31 22:58:14 +08:00
|
|
|
#include "usrsock/usrsock.h"
|
2014-06-27 04:36:24 +08:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-08-17 00:24:06 +08:00
|
|
|
/****************************************************************************
|
2018-11-10 03:54:55 +08:00
|
|
|
* Name: net_initialize
|
2014-08-17 00:24:06 +08:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This is called from the OS initialization logic at power-up reset in
|
2015-02-14 20:36:53 +08:00
|
|
|
* order to configure networking data structures. This is called prior
|
|
|
|
* to platform-specific driver initialization so that the networking
|
|
|
|
* subsystem is prepared to deal with network driver initialization
|
|
|
|
* actions.
|
|
|
|
*
|
|
|
|
* Actions performed in this initialization phase assume that base OS
|
|
|
|
* facilities such as semaphores are available but this logic cannot
|
|
|
|
* depend upon OS resources such as interrupts or timers which are not
|
|
|
|
* yet available.
|
2014-08-17 00:24:06 +08:00
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2014-06-27 04:36:24 +08:00
|
|
|
|
2018-11-10 03:54:55 +08:00
|
|
|
void net_initialize(void)
|
2014-06-27 04:36:24 +08:00
|
|
|
{
|
2022-03-12 14:16:00 +08:00
|
|
|
/* Initialize the device interface layer */
|
2017-03-28 23:32:52 +08:00
|
|
|
|
2022-03-12 14:16:00 +08:00
|
|
|
devif_initialize();
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_BLUETOOTH
|
|
|
|
/* Initialize Bluetooth socket support */
|
|
|
|
|
|
|
|
bluetooth_initialize();
|
2015-01-21 02:31:56 +08:00
|
|
|
#endif
|
2014-06-27 04:36:24 +08:00
|
|
|
|
2022-03-12 14:16:00 +08:00
|
|
|
#ifdef CONFIG_NET_CAN
|
|
|
|
/* Initialize SocketCAN support */
|
2014-06-27 04:36:24 +08:00
|
|
|
|
2022-03-12 14:16:00 +08:00
|
|
|
can_initialize();
|
|
|
|
#endif
|
2014-06-27 04:36:24 +08:00
|
|
|
|
2022-03-12 14:16:00 +08:00
|
|
|
#ifdef CONFIG_NET_IEEE802154
|
|
|
|
/* Initialize IEEE 802.15.4 socket support */
|
2017-07-08 08:33:06 +08:00
|
|
|
|
2022-03-12 14:16:00 +08:00
|
|
|
ieee802154_initialize();
|
2017-07-08 08:33:06 +08:00
|
|
|
#endif
|
|
|
|
|
2022-03-12 14:16:00 +08:00
|
|
|
#ifdef CONFIG_NET_NETLINK
|
|
|
|
/* Initialize the Netlink IPC support */
|
2014-06-27 04:36:24 +08:00
|
|
|
|
2022-03-12 14:16:00 +08:00
|
|
|
netlink_initialize();
|
2014-06-27 04:36:24 +08:00
|
|
|
#endif
|
|
|
|
|
2022-03-12 14:16:00 +08:00
|
|
|
#ifdef CONFIG_NET_PKT
|
|
|
|
/* Initialize packet socket support */
|
2017-10-23 22:45:12 +08:00
|
|
|
|
2022-03-12 14:16:00 +08:00
|
|
|
pkt_initialize();
|
2017-10-23 22:45:12 +08:00
|
|
|
#endif
|
|
|
|
|
2022-03-12 14:16:00 +08:00
|
|
|
#ifdef CONFIG_NET_ROUTE
|
|
|
|
/* Initialize the routing table */
|
2017-10-25 01:23:08 +08:00
|
|
|
|
2022-03-12 14:16:00 +08:00
|
|
|
net_init_route();
|
2017-10-25 01:23:08 +08:00
|
|
|
#endif
|
|
|
|
|
2022-03-12 14:16:00 +08:00
|
|
|
#ifdef CONFIG_NET_IPv6
|
|
|
|
#ifdef CONFIG_NET_6LOWPAN
|
|
|
|
/* Initialize 6LoWPAN data structures */
|
2018-04-01 04:55:03 +08:00
|
|
|
|
2022-03-12 14:16:00 +08:00
|
|
|
sixlowpan_initialize();
|
2018-04-01 04:55:03 +08:00
|
|
|
#endif
|
2022-03-12 14:16:00 +08:00
|
|
|
#endif /* CONFIG_NET_IPv6 */
|
2018-04-01 04:55:03 +08:00
|
|
|
|
2022-03-12 14:16:00 +08:00
|
|
|
#ifdef HAVE_FWDALLOC
|
|
|
|
/* Initialize IP forwarding support */
|
2017-08-19 22:48:52 +08:00
|
|
|
|
2022-03-12 14:16:00 +08:00
|
|
|
ipfwd_initialize();
|
2017-08-19 22:48:52 +08:00
|
|
|
#endif
|
|
|
|
|
2022-03-12 14:16:00 +08:00
|
|
|
#ifdef CONFIG_NET_ICMP_SOCKET
|
|
|
|
/* Initialize IPPPROTO_ICMP socket support */
|
2020-06-15 16:23:25 +08:00
|
|
|
|
2022-03-12 14:16:00 +08:00
|
|
|
icmp_sock_initialize();
|
2020-06-15 16:23:25 +08:00
|
|
|
#endif
|
|
|
|
|
2022-03-12 14:16:00 +08:00
|
|
|
#ifdef CONFIG_NET_ICMPv6_SOCKET
|
|
|
|
/* Initialize IPPPROTO_ICMP6 socket support */
|
2018-08-04 03:22:36 +08:00
|
|
|
|
2022-03-12 14:16:00 +08:00
|
|
|
icmpv6_sock_initialize();
|
2018-08-04 03:22:36 +08:00
|
|
|
#endif
|
|
|
|
|
2017-03-31 22:58:14 +08:00
|
|
|
#ifdef NET_TCP_HAVE_STACK
|
2014-06-27 04:36:24 +08:00
|
|
|
/* Initialize the TCP/IP connection structures */
|
|
|
|
|
|
|
|
tcp_initialize();
|
|
|
|
|
|
|
|
/* Initialize the TCP/IP write buffering */
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
|
|
|
|
tcp_wrbuffer_initialize();
|
|
|
|
#endif
|
|
|
|
#endif /* CONFIG_NET_TCP */
|
|
|
|
|
2017-03-31 22:58:14 +08:00
|
|
|
#ifdef NET_UDP_HAVE_STACK
|
2014-06-27 04:36:24 +08:00
|
|
|
/* Initialize the UDP connection structures */
|
|
|
|
|
|
|
|
udp_initialize();
|
2018-01-23 08:32:02 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_NET_UDP_WRITE_BUFFERS
|
|
|
|
udp_wrbuffer_initialize();
|
|
|
|
#endif
|
2014-06-27 04:36:24 +08:00
|
|
|
#endif
|
|
|
|
|
2017-03-31 22:58:14 +08:00
|
|
|
#ifdef CONFIG_NET_USRSOCK
|
|
|
|
/* Initialize the user-space socket API */
|
|
|
|
|
|
|
|
usrsock_initialize();
|
|
|
|
#endif
|
2015-02-14 20:36:53 +08:00
|
|
|
}
|
|
|
|
|
2014-06-27 04:36:24 +08:00
|
|
|
#endif /* CONFIG_NET */
|