This commit removes the private network initialization logic from NSH and puts in a common location at apps/netutils/netinit. Now that netork initialization logic can be used by applications that do not include NSH.
Squashed commit of the following: apps/nshlib: Remove NSH initialization. Now uses the common apps/netutils/netinit logic (which was cloned from nshlib to begin with). apps/netutils/netinit: Clone network initialization logic from NSH to this directory so that it can be available for general use.
This commit is contained in:
parent
6a970ec4e9
commit
94a0d92b54
121
include/netutils/netinit.h
Normal file
121
include/netutils/netinit.h
Normal file
@ -0,0 +1,121 @@
|
||||
/****************************************************************************
|
||||
* apps/include/netutils/netinit.h
|
||||
*
|
||||
* Copyright (C) 2007-2018 Gregory Nutt. All rights reserved.
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_NETUTILS_NETINIT_H
|
||||
#define __APPS_INCLUDE_NETUTILS_NETINIT_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#ifdef CONFIG_NETUTILS_NETINIT
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
/* Networking support. Make sure that all non-boolean configuration
|
||||
* settings have some value.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NETINIT_IPADDR
|
||||
# define CONFIG_NETINIT_IPADDR 0x0a000002
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NETINIT_DRIPADDR
|
||||
# define CONFIG_NETINIT_DRIPADDR 0x0a000001
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NETINIT_NETMASK
|
||||
# define CONFIG_NETINIT_NETMASK 0xffffff00
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NETINIT_DNSIPADDR
|
||||
# define CONFIG_NETINIT_DNSIPADDR CONFIG_NETINIT_DRIPADDR
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NETINIT_MACADDR
|
||||
# define CONFIG_NETINIT_MACADDR 0x00e0deadbeef
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_NETINIT_THREAD) || !defined(CONFIG_ARCH_PHY_INTERRUPT) || \
|
||||
!defined(CONFIG_NETDEV_PHY_IOCTL) || !defined(CONFIG_NET_UDP) || \
|
||||
defined(CONFIG_DISABLE_SIGNALS)
|
||||
# undef CONFIG_NETINIT_MONITOR
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NETINIT_RETRYMSEC
|
||||
# define CONFIG_NETINIT_RETRYMSEC 2000
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NETINIT_SIGNO
|
||||
# define CONFIG_NETINIT_SIGNO 18
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NETINIT_THREAD_STACKSIZE
|
||||
# define CONFIG_NETINIT_THREAD_STACKSIZE 1568
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NETINIT_THREAD_PRIORITY
|
||||
# define CONFIG_NETINIT_THREAD_PRIORITY 100
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: netinit_bringup
|
||||
*
|
||||
* Description:
|
||||
* Initialize the network per the selected NuttX configuration
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int netinit_bringup(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: netinit_associate
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_WIRELESS_WAPI
|
||||
int netinit_associate(FAR const char *ifname);
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_NETUTILS_NETINIT */
|
||||
#endif /* __APPS_INCLUDE_NETUTILS_NETINIT_H */
|
6
netutils/netinit/.gitignore
vendored
Normal file
6
netutils/netinit/.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
/.built
|
||||
/.depend
|
||||
/Make.dep
|
||||
/*.src
|
||||
/*.obj
|
||||
/*.lst
|
540
netutils/netinit/Kconfig
Normal file
540
netutils/netinit/Kconfig
Normal file
@ -0,0 +1,540 @@
|
||||
#
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
menuconfig NETUTILS_NETINIT
|
||||
bool "Network initialization"
|
||||
default n
|
||||
depends on NET
|
||||
---help---
|
||||
This option enables/disables all support for common network initialization.
|
||||
|
||||
if NETUTILS_NETINIT
|
||||
|
||||
config NETINIT_NETLOCAL
|
||||
bool "Local network initialization"
|
||||
default n
|
||||
---help---
|
||||
If this option is selected, then this logic will only initialize the local
|
||||
attributes of the network: The MAC address if needed and any IP
|
||||
addresses as needed. More importantly, it will not do the following:
|
||||
|
||||
- It will not bring the network up. That can be done later with the
|
||||
an ifup() call.
|
||||
- It will not associate any wireless devices to an access point.
|
||||
- It will not attempt to obtain an IP address if DHCPC is selected.
|
||||
This may be done later from the apps/system/dhcpc 'renew' command.
|
||||
- It will not start the NTPC daemon. This may be done later from
|
||||
the with the apps/system/ntpc 'ntpcstart' command.
|
||||
|
||||
This option permits you to divide the network configuration into two
|
||||
parts: The local configuration of the network device and the dynamic
|
||||
configuration of the device in the network. This may be important in
|
||||
an environment when, for example, you need to manually scan for
|
||||
available access points and associate the wireless driver with an
|
||||
access point.
|
||||
|
||||
config NETINIT_THREAD
|
||||
bool "Network initialization thread"
|
||||
default n
|
||||
depends on !DISABLE_PTHREAD && !NETINIT_NETLOCAL
|
||||
---help---
|
||||
NuttX is brought up through a series of sequential initialization
|
||||
steps. This includes networking. If the network is available on
|
||||
reset, then there is really no issue. Negotiating the link will
|
||||
take only a second or so and the delay to application startup is
|
||||
normally acceptable.
|
||||
|
||||
But if there is no network connected, then the start-up delay can
|
||||
be very long depending upon things like the particular PHY, driver
|
||||
timeout delay times and number of retries. A failed negotiation
|
||||
can potentially take a very long time, perhaps as much as a
|
||||
minute... Long enough that you might think that the board would
|
||||
never come up!
|
||||
|
||||
One solution is enabled by this option. If NETINIT_THREAD
|
||||
is selected, the network bring-up will occur in parallel with
|
||||
the application on a separate thread. In this case, the appliation
|
||||
will start immediately with the network becoming available some time
|
||||
later (if if all). This thread will terminate once it successfully
|
||||
initializes the network
|
||||
|
||||
NOTES: If no network is connected, the network bring-up will fail
|
||||
and the network initialization thread will simply exit. There are
|
||||
no retries and no mechanism to know if the network initialization
|
||||
was successful. Furthermore, there is currently no support for
|
||||
detecting loss of network connection. Lots of things to do!
|
||||
|
||||
if NETINIT_THREAD
|
||||
|
||||
config NETINIT_MONITOR
|
||||
bool "Monitor link state"
|
||||
default n
|
||||
depends on ARCH_PHY_INTERRUPT && NETDEV_PHY_IOCTL && NET_UDP && !DISABLE_SIGNALS
|
||||
---help---
|
||||
By default the net initialization thread will bring-up the network
|
||||
then exit, freeing all of the resources that it required. This is a
|
||||
good behavior for systems with limited memory.
|
||||
|
||||
If this option is selected, however, then the network initialization
|
||||
thread will persist forever; it will monitor the network status. In
|
||||
the event that the network goes down (for example, if a cable is
|
||||
removed), then the thread will monitor the link status and
|
||||
attempt to bring the network back up. In this case the resources
|
||||
required for network initialization are never released.
|
||||
|
||||
if NETINIT_MONITOR
|
||||
|
||||
config NETINIT_SIGNO
|
||||
int "Notification signal number"
|
||||
default 18
|
||||
---help---
|
||||
The network monitor logic will receive signals when there is any
|
||||
change in the link status. This setting may be used to customize
|
||||
that signal number in order to avoid conflicts.
|
||||
|
||||
config NETINIT_RETRYMSEC
|
||||
int "Network bring-up retry period (msec)"
|
||||
default 2000
|
||||
---help---
|
||||
When the network is down, the initialization thread will periodically
|
||||
try to bring the network up. This can be a time consuming operation
|
||||
so is done only periodically with that period specified by this
|
||||
selection in milliseconds.
|
||||
|
||||
endif # NETINIT_MONITOR
|
||||
|
||||
config NETINIT_THREAD_STACKSIZE
|
||||
int "Network initialization thread stack size"
|
||||
default 1568
|
||||
|
||||
config NETINIT_THREAD_PRIORITY
|
||||
int "Network initialization thread priority"
|
||||
default 80
|
||||
---help---
|
||||
This should be set to a priority lower than most tasks. The network
|
||||
PHY polling is CPU intensive and can interfere with the usability of
|
||||
of threads competing for CPU bandwidth.
|
||||
|
||||
endif # NETINIT_THREAD
|
||||
|
||||
config NETINIT_DEBUG
|
||||
bool "Network init debug"
|
||||
default n
|
||||
depends on DEBUG_FEATURES
|
||||
---help---
|
||||
Normally debug output is controlled by DEBUG_NET. However, that
|
||||
will generate a LOT of debug output, especially if CONFIG_DEBUG_INFO is
|
||||
also selected. This option is intended to force vervose debug
|
||||
output from the network initialization logic even if CONFIG_DEBUG_NET
|
||||
or CONFIG_DEBUG_INFO are not selected. This allows for focused, unit-
|
||||
level debug of the network initialization logic.
|
||||
|
||||
# No IP address if 6LOWPAN selected; but Ethernet has precedence.
|
||||
|
||||
menu "IP Address Configuration"
|
||||
depends on NET_ETHERNET || !NET_6LOWPAN
|
||||
|
||||
config NETINIT_DHCPC
|
||||
bool "Use DHCP to get IP address"
|
||||
default n
|
||||
depends on NETUTILS_DHCPC
|
||||
---help---
|
||||
Obtain the IP address via DHCP.
|
||||
|
||||
Per RFC2131 (p. 9), the DHCP client must be prepared to receive DHCP
|
||||
messages of up to 576 bytes (excluding Ethernet, IP, or UDP headers and FCS).
|
||||
|
||||
if NET_IPv4
|
||||
|
||||
comment "IPv4 Addresses"
|
||||
|
||||
config NETINIT_IPADDR
|
||||
hex "Target IPv4 address"
|
||||
default 0x0a000002
|
||||
depends on !NETINIT_DHCPC
|
||||
---help---
|
||||
If NETINIT_DHCPC is NOT set, then the static IP address must be provided.
|
||||
This is a 32-bit integer value in host order. So, as an example,
|
||||
0x0a000002 would be 10.0.0.2.
|
||||
|
||||
config NETINIT_DRIPADDR
|
||||
hex "Router IPv4 address"
|
||||
default 0x0a000001
|
||||
---help---
|
||||
Default router IP address (aka, Gateway). This is a 32-bit integer
|
||||
value in host order. So, as an example, 0x0a000001 would be 10.0.0.1.
|
||||
|
||||
config NETINIT_NETMASK
|
||||
hex "IPv4 Network mask"
|
||||
default 0xffffff00
|
||||
---help---
|
||||
Network mask. This is a 32-bit integer value in host order. So, as
|
||||
an example, 0xffffff00 would be 255.255.255.0.
|
||||
|
||||
endif # NET_IPv4
|
||||
|
||||
if NET_IPv6 && !NET_ICMPv6_AUTOCONF
|
||||
|
||||
comment "Target IPv6 address"
|
||||
|
||||
config NETINIT_IPv6ADDR_1
|
||||
hex "[0]"
|
||||
default 0xfc00
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
If NET_ICMPv6_AUTOCONF is NOT set, then the static IP address must be
|
||||
provided. This is a 16-bit integer value in host order. Each of the
|
||||
eight values forming the full IP address must be specified
|
||||
individually. This is the first of the 8-values. The default for
|
||||
all eight values is fc00::2.
|
||||
|
||||
config NETINIT_IPv6ADDR_2
|
||||
hex "[1]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
If NET_ICMPv6_AUTOCONF is NOT set, then the static IP address must be
|
||||
provided. This is a 16-bit integer value in host order. Each of the
|
||||
eight values forming the full IP address must be specified
|
||||
individually. This is the second of the 8-values. The default for
|
||||
all eight values is fc00::2.
|
||||
|
||||
config NETINIT_IPv6ADDR_3
|
||||
hex "[2]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
If NET_ICMPv6_AUTOCONF is NOT set, then the static IP address must be
|
||||
provided. This is a 16-bit integer value in host order. Each of the
|
||||
eight values forming the full IP address must be specified
|
||||
individually. This is the third of the 8-values. The default for
|
||||
all eight values is fc00::2.
|
||||
|
||||
config NETINIT_IPv6ADDR_4
|
||||
hex "[3]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
If NET_ICMPv6_AUTOCONF is NOT set, then the static IP address must be
|
||||
provided. This is a 16-bit integer value in host order. Each of the
|
||||
eight values forming the full IP address must be specified
|
||||
individually. This is the fourth of the 8-values. The default for
|
||||
all eight values is fc00::2.
|
||||
|
||||
config NETINIT_IPv6ADDR_5
|
||||
hex "[4]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
If NET_ICMPv6_AUTOCONF is NOT set, then the static IP address must be
|
||||
provided. This is a 16-bit integer value in host order. Each of the
|
||||
eight values forming the full IP address must be specified
|
||||
individually. This is the fifth of the 8-values. The default for
|
||||
all eight values is fc00::2.
|
||||
|
||||
config NETINIT_IPv6ADDR_6
|
||||
hex "[5]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
If NET_ICMPv6_AUTOCONF is NOT set, then the static IP address must be
|
||||
provided. This is a 16-bit integer value in host order. Each of the
|
||||
eight values forming the full IP address must be specified
|
||||
individually. This is the sixth of the 8-values. The default for
|
||||
all eight values is fc00::2.
|
||||
|
||||
config NETINIT_IPv6ADDR_7
|
||||
hex "[6]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
If NET_ICMPv6_AUTOCONF is NOT set, then the static IP address must be
|
||||
provided. This is a 16-bit integer value in host order. Each of the
|
||||
eight values forming the full IP address must be specified
|
||||
individually. This is the seventh of the 8-values. The default for
|
||||
all eight values is fc00::2.
|
||||
|
||||
config NETINIT_IPv6ADDR_8
|
||||
hex "[7]"
|
||||
default 0x0002
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
If NET_ICMPv6_AUTOCONF is NOT set, then the static IP address must be
|
||||
provided. This is a 16-bit integer value in host order. Each of the
|
||||
eight values forming the full IP address must be specified
|
||||
individually. This is the last of the 8-values. The default for
|
||||
all eight values is fc00::2.
|
||||
|
||||
comment "Router IPv6 address"
|
||||
|
||||
config NETINIT_DRIPv6ADDR_1
|
||||
hex "[0]"
|
||||
default 0xfc00
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||
value in host order. Each of the eight values forming the full IP
|
||||
address must be specified individually. This is the first of the
|
||||
8-values. The default for all eight values is fc00::1.
|
||||
|
||||
config NETINIT_DRIPv6ADDR_2
|
||||
hex "[1]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||
value in host order. Each of the eight values forming the full IP
|
||||
address must be specified individually. This is the second of the
|
||||
8-values. The default for all eight values is fc00::1.
|
||||
|
||||
config NETINIT_DRIPv6ADDR_3
|
||||
hex "[2]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||
value in host order. Each of the eight values forming the full IP
|
||||
address must be specified individually. This is the third of the
|
||||
8-values. The default for all eight values is fc00::1.
|
||||
|
||||
config NETINIT_DRIPv6ADDR_4
|
||||
hex "[3]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||
value in host order. Each of the eight values forming the full IP
|
||||
address must be specified individually. This is the fourth of the
|
||||
8-values. The default for all eight values is fc00::1.
|
||||
|
||||
config NETINIT_DRIPv6ADDR_5
|
||||
hex "[4]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||
value in host order. Each of the eight values forming the full IP
|
||||
address must be specified individually. This is the fifth of the
|
||||
8-values. The default for all eight values is fc00::1.
|
||||
|
||||
config NETINIT_DRIPv6ADDR_6
|
||||
hex "[5]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||
value in host order. Each of the eight values forming the full IP
|
||||
address must be specified individually. This is the sixth of the
|
||||
8-values. The default for all eight values is fc00::1.
|
||||
|
||||
config NETINIT_DRIPv6ADDR_7
|
||||
hex "[6]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||
value in host order. Each of the eight values forming the full IP
|
||||
address must be specified individually. This is the seventh of the
|
||||
8-values. The default for all eight values is fc00::1.
|
||||
|
||||
config NETINIT_DRIPv6ADDR_8
|
||||
hex "[7]"
|
||||
default 0x0001
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||
value in host order. Each of the eight values forming the full IP
|
||||
address must be specified individually. This is the last of the
|
||||
8-values. The default for all eight values is fc00::1.
|
||||
|
||||
comment "IPv6 Network mask"
|
||||
|
||||
config NETINIT_IPv6NETMASK_1
|
||||
hex "[0]"
|
||||
default 0xffff
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Network mask. This is a 16-bit integer value in host order. Each
|
||||
of the eight values forming the full IP address must be specified
|
||||
individually. This is the first of the 8-values. The default for
|
||||
all eight values is fe00::0.
|
||||
|
||||
config NETINIT_IPv6NETMASK_2
|
||||
hex "[1]"
|
||||
default 0xffff
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Network mask. This is a 16-bit integer value in host order. Each
|
||||
of the eight values forming the full IP address must be specified
|
||||
individually. This is the second of the 8-values. The default for
|
||||
all eight values is fe00::0.
|
||||
|
||||
config NETINIT_IPv6NETMASK_3
|
||||
hex "[2]"
|
||||
default 0xffff
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Network mask. This is a 16-bit integer value in host order. Each
|
||||
of the eight values forming the full IP address must be specified
|
||||
individually. This is the third of the 8-values. The default for
|
||||
all eight values is fe00::0.
|
||||
|
||||
config NETINIT_IPv6NETMASK_4
|
||||
hex "[3]"
|
||||
default 0xffff
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Network mask. This is a 16-bit integer value in host order. Each
|
||||
of the eight values forming the full IP address must be specified
|
||||
individually. This is the fourth of the 8-values. The default for
|
||||
all eight values is fe00::0.
|
||||
|
||||
config NETINIT_IPv6NETMASK_5
|
||||
hex "[4]"
|
||||
default 0xffff
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Network mask. This is a 16-bit integer value in host order. Each
|
||||
of the eight values forming the full IP address must be specified
|
||||
individually. This is the fifth of the 8-values. The default for
|
||||
all eight values is fe00::0.
|
||||
|
||||
config NETINIT_IPv6NETMASK_6
|
||||
hex "[5]"
|
||||
default 0xffff
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Network mask. This is a 16-bit integer value in host order. Each
|
||||
of the eight values forming the full IP address must be specified
|
||||
individually. This is the sixth of the 8-values. The default for
|
||||
all eight values is fe00::0.
|
||||
|
||||
config NETINIT_IPv6NETMASK_7
|
||||
hex "[6]"
|
||||
default 0xffff
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Network mask. This is a 16-bit integer value in host order. Each
|
||||
of the eight values forming the full IP address must be specified
|
||||
individually. This is the seventh of the 8-values. The default for
|
||||
all eight values is fe00::0.
|
||||
|
||||
config NETINIT_IPv6NETMASK_8
|
||||
hex "[7]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Network mask. This is a 16-bit integer value in host order. Each
|
||||
of the eight values forming the full IP address must be specified
|
||||
individually. This is the eighth of the 8-values. The default for
|
||||
all eight values is fe00::0.
|
||||
|
||||
endif # NET_IPv6 && !NET_ICMPv6_AUTOCONF
|
||||
endmenu # IP Address Configuration
|
||||
|
||||
config NETINIT_DNS
|
||||
bool "Use DNS"
|
||||
default n
|
||||
depends on NETDB_DNSCLIENT
|
||||
---help---
|
||||
Configure to use a DNS.
|
||||
|
||||
config NETINIT_DNSIPADDR
|
||||
hex "DNS IP address"
|
||||
default 0xa0000001
|
||||
depends on NETINIT_DNS
|
||||
---help---
|
||||
Configure the DNS address. This is a 32-bit integer value in host
|
||||
order. So, as an example, 0xa0000001 would be 10.0.0.1.
|
||||
|
||||
config NETINIT_NOMAC
|
||||
bool "Hardware has no MAC address"
|
||||
default n
|
||||
---help---
|
||||
Set if your Ethernet hardware has no built-in MAC address.
|
||||
If set, a bogus MAC will be assigned.
|
||||
|
||||
if NETINIT_NOMAC
|
||||
|
||||
choice
|
||||
prompt "MAC address selection"
|
||||
default NETINIT_SWMAC
|
||||
---help---
|
||||
If the hardware as no MAC address, then this logic must assign an
|
||||
address to the hardware before it brings the network up. This
|
||||
choice allows you select the source of that MAC address.
|
||||
|
||||
config NETINIT_SWMAC
|
||||
bool "Fixed address"
|
||||
---help---
|
||||
With this choice, you can assign a fixed MAC address determined by
|
||||
a NuttX configuration option.
|
||||
|
||||
endchoice # MAC address selection
|
||||
|
||||
config NETINIT_MACADDR
|
||||
hex "Fixed MAC address"
|
||||
default 0x00e0deadbeef if NET_ETHERNET
|
||||
default 0x00fade00deadbeef if !NET_ETHERNET && NET_6LOWPAN
|
||||
depends on NETINIT_SWMAC && (NET_ETHERNET || NET_6LOWPAN)
|
||||
---help---
|
||||
If the hardware has no built-in MAC address and if the NETINIT_SWMAC
|
||||
option is selected, then the fixed, software-assigned MAC address
|
||||
MAC address must provided with this selection.
|
||||
|
||||
endif # NETINIT_NOMAC
|
||||
|
||||
menu "WAPI Configuration"
|
||||
depends on NET && WIRELESS_WAPI
|
||||
|
||||
config NETINIT_WAPI_STAMODE
|
||||
int "Wireless mode of operation"
|
||||
default 2
|
||||
range 0 8
|
||||
---help---
|
||||
Mode of operation. See the IW_MODE_* definitions in
|
||||
include/nuttx/wireless/wireless. The default value corresponds to
|
||||
IW_MODE_INFRA
|
||||
|
||||
config NETINIT_WAPI_AUTHWPA
|
||||
hex "IW_AUTH_WPA_VERSION value"
|
||||
default 0x00000004
|
||||
range 0x00000001 0x00000004
|
||||
---help---
|
||||
IW_AUTH_WPA_VERSION values. See the IW_AUTH_WPA_VERSION_* definitions
|
||||
in include/nuttx/wireless/wireless. The default value corresponds to
|
||||
IW_AUTH_WPA_VERSION_WPA2. NOTE that this is a bit-encoded field. The
|
||||
only valid values are 0x00000001, 0x00000002, and 0x00000004
|
||||
|
||||
config NETINIT_WAPI_CIPHERMODE
|
||||
hex "IW_AUTH_PAIRWISE_CIPHER and IW_AUTH_GROUP_CIPHER values"
|
||||
default 0x00000008
|
||||
range 0x00000001 0x00000010
|
||||
---help---
|
||||
IW_AUTH_PAIRWISE_CIPHER and IW_AUTH_GROUP_CIPHER values. See the
|
||||
IW_AUTH_CIPHER_* definitions in include/nuttx/wireless/wireless.
|
||||
The default value corresponds to IW_AUTH_CIPHER_CCMP. NOTE that
|
||||
this is a bit-encoded field. The only valid values are 0x00000001,
|
||||
0x00000002,0x00000004, ... 0x00000010
|
||||
|
||||
config NETINIT_WAPI_ALG
|
||||
int "Algorithm"
|
||||
default 3
|
||||
range 0 13
|
||||
---help---
|
||||
Algorithm. See enum wpa_alg_e in apps/include/wireless/wapi.h. The
|
||||
default corresponds to WPA_ALG_CCMP.
|
||||
|
||||
config NETINIT_WAPI_SSID
|
||||
string "SSID"
|
||||
default "myApSSID"
|
||||
|
||||
config NETINIT_WAPI_PASSPHRASE
|
||||
string "Passprhase"
|
||||
default "mySSIDpassphrase"
|
||||
|
||||
endmenu # WAPI Configuration
|
||||
endif # NETUTILS_NETINIT
|
39
netutils/netinit/Make.defs
Normal file
39
netutils/netinit/Make.defs
Normal file
@ -0,0 +1,39 @@
|
||||
# apps/netutils/netinit/Make.defs
|
||||
# Adds selected applications to apps/ build
|
||||
#
|
||||
# Copyright (C) 2019 Gregory Nutt. All rights reserved.
|
||||
# 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
ifeq ($(CONFIG_NETUTILS_NETINIT),y)
|
||||
CONFIGURED_APPS += netutils/netinit
|
||||
endif
|
||||
|
46
netutils/netinit/Makefile
Normal file
46
netutils/netinit/Makefile
Normal file
@ -0,0 +1,46 @@
|
||||
############################################################################
|
||||
# apps/netutils/netinit/Makefile
|
||||
#
|
||||
# Copyright (C) 2019 Gregory Nutt. All rights reserved.
|
||||
# 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
-include $(TOPDIR)/Make.defs
|
||||
|
||||
CSRCS = netinit.c
|
||||
|
||||
ifeq ($(CONFIG_WIRELESS_WAPI),y)
|
||||
ifneq ($(CONFIG_NETINIT_NETLOCAL),y)
|
||||
CSRCS += netinit_associate.c
|
||||
endif
|
||||
endif
|
||||
|
||||
include $(APPDIR)/Application.mk
|
@ -1,15 +1,10 @@
|
||||
/****************************************************************************
|
||||
* apps/nshlib/nsh_netinit.c
|
||||
* apps/netutils/netinit/netinit.c
|
||||
*
|
||||
* Copyright (C) 2010-2012, 2014-2016 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2010-2012, 2014-2016, 2019 Gregory Nutt. All rights
|
||||
* reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* This is influenced by similar logic from uIP:
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
* Copyright (c) 2003, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@ -44,7 +39,7 @@
|
||||
|
||||
/* Is network initialization debug forced on? */
|
||||
|
||||
#ifdef CONFIG_NSH_NETINIT_DEBUG
|
||||
#ifdef CONFIG_NETINIT_DEBUG
|
||||
# undef CONFIG_DEBUG_INFO
|
||||
# define CONFIG_DEBUG_INFO 1
|
||||
# undef CONFIG_DEBUG_NET
|
||||
@ -68,7 +63,7 @@
|
||||
#include <nuttx/net/mii.h>
|
||||
|
||||
#include "netutils/netlib.h"
|
||||
#if defined(CONFIG_NSH_DHCPC) || defined(CONFIG_NSH_DNS)
|
||||
#if defined(CONFIG_NETINIT_DHCPC) || defined(CONFIG_NETINIT_DNS)
|
||||
# include "netutils/dhcpc.h"
|
||||
#endif
|
||||
|
||||
@ -84,9 +79,9 @@
|
||||
# include "netutils/ntpclient.h"
|
||||
#endif
|
||||
|
||||
#include "nsh.h"
|
||||
#include "netutils/netinit.h"
|
||||
|
||||
#ifdef CONFIG_NSH_NETINIT
|
||||
#ifdef CONFIG_NETUTILS_NETINIT
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
@ -158,19 +153,8 @@
|
||||
|
||||
/* Provide a default DNS address */
|
||||
|
||||
#if defined(CONFIG_NSH_DRIPADDR) && !defined(CONFIG_NSH_DNSIPADDR)
|
||||
# define CONFIG_NSH_DNSIPADDR CONFIG_NSH_DRIPADDR
|
||||
#endif
|
||||
|
||||
/* SLIP-specific configuration
|
||||
*
|
||||
* REVISIT: How will we handle Ethernet and SLIP networks together? In the
|
||||
* future, NSH will need to be extended to handle multiple networks with
|
||||
* mixed transports.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NET_MULILINK
|
||||
# warning REVISIT: CONFIG_NET_MULILINK multilink support incomplete
|
||||
#if defined(CONFIG_NETINIT_DRIPADDR) && !defined(CONFIG_NETINIT_DNSIPADDR)
|
||||
# define CONFIG_NETINIT_DNSIPADDR CONFIG_NETINIT_DRIPADDR
|
||||
#endif
|
||||
|
||||
/* Select the single network device name supported this this network
|
||||
@ -182,30 +166,30 @@
|
||||
|
||||
#if defined(CONFIG_DRIVERS_IEEE80211) /* Usually also has CONFIG_NET_ETHERNET */
|
||||
# define NET_DEVNAME "wlan0"
|
||||
# define NSH_HAVE_NETDEV
|
||||
# define NETINIT_HAVE_NETDEV
|
||||
#elif defined(CONFIG_NET_ETHERNET)
|
||||
# define NET_DEVNAME "eth0"
|
||||
# define NSH_HAVE_NETDEV
|
||||
# define NETINIT_HAVE_NETDEV
|
||||
#elif defined(CONFIG_NET_6LOWPAN) || defined(CONFIG_NET_IEEE802154)
|
||||
# define NET_DEVNAME "wpan0"
|
||||
# define NSH_HAVE_NETDEV
|
||||
# define NETINIT_HAVE_NETDEV
|
||||
#elif defined(CONFIG_NET_BLUETOOTH)
|
||||
# define NET_DEVNAME "bnep0"
|
||||
# define NSH_HAVE_NETDEV
|
||||
# define NETINIT_HAVE_NETDEV
|
||||
#elif defined(CONFIG_NET_SLIP)
|
||||
# define NET_DEVNAME "sl0"
|
||||
# ifndef CONFIG_NSH_NOMAC
|
||||
# error "CONFIG_NSH_NOMAC must be defined for SLIP"
|
||||
# ifndef CONFIG_NETINIT_NOMAC
|
||||
# error "CONFIG_NETINIT_NOMAC must be defined for SLIP"
|
||||
# endif
|
||||
# define NSH_HAVE_NETDEV
|
||||
# define NETINIT_HAVE_NETDEV
|
||||
#elif defined(CONFIG_NET_TUN)
|
||||
# define NET_DEVNAME "tun0"
|
||||
# define NSH_HAVE_NETDEV
|
||||
# define NETINIT_HAVE_NETDEV
|
||||
#elif defined(CONFIG_NET_LOCAL)
|
||||
# define NET_DEVNAME "lo"
|
||||
# define NSH_HAVE_NETDEV
|
||||
# define NETINIT_HAVE_NETDEV
|
||||
#elif defined(CONFIG_NET_USRSOCK)
|
||||
# undef NSH_HAVE_NETDEV
|
||||
# undef NETINIT_HAVE_NETDEV
|
||||
#elif !defined(CONFIG_NET_LOOPBACK)
|
||||
# error ERROR: No link layer protocol defined
|
||||
#endif
|
||||
@ -214,8 +198,8 @@
|
||||
* cannot support the network monitor.
|
||||
*/
|
||||
|
||||
#ifndef NSH_HAVE_NETDEV
|
||||
# undef CONFIG_NSH_NETINIT_MONITOR
|
||||
#ifndef NETINIT_HAVE_NETDEV
|
||||
# undef CONFIG_NETINIT_MONITOR
|
||||
#endif
|
||||
|
||||
/* We need a valid IP domain (any domain) to create a socket that we can use
|
||||
@ -240,7 +224,7 @@
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NSH_NETINIT_MONITOR
|
||||
#ifdef CONFIG_NETINIT_MONITOR
|
||||
static sem_t g_notify_sem;
|
||||
#endif
|
||||
|
||||
@ -250,42 +234,42 @@ static sem_t g_notify_sem;
|
||||
|
||||
static const uint16_t g_ipv6_hostaddr[8] =
|
||||
{
|
||||
HTONS(CONFIG_NSH_IPv6ADDR_1),
|
||||
HTONS(CONFIG_NSH_IPv6ADDR_2),
|
||||
HTONS(CONFIG_NSH_IPv6ADDR_3),
|
||||
HTONS(CONFIG_NSH_IPv6ADDR_4),
|
||||
HTONS(CONFIG_NSH_IPv6ADDR_5),
|
||||
HTONS(CONFIG_NSH_IPv6ADDR_6),
|
||||
HTONS(CONFIG_NSH_IPv6ADDR_7),
|
||||
HTONS(CONFIG_NSH_IPv6ADDR_8),
|
||||
HTONS(CONFIG_NETINIT_IPv6ADDR_1),
|
||||
HTONS(CONFIG_NETINIT_IPv6ADDR_2),
|
||||
HTONS(CONFIG_NETINIT_IPv6ADDR_3),
|
||||
HTONS(CONFIG_NETINIT_IPv6ADDR_4),
|
||||
HTONS(CONFIG_NETINIT_IPv6ADDR_5),
|
||||
HTONS(CONFIG_NETINIT_IPv6ADDR_6),
|
||||
HTONS(CONFIG_NETINIT_IPv6ADDR_7),
|
||||
HTONS(CONFIG_NETINIT_IPv6ADDR_8),
|
||||
};
|
||||
|
||||
/* Default routine IPv6 address */
|
||||
|
||||
static const uint16_t g_ipv6_draddr[8] =
|
||||
{
|
||||
HTONS(CONFIG_NSH_DRIPv6ADDR_1),
|
||||
HTONS(CONFIG_NSH_DRIPv6ADDR_2),
|
||||
HTONS(CONFIG_NSH_DRIPv6ADDR_3),
|
||||
HTONS(CONFIG_NSH_DRIPv6ADDR_4),
|
||||
HTONS(CONFIG_NSH_DRIPv6ADDR_5),
|
||||
HTONS(CONFIG_NSH_DRIPv6ADDR_6),
|
||||
HTONS(CONFIG_NSH_DRIPv6ADDR_7),
|
||||
HTONS(CONFIG_NSH_DRIPv6ADDR_8),
|
||||
HTONS(CONFIG_NETINIT_DRIPv6ADDR_1),
|
||||
HTONS(CONFIG_NETINIT_DRIPv6ADDR_2),
|
||||
HTONS(CONFIG_NETINIT_DRIPv6ADDR_3),
|
||||
HTONS(CONFIG_NETINIT_DRIPv6ADDR_4),
|
||||
HTONS(CONFIG_NETINIT_DRIPv6ADDR_5),
|
||||
HTONS(CONFIG_NETINIT_DRIPv6ADDR_6),
|
||||
HTONS(CONFIG_NETINIT_DRIPv6ADDR_7),
|
||||
HTONS(CONFIG_NETINIT_DRIPv6ADDR_8),
|
||||
};
|
||||
|
||||
/* IPv6 netmask */
|
||||
|
||||
static const uint16_t g_ipv6_netmask[8] =
|
||||
{
|
||||
HTONS(CONFIG_NSH_IPv6NETMASK_1),
|
||||
HTONS(CONFIG_NSH_IPv6NETMASK_2),
|
||||
HTONS(CONFIG_NSH_IPv6NETMASK_3),
|
||||
HTONS(CONFIG_NSH_IPv6NETMASK_4),
|
||||
HTONS(CONFIG_NSH_IPv6NETMASK_5),
|
||||
HTONS(CONFIG_NSH_IPv6NETMASK_6),
|
||||
HTONS(CONFIG_NSH_IPv6NETMASK_7),
|
||||
HTONS(CONFIG_NSH_IPv6NETMASK_8),
|
||||
HTONS(CONFIG_NETINIT_IPv6NETMASK_1),
|
||||
HTONS(CONFIG_NETINIT_IPv6NETMASK_2),
|
||||
HTONS(CONFIG_NETINIT_IPv6NETMASK_3),
|
||||
HTONS(CONFIG_NETINIT_IPv6NETMASK_4),
|
||||
HTONS(CONFIG_NETINIT_IPv6NETMASK_5),
|
||||
HTONS(CONFIG_NETINIT_IPv6NETMASK_6),
|
||||
HTONS(CONFIG_NETINIT_IPv6NETMASK_7),
|
||||
HTONS(CONFIG_NETINIT_IPv6NETMASK_8),
|
||||
};
|
||||
#endif /* CONFIG_NET_IPv6 && !CONFIG_NET_ICMPv6_AUTOCONF && !CONFIG_NET_6LOWPAN */
|
||||
|
||||
@ -294,7 +278,7 @@ static const uint16_t g_ipv6_netmask[8] =
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_set_macaddr
|
||||
* Name: netinit_set_macaddr
|
||||
*
|
||||
* Description:
|
||||
* Set the hardware MAC address if the hardware is not capable of doing
|
||||
@ -302,8 +286,8 @@ static const uint16_t g_ipv6_netmask[8] =
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(NSH_HAVE_NETDEV) && defined(CONFIG_NSH_NOMAC) && defined(HAVE_MAC)
|
||||
static void nsh_set_macaddr(void)
|
||||
#if defined(NETINIT_HAVE_NETDEV) && defined(CONFIG_NETINIT_NOMAC) && defined(HAVE_MAC)
|
||||
static void netinit_set_macaddr(void)
|
||||
{
|
||||
#if defined(CONFIG_NET_ETHERNET)
|
||||
uint8_t mac[IFHWADDRLEN];
|
||||
@ -316,12 +300,12 @@ static void nsh_set_macaddr(void)
|
||||
#if defined(CONFIG_NET_ETHERNET)
|
||||
/* Use the configured, fixed MAC address */
|
||||
|
||||
mac[0] = (CONFIG_NSH_MACADDR >> (8 * 5)) & 0xff;
|
||||
mac[1] = (CONFIG_NSH_MACADDR >> (8 * 4)) & 0xff;
|
||||
mac[2] = (CONFIG_NSH_MACADDR >> (8 * 3)) & 0xff;
|
||||
mac[3] = (CONFIG_NSH_MACADDR >> (8 * 2)) & 0xff;
|
||||
mac[4] = (CONFIG_NSH_MACADDR >> (8 * 1)) & 0xff;
|
||||
mac[5] = (CONFIG_NSH_MACADDR >> (8 * 0)) & 0xff;
|
||||
mac[0] = (CONFIG_NETINIT_MACADDR >> (8 * 5)) & 0xff;
|
||||
mac[1] = (CONFIG_NETINIT_MACADDR >> (8 * 4)) & 0xff;
|
||||
mac[2] = (CONFIG_NETINIT_MACADDR >> (8 * 3)) & 0xff;
|
||||
mac[3] = (CONFIG_NETINIT_MACADDR >> (8 * 2)) & 0xff;
|
||||
mac[4] = (CONFIG_NETINIT_MACADDR >> (8 * 1)) & 0xff;
|
||||
mac[5] = (CONFIG_NETINIT_MACADDR >> (8 * 0)) & 0xff;
|
||||
|
||||
/* Set the MAC address */
|
||||
|
||||
@ -330,14 +314,14 @@ static void nsh_set_macaddr(void)
|
||||
#elif defined(HAVE_EADDR)
|
||||
/* Use the configured, fixed extended address */
|
||||
|
||||
eaddr[0] = (CONFIG_NSH_MACADDR >> (8 * 7)) & 0xff;
|
||||
eaddr[1] = (CONFIG_NSH_MACADDR >> (8 * 6)) & 0xff;
|
||||
eaddr[2] = (CONFIG_NSH_MACADDR >> (8 * 5)) & 0xff;
|
||||
eaddr[3] = (CONFIG_NSH_MACADDR >> (8 * 4)) & 0xff;
|
||||
eaddr[4] = (CONFIG_NSH_MACADDR >> (8 * 3)) & 0xff;
|
||||
eaddr[5] = (CONFIG_NSH_MACADDR >> (8 * 2)) & 0xff;
|
||||
eaddr[6] = (CONFIG_NSH_MACADDR >> (8 * 1)) & 0xff;
|
||||
eaddr[7] = (CONFIG_NSH_MACADDR >> (8 * 0)) & 0xff;
|
||||
eaddr[0] = (CONFIG_NETINIT_MACADDR >> (8 * 7)) & 0xff;
|
||||
eaddr[1] = (CONFIG_NETINIT_MACADDR >> (8 * 6)) & 0xff;
|
||||
eaddr[2] = (CONFIG_NETINIT_MACADDR >> (8 * 5)) & 0xff;
|
||||
eaddr[3] = (CONFIG_NETINIT_MACADDR >> (8 * 4)) & 0xff;
|
||||
eaddr[4] = (CONFIG_NETINIT_MACADDR >> (8 * 3)) & 0xff;
|
||||
eaddr[5] = (CONFIG_NETINIT_MACADDR >> (8 * 2)) & 0xff;
|
||||
eaddr[6] = (CONFIG_NETINIT_MACADDR >> (8 * 1)) & 0xff;
|
||||
eaddr[7] = (CONFIG_NETINIT_MACADDR >> (8 * 0)) & 0xff;
|
||||
|
||||
/* Set the 6LoWPAN extended address */
|
||||
|
||||
@ -345,11 +329,11 @@ static void nsh_set_macaddr(void)
|
||||
#endif /* CONFIG_NET_ETHERNET or HAVE_EADDR */
|
||||
}
|
||||
#else
|
||||
# define nsh_set_macaddr()
|
||||
# define netinit_set_macaddr()
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_set_ipaddrs
|
||||
* Name: netinit_set_ipaddrs
|
||||
*
|
||||
* Description:
|
||||
* Setup IP addresses.
|
||||
@ -359,17 +343,17 @@ static void nsh_set_macaddr(void)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(NSH_HAVE_NETDEV) && !defined(CONFIG_NET_6LOWPAN) && ! \
|
||||
#if defined(NETINIT_HAVE_NETDEV) && !defined(CONFIG_NET_6LOWPAN) && ! \
|
||||
defined(CONFIG_NET_IEEE802154)
|
||||
static void nsh_set_ipaddrs(void)
|
||||
static void netinit_set_ipaddrs(void)
|
||||
{
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
struct in_addr addr;
|
||||
|
||||
/* Set up our host address */
|
||||
|
||||
#ifndef CONFIG_NSH_DHCPC
|
||||
addr.s_addr = HTONL(CONFIG_NSH_IPADDR);
|
||||
#ifndef CONFIG_NETINIT_DHCPC
|
||||
addr.s_addr = HTONL(CONFIG_NETINIT_IPADDR);
|
||||
#else
|
||||
addr.s_addr = 0;
|
||||
#endif
|
||||
@ -377,12 +361,12 @@ static void nsh_set_ipaddrs(void)
|
||||
|
||||
/* Set up the default router address */
|
||||
|
||||
addr.s_addr = HTONL(CONFIG_NSH_DRIPADDR);
|
||||
addr.s_addr = HTONL(CONFIG_NETINIT_DRIPADDR);
|
||||
netlib_set_dripv4addr(NET_DEVNAME, &addr);
|
||||
|
||||
/* Setup the subnet mask */
|
||||
|
||||
addr.s_addr = HTONL(CONFIG_NSH_NETMASK);
|
||||
addr.s_addr = HTONL(CONFIG_NETINIT_NETMASK);
|
||||
netlib_set_ipv4netmask(NET_DEVNAME, &addr);
|
||||
#endif
|
||||
|
||||
@ -406,27 +390,27 @@ static void nsh_set_ipaddrs(void)
|
||||
#endif /* CONFIG_NET_ICMPv6_AUTOCONF */
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
|
||||
#ifdef CONFIG_NSH_DNS
|
||||
addr.s_addr = HTONL(CONFIG_NSH_DNSIPADDR);
|
||||
#ifdef CONFIG_NETINIT_DNS
|
||||
addr.s_addr = HTONL(CONFIG_NETINIT_DNSIPADDR);
|
||||
netlib_set_ipv4dnsaddr(&addr);
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
# define nsh_set_ipaddrs()
|
||||
# define netinit_set_ipaddrs()
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_net_bringup()
|
||||
* Name: netinit_net_bringup()
|
||||
*
|
||||
* Description:
|
||||
* Bring up the configured network
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(NSH_HAVE_NETDEV) && !defined(CONFIG_NSH_NETLOCAL)
|
||||
static void nsh_net_bringup(void)
|
||||
#if defined(NETINIT_HAVE_NETDEV) && !defined(CONFIG_NETINIT_NETLOCAL)
|
||||
static void netinit_net_bringup(void)
|
||||
{
|
||||
#ifdef CONFIG_NSH_DHCPC
|
||||
#ifdef CONFIG_NETINIT_DHCPC
|
||||
uint8_t mac[IFHWADDRLEN];
|
||||
FAR void *handle;
|
||||
#endif
|
||||
@ -438,7 +422,7 @@ static void nsh_net_bringup(void)
|
||||
#ifdef CONFIG_WIRELESS_WAPI
|
||||
/* Associate the wlan with an access point. */
|
||||
|
||||
nsh_associate(NET_DEVNAME);
|
||||
netinit_associate(NET_DEVNAME);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_ICMPv6_AUTOCONF
|
||||
@ -447,7 +431,7 @@ static void nsh_net_bringup(void)
|
||||
netlib_icmpv6_autoconfiguration(NET_DEVNAME);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NSH_DHCPC
|
||||
#ifdef CONFIG_NETINIT_DHCPC
|
||||
/* Get the MAC address of the NIC */
|
||||
|
||||
netlib_getmacaddr(NET_DEVNAME, mac);
|
||||
@ -492,48 +476,48 @@ static void nsh_net_bringup(void)
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
# define nsh_net_bringup()
|
||||
# define netinit_net_bringup()
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_netinit_configure
|
||||
* Name: netinit_configure
|
||||
*
|
||||
* Description:
|
||||
* Initialize the network per the selected NuttX configuration
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void nsh_netinit_configure(void)
|
||||
static void netinit_configure(void)
|
||||
{
|
||||
#ifdef NSH_HAVE_NETDEV
|
||||
#ifdef NETINIT_HAVE_NETDEV
|
||||
/* Many embedded network interfaces must have a software assigned MAC */
|
||||
|
||||
nsh_set_macaddr();
|
||||
netinit_set_macaddr();
|
||||
|
||||
/* Set up IP addresses */
|
||||
|
||||
nsh_set_ipaddrs();
|
||||
netinit_set_ipaddrs();
|
||||
|
||||
/* That completes the 'local' initialization of the network device. */
|
||||
|
||||
#ifndef CONFIG_NSH_NETLOCAL
|
||||
#ifndef CONFIG_NETINIT_NETLOCAL
|
||||
/* Bring the network up. */
|
||||
|
||||
nsh_net_bringup();
|
||||
netinit_net_bringup();
|
||||
#endif
|
||||
#endif /* NSH_HAVE_NETDEV */
|
||||
#endif /* NETINIT_HAVE_NETDEV */
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_netinit_signal
|
||||
* Name: netinit_signal
|
||||
*
|
||||
* Description:
|
||||
* This signal handler responds to changes in PHY status.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NSH_NETINIT_MONITOR
|
||||
static void nsh_netinit_signal(int signo, FAR siginfo_t *siginfo,
|
||||
#ifdef CONFIG_NETINIT_MONITOR
|
||||
static void netinit_signal(int signo, FAR siginfo_t *siginfo,
|
||||
FAR void * context)
|
||||
{
|
||||
int semcount;
|
||||
@ -554,7 +538,7 @@ static void nsh_netinit_signal(int signo, FAR siginfo_t *siginfo,
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_netinit_monitor
|
||||
* Name: netinit_monitor
|
||||
*
|
||||
* Description:
|
||||
* Monitor link status, gracefully taking the link up and down as the
|
||||
@ -562,8 +546,8 @@ static void nsh_netinit_signal(int signo, FAR siginfo_t *siginfo,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NSH_NETINIT_MONITOR
|
||||
static int nsh_netinit_monitor(void)
|
||||
#ifdef CONFIG_NETINIT_MONITOR
|
||||
static int netinit_monitor(void)
|
||||
{
|
||||
struct timespec abstime;
|
||||
struct timespec reltime;
|
||||
@ -595,10 +579,10 @@ static int nsh_netinit_monitor(void)
|
||||
|
||||
/* Attach a signal handler so that we do not lose PHY events */
|
||||
|
||||
act.sa_sigaction = nsh_netinit_signal;
|
||||
act.sa_sigaction = netinit_signal;
|
||||
act.sa_flags = SA_SIGINFO;
|
||||
|
||||
ret = sigaction(CONFIG_NSH_NETINIT_SIGNO, &act, NULL);
|
||||
ret = sigaction(CONFIG_NETINIT_SIGNO, &act, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -errno;
|
||||
@ -618,7 +602,7 @@ static int nsh_netinit_monitor(void)
|
||||
strncpy(ifr.ifr_name, NET_DEVNAME, IFNAMSIZ);
|
||||
|
||||
ifr.ifr_mii_notify_event.sigev_notify = SIGEV_SIGNAL;
|
||||
ifr.ifr_mii_notify_event.sigev_signo = CONFIG_NSH_NETINIT_SIGNO;
|
||||
ifr.ifr_mii_notify_event.sigev_signo = CONFIG_NETINIT_SIGNO;
|
||||
|
||||
ret = ioctl(sd, SIOCMIINOTIFY, (unsigned long)&ifr);
|
||||
if (ret < 0)
|
||||
@ -744,8 +728,8 @@ static int nsh_netinit_monitor(void)
|
||||
|
||||
/* In either case, wait for the short, configurable delay */
|
||||
|
||||
reltime.tv_sec = CONFIG_NSH_NETINIT_RETRYMSEC / 1000;
|
||||
reltime.tv_nsec = (CONFIG_NSH_NETINIT_RETRYMSEC % 1000) * 1000000;
|
||||
reltime.tv_sec = CONFIG_NETINIT_RETRYMSEC / 1000;
|
||||
reltime.tv_nsec = (CONFIG_NETINIT_RETRYMSEC % 1000) * 1000000;
|
||||
}
|
||||
|
||||
/* Now wait for either the semaphore to be posted for a timed-out to
|
||||
@ -782,26 +766,26 @@ errout:
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_netinit_thread
|
||||
* Name: netinit_thread
|
||||
*
|
||||
* Description:
|
||||
* Initialize the network per the selected NuttX configuration
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NSH_NETINIT_THREAD
|
||||
static pthread_addr_t nsh_netinit_thread(pthread_addr_t arg)
|
||||
#ifdef CONFIG_NETINIT_THREAD
|
||||
static pthread_addr_t netinit_thread(pthread_addr_t arg)
|
||||
{
|
||||
ninfo("Entry\n");
|
||||
|
||||
/* Configure the network */
|
||||
|
||||
nsh_netinit_configure();
|
||||
netinit_configure();
|
||||
|
||||
#ifdef CONFIG_NSH_NETINIT_MONITOR
|
||||
#ifdef CONFIG_NETINIT_MONITOR
|
||||
/* Monitor the network status */
|
||||
|
||||
nsh_netinit_monitor();
|
||||
netinit_monitor();
|
||||
#endif
|
||||
|
||||
ninfo("Exit\n");
|
||||
@ -814,16 +798,16 @@ static pthread_addr_t nsh_netinit_thread(pthread_addr_t arg)
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_netinit
|
||||
* Name: netinit_bringup
|
||||
*
|
||||
* Description:
|
||||
* Initialize the network per the selected NuttX configuration
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nsh_netinit(void)
|
||||
int netinit_bringup(void)
|
||||
{
|
||||
#ifdef CONFIG_NSH_NETINIT_THREAD
|
||||
#ifdef CONFIG_NETINIT_THREAD
|
||||
struct sched_param sparam;
|
||||
pthread_attr_t attr;
|
||||
pthread_t tid;
|
||||
@ -834,16 +818,16 @@ int nsh_netinit(void)
|
||||
*/
|
||||
|
||||
pthread_attr_init(&attr);
|
||||
sparam.sched_priority = CONFIG_NSH_NETINIT_THREAD_PRIORITY;
|
||||
sparam.sched_priority = CONFIG_NETINIT_THREAD_PRIORITY;
|
||||
(void)pthread_attr_setschedparam(&attr, &sparam);
|
||||
(void)pthread_attr_setstacksize(&attr, CONFIG_NSH_NETINIT_THREAD_STACKSIZE);
|
||||
(void)pthread_attr_setstacksize(&attr, CONFIG_NETINIT_THREAD_STACKSIZE);
|
||||
|
||||
ninfo("Starting netinit thread\n");
|
||||
ret = pthread_create(&tid, &attr, nsh_netinit_thread, NULL);
|
||||
ret = pthread_create(&tid, &attr, netinit_thread, NULL);
|
||||
if (ret != OK)
|
||||
{
|
||||
nerr("ERROR: Failed to create netinit thread: %d\n", ret);
|
||||
(void)nsh_netinit_thread(NULL);
|
||||
(void)netinit_thread(NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -861,9 +845,9 @@ int nsh_netinit(void)
|
||||
#else
|
||||
/* Perform network initialization sequentially */
|
||||
|
||||
nsh_netinit_configure();
|
||||
netinit_configure();
|
||||
return OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NSH_NETINIT */
|
||||
#endif /* CONFIG_NETUTILS_NETINIT */
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* apps/nshlib/nsh_associate.c
|
||||
* apps/netutils/netinit/netinit_associate.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2017, 2019 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -45,7 +45,7 @@
|
||||
#include <nuttx/wireless/wireless.h>
|
||||
|
||||
#include "wireless/wapi.h"
|
||||
#include "nsh.h"
|
||||
#include "netutils/netinit.h"
|
||||
|
||||
#ifdef CONFIG_WIRELESS_WAPI
|
||||
|
||||
@ -54,22 +54,22 @@
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_associate
|
||||
* Name: netinit_associate
|
||||
****************************************************************************/
|
||||
|
||||
int nsh_associate(FAR const char *ifname)
|
||||
int netinit_associate(FAR const char *ifname)
|
||||
{
|
||||
static const char ssid[] = CONFIG_NSH_WAPI_SSID;
|
||||
static const char passphrase[] = CONFIG_NSH_WAPI_PASSPHRASE;
|
||||
static const char ssid[] = CONFIG_NETINIT_WAPI_SSID;
|
||||
static const char passphrase[] = CONFIG_NETINIT_WAPI_PASSPHRASE;
|
||||
struct wpa_wconfig_s wconfig;
|
||||
int ret;
|
||||
|
||||
/* Set up the network configuration */
|
||||
|
||||
wconfig.sta_mode = CONFIG_NSH_WAPI_STAMODE;
|
||||
wconfig.auth_wpa = CONFIG_NSH_WAPI_AUTHWPA;
|
||||
wconfig.cipher_mode = CONFIG_NSH_WAPI_CIPHERMODE;
|
||||
wconfig.alg = CONFIG_NSH_WAPI_ALG;
|
||||
wconfig.sta_mode = CONFIG_NETINIT_WAPI_STAMODE;
|
||||
wconfig.auth_wpa = CONFIG_NETINIT_WAPI_AUTHWPA;
|
||||
wconfig.cipher_mode = CONFIG_NETINIT_WAPI_CIPHERMODE;
|
||||
wconfig.alg = CONFIG_NETINIT_WAPI_ALG;
|
||||
wconfig.ifname = ifname;
|
||||
wconfig.ssid = (FAR const uint8_t *)ssid;
|
||||
wconfig.passphrase = (FAR const uint8_t *)passphrase;
|
530
nshlib/Kconfig
530
nshlib/Kconfig
@ -1098,538 +1098,10 @@ config NSH_NETINIT
|
||||
bool "Network initialization"
|
||||
default y
|
||||
depends on NET
|
||||
select NETUTILS_NETINIT
|
||||
---help---
|
||||
This option enables/disables all network initialization in NSH.
|
||||
|
||||
if NSH_NETINIT
|
||||
|
||||
config NSH_NETLOCAL
|
||||
bool "Local network initialization"
|
||||
default n
|
||||
---help---
|
||||
If this option is selected, then NSH will only initialize the local
|
||||
attributes of the network: The MAC address if needed and any IP
|
||||
addresses as needed. More importantly, it will not do the following:
|
||||
|
||||
- It will not bring the network up. That can be done later with the
|
||||
NSH ifup command.
|
||||
- It will not associate any wireless devices to an access point.
|
||||
- It will not attempt to obtain an IP address if DHCPC is selected.
|
||||
This may be done later from the NSH command line with the
|
||||
apps/system/dhcpc 'renew' command.
|
||||
- It will not start the NTPC daemon. This may be done later from
|
||||
the NSH command line with the apps/system/ntpc 'ntpcstart' command.
|
||||
|
||||
This option permits you to divide the network configuration into two
|
||||
parts: The local configuration of the network device and the dynamic
|
||||
configuration of the device in the network. This may be important in
|
||||
an environment when, for example, you need to manually scan for
|
||||
available access points and associate the wireless driver with an
|
||||
access point.
|
||||
|
||||
config NSH_NETINIT_THREAD
|
||||
bool "Network initialization thread"
|
||||
default n
|
||||
depends on !DISABLE_PTHREAD && !NSH_NETLOCAL
|
||||
---help---
|
||||
NSH is brought up through a series of sequential initialization
|
||||
steps. This includes networking. If the network is available on
|
||||
reset, then there is really no issue. Negotiating the link will
|
||||
take only a second or so and the delay to the NSH prompt is
|
||||
normally acceptable.
|
||||
|
||||
But if there is no network connected, then the start-up delay can
|
||||
be very long depending upon things like the particular PHY, driver
|
||||
timeout delay times and number of retries. A failed negotiation
|
||||
can potentially take a very long time, perhaps as much as a
|
||||
minute... Long enough that you might think that the board would
|
||||
never come up!
|
||||
|
||||
One solution is enabled by this option. If NSH_NETINIT_THREAD
|
||||
is selected, the network bring-up will occur in parallel with
|
||||
NSH on a separate thread. In this case, the NSH prompt will occur
|
||||
immediately with the network becoming available some time later (if
|
||||
if all). This thread will terminate once it successfully initializes
|
||||
the network
|
||||
|
||||
NOTES: If no network is connected, the network bring-up will fail
|
||||
and the network initialization thread will simply exit. There are
|
||||
no retries and no mechanism to know if the network initialization
|
||||
was successful. Furthermore, there is currently no support for
|
||||
detecting loss of network connection. Lots of things to do!
|
||||
|
||||
if NSH_NETINIT_THREAD
|
||||
|
||||
config NSH_NETINIT_MONITOR
|
||||
bool "Monitor link state"
|
||||
default n
|
||||
depends on ARCH_PHY_INTERRUPT && NETDEV_PHY_IOCTL && NET_UDP && !DISABLE_SIGNALS
|
||||
---help---
|
||||
By default the net initialization thread will bring-up the network
|
||||
then exit, freeing all of the resources that it required. This is a
|
||||
good behavior for systems with limited memory.
|
||||
|
||||
If this option is selected, however, then the network initialization
|
||||
thread will persist forever; it will monitor the network status. In
|
||||
the event that the network goes down (for example, if a cable is
|
||||
removed), then the thread will monitor the link status and
|
||||
attempt to bring the network back up. In this case the resources
|
||||
required for network initialization are never released.
|
||||
|
||||
if NSH_NETINIT_MONITOR
|
||||
|
||||
config NSH_NETINIT_SIGNO
|
||||
int "Notification signal number"
|
||||
default 18
|
||||
---help---
|
||||
The network monitor logic will receive signals when there is any
|
||||
change in the link status. This setting may be used to customize
|
||||
that signal number in order to avoid conflicts.
|
||||
|
||||
config NSH_NETINIT_RETRYMSEC
|
||||
int "Network bring-up retry period (msec)"
|
||||
default 2000
|
||||
---help---
|
||||
When the network is down, the initialization thread will periodically
|
||||
try to bring the network up. This can be a time consuming operation
|
||||
so is done only periodically with that period specified by this
|
||||
selection in milliseconds.
|
||||
|
||||
endif # NSH_NETINIT_MONITOR
|
||||
|
||||
config NSH_NETINIT_THREAD_STACKSIZE
|
||||
int "Network initialization thread stack size"
|
||||
default 1568
|
||||
|
||||
config NSH_NETINIT_THREAD_PRIORITY
|
||||
int "Network initialization thread priority"
|
||||
default 80
|
||||
---help---
|
||||
This should be set to a priority lower than most tasks. The network
|
||||
PHY polling is CPU intensive and can interfere with the usability of
|
||||
of threads competing for CPU bandwidth.
|
||||
|
||||
endif # NSH_NETINIT_THREAD
|
||||
|
||||
config NSH_NETINIT_DEBUG
|
||||
bool "Network init debug"
|
||||
default n
|
||||
depends on DEBUG_FEATURES
|
||||
---help---
|
||||
Normally debug output is controlled by DEBUG_NET. However, that
|
||||
will generate a LOT of debug output, especially if CONFIG_DEBUG_INFO is
|
||||
also selected. This option is intended to force vervose debug
|
||||
output from the NSH network initialization logic even if CONFIG_DEBUG_NET
|
||||
or CONFIG_DEBUG_INFO are not selected. This allows for focused, unit-
|
||||
level debug of the NSH network initialization logic.
|
||||
|
||||
# No IP address if 6LOWPAN selected; but Ethernet has precedence.
|
||||
|
||||
menu "IP Address Configuration"
|
||||
depends on NET_ETHERNET || !NET_6LOWPAN
|
||||
|
||||
config NSH_DHCPC
|
||||
bool "Use DHCP to get IP address"
|
||||
default n
|
||||
depends on NETUTILS_DHCPC
|
||||
---help---
|
||||
Obtain the IP address via DHCP.
|
||||
|
||||
Per RFC2131 (p. 9), the DHCP client must be prepared to receive DHCP
|
||||
messages of up to 576 bytes (excluding Ethernet, IP, or UDP headers and FCS).
|
||||
|
||||
if NET_IPv4
|
||||
|
||||
comment "IPv4 Addresses"
|
||||
|
||||
config NSH_IPADDR
|
||||
hex "Target IPv4 address"
|
||||
default 0x0a000002
|
||||
depends on !NSH_DHCPC
|
||||
---help---
|
||||
If NSH_DHCPC is NOT set, then the static IP address must be provided.
|
||||
This is a 32-bit integer value in host order. So, as an example,
|
||||
0x0a000002 would be 10.0.0.2.
|
||||
|
||||
config NSH_DRIPADDR
|
||||
hex "Router IPv4 address"
|
||||
default 0x0a000001
|
||||
---help---
|
||||
Default router IP address (aka, Gateway). This is a 32-bit integer
|
||||
value in host order. So, as an example, 0x0a000001 would be 10.0.0.1.
|
||||
|
||||
config NSH_NETMASK
|
||||
hex "IPv4 Network mask"
|
||||
default 0xffffff00
|
||||
---help---
|
||||
Network mask. This is a 32-bit integer value in host order. So, as
|
||||
an example, 0xffffff00 would be 255.255.255.0.
|
||||
|
||||
endif # NET_IPv4
|
||||
|
||||
if NET_IPv6 && !NET_ICMPv6_AUTOCONF
|
||||
|
||||
comment "Target IPv6 address"
|
||||
|
||||
config NSH_IPv6ADDR_1
|
||||
hex "[0]"
|
||||
default 0xfc00
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
If NET_ICMPv6_AUTOCONF is NOT set, then the static IP address must be
|
||||
provided. This is a 16-bit integer value in host order. Each of the
|
||||
eight values forming the full IP address must be specified
|
||||
individually. This is the first of the 8-values. The default for
|
||||
all eight values is fc00::2.
|
||||
|
||||
config NSH_IPv6ADDR_2
|
||||
hex "[1]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
If NET_ICMPv6_AUTOCONF is NOT set, then the static IP address must be
|
||||
provided. This is a 16-bit integer value in host order. Each of the
|
||||
eight values forming the full IP address must be specified
|
||||
individually. This is the second of the 8-values. The default for
|
||||
all eight values is fc00::2.
|
||||
|
||||
config NSH_IPv6ADDR_3
|
||||
hex "[2]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
If NET_ICMPv6_AUTOCONF is NOT set, then the static IP address must be
|
||||
provided. This is a 16-bit integer value in host order. Each of the
|
||||
eight values forming the full IP address must be specified
|
||||
individually. This is the third of the 8-values. The default for
|
||||
all eight values is fc00::2.
|
||||
|
||||
config NSH_IPv6ADDR_4
|
||||
hex "[3]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
If NET_ICMPv6_AUTOCONF is NOT set, then the static IP address must be
|
||||
provided. This is a 16-bit integer value in host order. Each of the
|
||||
eight values forming the full IP address must be specified
|
||||
individually. This is the fourth of the 8-values. The default for
|
||||
all eight values is fc00::2.
|
||||
|
||||
config NSH_IPv6ADDR_5
|
||||
hex "[4]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
If NET_ICMPv6_AUTOCONF is NOT set, then the static IP address must be
|
||||
provided. This is a 16-bit integer value in host order. Each of the
|
||||
eight values forming the full IP address must be specified
|
||||
individually. This is the fifth of the 8-values. The default for
|
||||
all eight values is fc00::2.
|
||||
|
||||
config NSH_IPv6ADDR_6
|
||||
hex "[5]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
If NET_ICMPv6_AUTOCONF is NOT set, then the static IP address must be
|
||||
provided. This is a 16-bit integer value in host order. Each of the
|
||||
eight values forming the full IP address must be specified
|
||||
individually. This is the sixth of the 8-values. The default for
|
||||
all eight values is fc00::2.
|
||||
|
||||
config NSH_IPv6ADDR_7
|
||||
hex "[6]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
If NET_ICMPv6_AUTOCONF is NOT set, then the static IP address must be
|
||||
provided. This is a 16-bit integer value in host order. Each of the
|
||||
eight values forming the full IP address must be specified
|
||||
individually. This is the seventh of the 8-values. The default for
|
||||
all eight values is fc00::2.
|
||||
|
||||
config NSH_IPv6ADDR_8
|
||||
hex "[7]"
|
||||
default 0x0002
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
If NET_ICMPv6_AUTOCONF is NOT set, then the static IP address must be
|
||||
provided. This is a 16-bit integer value in host order. Each of the
|
||||
eight values forming the full IP address must be specified
|
||||
individually. This is the last of the 8-values. The default for
|
||||
all eight values is fc00::2.
|
||||
|
||||
comment "Router IPv6 address"
|
||||
|
||||
config NSH_DRIPv6ADDR_1
|
||||
hex "[0]"
|
||||
default 0xfc00
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||
value in host order. Each of the eight values forming the full IP
|
||||
address must be specified individually. This is the first of the
|
||||
8-values. The default for all eight values is fc00::1.
|
||||
|
||||
config NSH_DRIPv6ADDR_2
|
||||
hex "[1]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||
value in host order. Each of the eight values forming the full IP
|
||||
address must be specified individually. This is the second of the
|
||||
8-values. The default for all eight values is fc00::1.
|
||||
|
||||
config NSH_DRIPv6ADDR_3
|
||||
hex "[2]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||
value in host order. Each of the eight values forming the full IP
|
||||
address must be specified individually. This is the third of the
|
||||
8-values. The default for all eight values is fc00::1.
|
||||
|
||||
config NSH_DRIPv6ADDR_4
|
||||
hex "[3]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||
value in host order. Each of the eight values forming the full IP
|
||||
address must be specified individually. This is the fourth of the
|
||||
8-values. The default for all eight values is fc00::1.
|
||||
|
||||
config NSH_DRIPv6ADDR_5
|
||||
hex "[4]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||
value in host order. Each of the eight values forming the full IP
|
||||
address must be specified individually. This is the fifth of the
|
||||
8-values. The default for all eight values is fc00::1.
|
||||
|
||||
config NSH_DRIPv6ADDR_6
|
||||
hex "[5]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||
value in host order. Each of the eight values forming the full IP
|
||||
address must be specified individually. This is the sixth of the
|
||||
8-values. The default for all eight values is fc00::1.
|
||||
|
||||
config NSH_DRIPv6ADDR_7
|
||||
hex "[6]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||
value in host order. Each of the eight values forming the full IP
|
||||
address must be specified individually. This is the seventh of the
|
||||
8-values. The default for all eight values is fc00::1.
|
||||
|
||||
config NSH_DRIPv6ADDR_8
|
||||
hex "[7]"
|
||||
default 0x0001
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||
value in host order. Each of the eight values forming the full IP
|
||||
address must be specified individually. This is the last of the
|
||||
8-values. The default for all eight values is fc00::1.
|
||||
|
||||
comment "IPv6 Network mask"
|
||||
|
||||
config NSH_IPv6NETMASK_1
|
||||
hex "[0]"
|
||||
default 0xffff
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Network mask. This is a 16-bit integer value in host order. Each
|
||||
of the eight values forming the full IP address must be specified
|
||||
individually. This is the first of the 8-values. The default for
|
||||
all eight values is fe00::0.
|
||||
|
||||
config NSH_IPv6NETMASK_2
|
||||
hex "[1]"
|
||||
default 0xffff
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Network mask. This is a 16-bit integer value in host order. Each
|
||||
of the eight values forming the full IP address must be specified
|
||||
individually. This is the second of the 8-values. The default for
|
||||
all eight values is fe00::0.
|
||||
|
||||
config NSH_IPv6NETMASK_3
|
||||
hex "[2]"
|
||||
default 0xffff
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Network mask. This is a 16-bit integer value in host order. Each
|
||||
of the eight values forming the full IP address must be specified
|
||||
individually. This is the third of the 8-values. The default for
|
||||
all eight values is fe00::0.
|
||||
|
||||
config NSH_IPv6NETMASK_4
|
||||
hex "[3]"
|
||||
default 0xffff
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Network mask. This is a 16-bit integer value in host order. Each
|
||||
of the eight values forming the full IP address must be specified
|
||||
individually. This is the fourth of the 8-values. The default for
|
||||
all eight values is fe00::0.
|
||||
|
||||
config NSH_IPv6NETMASK_5
|
||||
hex "[4]"
|
||||
default 0xffff
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Network mask. This is a 16-bit integer value in host order. Each
|
||||
of the eight values forming the full IP address must be specified
|
||||
individually. This is the fifth of the 8-values. The default for
|
||||
all eight values is fe00::0.
|
||||
|
||||
config NSH_IPv6NETMASK_6
|
||||
hex "[5]"
|
||||
default 0xffff
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Network mask. This is a 16-bit integer value in host order. Each
|
||||
of the eight values forming the full IP address must be specified
|
||||
individually. This is the sixth of the 8-values. The default for
|
||||
all eight values is fe00::0.
|
||||
|
||||
config NSH_IPv6NETMASK_7
|
||||
hex "[6]"
|
||||
default 0xffff
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Network mask. This is a 16-bit integer value in host order. Each
|
||||
of the eight values forming the full IP address must be specified
|
||||
individually. This is the seventh of the 8-values. The default for
|
||||
all eight values is fe00::0.
|
||||
|
||||
config NSH_IPv6NETMASK_8
|
||||
hex "[7]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Network mask. This is a 16-bit integer value in host order. Each
|
||||
of the eight values forming the full IP address must be specified
|
||||
individually. This is the eighth of the 8-values. The default for
|
||||
all eight values is fe00::0.
|
||||
|
||||
endif # NET_IPv6 && !NET_ICMPv6_AUTOCONF
|
||||
endmenu # IP Address Configuration
|
||||
|
||||
config NSH_DNS
|
||||
bool "Use DNS"
|
||||
default n
|
||||
depends on NSH_LIBRARY && NETDB_DNSCLIENT
|
||||
---help---
|
||||
Configure to use a DNS.
|
||||
|
||||
config NSH_DNSIPADDR
|
||||
hex "DNS IP address"
|
||||
default 0xa0000001
|
||||
depends on NSH_DNS
|
||||
---help---
|
||||
Configure the DNS address. This is a 32-bit integer value in host
|
||||
order. So, as an example, 0xa0000001 would be 10.0.0.1.
|
||||
|
||||
config NSH_NOMAC
|
||||
bool "Hardware has no MAC address"
|
||||
default n
|
||||
depends on NSH_LIBRARY && NET
|
||||
---help---
|
||||
Set if your Ethernet hardware has no built-in MAC address.
|
||||
If set, a bogus MAC will be assigned.
|
||||
|
||||
if NSH_NOMAC
|
||||
|
||||
choice
|
||||
prompt "MAC address selection"
|
||||
default NSH_SWMAC
|
||||
---help---
|
||||
If the hardware as no MAC address, then NSH must assign an address
|
||||
to the hardware before it brings the network up. This choice allows
|
||||
you select the source of that MAC address.
|
||||
|
||||
config NSH_SWMAC
|
||||
bool "Fixed address"
|
||||
---help---
|
||||
With this choice, you can assign a fixed MAC address determined by
|
||||
a NuttX configuration option.
|
||||
|
||||
endchoice # MAC address selection
|
||||
|
||||
config NSH_MACADDR
|
||||
hex "Fixed MAC address"
|
||||
default 0x00e0deadbeef if NET_ETHERNET
|
||||
default 0x00fade00deadbeef if !NET_ETHERNET && NET_6LOWPAN
|
||||
depends on NSH_SWMAC && (NET_ETHERNET || NET_6LOWPAN)
|
||||
---help---
|
||||
If the hardware has no built-in MAC address and if the NSH_SWMAC
|
||||
option is selected, then the fixed, software-assigned MAC address
|
||||
MAC address must provided with this selection.
|
||||
|
||||
endif # NSH_NOMAC
|
||||
|
||||
menu "WAPI Configuration"
|
||||
depends on NET && WIRELESS_WAPI
|
||||
|
||||
config NSH_WAPI_STAMODE
|
||||
int "Wireless mode of operation"
|
||||
default 2
|
||||
range 0 8
|
||||
---help---
|
||||
Mode of operation. See the IW_MODE_* definitions in
|
||||
include/nuttx/wireless/wireless. The default value corresponds to
|
||||
IW_MODE_INFRA
|
||||
|
||||
config NSH_WAPI_AUTHWPA
|
||||
hex "IW_AUTH_WPA_VERSION value"
|
||||
default 0x00000004
|
||||
range 0x00000001 0x00000004
|
||||
---help---
|
||||
IW_AUTH_WPA_VERSION values. See the IW_AUTH_WPA_VERSION_* definitions
|
||||
in include/nuttx/wireless/wireless. The default value corresponds to
|
||||
IW_AUTH_WPA_VERSION_WPA2. NOTE that this is a bit-encoded field. The
|
||||
only valid values are 0x00000001, 0x00000002, and 0x00000004
|
||||
|
||||
config NSH_WAPI_CIPHERMODE
|
||||
hex "IW_AUTH_PAIRWISE_CIPHER and IW_AUTH_GROUP_CIPHER values"
|
||||
default 0x00000008
|
||||
range 0x00000001 0x00000010
|
||||
---help---
|
||||
IW_AUTH_PAIRWISE_CIPHER and IW_AUTH_GROUP_CIPHER values. See the
|
||||
IW_AUTH_CIPHER_* definitions in include/nuttx/wireless/wireless.
|
||||
The default value corresponds to IW_AUTH_CIPHER_CCMP. NOTE that
|
||||
this is a bit-encoded field. The only valid values are 0x00000001,
|
||||
0x00000002,0x00000004, ... 0x00000010
|
||||
|
||||
config NSH_WAPI_ALG
|
||||
int "Algorithm"
|
||||
default 3
|
||||
range 0 13
|
||||
---help---
|
||||
Algorithm. See enum wpa_alg_e in apps/include/wireless/wapi.h. The
|
||||
default corresponds to WPA_ALG_CCMP.
|
||||
|
||||
config NSH_WAPI_SSID
|
||||
string "SSID"
|
||||
default "myApSSID"
|
||||
|
||||
config NSH_WAPI_PASSPHRASE
|
||||
string "Passprhase"
|
||||
default "mySSIDpassphrase"
|
||||
|
||||
endmenu # WAPI Configuration
|
||||
endif # NSH_NETINIT
|
||||
endmenu # Networking Configuration"
|
||||
|
||||
menu "Telnet Configuration"
|
||||
|
@ -72,15 +72,7 @@ CSRCS += nsh_romfsetc.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NET),y)
|
||||
CSRCS += nsh_netinit.c nsh_netcmds.c
|
||||
|
||||
ifeq ($(CONFIG_WIRELESS_WAPI),y)
|
||||
ifeq ($(CONFIG_NSH_NETINIT),y)
|
||||
ifneq ($(CONFIG_NSH_NETLOCAL),y)
|
||||
CSRCS += nsh_associate.c
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
CSRCS += nsh_netcmds.c
|
||||
|
||||
ifeq ($(CONFIG_NET_ROUTE),y)
|
||||
CSRCS += nsh_routecmds.c
|
||||
|
@ -1203,7 +1203,7 @@ o telnetd
|
||||
|
||||
Normally this command would be suppressed with CONFIG_NSH_DISABLE_TELNETD
|
||||
because the Telnet daemon is automatically started in nsh_main.c. The
|
||||
exception is when CONFIG_NSH_NETLOCAL is selected. IN that case, the
|
||||
exception is when CONFIG_NETINIT_NETLOCAL is selected. IN that case, the
|
||||
network is not enabled at initialization but rather must be enabled from
|
||||
the NSH command line or via other applications.
|
||||
|
||||
@ -1836,20 +1836,20 @@ NSH-Specific Configuration Settings
|
||||
Determines the size of the I/O buffer to use for sending/
|
||||
receiving TELNET commands/reponses
|
||||
|
||||
* CONFIG_NSH_DHCPC
|
||||
* CONFIG_NETINIT_DHCPC
|
||||
Obtain the IP address via DHCP.
|
||||
|
||||
* CONFIG_NSH_IPADDR
|
||||
If CONFIG_NSH_DHCPC is NOT set, then the static IP
|
||||
* CONFIG_NETINIT_IPADDR
|
||||
If CONFIG_NETINIT_DHCPC is NOT set, then the static IP
|
||||
address must be provided.
|
||||
|
||||
* CONFIG_NSH_DRIPADDR
|
||||
* CONFIG_NETINIT_DRIPADDR
|
||||
Default router IP address
|
||||
|
||||
* CONFIG_NSH_NETMASK
|
||||
* CONFIG_NETINIT_NETMASK
|
||||
Network mask
|
||||
|
||||
* CONFIG_NSH_NOMAC
|
||||
* CONFIG_NETINIT_NOMAC
|
||||
Set if your ethernet hardware has no built-in MAC address.
|
||||
If set, a bogus MAC will be assigned.
|
||||
|
||||
|
58
nshlib/nsh.h
58
nshlib/nsh.h
@ -104,52 +104,6 @@
|
||||
# define CONFIG_LIBC_TMPDIR "/tmp"
|
||||
#endif
|
||||
|
||||
/* Networking support. Make sure that all non-boolean configuration
|
||||
* settings have some value.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NSH_IPADDR
|
||||
# define CONFIG_NSH_IPADDR 0x0a000002
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NSH_DRIPADDR
|
||||
# define CONFIG_NSH_DRIPADDR 0x0a000001
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NSH_NETMASK
|
||||
# define CONFIG_NSH_NETMASK 0xffffff00
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NSH_DNSIPADDR
|
||||
# define CONFIG_NSH_DNSIPADDR CONFIG_NSH_DRIPADDR
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NSH_MACADDR
|
||||
# define CONFIG_NSH_MACADDR 0x00e0deadbeef
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_NSH_NETINIT_THREAD) || !defined(CONFIG_ARCH_PHY_INTERRUPT) || \
|
||||
!defined(CONFIG_NETDEV_PHY_IOCTL) || !defined(CONFIG_NET_UDP) || \
|
||||
defined(CONFIG_DISABLE_SIGNALS)
|
||||
# undef CONFIG_NSH_NETINIT_MONITOR
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NSH_NETINIT_RETRYMSEC
|
||||
# define CONFIG_NSH_NETINIT_RETRYMSEC 2000
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NSH_NETINIT_SIGNO
|
||||
# define CONFIG_NSH_NETINIT_SIGNO 18
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NSH_NETINIT_THREAD_STACKSIZE
|
||||
# define CONFIG_NSH_NETINIT_THREAD_STACKSIZE 1568
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NSH_NETINIT_THREAD_PRIORITY
|
||||
# define CONFIG_NSH_NETINIT_THREAD_PRIORITY 100
|
||||
#endif
|
||||
|
||||
/* Some networking commands do not make sense unless there is a network
|
||||
* device. There might not be a network device if, for example, only Unix
|
||||
* domain sockets were enable.
|
||||
@ -913,12 +867,6 @@ int nsh_romfsetc(void);
|
||||
# define nsh_romfsetc() (-ENOSYS)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NSH_NETINIT
|
||||
int nsh_netinit(void);
|
||||
#else
|
||||
# define nsh_netinit() (-ENOSYS)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_USB_CONSOLE
|
||||
int nsh_usbconsole(void);
|
||||
#else
|
||||
@ -993,12 +941,6 @@ void nsh_freefullpath(FAR char *fullpath);
|
||||
void nsh_dumpbuffer(FAR struct nsh_vtbl_s *vtbl, const char *msg,
|
||||
const uint8_t *buffer, ssize_t nbytes);
|
||||
|
||||
#ifdef CONFIG_WIRELESS_WAPI
|
||||
/* Wireless */
|
||||
|
||||
int nsh_associate(FAR const char *ifname);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NSH_USBDEV_TRACE
|
||||
/* USB debug support */
|
||||
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include <sys/boardctl.h>
|
||||
|
||||
#include "system/readline.h"
|
||||
#include "netutils/netinit.h"
|
||||
#include "nshlib/nshlib.h"
|
||||
|
||||
#include "nsh.h"
|
||||
@ -103,7 +104,9 @@ void nsh_initialize(void)
|
||||
(void)boardctl(BOARDIOC_INIT, 0);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NSH_NETINIT
|
||||
/* Bring up the network */
|
||||
|
||||
(void)nsh_netinit();
|
||||
(void)netinit_bringup();
|
||||
#endif
|
||||
}
|
||||
|
@ -102,7 +102,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NSH_DHCPC) || defined(CONFIG_NSH_DNS)
|
||||
#if defined(CONFIG_NETINIT_DHCPC) || defined(CONFIG_NETINIT_DNS)
|
||||
# include "netutils/dhcpc.h"
|
||||
#endif
|
||||
|
||||
@ -564,7 +564,7 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
#ifdef HAVE_HWADDR
|
||||
FAR char *hw = NULL;
|
||||
#endif
|
||||
#if defined(CONFIG_NSH_DHCPC) || defined(CONFIG_NSH_DNS)
|
||||
#if defined(CONFIG_NETINIT_DHCPC) || defined(CONFIG_NETINIT_DNS)
|
||||
FAR char *dns = NULL;
|
||||
#endif
|
||||
#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6)
|
||||
@ -575,7 +575,7 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
#ifdef HAVE_HWADDR
|
||||
mac_addr_t macaddr;
|
||||
#endif
|
||||
#if defined(CONFIG_NSH_DHCPC)
|
||||
#if defined(CONFIG_NETINIT_DHCPC)
|
||||
FAR void *handle;
|
||||
#endif
|
||||
int ret;
|
||||
@ -679,7 +679,7 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NSH_DHCPC) || defined(CONFIG_NSH_DNS)
|
||||
#if defined(CONFIG_NETINIT_DHCPC) || defined(CONFIG_NETINIT_DNS)
|
||||
else if (!strcmp(tmp, "dns"))
|
||||
{
|
||||
if (argc - 1 >= i + 1)
|
||||
@ -754,7 +754,7 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
if (hostip != NULL)
|
||||
{
|
||||
#if defined(CONFIG_NSH_DHCPC)
|
||||
#if defined(CONFIG_NETINIT_DHCPC)
|
||||
if (strcmp(hostip, "dhcp") == 0)
|
||||
{
|
||||
/* Set DHCP addr */
|
||||
@ -869,7 +869,7 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
|
||||
UNUSED(ifname); /* Not used in all configurations */
|
||||
|
||||
#if defined(CONFIG_NSH_DHCPC) || defined(CONFIG_NSH_DNS)
|
||||
#if defined(CONFIG_NETINIT_DHCPC) || defined(CONFIG_NETINIT_DNS)
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
if (inet6)
|
||||
@ -898,9 +898,9 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
netlib_set_ipv4dnsaddr(&addr);
|
||||
}
|
||||
#endif /* CONFIG_NET_IPv4 */
|
||||
#endif /* CONFIG_NSH_DHCPC || CONFIG_NSH_DNS */
|
||||
#endif /* CONFIG_NETINIT_DHCPC || CONFIG_NETINIT_DNS */
|
||||
|
||||
#if defined(CONFIG_NSH_DHCPC)
|
||||
#if defined(CONFIG_NETINIT_DHCPC)
|
||||
/* Get the MAC address of the NIC */
|
||||
|
||||
if (!gip)
|
||||
|
@ -284,7 +284,7 @@ int nsh_telnetstart(sa_family_t family)
|
||||
*
|
||||
* Normally this command would be suppressed with CONFIG_NSH_DISABLE_TELNETD
|
||||
* because the Telnet daemon is automatically started in nsh_main.c. The
|
||||
* exception is when CONFIG_NSH_NETLOCAL is selected. IN that case, the
|
||||
* exception is when CONFIG_NETINIT_NETLOCAL is selected. IN that case, the
|
||||
* network is not enabled at initialization but rather must be enabled from
|
||||
* the NSH command line or via other applications.
|
||||
*
|
||||
|
@ -215,10 +215,10 @@ static int nsh_task(void)
|
||||
|
||||
nsh_initialize();
|
||||
|
||||
#if defined(CONFIG_NSH_TELNET) && !defined(CONFIG_NSH_NETLOCAL)
|
||||
#if defined(CONFIG_NSH_TELNET) && !defined(CONFIG_NETINIT_NETLOCAL)
|
||||
/* If the Telnet console is selected as a front-end, then start the
|
||||
* Telnet daemon UNLESS network initialization is deferred via
|
||||
* CONFIG_NSH_NETLOCAL. In that case, the telnet daemon must be
|
||||
* CONFIG_NETINIT_NETLOCAL. In that case, the telnet daemon must be
|
||||
* started manually with the telnetd command after the network has
|
||||
* been initialized
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user