2014-06-26 22:36:24 +02:00
|
|
|
/****************************************************************************
|
2017-03-28 17:32:52 +02:00
|
|
|
* net/net_initialize.c
|
2014-06-26 22:36:24 +02:00
|
|
|
*
|
2017-03-28 17:32:52 +02:00
|
|
|
* Copyright (C) 2007-2009, 2011-2015, 2017 Gregory Nutt. All rights reserved.
|
2014-06-26 22:36:24 +02:00
|
|
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
|
|
* used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
#ifdef CONFIG_NET
|
|
|
|
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
#include <nuttx/net/iob.h>
|
|
|
|
#include <nuttx/net/net.h>
|
|
|
|
|
2014-06-29 01:25:18 +02:00
|
|
|
#include "socket/socket.h"
|
2014-06-29 02:07:02 +02:00
|
|
|
#include "devif/devif.h"
|
2014-06-27 17:56:45 +02:00
|
|
|
#include "netdev/netdev.h"
|
2014-07-06 19:05:28 +02:00
|
|
|
#include "arp/arp.h"
|
2017-03-28 17:32:52 +02:00
|
|
|
#include "sixlowpan/sixlowpan.h"
|
2015-01-20 19:31:56 +01:00
|
|
|
#include "neighbor/neighbor.h"
|
2014-06-26 22:36:24 +02:00
|
|
|
#include "tcp/tcp.h"
|
|
|
|
#include "udp/udp.h"
|
|
|
|
#include "pkt/pkt.h"
|
2015-01-24 22:19:50 +01:00
|
|
|
#include "local/local.h"
|
2014-06-26 22:36:24 +02:00
|
|
|
#include "igmp/igmp.h"
|
|
|
|
#include "route/route.h"
|
2014-07-05 00:38:51 +02:00
|
|
|
#include "utils/utils.h"
|
2014-06-26 22:36:24 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-08-16 18:24:06 +02:00
|
|
|
/****************************************************************************
|
2015-02-14 13:36:53 +01:00
|
|
|
* Name: net_setup
|
2014-08-16 18:24:06 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This is called from the OS initialization logic at power-up reset in
|
2015-02-14 13:36:53 +01: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-16 18:24:06 +02:00
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2014-06-26 22:36:24 +02:00
|
|
|
|
2015-02-14 13:36:53 +01:00
|
|
|
void net_setup(void)
|
2014-06-26 22:36:24 +02:00
|
|
|
{
|
|
|
|
/* Initialize the locking facility */
|
|
|
|
|
|
|
|
net_lockinitialize();
|
|
|
|
|
2014-07-06 19:05:28 +02:00
|
|
|
/* Clear the ARP table */
|
|
|
|
|
|
|
|
arp_reset();
|
|
|
|
|
2015-01-20 19:31:56 +01:00
|
|
|
#ifdef CONFIG_NET_IPv6
|
2015-02-14 13:36:53 +01:00
|
|
|
/* Initialize the Neighbor Table data structures */
|
2015-01-20 19:31:56 +01:00
|
|
|
|
2016-02-03 19:12:41 +01:00
|
|
|
neighbor_initialize();
|
2017-03-28 17:32:52 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_NET_6LOWPAN
|
|
|
|
/* Initialize 6loWPAN data structures */
|
|
|
|
|
|
|
|
sixlowpan_initialize();
|
2015-01-20 19:31:56 +01:00
|
|
|
#endif
|
2017-03-28 17:32:52 +02:00
|
|
|
#endif /* CONFIG_NET_IPv6 */
|
2014-06-26 22:36:24 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_NET_IOB
|
2015-01-20 19:31:56 +01:00
|
|
|
/* Initialize I/O buffering */
|
|
|
|
|
2014-06-26 22:36:24 +02:00
|
|
|
iob_initialize();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Initialize the device interface layer */
|
|
|
|
|
2014-06-29 02:07:02 +02:00
|
|
|
devif_initialize();
|
2014-06-26 22:36:24 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_NET_PKT
|
|
|
|
/* Initialize packet socket support */
|
|
|
|
|
|
|
|
pkt_initialize();
|
|
|
|
#endif
|
|
|
|
|
2015-01-28 18:48:23 +01:00
|
|
|
#ifdef CONFIG_NET_LOCAL
|
2015-01-24 22:19:50 +01:00
|
|
|
/* Initialize the local, "Unix domain" socket support */
|
|
|
|
|
|
|
|
local_initialize();
|
|
|
|
#endif
|
|
|
|
|
2014-06-26 22:36:24 +02:00
|
|
|
#ifdef CONFIG_NET_TCP
|
|
|
|
/* Initialize the listening port structures */
|
|
|
|
|
2014-07-06 20:34:27 +02:00
|
|
|
tcp_listen_initialize();
|
2014-06-26 22:36:24 +02: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 */
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_UDP
|
|
|
|
/* Initialize the UDP connection structures */
|
|
|
|
|
|
|
|
udp_initialize();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_IGMP
|
|
|
|
/* Initialize IGMP support */
|
|
|
|
|
|
|
|
igmp_initialize();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ROUTE
|
|
|
|
/* Initialize the routing table */
|
|
|
|
|
|
|
|
net_initroute();
|
|
|
|
#endif
|
2015-02-14 13:36:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: net_initialize
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This function is called from the OS initialization logic at power-up
|
|
|
|
* reset AFTER initialization of hardware facilities such as timers and
|
|
|
|
* interrupts. This logic completes the initialization started by
|
|
|
|
* net_setup().
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void net_initialize(void)
|
|
|
|
{
|
2014-06-26 22:36:24 +02:00
|
|
|
/* Initialize the periodic ARP timer */
|
|
|
|
|
2014-07-06 19:05:28 +02:00
|
|
|
arp_timer_initialize();
|
2014-06-26 22:36:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_NET */
|