examples/nettest: Trying to adapt to use for testing 6loWPAN.

This commit is contained in:
Gregory Nutt 2017-04-03 15:33:39 -06:00
parent efa2de16a4
commit eef0161dd4
5 changed files with 47 additions and 13 deletions

View File

@ -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"

View File

@ -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

View File

@ -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)
{

View File

@ -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

View File

@ -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