From eef0161dd4b64481048ddc5ada2393a67d01a5d1 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 3 Apr 2017 15:33:39 -0600 Subject: [PATCH] examples/nettest: Trying to adapt to use for testing 6loWPAN. --- examples/nettest/Kconfig | 24 ++++++++++++++++++++---- examples/nettest/Makefile | 10 ++++++++-- examples/nettest/nettest.c | 4 ++-- examples/nettest/nettest_client.c | 12 ++++++++++-- nshlib/nsh_netinit.c | 10 +++++++--- 5 files changed, 47 insertions(+), 13 deletions(-) diff --git a/examples/nettest/Kconfig b/examples/nettest/Kconfig index 7f5d8d8b0..d12d4a618 100644 --- a/examples/nettest/Kconfig +++ b/examples/nettest/Kconfig @@ -12,21 +12,37 @@ config EXAMPLES_NETTEST if EXAMPLES_NETTEST +config EXAMPLES_NETTEST_PROGNAME + string "Program name" + default "nettest" + depends on BUILD_KERNEL + ---help--- + This is the name of the program that will be use when the Nettest + program is installed. + +config EXAMPLES_NETTEST_STACKSIZE + int "Nettest stack size" + default 2048 + +config EXAMPLES_NETTEST_PRIORITY + int "Nettest priority" + default 100 + config EXAMPLES_NETTEST_LOOPBACK bool "Loopback test" default n - depends on NET_LOOPBACK + depends on NET_LOOPBACK || IEEE802154_LOOPBACK ---help--- Perform the test using the local loopback device. In this case, both the client and the server reside on the target. if EXAMPLES_NETTEST_LOOPBACK -config EXAMPLES_NETTEST_STACKSIZE +config EXAMPLES_NETTEST_SERVER_STACKSIZE int "Server stack size" default 2048 -config EXAMPLES_NETTEST_PRIORITY +config EXAMPLES_NETTEST_SERVER_PRIORITY int "Server priority" default 100 @@ -369,7 +385,7 @@ config EXAMPLES_NETTEST_IPv6NETMASK_8 endif # NET_ICMPv6_AUTOCONF endif # EXAMPLES_NETTEST_INIT -if !EXAMPLES_NETTEST_LOOPBACK +if !EXAMPLES_NETTEST_LOOPBACK || !NET_LOOPBACK comment "Client IPv6 address" diff --git a/examples/nettest/Makefile b/examples/nettest/Makefile index 08a6a8737..6fc5a26af 100644 --- a/examples/nettest/Makefile +++ b/examples/nettest/Makefile @@ -106,9 +106,15 @@ ROOTDEPPATH = --dep-path . # NET test built-in application info +CONFIG_EXAMPLES_NETTEST_STACKSIZE ?= 2048 +CONFIG_EXAMPLES_NETTEST_PRIORITY ?= 100 + APPNAME = nettest -PRIORITY = SCHED_PRIORITY_DEFAULT -STACKSIZE = 2048 +PRIORITY = $(CONFIG_EXAMPLES_NETTEST_PRIORITY) +STACKSIZE = $(CONFIG_EXAMPLES_NETTEST_STACKSIZE) + +CONFIG_EXAMPLES_NETTEST_PROGNAME ?= nettest$(EXEEXT) +PROGNAME = $(CONFIG_EXAMPLES_HELLO_PROGNAME) # Common build diff --git a/examples/nettest/nettest.c b/examples/nettest/nettest.c index e9f0d5652..12b33e02b 100644 --- a/examples/nettest/nettest.c +++ b/examples/nettest/nettest.c @@ -219,8 +219,8 @@ int nettest_main(int argc, char *argv[]) #if defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK) /* Then perform the server side of the test on a child task */ - child = task_create("Nettest Child", CONFIG_EXAMPLES_NETTEST_PRIORITY, - CONFIG_EXAMPLES_NETTEST_STACKSIZE, server_child, + child = task_create("Nettest Child", CONFIG_EXAMPLES_NETTEST_SERVER_PRIORITY, + CONFIG_EXAMPLES_NETTEST_SERVER_STACKSIZE, server_child, NULL); if (child < 0) { diff --git a/examples/nettest/nettest_client.c b/examples/nettest/nettest_client.c index d377a9b3a..8de196bca 100644 --- a/examples/nettest/nettest_client.c +++ b/examples/nettest/nettest_client.c @@ -106,8 +106,8 @@ void send_client(void) myaddr.sin6_family = AF_INET6; myaddr.sin6_port = HTONS(PORTNO); -#ifdef CONFIG_EXAMPLES_NETTEST_LOOPBACK - myaddr.sin6_addr.s6_addr16[0] = 0; +#if defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK) && defined(NET_LOOPBACK) + myaddr.sin6_addr.s6_addr16[0] = 0; /* Use the loopback address */ myaddr.sin6_addr.s6_addr16[1] = 0; myaddr.sin6_addr.s6_addr16[2] = 0; myaddr.sin6_addr.s6_addr16[3] = 0; @@ -126,6 +126,12 @@ void send_client(void) myaddr.sin6_addr.s6_addr16[7] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_8); #endif + printf("IPv6 Address: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", + myaddr.sin6_addr.s6_addr16[0], myaddr.sin6_addr.s6_addr16[1], + myaddr.sin6_addr.s6_addr16[2], myaddr.sin6_addr.s6_addr16[3], + myaddr.sin6_addr.s6_addr16[4], myaddr.sin6_addr.s6_addr16[5], + myaddr.sin6_addr.s6_addr16[6], myaddr.sin6_addr.s6_addr16[7]); + addrlen = sizeof(struct sockaddr_in6); #else myaddr.sin_family = AF_INET; @@ -137,6 +143,8 @@ void send_client(void) myaddr.sin_addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_CLIENTIP); #endif + printf("IPv4 Address: %08x\n", myaddr.sin_addr.s_addr); + addrlen = sizeof(struct sockaddr_in); #endif diff --git a/nshlib/nsh_netinit.c b/nshlib/nsh_netinit.c index 407802f5f..8ee0958ef 100644 --- a/nshlib/nsh_netinit.c +++ b/nshlib/nsh_netinit.c @@ -101,13 +101,17 @@ /* Select the single network device name supported this this network * initialization logci. If multiple interfaces are present with different - * link types, the the orider of definition in the following conditional - * logic will select the one interface that will be used. + * link types, the the order of definition in the following conditional + * logic will select the one interface that will be used (which might + * not be the one that you want). */ #if defined(CONFIG_NET_ETHERNET) # define NET_DEVNAME "eth0" # define NSH_HAVE_NETDEV +#elif defined(CONFIG_NET_6LOWPAN) +# define NET_DEVNAME "wpan0" +# define NSH_HAVE_NETDEV #elif defined(CONFIG_NET_SLIP) # define NET_DEVNAME "sl0" # ifndef CONFIG_NSH_NOMAC @@ -202,7 +206,7 @@ static const uint16_t g_ipv6_netmask[8] = HTONS(CONFIG_NSH_IPv6NETMASK_7), HTONS(CONFIG_NSH_IPv6NETMASK_8), }; -#endif /* CONFIG_NET_IPv6 && !CONFIG_NET_ICMPv6_AUTOCONF*/ +#endif /* CONFIG_NET_IPv6 && !CONFIG_NET_ICMPv6_AUTOCONF */ /**************************************************************************** * Private Functions