From 8c1446671c4310e6837830888c39d5c66839648b Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 21 May 2017 12:00:55 -0600 Subject: [PATCH] apps/nshlib: Add a new option CONFIG_NSH_NETLOCAL that will suppress some built in operations and will support manual configuration of a wireless network --- nshlib/Kconfig | 26 +++++++++++++++++++++++++- nshlib/Makefile | 4 ++++ nshlib/nsh_netinit.c | 13 ++++++++----- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/nshlib/Kconfig b/nshlib/Kconfig index e3dd1fbae..deb9afa4c 100644 --- a/nshlib/Kconfig +++ b/nshlib/Kconfig @@ -1009,10 +1009,34 @@ config NSH_NETINIT 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 is needed and any IP + addresses as needed. More importantly, it will not do the following: + + - It will not bring the netup up. The 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 divid 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 + 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 diff --git a/nshlib/Makefile b/nshlib/Makefile index 47ea7ab9f..50adedf40 100644 --- a/nshlib/Makefile +++ b/nshlib/Makefile @@ -74,11 +74,15 @@ 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 + ifeq ($(CONFIG_NET_ROUTE),y) CSRCS += nsh_routecmds.c endif diff --git a/nshlib/nsh_netinit.c b/nshlib/nsh_netinit.c index 00a952877..d030bf7d4 100644 --- a/nshlib/nsh_netinit.c +++ b/nshlib/nsh_netinit.c @@ -248,11 +248,12 @@ static void nsh_netinit_configure(void) struct in_addr addr; #endif -#if defined(CONFIG_NSH_DHCPC) +#if defined(CONFIG_NSH_DHCPC) && !defined(CONFIG_NSH_NETLOCAL) FAR void *handle; #endif -#if (defined(CONFIG_NSH_DHCPC) || defined(CONFIG_NSH_NOMAC)) && defined(HAVE_MAC) +#if (((defined(CONFIG_NSH_DHCPC) && !defined(CONFIG_NSH_NETLOCAL)) || \ + defined(CONFIG_NSH_NOMAC)) && defined(HAVE_MAC)) #if defined(CONFIG_NET_ETHERNET) uint8_t mac[IFHWADDRLEN]; #elif defined(CONFIG_NET_6LOWPAN) @@ -358,9 +359,10 @@ static void nsh_netinit_configure(void) netlib_set_ipv4dnsaddr(&addr); #endif - /* New versions of netlib_set_ipvXaddr will not bring the network up, - * So ensure the network is really up at this point. - */ + /* That completes the 'local' initialization of the network device. */ + +#ifndef CONFIG_NSH_NETLOCAL + /* Bring the network up. */ netlib_ifup("eth0"); @@ -413,6 +415,7 @@ static void nsh_netinit_configure(void) ntpc_start(); #endif +#endif /* CONFIG_NSH_NETLOCAL */ #endif /* NSH_HAVE_NETDEV */ ninfo("Exit\n");