apps/examples/nettest: Add option to suppress networking initialization

This commit is contained in:
Gregory Nutt 2015-08-26 09:06:41 -06:00
parent b7b943067a
commit 6cedfcd632
3 changed files with 59 additions and 16 deletions

View File

@ -1412,4 +1412,7 @@
substantial effect on system image size. Mainly code/text. If
loading of applications at runtime is not planned do not select
this. From Pavel Pisa (2015-08-23).
* apps/nettest: Add option to suppress network initialization. This
is necessary if the nettest is run from NSH which has already
initialized the network (2015-08-26).

View File

@ -26,10 +26,6 @@ config EXAMPLES_NETTEST_PERFORMANCE
Configure the example to test for network performance. Default: Test
is for network functionality.
config EXAMPLES_NETTEST_NOMAC
bool "Use Canned MAC Address"
default n
choice
prompt "IP Domain"
default EXAMPLES_NETTEST_IPv4 if NET_IPv4
@ -45,10 +41,28 @@ config EXAMPLES_NETTEST_IPv6
endchoice # IP Domain
config EXAMPLES_NETTEST_INIT
bool "Initialize network"
default n if NSH_BUILTIN_APPS
default y if !NSH_BUILTIN_APPS
depends on !BUILD_KERNEL
---help---
Include logic to initialize the network. This should not be done if
the network is already initialized when nettest runs. This is
usually the case, for example, when nettest is run as an NSH built-
in task.
config EXAMPLES_NETTEST_NOMAC
bool "Use Canned MAC Address"
default n
depends on EXAMPLES_NETTEST_INIT
if EXAMPLES_NETTEST_IPv4
comment "IPv4 addresses"
if EXAMPLES_NETTEST_INIT
config EXAMPLES_NETTEST_IPADDR
hex "Target IP address"
default 0x0a000002
@ -61,6 +75,8 @@ config EXAMPLES_NETTEST_NETMASK
hex "Network Mask"
default 0xffffff00
endif # EXAMPLES_NETTEST_INIT
config EXAMPLES_NETTEST_CLIENTIP
hex "Client IP Address"
default 0x0a000001 if !EXAMPLES_NETTEST_SERVER
@ -80,6 +96,8 @@ if !NET_ICMPv6_AUTOCONF
comment "Target IPv6 address"
if EXAMPLES_NETTEST_INIT
config EXAMPLES_NETTEST_IPv6ADDR_1
hex "[0]"
default 0xfc00
@ -325,6 +343,7 @@ config EXAMPLES_NETTEST_IPv6NETMASK_8
all eight values is fe00::0.
endif # NET_ICMPv6_AUTOCONF
endif # EXAMPLES_NETTEST_INIT
comment "Client IPv6 address"

View File

@ -60,7 +60,9 @@
* Private Data
****************************************************************************/
#if defined(CONFIG_EXAMPLES_NETTEST_IPv6) && !defined(CONFIG_NET_ICMPv6_AUTOCONF)
#if defined(CONFIG_EXAMPLES_NETTEST_INIT) && \
defined(CONFIG_EXAMPLES_NETTEST_IPv6) && \
!defined(CONFIG_NET_ICMPv6_AUTOCONF)
/* Our host IPv6 address */
static const uint16_t g_ipv6_hostaddr[8] =
@ -102,21 +104,14 @@ static const uint16_t g_ipv6_netmask[8] =
HTONS(CONFIG_EXAMPLES_NETTEST_IPv6NETMASK_7),
HTONS(CONFIG_EXAMPLES_NETTEST_IPv6NETMASK_8),
};
#endif /* CONFIG_EXAMPLES_NETTEST_IPv6 && !CONFIG_NET_ICMPv6_AUTOCONF */
#endif /* CONFIG_EXAMPLES_NETTEST_INIT && CONFIG_EXAMPLES_NETTEST_IPv6 && !CONFIG_NET_ICMPv6_AUTOCONF */
/****************************************************************************
* Public Functions
* Private Functions
****************************************************************************/
/****************************************************************************
* nettest_main
****************************************************************************/
#ifdef CONFIG_BUILD_KERNEL
int main(int argc, FAR char *argv[])
#else
int nettest_main(int argc, char *argv[])
#endif
#ifdef CONFIG_EXAMPLES_NETTEST_INIT
static void netest_initialize(void)
{
#ifndef CONFIG_EXAMPLES_NETTEST_IPv6
struct in_addr addr;
@ -179,10 +174,36 @@ int nettest_main(int argc, char *argv[])
netlib_set_ipv4netmask("eth0", &addr);
#endif /* CONFIG_EXAMPLES_NETTEST_IPv6 */
}
#endif /*CONFIG_EXAMPLES_NETTEST_INIT */
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* nettest_main
****************************************************************************/
#ifdef CONFIG_BUILD_KERNEL
int main(int argc, FAR char *argv[])
#else
int nettest_main(int argc, char *argv[])
#endif
{
#ifdef CONFIG_EXAMPLES_NETTEST_INIT
/* Initialize the network */
netest_initialize();
#endif
#ifdef CONFIG_EXAMPLES_NETTEST_SERVER
/* Then perform the server side of the test */
recv_server();
#else
/* Then perform the client side of the test */
send_client();
#endif