From 62f2b8a7cdc34c1a623c81d12dd82ae0e2dbf5f1 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 20 Jun 2017 07:08:27 -0600 Subject: [PATCH 01/19] examples/smart: Fix some compilation errors. Obviously this test has not been used in a LONG time. --- examples/smart/smart_main.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/examples/smart/smart_main.c b/examples/smart/smart_main.c index 0504ec976..56df54d73 100644 --- a/examples/smart/smart_main.c +++ b/examples/smart/smart_main.c @@ -55,7 +55,8 @@ #include #include #include -#include + +#include "fsutils/mksmartfs.h" /**************************************************************************** * Pre-processor Definitions @@ -821,7 +822,7 @@ int smart_main(int argc, char *argv[]) /* Initialize to provide SMART on an MTD interface */ MTD_IOCTL(mtd, MTDIOC_BULKERASE, 0); - ret = smart_initialize(1, mtd); + ret = smart_initialize(1, mtd, "SmartTest"); if (ret < 0) { printf("ERROR: SMART initialization failed: %d\n", -ret); @@ -831,7 +832,11 @@ int smart_main(int argc, char *argv[]) /* Create a SMARTFS filesystem */ - (void)mksmartfs("/dev/smart1"); +#ifdef CONFIG_SMARTFS_MULTI_ROOT_DIRS + (void)mksmartfs("/dev/smart1", 1024, 1); +#else + (void)mksmartfs("/dev/smart1", 1024); +#endif /* Mount the file system */ From c0286c1276007dd6a231d81a441f9812d7258856 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 20 Jun 2017 10:40:09 -0600 Subject: [PATCH 02/19] examples/udp: Port numbers need to be configurable to work with 6LoWPAN. Need to bind the client socket to a port number. This was not required before so is a apparently a change in the UDP packet dispatch logic. --- examples/udp/Kconfig | 9 ++++++ examples/udp/udp.h | 8 ++++- examples/udp/udp_client.c | 61 +++++++++++++++++++++++++++++++++++--- examples/udp/udp_cmdline.c | 2 +- examples/udp/udp_server.c | 4 +-- 5 files changed, 76 insertions(+), 8 deletions(-) diff --git a/examples/udp/Kconfig b/examples/udp/Kconfig index 62253544e..392ab6f73 100644 --- a/examples/udp/Kconfig +++ b/examples/udp/Kconfig @@ -511,4 +511,13 @@ config EXAMPLES_UDP_SERVERIPv6ADDR_8 This is the last of the 8-values. endif # EXAMPLES_UDP_IPv6 + +config EXAMPLES_SERVER_PORTNO + int "Server port number" + default 5471 + +config EXAMPLES_CLIENT_PORTNO + int "Client port number" + default 5472 + endif # EXAMPLES_UDP diff --git a/examples/udp/udp.h b/examples/udp/udp.h index 610da91c4..9316240be 100644 --- a/examples/udp/udp.h +++ b/examples/udp/udp.h @@ -83,7 +83,13 @@ # define PF_INETX PF_INET #endif -#define PORTNO 5471 +#ifndef CONFIG_EXAMPLES_SERVER_PORTNO +# define CONFIG_EXAMPLES_SERVER_PORTNO 5471 +#endif + +#ifndef CONFIG_EXAMPLES_CLIENT_PORTNO +# define CONFIG_EXAMPLES_CLIENT_PORTNO 5472 +#endif #define ASCIISIZE (0x7f - 0x20) #define SENDSIZE (ASCIISIZE+1) diff --git a/examples/udp/udp_client.c b/examples/udp/udp_client.c index 4d13a2649..18368c1a3 100644 --- a/examples/udp/udp_client.c +++ b/examples/udp/udp_client.c @@ -57,6 +57,59 @@ * Private Functions ****************************************************************************/ +static int create_socket(void) +{ + socklen_t addrlen; + int sockfd; + +#ifdef CONFIG_EXAMPLES_UDP_IPv4 + struct sockaddr_in addr; + + /* Create a new IPv4 UDP socket */ + + sockfd = socket(AF_INET, SOCK_DGRAM, 0); + if (sockfd < 0) + { + printf("client ERROR: client socket failure %d\n", errno); + return -1; + } + + /* Bind the UDP socket to a IPv4 port */ + + addr.sin_family = AF_INET; + addr.sin_port = HTONS(CONFIG_EXAMPLES_CLIENT_PORTNO); + addr.sin_addr.s_addr = HTONL(INADDR_ANY); + addrlen = sizeof(struct sockaddr_in); + +#else + struct sockaddr_in6 addr; + + /* Create a new IPv6 UDP socket */ + + sockfd = socket(AF_INET6, SOCK_DGRAM, 0); + if (sockfd < 0) + { + printf("client ERROR: client socket failure %d\n", errno); + return -1; + } + + /* Bind the UDP socket to a IPv6 port */ + + addr.sin6_family = AF_INET6; + addr.sin6_port = HTONS(CONFIG_EXAMPLES_CLIENT_PORTNO); + memset(addr.sin6_addr.s6_addr, 0, sizeof(struct in6_addr)); + addrlen = sizeof(struct sockaddr_in6); +#endif + + if (bind(sockfd, (FAR struct sockaddr *)&addr, addrlen) < 0) + { + printf("client ERROR: Bind failure: %d\n", errno); + return -1; + } + + return sockfd; +} + static inline void fill_buffer(unsigned char *buf, int offset) { int ch; @@ -92,10 +145,10 @@ void send_client(void) /* Create a new UDP socket */ - sockfd = socket(PF_INETX, SOCK_DGRAM, 0); + sockfd = create_socket(); if (sockfd < 0) { - printf("client socket failure %d\n", errno); + printf("client ERROR: create_socket failed %d\n"); exit(1); } @@ -111,12 +164,12 @@ void send_client(void) #ifdef CONFIG_EXAMPLES_UDP_IPv6 server.sin6_family = AF_INET6; - server.sin6_port = HTONS(PORTNO); + server.sin6_port = HTONS(CONFIG_EXAMPLES_SERVER_PORTNO); memcpy(server.sin6_addr.s6_addr16, g_server_ipv6, 8 * sizeof(uint16_t)); addrlen = sizeof(struct sockaddr_in6); #else server.sin_family = AF_INET; - server.sin_port = HTONS(PORTNO); + server.sin_port = HTONS(CONFIG_EXAMPLES_SERVER_PORTNO); server.sin_addr.s_addr = (in_addr_t)g_server_ipv4; addrlen = sizeof(struct sockaddr_in); #endif diff --git a/examples/udp/udp_cmdline.c b/examples/udp/udp_cmdline.c index 13695cf48..8eb93f8d8 100644 --- a/examples/udp/udp_cmdline.c +++ b/examples/udp/udp_cmdline.c @@ -50,7 +50,7 @@ ****************************************************************************/ #ifdef CONFIG_EXAMPLES_UDP_IPv6 -uint16_t g_server_ipv6[8] = +uint16_t g_server_ipv6[8] = { HTONS(CONFIG_EXAMPLES_UDP_SERVERIPv6ADDR_1), HTONS(CONFIG_EXAMPLES_UDP_SERVERIPv6ADDR_2), diff --git a/examples/udp/udp_server.c b/examples/udp/udp_server.c index f9fbbdc84..03233d68b 100644 --- a/examples/udp/udp_server.c +++ b/examples/udp/udp_server.c @@ -124,13 +124,13 @@ void recv_server(void) #ifdef CONFIG_EXAMPLES_UDP_IPv6 server.sin6_family = AF_INET6; - server.sin6_port = HTONS(PORTNO); + server.sin6_port = HTONS(CONFIG_EXAMPLES_SERVER_PORTNO); memset(&server.sin6_addr, 0, sizeof(struct in6_addr)); addrlen = sizeof(struct sockaddr_in6); #else server.sin_family = AF_INET; - server.sin_port = HTONS(PORTNO); + server.sin_port = HTONS(CONFIG_EXAMPLES_SERVER_PORTNO); server.sin_addr.s_addr = HTONL(INADDR_ANY); addrlen = sizeof(struct sockaddr_in); From f96b4b15f4c41f1e0f69bf6f6c60a9b7086d7094 Mon Sep 17 00:00:00 2001 From: Anthony Merlino Date: Wed, 21 Jun 2017 15:27:04 -0400 Subject: [PATCH 03/19] wireless/ieee802154: Adds option to make it easy to send large frame for testing purposes --- wireless/ieee802154/i8sak/i8sak_tx.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/wireless/ieee802154/i8sak/i8sak_tx.c b/wireless/ieee802154/i8sak/i8sak_tx.c index 856d7dcb3..56fc83454 100644 --- a/wireless/ieee802154/i8sak/i8sak_tx.c +++ b/wireless/ieee802154/i8sak/i8sak_tx.c @@ -80,6 +80,7 @@ void i8sak_tx_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) enum ieee802154_devmode_e devmode; struct wpanlistener_eventfilter_s eventfilter; bool sendasdev = false; + bool sendmax = false; int argind; int option; int fd; @@ -87,7 +88,7 @@ void i8sak_tx_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) ret = OK; argind = 1; - while ((option = getopt(argc, argv, ":hd")) != ERROR) + while ((option = getopt(argc, argv, ":hdm")) != ERROR) { switch (option) { @@ -96,6 +97,7 @@ void i8sak_tx_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) "Usage: %s [-h|d] []\n" " -h = this help menu\n" " -d = send as device instead of coord\n" + " -m = send the largest frame possible" , argv[0]); /* Must manually reset optind if we are going to exit early */ @@ -107,6 +109,11 @@ void i8sak_tx_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) sendasdev = true; argind++; break; + + case 'm': + sendmax = true; + argind++; + break; case ':': fprintf(stderr, "ERROR: missing argument\n"); @@ -132,6 +139,11 @@ void i8sak_tx_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) { i8sak->payload_len = i8sak_str2payload(argv[1], &i8sak->payload[0]); } + + if (sendmax) + { + i8sak->payload_len = IEEE802154_MAX_SAFE_MAC_PAYLOAD_SIZE; + } fd = open(i8sak->devname, O_RDWR); if (fd < 0) From 4f64213758235cc6a664b0d0675406a401392f82 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 23 Jun 2017 10:58:41 -0600 Subject: [PATCH 04/19] examples/udp: Renaming some files to prevent name collision in libapps.a --- examples/udp/Makefile | 15 ++++++++------- examples/udp/{host.c => udp_host.c} | 2 +- examples/udp/{target1.c => udp_target1.c} | 2 +- examples/udp/{target2.c => udp_target2.c} | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) rename examples/udp/{host.c => udp_host.c} (99%) rename examples/udp/{target1.c => udp_target1.c} (98%) rename examples/udp/{target2.c => udp_target2.c} (98%) diff --git a/examples/udp/Makefile b/examples/udp/Makefile index 0627426e6..1e80bba84 100644 --- a/examples/udp/Makefile +++ b/examples/udp/Makefile @@ -1,7 +1,7 @@ ############################################################################ # apps/examples/udp/Makefile # -# Copyright (C) 2007-2008, 2011-2012, 2014 Gregory Nutt. All rights reserved. +# Copyright (C) 2007-2008, 2011-2012, 2014, 2017 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -53,7 +53,7 @@ TARG1_CRCS += udp_server.c else TARG1_CRCS += udp_client.c endif -TARG1_MAINSRC = target1.c +TARG1_MAINSRC = udp_target1.c TARG1_COBJS = $(TARG1_CRCS:.c=$(OBJEXT)) TARG1_MAINOBJ = $(TARG1_MAINSRC:.c=$(OBJEXT)) @@ -82,7 +82,7 @@ TARG2_CRCS += udp_client.c else TARG2_CRCS += udp_server.c endif -TARG2_MAINSRC = target2.c +TARG2_MAINSRC = udp_target2.c TARG2_COBJS = $(TARG2_CRCS:.c=$(OBJEXT)) TARG2_MAINOBJ = $(TARG2_MAINSRC:.c=$(OBJEXT)) @@ -97,6 +97,7 @@ endif CONFIG_EXAMPLES_UDP_PRIORITY2 ?= 100 CONFIG_EXAMPLES_UDP_STACKSIZE2 ?= 2048 + PROGNAME2 = $(CONFIG_EXAMPLES_UDP_PROGNAME2) PRIORITY2 = $(CONFIG_EXAMPLES_UDP_PRIORITY2) STACKSIZE2 = $(CONFIG_EXAMPLES_UDP_STACKSIZE2) @@ -117,16 +118,16 @@ ifneq ($(CONFIG_EXAMPLES_UDP_TARGET2),y) HOSTCFLAGS += -DEXAMPLES_UDP_HOST=1 HOSTOBJSEXT ?= o1 -HOST_SRCS = host.c udp_cmdline.c +HOST_SRCS = udp_host.c udp_cmdline.c ifeq ($(CONFIG_EXAMPLES_UDP_SERVER1),y) HOST_SRCS += udp_client.c +HOST_BIN = udpclient$(EXEEXT) else HOST_SRCS += udp_server.c +HOST_BIN = udpserver$(EXEEXT) endif HOST_OBJS = $(HOST_SRCS:.c=.$(HOSTOBJSEXT)) -HOST_BIN = host$(EXEEXT) - endif ifeq ($(CONFIG_WINDOWS_NATIVE),y) @@ -161,7 +162,7 @@ VPATH = all: .built .PHONY: clean depend distclean preconfig -$(TARG1_COBJS) $(TARG1_MAINOBJ)$(TARG2_COBJS) $(TARG2_MAINOBJ) $(TARGCMN_COBJS): %$(OBJEXT): %.c +$(TARG1_COBJS) $(TARG1_MAINOBJ) $(TARG2_COBJS) $(TARG2_MAINOBJ) $(TARGCMN_COBJS): %$(OBJEXT): %.c $(call COMPILE, $<, $@) $(TARG_BIN): $(TARG_OBJS) $(HOST_BIN) diff --git a/examples/udp/host.c b/examples/udp/udp_host.c similarity index 99% rename from examples/udp/host.c rename to examples/udp/udp_host.c index f51410913..7e1aaacc5 100644 --- a/examples/udp/host.c +++ b/examples/udp/udp_host.c @@ -1,5 +1,5 @@ /**************************************************************************** - * examples/udp/host.c + * examples/udp/udp_host.c * * Copyright (C) 2007 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/examples/udp/target1.c b/examples/udp/udp_target1.c similarity index 98% rename from examples/udp/target1.c rename to examples/udp/udp_target1.c index f64c7e098..ce655aec5 100644 --- a/examples/udp/target1.c +++ b/examples/udp/udp_target1.c @@ -1,5 +1,5 @@ /**************************************************************************** - * examples/udp/target1.c + * examples/udp/udp_target1.c * * Copyright (C) 2007, 2011, 2015, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/examples/udp/target2.c b/examples/udp/udp_target2.c similarity index 98% rename from examples/udp/target2.c rename to examples/udp/udp_target2.c index 84332504b..0fcb6e37c 100644 --- a/examples/udp/target2.c +++ b/examples/udp/udp_target2.c @@ -1,5 +1,5 @@ /**************************************************************************** - * examples/udp/target2.c + * examples/udp/udp_target2.c * * Copyright (C) 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt From 41457d6fe8cd3d6cf5db4737967f665bd8b76159 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 23 Jun 2017 11:23:43 -0600 Subject: [PATCH 05/19] examples/nettest: Renaming some files to prevent name collision in libapps.a and to prepare to support target boards on both ends of the test --- examples/nettest/Makefile | 62 +++++++++---------- examples/nettest/{host.c => nettest_host.c} | 2 +- .../nettest/{nettest.c => nettest_target1.c} | 2 +- examples/udp/Makefile | 2 +- 4 files changed, 31 insertions(+), 37 deletions(-) rename examples/nettest/{host.c => nettest_host.c} (98%) rename examples/nettest/{nettest.c => nettest_target1.c} (99%) diff --git a/examples/nettest/Makefile b/examples/nettest/Makefile index a76a15d46..e51da8fdd 100644 --- a/examples/nettest/Makefile +++ b/examples/nettest/Makefile @@ -1,7 +1,7 @@ ############################################################################ # examples/nettest/Makefile # -# Copyright (C) 2007-2008, 2010-2012 Gregory Nutt. All rights reserved. +# Copyright (C) 2007-2008, 2010-2012, 2017 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -39,27 +39,24 @@ include $(APPDIR)/Make.defs # Basic TCP networking test -TARG_ASRCS = -TARG_AOBJS = $(TARG_ASRCS:.S=$(OBJEXT)) - -TARG_CSRCS = +TARG1_CSRCS = ifeq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y) -TARG_CSRCS += nettest_server.c nettest_client.c +TARG1_CSRCS += nettest_server.c nettest_client.c else ifeq ($(CONFIG_EXAMPLES_NETTEST_SERVER),y) -TARG_CSRCS += nettest_server.c +TARG1_CSRCS += nettest_server.c else -TARG_CSRCS += nettest_client.c +TARG1_CSRCS += nettest_client.c endif -TARG_MAINSRC = nettest.c +TARG1_MAINSRC = nettest_target1.c -TARG_COBJS = $(TARG_CSRCS:.c=$(OBJEXT)) -TARG_MAINOBJ = $(TARG_MAINSRC:.c=$(OBJEXT)) +TARG1_COBJS = $(TARG1_CSRCS:.c=$(OBJEXT)) +TARG1_MAINOBJ = $(TARG1_MAINSRC:.c=$(OBJEXT)) -TARG_SRCS = $(TARG_ASRCS) $(TARG_CSRCS) $(TARG_CSRCS) -TARG_OBJS = $(TARG_AOBJS) $(TARG_COBJS) +TARG_CSRCS = $(TARG1_CSRCS) $(TARG1_CSRCS) +TARG_OBJS = $(TARG1_COBJS) ifneq ($(CONFIG_BUILD_KERNEL),y) - TARG_OBJS += $(TARG_MAINOBJ) + TARG_OBJS += $(TARG1_MAINOBJ) endif ifeq ($(CONFIG_WINDOWS_NATIVE),y) @@ -81,16 +78,17 @@ ifneq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y) HOSTCFLAGS += -DCONFIG_EXAMPLES_NETTEST_PERFORMANCE=1 endif - HOST_SRCS = host.c + HOST_SRCS = nettest_host.c ifeq ($(CONFIG_EXAMPLES_NETTEST_SERVER),y) - HOST_SRCS += nettest_client.c + HOST_SRCS += nettest_client.c + HOST_BIN = tcpclient$(EXEEXT) else - HOST_SRCS += nettest_server.c + HOST_SRCS += nettest_server.c + HOST_BIN = tcpserver$(EXEEXT) endif - HOSTOBJEXT ?= .hobj - HOST_OBJS = $(HOST_SRCS:.c=$(HOSTOBJEXT)) - HOST_BIN = host + HOSTOBJEXT ?= hobj + HOST_OBJS = $(HOST_SRCS:.c=.$(HOSTOBJEXT)) endif ifeq ($(WINTOOL),y) @@ -118,16 +116,13 @@ PROGNAME = $(CONFIG_EXAMPLES_HELLO_PROGNAME) VPATH = all: .built $(HOST_BIN) -.PHONY: clean depend distclean +.PHONY: clean depend distclean preconfig -$(TARG_AOBJS): %$(OBJEXT): %.S - $(call ASSEMBLE, $<, $@) - -$(TARG_COBJS) $(TARG_MAINOBJ): %$(OBJEXT): %.c +$(TARG1_COBJS) $(TARG1_MAINOBJ): %$(OBJEXT): %.c $(call COMPILE, $<, $@) ifneq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y) -$(HOST_OBJS): %$(HOSTOBJEXT): %.c +$(HOST_OBJS): %.$(HOSTOBJEXT): %.c @echo "CC: $<" $(Q) $(HOSTCC) -c $(HOSTCFLAGS) $< -o $@ endif @@ -147,9 +142,9 @@ endif $(Q) touch .built ifeq ($(CONFIG_BUILD_KERNEL),y) -$(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJS) $(TARG_MAINOBJ) +$(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJS) $(TARG1_MAINOBJ) @echo "LD: $(PROGNAME)" - $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME) $(ARCHCRT0OBJ) $(TARG_MAINOBJ) $(LDLIBS) + $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME) $(ARCHCRT0OBJ) $(TARG1_MAINOBJ) $(LDLIBS) $(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(PROGNAME) install: $(BIN_DIR)$(DELIM)$(PROGNAME) @@ -168,15 +163,15 @@ else context: endif -.depend: Makefile config.h $(TARG_SRCS) - @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(TARG_SRCS) >Make.dep +.depend: Makefile config.h $(TARG_CSRCS) + @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(TARG_CSRCS) >Make.dep @touch $@ depend: .depend clean: ifneq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y) - $(call DELFILE, *$(HOSTOBJEXT)) + $(call DELFILE, *.$(HOSTOBJEXT)) $(call DELFILE, $(HOST_BIN)) endif $(call DELFILE, .built) @@ -188,7 +183,6 @@ distclean: clean $(call DELFILE, Make.dep) $(call DELFILE, .depend) --include Make.dep - -.PHONY: preconfig preconfig: + +-include Make.dep diff --git a/examples/nettest/host.c b/examples/nettest/nettest_host.c similarity index 98% rename from examples/nettest/host.c rename to examples/nettest/nettest_host.c index c376dac8e..f89477655 100644 --- a/examples/nettest/host.c +++ b/examples/nettest/nettest_host.c @@ -1,5 +1,5 @@ /**************************************************************************** - * examples/nettest/host.c + * examples/nettest/nettest_host.c * * Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/examples/nettest/nettest.c b/examples/nettest/nettest_target1.c similarity index 99% rename from examples/nettest/nettest.c rename to examples/nettest/nettest_target1.c index ca5437b80..52aed8a13 100644 --- a/examples/nettest/nettest.c +++ b/examples/nettest/nettest_target1.c @@ -1,5 +1,5 @@ /**************************************************************************** - * examples/nettest/nettest.c + * examples/nettest/nettest_target1.c * * Copyright (C) 2007, 2009-2011, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/examples/udp/Makefile b/examples/udp/Makefile index 1e80bba84..b53a053c6 100644 --- a/examples/udp/Makefile +++ b/examples/udp/Makefile @@ -116,7 +116,7 @@ endif ifneq ($(CONFIG_EXAMPLES_UDP_TARGET2),y) HOSTCFLAGS += -DEXAMPLES_UDP_HOST=1 -HOSTOBJSEXT ?= o1 +HOSTOBJSEXT ?= hobj HOST_SRCS = udp_host.c udp_cmdline.c ifeq ($(CONFIG_EXAMPLES_UDP_SERVER1),y) From c88cf75064f3fd7a370164ab3adc78e3732a8154 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 23 Jun 2017 11:40:02 -0600 Subject: [PATCH 06/19] examples/nettest: Separate out network initialization so that it may, eventually, be used by both a target server and a target client. --- examples/nettest/Makefile | 15 ++- examples/nettest/nettest.h | 4 + examples/nettest/nettest_target1.c | 148 +--------------------- examples/nettest/target_netinit.c | 193 +++++++++++++++++++++++++++++ examples/udp/Makefile | 2 +- 5 files changed, 211 insertions(+), 151 deletions(-) create mode 100644 examples/nettest/target_netinit.c diff --git a/examples/nettest/Makefile b/examples/nettest/Makefile index e51da8fdd..2b3e0d99b 100644 --- a/examples/nettest/Makefile +++ b/examples/nettest/Makefile @@ -39,6 +39,15 @@ include $(APPDIR)/Make.defs # Basic TCP networking test +TARGCMN_CSRCS = +ifeq ($(CONFIG_EXAMPLES_NETTEST_INIT),y) +TARGCMN_CSRCS += target_netinit.c +endif + +TARGCMN_COBJS = $(TARGCMN_CSRCS:.c=$(OBJEXT)) + +# Target 1 + TARG1_CSRCS = ifeq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y) TARG1_CSRCS += nettest_server.c nettest_client.c @@ -52,8 +61,8 @@ TARG1_MAINSRC = nettest_target1.c TARG1_COBJS = $(TARG1_CSRCS:.c=$(OBJEXT)) TARG1_MAINOBJ = $(TARG1_MAINSRC:.c=$(OBJEXT)) -TARG_CSRCS = $(TARG1_CSRCS) $(TARG1_CSRCS) -TARG_OBJS = $(TARG1_COBJS) +TARG_CSRCS = $(TARG1_CSRCS) $(TARG1_CSRCS) $(TARGCMN_CSRCS) +TARG_OBJS = $(TARG1_COBJS) $(TARGCMN_COBJS) ifneq ($(CONFIG_BUILD_KERNEL),y) TARG_OBJS += $(TARG1_MAINOBJ) @@ -118,7 +127,7 @@ VPATH = all: .built $(HOST_BIN) .PHONY: clean depend distclean preconfig -$(TARG1_COBJS) $(TARG1_MAINOBJ): %$(OBJEXT): %.c +$(TARG1_COBJS) $(TARG1_MAINOBJ) $(TARGCMN_COBJS) : %$(OBJEXT): %.c $(call COMPILE, $<, $@) ifneq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y) diff --git a/examples/nettest/nettest.h b/examples/nettest/nettest.h index bf5fc8338..2aa9f61e6 100644 --- a/examples/nettest/nettest.h +++ b/examples/nettest/nettest.h @@ -84,6 +84,10 @@ * Public Function Prototypes ****************************************************************************/ +#ifdef CONFIG_EXAMPLES_NETTEST_INIT +void nettest_initialize(void); +#endif + extern void send_client(void); extern void recv_server(void); diff --git a/examples/nettest/nettest_target1.c b/examples/nettest/nettest_target1.c index 52aed8a13..1d5b05418 100644 --- a/examples/nettest/nettest_target1.c +++ b/examples/nettest/nettest_target1.c @@ -38,7 +38,6 @@ ****************************************************************************/ #include "config.h" -//#include #include #include @@ -48,153 +47,8 @@ #include #include -#include -#include -#include - -#include "netutils/netlib.h" - #include "nettest.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -#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] = -{ - HTONS(CONFIG_EXAMPLES_NETTEST_IPv6ADDR_1), - HTONS(CONFIG_EXAMPLES_NETTEST_IPv6ADDR_2), - HTONS(CONFIG_EXAMPLES_NETTEST_IPv6ADDR_3), - HTONS(CONFIG_EXAMPLES_NETTEST_IPv6ADDR_4), - HTONS(CONFIG_EXAMPLES_NETTEST_IPv6ADDR_5), - HTONS(CONFIG_EXAMPLES_NETTEST_IPv6ADDR_6), - HTONS(CONFIG_EXAMPLES_NETTEST_IPv6ADDR_7), - HTONS(CONFIG_EXAMPLES_NETTEST_IPv6ADDR_8), -}; - -/* Default routine IPv6 address */ - -static const uint16_t g_ipv6_draddr[8] = -{ - HTONS(CONFIG_EXAMPLES_NETTEST_DRIPv6ADDR_1), - HTONS(CONFIG_EXAMPLES_NETTEST_DRIPv6ADDR_2), - HTONS(CONFIG_EXAMPLES_NETTEST_DRIPv6ADDR_3), - HTONS(CONFIG_EXAMPLES_NETTEST_DRIPv6ADDR_4), - HTONS(CONFIG_EXAMPLES_NETTEST_DRIPv6ADDR_5), - HTONS(CONFIG_EXAMPLES_NETTEST_DRIPv6ADDR_6), - HTONS(CONFIG_EXAMPLES_NETTEST_DRIPv6ADDR_7), - HTONS(CONFIG_EXAMPLES_NETTEST_DRIPv6ADDR_8), -}; - -/* IPv6 netmask */ - -static const uint16_t g_ipv6_netmask[8] = -{ - HTONS(CONFIG_EXAMPLES_NETTEST_IPv6NETMASK_1), - HTONS(CONFIG_EXAMPLES_NETTEST_IPv6NETMASK_2), - HTONS(CONFIG_EXAMPLES_NETTEST_IPv6NETMASK_3), - HTONS(CONFIG_EXAMPLES_NETTEST_IPv6NETMASK_4), - HTONS(CONFIG_EXAMPLES_NETTEST_IPv6NETMASK_5), - HTONS(CONFIG_EXAMPLES_NETTEST_IPv6NETMASK_6), - HTONS(CONFIG_EXAMPLES_NETTEST_IPv6NETMASK_7), - HTONS(CONFIG_EXAMPLES_NETTEST_IPv6NETMASK_8), -}; -#endif /* CONFIG_EXAMPLES_NETTEST_INIT && CONFIG_EXAMPLES_NETTEST_IPv6 && !CONFIG_NET_ICMPv6_AUTOCONF */ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -#ifdef CONFIG_EXAMPLES_NETTEST_INIT -static void netest_initialize(void) -{ -#ifndef CONFIG_EXAMPLES_NETTEST_IPv6 - struct in_addr addr; -#endif -#ifdef CONFIG_EXAMPLES_NETTEST_NOMAC - uint8_t mac[IFHWADDRLEN]; -#endif - -/* Many embedded network interfaces must have a software assigned MAC */ - -#ifdef CONFIG_EXAMPLES_NETTEST_NOMAC - mac[0] = 0x00; - mac[1] = 0xe0; - mac[2] = 0xde; - mac[3] = 0xad; - mac[4] = 0xbe; - mac[5] = 0xef; - netlib_setmacaddr("eth0", mac); -#endif - -#ifdef CONFIG_EXAMPLES_NETTEST_IPv6 -#ifdef CONFIG_NET_ICMPv6_AUTOCONF - /* Perform ICMPv6 auto-configuration */ - - netlib_icmpv6_autoconfiguration("eth0"); - -#else /* CONFIG_NET_ICMPv6_AUTOCONF */ - - /* Set up our fixed host address */ - - netlib_set_ipv6addr("eth0", - (FAR const struct in6_addr *)g_ipv6_hostaddr); - - /* Set up the default router address */ - - netlib_set_dripv6addr("eth0", - (FAR const struct in6_addr *)g_ipv6_draddr); - - /* Setup the subnet mask */ - - netlib_set_ipv6netmask("eth0", - (FAR const struct in6_addr *)g_ipv6_netmask); - - /* New versions of netlib_set_ipvXaddr will not bring the network up, - * So ensure the network is really up at this point. - */ - - netlib_ifup("eth0"); - -#endif /* CONFIG_NET_ICMPv6_AUTOCONF */ -#else /* CONFIG_EXAMPLES_NETTEST_IPv6 */ - - /* Set up our host address */ - - addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_IPADDR); - netlib_set_ipv4addr("eth0", &addr); - - /* Set up the default router address */ - - addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_DRIPADDR); - netlib_set_dripv4addr("eth0", &addr); - - /* Setup the subnet mask */ - - addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_NETMASK); - netlib_set_ipv4netmask("eth0", &addr); - -#endif /* CONFIG_EXAMPLES_NETTEST_IPv6 */ -} -#endif /*CONFIG_EXAMPLES_NETTEST_INIT */ - -#ifdef CONFIG_EXAMPLES_NETTEST_LOOPBACK -static int server_child(int argc, char *argv[]) -{ - recv_server(); - return EXIT_SUCCESS; -} -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -219,7 +73,7 @@ int nettest_main(int argc, char *argv[]) #ifdef CONFIG_EXAMPLES_NETTEST_INIT /* Initialize the network */ - netest_initialize(); + nettest_initialize(); #endif #if defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK) diff --git a/examples/nettest/target_netinit.c b/examples/nettest/target_netinit.c new file mode 100644 index 000000000..e7de618f1 --- /dev/null +++ b/examples/nettest/target_netinit.c @@ -0,0 +1,193 @@ +/**************************************************************************** + * examples/nettest/target_netinit.c + * + * Copyright (C) 2007, 2011, 2015, 2017 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include "config.h" + +#include +#include +#include + +#include +#include +#include + +#include "netutils/netlib.h" + +#include "nettest.h" + +#ifdef CONFIG_EXAMPLES_NETTEST_INIT + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +#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] = +{ + HTONS(CONFIG_EXAMPLES_NETTEST_IPv6ADDR_1), + HTONS(CONFIG_EXAMPLES_NETTEST_IPv6ADDR_2), + HTONS(CONFIG_EXAMPLES_NETTEST_IPv6ADDR_3), + HTONS(CONFIG_EXAMPLES_NETTEST_IPv6ADDR_4), + HTONS(CONFIG_EXAMPLES_NETTEST_IPv6ADDR_5), + HTONS(CONFIG_EXAMPLES_NETTEST_IPv6ADDR_6), + HTONS(CONFIG_EXAMPLES_NETTEST_IPv6ADDR_7), + HTONS(CONFIG_EXAMPLES_NETTEST_IPv6ADDR_8), +}; + +/* Default routine IPv6 address */ + +static const uint16_t g_ipv6_draddr[8] = +{ + HTONS(CONFIG_EXAMPLES_NETTEST_DRIPv6ADDR_1), + HTONS(CONFIG_EXAMPLES_NETTEST_DRIPv6ADDR_2), + HTONS(CONFIG_EXAMPLES_NETTEST_DRIPv6ADDR_3), + HTONS(CONFIG_EXAMPLES_NETTEST_DRIPv6ADDR_4), + HTONS(CONFIG_EXAMPLES_NETTEST_DRIPv6ADDR_5), + HTONS(CONFIG_EXAMPLES_NETTEST_DRIPv6ADDR_6), + HTONS(CONFIG_EXAMPLES_NETTEST_DRIPv6ADDR_7), + HTONS(CONFIG_EXAMPLES_NETTEST_DRIPv6ADDR_8), +}; + +/* IPv6 netmask */ + +static const uint16_t g_ipv6_netmask[8] = +{ + HTONS(CONFIG_EXAMPLES_NETTEST_IPv6NETMASK_1), + HTONS(CONFIG_EXAMPLES_NETTEST_IPv6NETMASK_2), + HTONS(CONFIG_EXAMPLES_NETTEST_IPv6NETMASK_3), + HTONS(CONFIG_EXAMPLES_NETTEST_IPv6NETMASK_4), + HTONS(CONFIG_EXAMPLES_NETTEST_IPv6NETMASK_5), + HTONS(CONFIG_EXAMPLES_NETTEST_IPv6NETMASK_6), + HTONS(CONFIG_EXAMPLES_NETTEST_IPv6NETMASK_7), + HTONS(CONFIG_EXAMPLES_NETTEST_IPv6NETMASK_8), +}; +#endif /* CONFIG_EXAMPLES_NETTEST_INIT && CONFIG_EXAMPLES_NETTEST_IPv6 && !CONFIG_NET_ICMPv6_AUTOCONF */ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +#ifdef CONFIG_EXAMPLES_NETTEST_INIT +void nettest_initialize(void) +{ +#ifndef CONFIG_EXAMPLES_NETTEST_IPv6 + struct in_addr addr; +#endif +#ifdef CONFIG_EXAMPLES_NETTEST_NOMAC + uint8_t mac[IFHWADDRLEN]; +#endif + +/* Many embedded network interfaces must have a software assigned MAC */ + +#ifdef CONFIG_EXAMPLES_NETTEST_NOMAC + mac[0] = 0x00; + mac[1] = 0xe0; + mac[2] = 0xde; + mac[3] = 0xad; + mac[4] = 0xbe; + mac[5] = 0xef; + netlib_setmacaddr("eth0", mac); +#endif + +#ifdef CONFIG_EXAMPLES_NETTEST_IPv6 +#ifdef CONFIG_NET_ICMPv6_AUTOCONF + /* Perform ICMPv6 auto-configuration */ + + netlib_icmpv6_autoconfiguration("eth0"); + +#else /* CONFIG_NET_ICMPv6_AUTOCONF */ + + /* Set up our fixed host address */ + + netlib_set_ipv6addr("eth0", + (FAR const struct in6_addr *)g_ipv6_hostaddr); + + /* Set up the default router address */ + + netlib_set_dripv6addr("eth0", + (FAR const struct in6_addr *)g_ipv6_draddr); + + /* Setup the subnet mask */ + + netlib_set_ipv6netmask("eth0", + (FAR const struct in6_addr *)g_ipv6_netmask); + + /* New versions of netlib_set_ipvXaddr will not bring the network up, + * So ensure the network is really up at this point. + */ + + netlib_ifup("eth0"); + +#endif /* CONFIG_NET_ICMPv6_AUTOCONF */ +#else /* CONFIG_EXAMPLES_NETTEST_IPv6 */ + + /* Set up our host address */ + + addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_IPADDR); + netlib_set_ipv4addr("eth0", &addr); + + /* Set up the default router address */ + + addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_DRIPADDR); + netlib_set_dripv4addr("eth0", &addr); + + /* Setup the subnet mask */ + + addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_NETMASK); + netlib_set_ipv4netmask("eth0", &addr); + +#endif /* CONFIG_EXAMPLES_NETTEST_IPv6 */ +} +#endif /*CONFIG_EXAMPLES_NETTEST_INIT */ + +#ifdef CONFIG_EXAMPLES_NETTEST_LOOPBACK +static int server_child(int argc, char *argv[]) +{ + recv_server(); + return EXIT_SUCCESS; +} +#endif + + +#endif /* CONFIG_EXAMPLES_NETTEST_INIT */ + diff --git a/examples/udp/Makefile b/examples/udp/Makefile index b53a053c6..f4a7e2994 100644 --- a/examples/udp/Makefile +++ b/examples/udp/Makefile @@ -43,6 +43,7 @@ TARGCMN_CSRCS = udp_cmdline.c ifeq ($(CONFIG_EXAMPLES_UDP_NETINIT),y) TARGCMN_CSRCS += target_netinit.c endif + TARGCMN_COBJS = $(TARGCMN_CSRCS:.c=$(OBJEXT)) # Target 1 @@ -97,7 +98,6 @@ endif CONFIG_EXAMPLES_UDP_PRIORITY2 ?= 100 CONFIG_EXAMPLES_UDP_STACKSIZE2 ?= 2048 - PROGNAME2 = $(CONFIG_EXAMPLES_UDP_PROGNAME2) PRIORITY2 = $(CONFIG_EXAMPLES_UDP_PRIORITY2) STACKSIZE2 = $(CONFIG_EXAMPLES_UDP_STACKSIZE2) From a0251ae9748d0fc6d9e647a37a09c8f356fc6d64 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 23 Jun 2017 12:21:13 -0600 Subject: [PATCH 07/19] examples/nettest: Fix client/server naming confusion; add command line option to select the server address on the target; examples/udp: Fix naming of a configuration setting --- examples/nettest/Kconfig | 97 ++++++++++++++++-------------- examples/nettest/Makefile | 4 +- examples/nettest/nettest.h | 16 ++++- examples/nettest/nettest_client.c | 63 ++++++------------- examples/nettest/nettest_server.c | 32 +++++----- examples/nettest/nettest_target1.c | 6 +- examples/nettest/target_netinit.c | 2 +- examples/udp/Kconfig | 4 +- examples/udp/udp.h | 8 +-- examples/udp/udp_client.c | 8 +-- examples/udp/udp_server.c | 4 +- 11 files changed, 120 insertions(+), 124 deletions(-) diff --git a/examples/nettest/Kconfig b/examples/nettest/Kconfig index d12d4a618..02105c4ec 100644 --- a/examples/nettest/Kconfig +++ b/examples/nettest/Kconfig @@ -116,15 +116,15 @@ endif # EXAMPLES_NETTEST_INIT if !EXAMPLES_NETTEST_LOOPBACK -config EXAMPLES_NETTEST_CLIENTIP - hex "Client IP Address" +config EXAMPLES_NETTEST_SERVERIP + hex "Server IP Address" default 0x0a000001 if !EXAMPLES_NETTEST_SERVER default 0x0a000002 if EXAMPLES_NETTEST_SERVER ---help--- - IP address of the client. If the target is the client, then - EXAMPLES_NETTEST_CLIENTIP should be the same as - EXAMPLES_NETTEST_IPADDR (default). If the target is the server, - then the default value of EXAMPLES_NETTEST_CLIENTIP is set to the + IP address of the server. If the target is the server, then + EXAMPLES_NETTEST_SERVERIP should be the same as + EXAMPLES_NETTEST_IPADDR (default). If the target is the client, + then the default value of EXAMPLES_NETTEST_SERVERIP is set to the host PC IP address (possibly the gateway address, EXAMPLES_NETTEST_DRIPADDR?). @@ -389,15 +389,15 @@ if !EXAMPLES_NETTEST_LOOPBACK || !NET_LOOPBACK comment "Client IPv6 address" -config EXAMPLES_NETTEST_CLIENTIPv6ADDR_1 +config EXAMPLES_NETTEST_SERVERIPv6ADDR_1 hex "[0]" default 0xfc00 range 0x0 0xffff ---help--- - IP address of the client. If the target is the client, then - EXAMPLES_NETTEST_CLIENTIP should be the same as - EXAMPLES_NETTEST_IPADDR (default). If the target is the server, - then the default value of EXAMPLES_NETTEST_CLIENTIP is set to the + IP address of the server. If the target is the server, then + EXAMPLES_NETTEST_SERVERIP should be the same as + EXAMPLES_NETTEST_IPADDR (default). If the target is the cleint, + then the default value of EXAMPLES_NETTEST_SERVERIP is set to the host PC IP address (possibly the gateway address, EXAMPLES_NETTEST_DRIPADDR?). @@ -405,15 +405,15 @@ config EXAMPLES_NETTEST_CLIENTIPv6ADDR_1 values forming the full IP address must be specified individually. This is the first of the 8-values. -config EXAMPLES_NETTEST_CLIENTIPv6ADDR_2 +config EXAMPLES_NETTEST_SERVERIPv6ADDR_2 hex "[1]" default 0x0000 range 0x0 0xffff ---help--- - IP address of the client. If the target is the client, then - EXAMPLES_NETTEST_CLIENTIP should be the same as - EXAMPLES_NETTEST_IPADDR (default). If the target is the server, - then the default value of EXAMPLES_NETTEST_CLIENTIP is set to the + IP address of the server. If the target is the server, then + EXAMPLES_NETTEST_SERVERIP should be the same as + EXAMPLES_NETTEST_IPADDR (default). If the target is the client, + then the default value of EXAMPLES_NETTEST_SERVERIP is set to the host PC IP address (possibly the gateway address, EXAMPLES_NETTEST_DRIPADDR?). @@ -421,15 +421,15 @@ config EXAMPLES_NETTEST_CLIENTIPv6ADDR_2 values forming the full IP address must be specified individually. This is the second of the 8-values. -config EXAMPLES_NETTEST_CLIENTIPv6ADDR_3 +config EXAMPLES_NETTEST_SERVERIPv6ADDR_3 hex "[2]" default 0x0000 range 0x0 0xffff ---help--- - IP address of the client. If the target is the client, then - EXAMPLES_NETTEST_CLIENTIP should be the same as - EXAMPLES_NETTEST_IPADDR (default). If the target is the server, - then the default value of EXAMPLES_NETTEST_CLIENTIP is set to the + IP address of the server. If the target is the server, then + EXAMPLES_NETTEST_SERVERIP should be the same as + EXAMPLES_NETTEST_IPADDR (default). If the target is the client, + then the default value of EXAMPLES_NETTEST_SERVERIP is set to the host PC IP address (possibly the gateway address, EXAMPLES_NETTEST_DRIPADDR?). @@ -437,15 +437,15 @@ config EXAMPLES_NETTEST_CLIENTIPv6ADDR_3 values forming the full IP address must be specified individually. This is the Third of the 8-values. -config EXAMPLES_NETTEST_CLIENTIPv6ADDR_4 +config EXAMPLES_NETTEST_SERVERIPv6ADDR_4 hex "[3]" default 0x0000 range 0x0 0xffff ---help--- - IP address of the client. If the target is the client, then - EXAMPLES_NETTEST_CLIENTIP should be the same as - EXAMPLES_NETTEST_IPADDR (default). If the target is the server, - then the default value of EXAMPLES_NETTEST_CLIENTIP is set to the + IP address of the server. If the target is the server, then + EXAMPLES_NETTEST_SERVERIP should be the same as + EXAMPLES_NETTEST_IPADDR (default). If the target is the client, + then the default value of EXAMPLES_NETTEST_SERVERIP is set to the host PC IP address (possibly the gateway address, EXAMPLES_NETTEST_DRIPADDR?). @@ -453,15 +453,15 @@ config EXAMPLES_NETTEST_CLIENTIPv6ADDR_4 values forming the full IP address must be specified individually. This is the fourth of the 8-values. -config EXAMPLES_NETTEST_CLIENTIPv6ADDR_5 +config EXAMPLES_NETTEST_SERVERIPv6ADDR_5 hex "[4]" default 0x0000 range 0x0 0xffff ---help--- - IP address of the client. If the target is the client, then - EXAMPLES_NETTEST_CLIENTIP should be the same as - EXAMPLES_NETTEST_IPADDR (default). If the target is the server, - then the default value of EXAMPLES_NETTEST_CLIENTIP is set to the + IP address of the server. If the target is the server, then + EXAMPLES_NETTEST_SERVERIP should be the same as + EXAMPLES_NETTEST_IPADDR (default). If the target is the client, + then the default value of EXAMPLES_NETTEST_SERVERIP is set to the host PC IP address (possibly the gateway address, EXAMPLES_NETTEST_DRIPADDR?). @@ -469,15 +469,15 @@ config EXAMPLES_NETTEST_CLIENTIPv6ADDR_5 values forming the full IP address must be specified individually. This is the fifth of the 8-values. -config EXAMPLES_NETTEST_CLIENTIPv6ADDR_6 +config EXAMPLES_NETTEST_SERVERIPv6ADDR_6 hex "[5]" default 0x0000 range 0x0 0xffff ---help--- - IP address of the client. If the target is the client, then - EXAMPLES_NETTEST_CLIENTIP should be the same as - EXAMPLES_NETTEST_IPADDR (default). If the target is the server, - then the default value of EXAMPLES_NETTEST_CLIENTIP is set to the + IP address of the server. If the target is the server, then + EXAMPLES_NETTEST_SERVERIP should be the same as + EXAMPLES_NETTEST_IPADDR (default). If the target is the client, + then the default value of EXAMPLES_NETTEST_SERVERIP is set to the host PC IP address (possibly the gateway address, EXAMPLES_NETTEST_DRIPADDR?). @@ -485,15 +485,15 @@ config EXAMPLES_NETTEST_CLIENTIPv6ADDR_6 values forming the full IP address must be specified individually. This is the sixth of the 8-values. -config EXAMPLES_NETTEST_CLIENTIPv6ADDR_7 +config EXAMPLES_NETTEST_SERVERIPv6ADDR_7 hex "[6]" default 0x0000 range 0x0 0xffff ---help--- - IP address of the client. If the target is the client, then - EXAMPLES_NETTEST_CLIENTIP should be the same as - EXAMPLES_NETTEST_IPADDR (default). If the target is the server, - then the default value of EXAMPLES_NETTEST_CLIENTIP is set to the + IP address of the server. If the target is the server, then + EXAMPLES_NETTEST_SERVERIP should be the same as + EXAMPLES_NETTEST_IPADDR (default). If the target is the client, + then the default value of EXAMPLES_NETTEST_SERVERIP is set to the host PC IP address (possibly the gateway address, EXAMPLES_NETTEST_DRIPADDR?). @@ -501,16 +501,16 @@ config EXAMPLES_NETTEST_CLIENTIPv6ADDR_7 values forming the full IP address must be specified individually. This is the seventh of the 8-values. -config EXAMPLES_NETTEST_CLIENTIPv6ADDR_8 +config EXAMPLES_NETTEST_SERVERIPv6ADDR_8 hex "[7]" default 0x0001 if !EXAMPLES_NETTEST_SERVER default 0x0002 if EXAMPLES_NETTEST_SERVER range 0x0 0xffff ---help--- - IP address of the client. If the target is the client, then - EXAMPLES_NETTEST_CLIENTIP should be the same as - EXAMPLES_NETTEST_IPADDR (default). If the target is the server, - then the default value of EXAMPLES_NETTEST_CLIENTIP is set to the + IP address of the server. If the target is the server, then + EXAMPLES_NETTEST_SERVERIP should be the same as + EXAMPLES_NETTEST_IPADDR (default). If the target is the client, + then the default value of EXAMPLES_NETTEST_SERVERIP is set to the host PC IP address (possibly the gateway address, EXAMPLES_NETTEST_DRIPADDR?). @@ -520,4 +520,9 @@ config EXAMPLES_NETTEST_CLIENTIPv6ADDR_8 endif # !EXAMPLES_NETTEST_LOOPBACK endif # EXAMPLES_NETTEST_IPv6 + +config EXAMPLES_NETTEST_SERVER_PORTNO + int "Server port number" + default 5471 + endif # EXAMPLES_NETTEST diff --git a/examples/nettest/Makefile b/examples/nettest/Makefile index 2b3e0d99b..173aa4ece 100644 --- a/examples/nettest/Makefile +++ b/examples/nettest/Makefile @@ -39,7 +39,7 @@ include $(APPDIR)/Make.defs # Basic TCP networking test -TARGCMN_CSRCS = +TARGCMN_CSRCS = nettest_cmdline.c ifeq ($(CONFIG_EXAMPLES_NETTEST_INIT),y) TARGCMN_CSRCS += target_netinit.c endif @@ -81,7 +81,7 @@ endif ifneq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y) HOSTCFLAGS += -DNETTEST_HOST=1 ifeq ($(CONFIG_EXAMPLES_NETTEST_SERVER),y) - HOSTCFLAGS += -DCONFIG_EXAMPLES_NETTEST_SERVER=1 -DCONFIG_EXAMPLES_NETTEST_CLIENTIP="$(CONFIG_EXAMPLES_NETTEST_CLIENTIP)" + HOSTCFLAGS += -DCONFIG_EXAMPLES_NETTEST_SERVER=1 -DCONFIG_EXAMPLES_NETTEST_SERVERIP="$(CONFIG_EXAMPLES_NETTEST_SERVERIP)" endif ifeq ($(CONFIG_EXAMPLES_NETTEST_PERFORMANCE),y) HOSTCFLAGS += -DCONFIG_EXAMPLES_NETTEST_PERFORMANCE=1 diff --git a/examples/nettest/nettest.h b/examples/nettest/nettest.h index 2aa9f61e6..a795e96e9 100644 --- a/examples/nettest/nettest.h +++ b/examples/nettest/nettest.h @@ -77,9 +77,22 @@ # define PF_INETX PF_INET #endif -#define PORTNO 5471 +#ifndef CONFIG_EXAMPLES_NETTEST_SERVER_PORTNO +# define CONFIG_EXAMPLES_NETTEST_SERVER_PORTNO 5471 +#endif + #define SENDSIZE 4096 +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifdef CONFIG_EXAMPLES_NETTEST_IPv6 +uint16_t g_server_ipv6[8]; +#else +uint32_t g_server_ipv4; +#endif + /**************************************************************************** * Public Function Prototypes ****************************************************************************/ @@ -88,6 +101,7 @@ void nettest_initialize(void); #endif +void parse_cmdline(int argc, char **argv); extern void send_client(void); extern void recv_server(void); diff --git a/examples/nettest/nettest_client.c b/examples/nettest/nettest_client.c index 6a24d68ec..4883504df 100644 --- a/examples/nettest/nettest_client.c +++ b/examples/nettest/nettest_client.c @@ -59,9 +59,9 @@ void send_client(void) { #ifdef CONFIG_EXAMPLES_NETTEST_IPv6 - struct sockaddr_in6 myaddr; + struct sockaddr_in6 server; #else - struct sockaddr_in myaddr; + struct sockaddr_in server; #endif char *outbuf; #ifndef CONFIG_EXAMPLES_NETTEST_PERFORMANCE @@ -100,56 +100,29 @@ void send_client(void) goto errout_with_buffers; } - /* Connect the socket to the server */ + /* Set up the server address */ #ifdef CONFIG_EXAMPLES_NETTEST_IPv6 - myaddr.sin6_family = AF_INET6; - myaddr.sin6_port = HTONS(PORTNO); + server.sin6_family = AF_INET6; + server.sin6_port = HTONS(CONFIG_EXAMPLES_NETTEST_SERVER_PORTNO); + memcpy(server.sin6_addr.s6_addr16, g_server_ipv6, 8 * sizeof(uint16_t)); + addrlen = sizeof(struct sockaddr_in6); -#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; - myaddr.sin6_addr.s6_addr16[4] = 0; - myaddr.sin6_addr.s6_addr16[5] = 0; - myaddr.sin6_addr.s6_addr16[6] = 0; - myaddr.sin6_addr.s6_addr16[7] = HTONS(1); + printf("Connecting to IPv6 Address: %04x:04x:04x:04x:04x:04x:04x:04x\n", + g_server_ipv6[0], g_server_ipv6[1], g_server_ipv6[2], g_server_ipv6[3], + g_server_ipv6[4], g_server_ipv6[5], g_server_ipv6[6], g_server_ipv6[7]); #else - myaddr.sin6_addr.s6_addr16[0] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_1); - myaddr.sin6_addr.s6_addr16[1] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_2); - myaddr.sin6_addr.s6_addr16[2] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_3); - myaddr.sin6_addr.s6_addr16[3] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_4); - myaddr.sin6_addr.s6_addr16[4] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_5); - myaddr.sin6_addr.s6_addr16[5] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_6); - myaddr.sin6_addr.s6_addr16[6] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_7); - myaddr.sin6_addr.s6_addr16[7] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_8); + server.sin_family = AF_INET; + server.sin_port = HTONS(CONFIG_EXAMPLES_NETTEST_SERVER_PORTNO); + server.sin_addr.s_addr = (in_addr_t)g_server_ipv4; + addrlen = sizeof(struct sockaddr_in); + + printf("Connecting to IPv4 Address: %08lx\n", (unsigned long)g_server_ipv4); #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]); + /* Connect the socket to the server */ - addrlen = sizeof(struct sockaddr_in6); -#else - myaddr.sin_family = AF_INET; - myaddr.sin_port = HTONS(PORTNO); - -#if defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK) && defined(NET_LOOPBACK) - myaddr.sin_addr.s_addr = HTONL(0x7f000001); -#else - 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 - - printf("client: Connecting...\n"); - if (connect( sockfd, (struct sockaddr*)&myaddr, addrlen) < 0) + if (connect( sockfd, (struct sockaddr*)&server, addrlen) < 0) { printf("client: connect failure: %d\n", errno); goto errout_with_socket; diff --git a/examples/nettest/nettest_server.c b/examples/nettest/nettest_server.c index ad55506a1..755fdf096 100644 --- a/examples/nettest/nettest_server.c +++ b/examples/nettest/nettest_server.c @@ -112,33 +112,32 @@ void recv_server(void) #ifdef CONFIG_EXAMPLES_NETTEST_IPv6 myaddr.sin6_family = AF_INET6; - myaddr.sin6_port = HTONS(PORTNO); - + myaddr.sin6_port = HTONS(CONFIG_EXAMPLES_NETTEST_SERVER_PORTNO); #if defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK) && !defined(NET_LOOPBACK) - myaddr.sin6_addr.s6_addr16[0] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_1); - myaddr.sin6_addr.s6_addr16[1] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_2); - myaddr.sin6_addr.s6_addr16[2] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_3); - myaddr.sin6_addr.s6_addr16[3] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_4); - myaddr.sin6_addr.s6_addr16[4] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_5); - myaddr.sin6_addr.s6_addr16[5] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_6); - myaddr.sin6_addr.s6_addr16[6] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_7); - myaddr.sin6_addr.s6_addr16[7] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_8); + memcpy(myaddr.sin6_addr.s6_addr16, g_server_ipv6, 8 * sizeof(uint16_t)); #else - memset(&myaddr.sin6_addr, 0, sizeof(struct in6_addr)); + memset(myaddr.sin6_addr.s6_addr16, 0, 8 * sizeof(uint16_t)); #endif - addrlen = sizeof(struct sockaddr_in6); + + printf("Binding to 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]); #else myaddr.sin_family = AF_INET; - myaddr.sin_port = HTONS(PORTNO); + myaddr.sin_port = HTONS(CONFIG_EXAMPLES_NETTEST_SERVER_PORTNO); #if defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK) && !defined(NET_LOOPBACK) - myaddr.sin_addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_CLIENTIP); + myaddr.sin_addr.s_addr = (in_addr_t)g_server_ipv4; #else myaddr.sin_addr.s_addr = INADDR_ANY; #endif - addrlen = sizeof(struct sockaddr_in); + + printf("Binding to IPv4 Address: %08lx\n", + (unsigned long)myaddr.sin_addr.s_addr); #endif if (bind(listensd, (struct sockaddr*)&myaddr, addrlen) < 0) @@ -157,7 +156,8 @@ void recv_server(void) /* Accept only one connection */ - printf("server: Accepting connections on port %d\n", PORTNO); + printf("server: Accepting connections on port %d\n", + CONFIG_EXAMPLES_NETTEST_SERVER_PORTNO); acceptsd = accept(listensd, (struct sockaddr*)&myaddr, &addrlen); if (acceptsd < 0) { diff --git a/examples/nettest/nettest_target1.c b/examples/nettest/nettest_target1.c index 1d5b05418..784e7e76e 100644 --- a/examples/nettest/nettest_target1.c +++ b/examples/nettest/nettest_target1.c @@ -1,7 +1,7 @@ /**************************************************************************** * examples/nettest/nettest_target1.c * - * Copyright (C) 2007, 2009-2011, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009-2011, 2015, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -70,6 +70,10 @@ int nettest_main(int argc, char *argv[]) #endif #endif + /* Parse any command line options */ + + parse_cmdline(argc, argv); + #ifdef CONFIG_EXAMPLES_NETTEST_INIT /* Initialize the network */ diff --git a/examples/nettest/target_netinit.c b/examples/nettest/target_netinit.c index e7de618f1..e5c84518e 100644 --- a/examples/nettest/target_netinit.c +++ b/examples/nettest/target_netinit.c @@ -1,7 +1,7 @@ /**************************************************************************** * examples/nettest/target_netinit.c * - * Copyright (C) 2007, 2011, 2015, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009-2011, 2015, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without diff --git a/examples/udp/Kconfig b/examples/udp/Kconfig index 392ab6f73..851094d9a 100644 --- a/examples/udp/Kconfig +++ b/examples/udp/Kconfig @@ -512,11 +512,11 @@ config EXAMPLES_UDP_SERVERIPv6ADDR_8 endif # EXAMPLES_UDP_IPv6 -config EXAMPLES_SERVER_PORTNO +config EXAMPLES_UDP_SERVER_PORTNO int "Server port number" default 5471 -config EXAMPLES_CLIENT_PORTNO +config EXAMPLES_UDP_CLIENT_PORTNO int "Client port number" default 5472 diff --git a/examples/udp/udp.h b/examples/udp/udp.h index 9316240be..193d5e2cb 100644 --- a/examples/udp/udp.h +++ b/examples/udp/udp.h @@ -83,12 +83,12 @@ # define PF_INETX PF_INET #endif -#ifndef CONFIG_EXAMPLES_SERVER_PORTNO -# define CONFIG_EXAMPLES_SERVER_PORTNO 5471 +#ifndef CONFIG_EXAMPLES_UDP_SERVER_PORTNO +# define CONFIG_EXAMPLES_UDP_SERVER_PORTNO 5471 #endif -#ifndef CONFIG_EXAMPLES_CLIENT_PORTNO -# define CONFIG_EXAMPLES_CLIENT_PORTNO 5472 +#ifndef CONFIG_EXAMPLES_UDP_CLIENT_PORTNO +# define CONFIG_EXAMPLES_UDP_CLIENT_PORTNO 5472 #endif #define ASCIISIZE (0x7f - 0x20) diff --git a/examples/udp/udp_client.c b/examples/udp/udp_client.c index 18368c1a3..89742dca8 100644 --- a/examples/udp/udp_client.c +++ b/examples/udp/udp_client.c @@ -77,7 +77,7 @@ static int create_socket(void) /* Bind the UDP socket to a IPv4 port */ addr.sin_family = AF_INET; - addr.sin_port = HTONS(CONFIG_EXAMPLES_CLIENT_PORTNO); + addr.sin_port = HTONS(CONFIG_EXAMPLES_UDP_CLIENT_PORTNO); addr.sin_addr.s_addr = HTONL(INADDR_ANY); addrlen = sizeof(struct sockaddr_in); @@ -96,7 +96,7 @@ static int create_socket(void) /* Bind the UDP socket to a IPv6 port */ addr.sin6_family = AF_INET6; - addr.sin6_port = HTONS(CONFIG_EXAMPLES_CLIENT_PORTNO); + addr.sin6_port = HTONS(CONFIG_EXAMPLES_UDP_CLIENT_PORTNO); memset(addr.sin6_addr.s6_addr, 0, sizeof(struct in6_addr)); addrlen = sizeof(struct sockaddr_in6); #endif @@ -164,12 +164,12 @@ void send_client(void) #ifdef CONFIG_EXAMPLES_UDP_IPv6 server.sin6_family = AF_INET6; - server.sin6_port = HTONS(CONFIG_EXAMPLES_SERVER_PORTNO); + server.sin6_port = HTONS(CONFIG_EXAMPLES_UDP_SERVER_PORTNO); memcpy(server.sin6_addr.s6_addr16, g_server_ipv6, 8 * sizeof(uint16_t)); addrlen = sizeof(struct sockaddr_in6); #else server.sin_family = AF_INET; - server.sin_port = HTONS(CONFIG_EXAMPLES_SERVER_PORTNO); + server.sin_port = HTONS(CONFIG_EXAMPLES_UDP_SERVER_PORTNO); server.sin_addr.s_addr = (in_addr_t)g_server_ipv4; addrlen = sizeof(struct sockaddr_in); #endif diff --git a/examples/udp/udp_server.c b/examples/udp/udp_server.c index 03233d68b..967b493c7 100644 --- a/examples/udp/udp_server.c +++ b/examples/udp/udp_server.c @@ -124,13 +124,13 @@ void recv_server(void) #ifdef CONFIG_EXAMPLES_UDP_IPv6 server.sin6_family = AF_INET6; - server.sin6_port = HTONS(CONFIG_EXAMPLES_SERVER_PORTNO); + server.sin6_port = HTONS(CONFIG_EXAMPLES_UDP_SERVER_PORTNO); memset(&server.sin6_addr, 0, sizeof(struct in6_addr)); addrlen = sizeof(struct sockaddr_in6); #else server.sin_family = AF_INET; - server.sin_port = HTONS(CONFIG_EXAMPLES_SERVER_PORTNO); + server.sin_port = HTONS(CONFIG_EXAMPLES_UDP_SERVER_PORTNO); server.sin_addr.s_addr = HTONL(INADDR_ANY); addrlen = sizeof(struct sockaddr_in); From cde3cb1544f7654e827b368f6ca51fa46c4b4342 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 23 Jun 2017 12:30:11 -0600 Subject: [PATCH 08/19] Forgot to add files before last commit. --- examples/nettest/nettest_cmdline.c | 137 +++++++++++++++++++++++++++++ examples/nettest/nettest_target2.c | 75 ++++++++++++++++ 2 files changed, 212 insertions(+) create mode 100644 examples/nettest/nettest_cmdline.c create mode 100644 examples/nettest/nettest_target2.c diff --git a/examples/nettest/nettest_cmdline.c b/examples/nettest/nettest_cmdline.c new file mode 100644 index 000000000..479e83336 --- /dev/null +++ b/examples/nettest/nettest_cmdline.c @@ -0,0 +1,137 @@ +/**************************************************************************** + * examples/nettest/netest_cmdline.c + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include "config.h" + +#include +#include +#include + +#include "nettest.h" + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifdef CONFIG_EXAMPLES_NETTEST_IPv6 + +uint16_t g_server_ipv6[8] = +{ +#if defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK) && defined(NET_LOOPBACK) + 0 /* Use the loopback address */ + 0 + 0 + 0 + 0 + 0 + 0 + HTONS(1); +#else + HTONS(CONFIG_EXAMPLES_NETTEST_SERVERIPv6ADDR_1), + HTONS(CONFIG_EXAMPLES_NETTEST_SERVERIPv6ADDR_2), + HTONS(CONFIG_EXAMPLES_NETTEST_SERVERIPv6ADDR_3), + HTONS(CONFIG_EXAMPLES_NETTEST_SERVERIPv6ADDR_4), + HTONS(CONFIG_EXAMPLES_NETTEST_SERVERIPv6ADDR_5), + HTONS(CONFIG_EXAMPLES_NETTEST_SERVERIPv6ADDR_6), + HTONS(CONFIG_EXAMPLES_NETTEST_SERVERIPv6ADDR_7), + HTONS(CONFIG_EXAMPLES_NETTEST_SERVERIPv6ADDR_8) +#endif +}; + +#else + +#if defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK) && defined(NET_LOOPBACK) +uint32_t g_server_ipv4 = HTONL(0x7f000001); +#else +uint32_t g_server_ipv4 = HTONL(CONFIG_EXAMPLES_NETTEST_SERVERIP); +#endif + +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * show_usage + ****************************************************************************/ + +static void show_usage(FAR const char *progname) +{ + fprintf(stderr, "USAGE: %s []\n", progname); + exit(1); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * parse_cmdline + ****************************************************************************/ + +void parse_cmdline(int argc, char **argv) +{ + /* Currently only a single command line option is supported: The server + * IP address. + */ + + if (argc == 2) + { + int ret; + + /* Convert the argument into a binary address */ + +#ifdef CONFIG_EXAMPLES_NETTEST_IPv6 + ret = inet_pton(AF_INET6, argv[1], g_server_ipv6); +#else + ret = inet_pton(AF_INET, argv[1], &g_server_ipv4); +#endif + if (ret < 0) + { + fprintf(stderr, "ERROR: is invalid\n"); + show_usage(argv[0]); + } + } + else if (argc != 1) + { + fprintf(stderr, "ERROR: Too many arguments\n"); + show_usage(argv[0]); + } +} diff --git a/examples/nettest/nettest_target2.c b/examples/nettest/nettest_target2.c new file mode 100644 index 000000000..660a424fd --- /dev/null +++ b/examples/nettest/nettest_target2.c @@ -0,0 +1,75 @@ +/**************************************************************************** + * examples/nettest/nettest_target2.c + * + * Copyright (C) 2007, 2009-2011, 2015, 2017 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include "config.h" + +#include "nettest.h" + +/**************************************************************************** + * nettest_main + ****************************************************************************/ + +#ifdef CONFIG_BUILD_KERNEL +int main(int argc, FAR char *argv[]) +#else +int nettest2_main(int argc, char *argv[]) +#endif +{ + /* Parse any command line options */ + + parse_cmdline(argc, argv); + +#ifdef CONFIG_EXAMPLES_NETTEST_INIT + /* Initialize the network */ + + nettest_initialize(); +#endif + +#if defined(CONFIG_EXAMPLES_NETTEST_SERVER) + /* Then perform the client side of the test on this thread */ + + send_client(); +#else + /* Then perform the server side of the test on this thread */ + + recv_server(); +#endif + + return EXIT_SUCCESS; +} From 1c0f237c0604ec7a09218128162cca45e4c81729 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 23 Jun 2017 15:49:27 -0600 Subject: [PATCH 09/19] examples/nettest: More prep for a second target --- examples/nettest/Kconfig | 16 ++++++------ examples/nettest/Makefile | 54 ++++++++++++++++++++++++--------------- 2 files changed, 41 insertions(+), 29 deletions(-) diff --git a/examples/nettest/Kconfig b/examples/nettest/Kconfig index 02105c4ec..285965787 100644 --- a/examples/nettest/Kconfig +++ b/examples/nettest/Kconfig @@ -12,20 +12,20 @@ config EXAMPLES_NETTEST if EXAMPLES_NETTEST -config EXAMPLES_NETTEST_PROGNAME - string "Program name" +config EXAMPLES_NETTEST_PROGNAME1 + string "Target1 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" +config EXAMPLES_NETTEST_STACKSIZE1 + int "Target1 stack size" default 2048 -config EXAMPLES_NETTEST_PRIORITY - int "Nettest priority" +config EXAMPLES_NETTEST_PRIORITY1 + int "Target1 priority" default 100 config EXAMPLES_NETTEST_LOOPBACK @@ -48,8 +48,8 @@ config EXAMPLES_NETTEST_SERVER_PRIORITY endif # EXAMPLES_NETTEST_LOOPBACK -config EXAMPLES_NETTEST_SERVER - bool "Target is server" +config EXAMPLES_NETTEST_SERVER1 + bool "Target1 is server" default n depends on !EXAMPLES_NETTEST_LOOPBACK ---help--- diff --git a/examples/nettest/Makefile b/examples/nettest/Makefile index 173aa4ece..ef65292d1 100644 --- a/examples/nettest/Makefile +++ b/examples/nettest/Makefile @@ -46,7 +46,7 @@ endif TARGCMN_COBJS = $(TARGCMN_CSRCS:.c=$(OBJEXT)) -# Target 1 +# Target 1 Files TARG1_CSRCS = ifeq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y) @@ -64,6 +64,28 @@ TARG1_MAINOBJ = $(TARG1_MAINSRC:.c=$(OBJEXT)) TARG_CSRCS = $(TARG1_CSRCS) $(TARG1_CSRCS) $(TARGCMN_CSRCS) TARG_OBJS = $(TARG1_COBJS) $(TARGCMN_COBJS) +# Target 1 Application Info + +ifeq ($(CONFIG_EXAMPLES_NETTEST_SERVER1),y) +CONFIG_EXAMPLES_NETTEST_PROGNAME1 ?= tcpserver +APPNAME1 = tcpserver +else +CONFIG_EXAMPLES_NETTEST_PROGNAME1 ?= tcpclient +APPNAME1 = tcpclient +endif +CONFIG_EXAMPLES_NETTEST_PRIORITY1 ?= 100 +CONFIG_EXAMPLES_NETTEST_STACKSIZE1 ?= 2048 + +PROGNAME1 = $(CONFIG_EXAMPLES_NETTEST_PROGNAME1) +PRIORITY1 = $(CONFIG_EXAMPLES_NETTEST_PRIORITY1) +STACKSIZE1 = $(CONFIG_EXAMPLES_NETTEST_STACKSIZE1) + +# Target 2 + +# Target 2 Application Info + +# Target common + ifneq ($(CONFIG_BUILD_KERNEL),y) TARG_OBJS += $(TARG1_MAINOBJ) endif @@ -78,6 +100,8 @@ else endif endif +# Host + ifneq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y) HOSTCFLAGS += -DNETTEST_HOST=1 ifeq ($(CONFIG_EXAMPLES_NETTEST_SERVER),y) @@ -108,18 +132,6 @@ endif ROOTDEPPATH = --dep-path . -# NET test built-in application info - -CONFIG_EXAMPLES_NETTEST_STACKSIZE ?= 2048 -CONFIG_EXAMPLES_NETTEST_PRIORITY ?= 100 - -APPNAME = nettest -PRIORITY = $(CONFIG_EXAMPLES_NETTEST_PRIORITY) -STACKSIZE = $(CONFIG_EXAMPLES_NETTEST_STACKSIZE) - -CONFIG_EXAMPLES_NETTEST_PROGNAME ?= nettest$(EXEEXT) -PROGNAME = $(CONFIG_EXAMPLES_HELLO_PROGNAME) - # Common build VPATH = @@ -151,12 +163,12 @@ endif $(Q) touch .built ifeq ($(CONFIG_BUILD_KERNEL),y) -$(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJS) $(TARG1_MAINOBJ) - @echo "LD: $(PROGNAME)" - $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME) $(ARCHCRT0OBJ) $(TARG1_MAINOBJ) $(LDLIBS) - $(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(PROGNAME) +$(BIN_DIR)$(DELIM)$(PROGNAME1): $(OBJS) $(TARG1_MAINOBJ) + @echo "LD: $(PROGNAME1)" + $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME1) $(ARCHCRT0OBJ) $(TARG1_MAINOBJ) $(LDLIBS) + $(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(PROGNAME1) -install: $(BIN_DIR)$(DELIM)$(PROGNAME) +install: $(BIN_DIR)$(DELIM)$(PROGNAME1) else install: @@ -164,10 +176,10 @@ install: endif ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile - $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat: $(DEPCONFIG) Makefile + $(call REGISTER,$(APPNAME1),$(PRIORITY1),$(STACKSIZE1),$(APPNAME1)_main) -context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat else context: endif From a3ac695f1701d18e4fbdca00900e58116301d2a8 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 23 Jun 2017 18:12:34 -0600 Subject: [PATCH 10/19] examples/nettest: Add support for both enpoints on target boards vs. one on a target and one on the host PC. --- examples/nettest/Kconfig | 65 ++++++++++++++++++++++++----- examples/nettest/Makefile | 67 ++++++++++++++++++++++++++++-- examples/nettest/nettest_target1.c | 8 ++-- examples/nettest/nettest_target2.c | 2 +- examples/nettest/target_netinit.c | 28 +++++++++---- examples/udp/Kconfig | 2 +- examples/udp/Makefile | 10 ++--- 7 files changed, 149 insertions(+), 33 deletions(-) diff --git a/examples/nettest/Kconfig b/examples/nettest/Kconfig index 285965787..67aef0954 100644 --- a/examples/nettest/Kconfig +++ b/examples/nettest/Kconfig @@ -36,17 +36,9 @@ config EXAMPLES_NETTEST_LOOPBACK 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 +# No server if loopback; No second target if loopback -config EXAMPLES_NETTEST_SERVER_STACKSIZE - int "Server stack size" - default 2048 - -config EXAMPLES_NETTEST_SERVER_PRIORITY - int "Server priority" - default 100 - -endif # EXAMPLES_NETTEST_LOOPBACK +if !EXAMPLES_NETTEST_LOOPBACK config EXAMPLES_NETTEST_SERVER1 bool "Target1 is server" @@ -56,6 +48,51 @@ config EXAMPLES_NETTEST_SERVER1 Select to use the host as the client side of the test. Default: The target is the client side of the test +config EXAMPLES_NETTEST_TARGET2 + bool "Second endpoint is a target" + default n + ---help--- + By default, the host PC is configured as the second endpoint of the + NETTEST. If this option is selected, then the second endpoint + will be built into the FLASH image as well. This means that you + can use two target boards to run the test with no host PC + involvement. + +if EXAMPLES_NETTEST_TARGET2 + +config EXAMPLES_NETTEST_PROGNAME2 + string "Target2 program name" + default "udpserver" if !EXAMPLES_NETTEST_SERVER2 + default "udpclient" if EXAMPLES_NETTEST_SERVER2 + depends on BUILD_KERNEL + ---help--- + This is the name of the Target2 program that will be use when the + NSH ELF program is installed. + +config EXAMPLES_NETTEST_PRIORITY2 + int "Target2 task priority" + default 100 + +config EXAMPLES_NETTEST_STACKSIZE2 + int "Target2 stack size" + default 2048 + +endif # EXAMPLES_NETTEST_TARGET2 + +config EXAMPLES_NETTEST_DAEMON_STACKSIZE + int "Server daemon stack size" + default 2048 + +config EXAMPLES_NETTEST_DEAMON_PRIORITY + int "Server daemon priority" + default 100 + +endif # EXAMPLES_NETTEST_LOOPBACK + +config EXAMPLES_NETTEST_DEVNAME + string "Network device" + default "eth0" + config EXAMPLES_NETTEST_PERFORMANCE bool "Test for Performance" default n @@ -78,6 +115,8 @@ config EXAMPLES_NETTEST_IPv6 endchoice # IP Domain +# No hardware initialization if loopback + config EXAMPLES_NETTEST_INIT bool "Initialize network" default n if NSH_BUILTIN_APPS @@ -114,6 +153,8 @@ config EXAMPLES_NETTEST_NETMASK endif # EXAMPLES_NETTEST_INIT +# No server if loopback + if !EXAMPLES_NETTEST_LOOPBACK config EXAMPLES_NETTEST_SERVERIP @@ -385,9 +426,11 @@ config EXAMPLES_NETTEST_IPv6NETMASK_8 endif # NET_ICMPv6_AUTOCONF endif # EXAMPLES_NETTEST_INIT +# Addresses are well known if loopback is used. + if !EXAMPLES_NETTEST_LOOPBACK || !NET_LOOPBACK -comment "Client IPv6 address" +comment "Server IPv6 address" config EXAMPLES_NETTEST_SERVERIPv6ADDR_1 hex "[0]" diff --git a/examples/nettest/Makefile b/examples/nettest/Makefile index ef65292d1..b082fe532 100644 --- a/examples/nettest/Makefile +++ b/examples/nettest/Makefile @@ -82,12 +82,51 @@ STACKSIZE1 = $(CONFIG_EXAMPLES_NETTEST_STACKSIZE1) # Target 2 +ifeq ($(CONFIG_EXAMPLES_NETTEST_TARGET2),y) + +TARG2_CSRCS = +ifeq ($(CONFIG_EXAMPLES_NETTEST_SERVER1),y) +TARG2_CSRCS += nettest_client.c +else +TARG2_CSRCS += nettest_server.c +endif +TARG2_MAINSRC = nettest_target2.c + +TARG2_COBJS = $(TARG2_CCRCS:.c=$(OBJEXT)) +TARG2_MAINOBJ = $(TARG2_MAINSRC:.c=$(OBJEXT)) + # Target 2 Application Info -# Target common +ifeq ($(CONFIG_EXAMPLES_NETTEST_SERVER1),y) +CONFIG_EXAMPLES_NETTEST_PROGNAME2 ?= tcpclient +APPNAME2 = tcpclient +else +CONFIG_EXAMPLES_NETTEST_PROGNAME2 ?= tcpserver +APPNAME2 = tcpserver +endif +CONFIG_EXAMPLES_NETTEST_PRIORITY2 ?= 100 +CONFIG_EXAMPLES_NETTEST_STACKSIZE2 ?= 2048 + +PROGNAME2 = $(CONFIG_EXAMPLES_NETTEST_PROGNAME2) +PRIORITY2 = $(CONFIG_EXAMPLES_NETTEST_PRIORITY2) +STACKSIZE2 = $(CONFIG_EXAMPLES_NETTEST_STACKSIZE2) + +endif + +# All targets + +TARG_SRCS = $(TARG1_CRCS) $(TARG1_MAINSRC) $(TARG2_CSRCS) $(TARG2_MAINSRC) $(TARGCMN_CSRCS) +TARG_OBJS = $(TARG1_COBJS) $(TARG2_COBJS) $(TARGCMN_COBJS) ifneq ($(CONFIG_BUILD_KERNEL),y) - TARG_OBJS += $(TARG1_MAINOBJ) + TARG_OBJS += $(TARG1_MAINOBJ) $(TARG2_MAINOBJ) +endif + +ifeq ($(CONFIG_EXAMPLES_NETTEST_TARGET2),y) +MAINNAME1 = nettest1_main +MAINNAME2 = nettest2_main +else +MAINNAME1 = nettest_main endif ifeq ($(CONFIG_WINDOWS_NATIVE),y) @@ -102,7 +141,9 @@ endif # Host +ifneq ($(CONFIG_EXAMPLES_NETTEST_TARGET2),y) ifneq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y) + HOSTCFLAGS += -DNETTEST_HOST=1 ifeq ($(CONFIG_EXAMPLES_NETTEST_SERVER),y) HOSTCFLAGS += -DCONFIG_EXAMPLES_NETTEST_SERVER=1 -DCONFIG_EXAMPLES_NETTEST_SERVERIP="$(CONFIG_EXAMPLES_NETTEST_SERVERIP)" @@ -122,6 +163,8 @@ ifneq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y) HOSTOBJEXT ?= hobj HOST_OBJS = $(HOST_SRCS:.c=.$(HOSTOBJEXT)) + +endif endif ifeq ($(WINTOOL),y) @@ -142,20 +185,28 @@ all: .built $(HOST_BIN) $(TARG1_COBJS) $(TARG1_MAINOBJ) $(TARGCMN_COBJS) : %$(OBJEXT): %.c $(call COMPILE, $<, $@) +ifneq ($(CONFIG_EXAMPLES_UDP_TARGET2),y) ifneq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y) + $(HOST_OBJS): %.$(HOSTOBJEXT): %.c @echo "CC: $<" $(Q) $(HOSTCC) -c $(HOSTCFLAGS) $< -o $@ + +endif endif config.h: $(TOPDIR)/include/nuttx/config.h @echo "CP: $<" $(Q) cp $< $@ +ifneq ($(CONFIG_EXAMPLES_UDP_TARGET2),y) ifneq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y) + $(HOST_BIN): config.h $(HOST_OBJS) @echo "LD: $@" $(Q) $(HOSTCC) $(HOSTLDFLAGS) $(HOST_OBJS) -o $@ + +endif endif .built: config.h $(TARG_OBJS) @@ -177,9 +228,17 @@ endif ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat: $(DEPCONFIG) Makefile - $(call REGISTER,$(APPNAME1),$(PRIORITY1),$(STACKSIZE1),$(APPNAME1)_main) + $(call REGISTER,$(APPNAME1),$(PRIORITY1),$(STACKSIZE1),$(MAINNAME1)) +ifeq ($(CONFIG_EXAMPLES_UDP_TARGET2),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME2)_main.bdat: $(DEPCONFIG) Makefile + $(call REGISTER,$(APPNAME2),$(PRIORITY2),$(STACKSIZE2),$(MAINNAME2)) + +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat \ + $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME2)_main.bdat +else context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat +endif else context: endif @@ -191,9 +250,11 @@ endif depend: .depend clean: +ifneq ($(CONFIG_EXAMPLES_UDP_TARGET2),y) ifneq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y) $(call DELFILE, *.$(HOSTOBJEXT)) $(call DELFILE, $(HOST_BIN)) +endif endif $(call DELFILE, .built) $(call DELFILE, *.dSYM) diff --git a/examples/nettest/nettest_target1.c b/examples/nettest/nettest_target1.c index 784e7e76e..0a5d968dc 100644 --- a/examples/nettest/nettest_target1.c +++ b/examples/nettest/nettest_target1.c @@ -57,8 +57,10 @@ * nettest_main ****************************************************************************/ -#ifdef CONFIG_BUILD_KERNEL +#if defined(CONFIG_BUILD_KERNEL) int main(int argc, FAR char *argv[]) +#elif defined(CONFIG_EXAMPLES_NETTEST_TARGET2) +int nettest1_main(int argc, char *argv[]) #else int nettest_main(int argc, char *argv[]) #endif @@ -83,8 +85,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_SERVER_PRIORITY, - CONFIG_EXAMPLES_NETTEST_SERVER_STACKSIZE, server_child, + child = task_create("Nettest Child", CONFIG_EXAMPLES_NETTEST_DAEMON_PRIORITY, + CONFIG_EXAMPLES_NETTEST_DAEMON_STACKSIZE, server_child, NULL); if (child < 0) { diff --git a/examples/nettest/nettest_target2.c b/examples/nettest/nettest_target2.c index 660a424fd..aa246b3c9 100644 --- a/examples/nettest/nettest_target2.c +++ b/examples/nettest/nettest_target2.c @@ -38,7 +38,7 @@ ****************************************************************************/ #include "config.h" - +#include #include "nettest.h" /**************************************************************************** diff --git a/examples/nettest/target_netinit.c b/examples/nettest/target_netinit.c index e5c84518e..78193737b 100644 --- a/examples/nettest/target_netinit.c +++ b/examples/nettest/target_netinit.c @@ -53,6 +53,16 @@ #ifdef CONFIG_EXAMPLES_NETTEST_INIT +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifdef CONFIG_EXAMPLES_NETTEST_DEVNAME +# define DEVNAME CONFIG_EXAMPLES_NETTEST_DEVNAME +#else +# define DEVNAME "eth0" +#endif + /**************************************************************************** * Private Data ****************************************************************************/ @@ -126,37 +136,37 @@ void nettest_initialize(void) mac[3] = 0xad; mac[4] = 0xbe; mac[5] = 0xef; - netlib_setmacaddr("eth0", mac); + netlib_setmacaddr(DEVNAME, mac); #endif #ifdef CONFIG_EXAMPLES_NETTEST_IPv6 #ifdef CONFIG_NET_ICMPv6_AUTOCONF /* Perform ICMPv6 auto-configuration */ - netlib_icmpv6_autoconfiguration("eth0"); + netlib_icmpv6_autoconfiguration(DEVNAME); #else /* CONFIG_NET_ICMPv6_AUTOCONF */ /* Set up our fixed host address */ - netlib_set_ipv6addr("eth0", + netlib_set_ipv6addr(DEVNAME, (FAR const struct in6_addr *)g_ipv6_hostaddr); /* Set up the default router address */ - netlib_set_dripv6addr("eth0", + netlib_set_dripv6addr(DEVNAME, (FAR const struct in6_addr *)g_ipv6_draddr); /* Setup the subnet mask */ - netlib_set_ipv6netmask("eth0", + netlib_set_ipv6netmask(DEVNAME, (FAR const struct in6_addr *)g_ipv6_netmask); /* New versions of netlib_set_ipvXaddr will not bring the network up, * So ensure the network is really up at this point. */ - netlib_ifup("eth0"); + netlib_ifup(DEVNAME); #endif /* CONFIG_NET_ICMPv6_AUTOCONF */ #else /* CONFIG_EXAMPLES_NETTEST_IPv6 */ @@ -164,17 +174,17 @@ void nettest_initialize(void) /* Set up our host address */ addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_IPADDR); - netlib_set_ipv4addr("eth0", &addr); + netlib_set_ipv4addr(DEVNAME, &addr); /* Set up the default router address */ addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_DRIPADDR); - netlib_set_dripv4addr("eth0", &addr); + netlib_set_dripv4addr(DEVNAME, &addr); /* Setup the subnet mask */ addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_NETMASK); - netlib_set_ipv4netmask("eth0", &addr); + netlib_set_ipv4netmask(DEVNAME, &addr); #endif /* CONFIG_EXAMPLES_NETTEST_IPv6 */ } diff --git a/examples/udp/Kconfig b/examples/udp/Kconfig index 851094d9a..ba81ca0de 100644 --- a/examples/udp/Kconfig +++ b/examples/udp/Kconfig @@ -42,7 +42,7 @@ config EXAMPLES_UDP_TARGET2 By default, the host PC is configured as the second endpoint of the UDP test. If this option is selected, then the second endpoint will be built into the FLASH image as well. This means that you - can use two target boards to run the test with not host PC + can use two target boards to run the test with no host PC involvement. if EXAMPLES_UDP_TARGET2 diff --git a/examples/udp/Makefile b/examples/udp/Makefile index f4a7e2994..902d34d66 100644 --- a/examples/udp/Makefile +++ b/examples/udp/Makefile @@ -77,15 +77,15 @@ STACKSIZE1 = $(CONFIG_EXAMPLES_UDP_STACKSIZE1) ifeq ($(CONFIG_EXAMPLES_UDP_TARGET2),y) -TARG2_CRCS = +TARG2_CSRCS = ifeq ($(CONFIG_EXAMPLES_UDP_SERVER1),y) -TARG2_CRCS += udp_client.c +TARG2_CSRCS += udp_client.c else -TARG2_CRCS += udp_server.c +TARG2_CSRCS += udp_server.c endif TARG2_MAINSRC = udp_target2.c -TARG2_COBJS = $(TARG2_CRCS:.c=$(OBJEXT)) +TARG2_COBJS = $(TARG2_CSRCS:.c=$(OBJEXT)) TARG2_MAINOBJ = $(TARG2_MAINSRC:.c=$(OBJEXT)) ifeq ($(CONFIG_EXAMPLES_UDP_SERVER1),y) @@ -104,7 +104,7 @@ STACKSIZE2 = $(CONFIG_EXAMPLES_UDP_STACKSIZE2) endif -TARG_SRCS = $(TARG1_CRCS) $(TARG1_MAINSRC) $(TARG2_CRCS) $(TARG2_MAINSRC) $(TARGCMN_CSRCS) +TARG_SRCS = $(TARG1_CRCS) $(TARG1_MAINSRC) $(TARG2_CSRCS) $(TARG2_MAINSRC) $(TARGCMN_CSRCS) TARG_OBJS = $(TARG1_COBJS) $(TARG2_COBJS) $(TARGCMN_COBJS) ifneq ($(CONFIG_BUILD_KERNEL),y) From 54d55cb307bdc95bd8e358b9c459328e51ec0bc9 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 23 Jun 2017 18:13:51 -0600 Subject: [PATCH 11/19] system/dhcpc: The DHCPC renew command did not build correctly due to naming problems. Noted by Masayuki Ishikawa, --- system/dhcpc/Kconfig | 10 ++-- system/dhcpc/Make.defs | 2 +- system/dhcpc/Makefile | 53 ++++++++++----------- system/dhcpc/{dhcpc_main.c => renew_main.c} | 6 +-- 4 files changed, 34 insertions(+), 37 deletions(-) rename system/dhcpc/{dhcpc_main.c => renew_main.c} (98%) diff --git a/system/dhcpc/Kconfig b/system/dhcpc/Kconfig index 9b88c0392..014e94f49 100644 --- a/system/dhcpc/Kconfig +++ b/system/dhcpc/Kconfig @@ -3,7 +3,7 @@ # see the file kconfig-language.txt in the NuttX tools repository. # -config SYSTEM_DHCPC +config SYSTEM_DHCPC_RENEW bool "DHCP Address Renewal" default n select NETUTILS_DHCPC @@ -11,9 +11,9 @@ config SYSTEM_DHCPC ---help--- Enble the DHCP client 'renew' command -if SYSTEM_DHCPC +if SYSTEM_DHCPC_RENEW -config SYSTEM_DHCPC_PROGNAME +config DHCPC_RENEW_PROGNAME string "Program name" default "renew" depends on BUILD_KERNEL @@ -21,11 +21,11 @@ config SYSTEM_DHCPC_PROGNAME This is the name of the program that will be use when the NSH ELF program is installed. -config SYSTEM_DHCPC_PRIORITY +config DHCPC_RENEW_PRIORITY int "DHCPC task priority" default 100 -config SYSTEM_DHCPC_STACKSIZE +config DHCPC_RENEW_STACKSIZE int "DHCPC stack size" default 2048 diff --git a/system/dhcpc/Make.defs b/system/dhcpc/Make.defs index 7e559c2a2..81c55afe8 100644 --- a/system/dhcpc/Make.defs +++ b/system/dhcpc/Make.defs @@ -34,7 +34,7 @@ # ############################################################################ -ifeq ($(CONFIG_SYSTEM_DHCPC),y) +ifeq ($(CONFIG_SYSTEM_DHCPC_RENEW),y) CONFIGURED_APPS += system/dhcpc endif diff --git a/system/dhcpc/Makefile b/system/dhcpc/Makefile index 935277acf..52e937d6e 100644 --- a/system/dhcpc/Makefile +++ b/system/dhcpc/Makefile @@ -39,31 +39,31 @@ include $(APPDIR)/Make.defs # DHCPC address renewal built-in application info -CONFIG_SYSTEM_DHCPC_PRIORITY ?= SCHED_PRIORITY_DEFAULT -CONFIG_SYSTEM_DHCPC_STACKSIZE ?= 2048 +CONFIG_DHCPC_RENEW_PRIORITY ?= SCHED_PRIORITY_DEFAULT +CONFIG_DHCPC_RENEW_STACKSIZE ?= 2048 -APPNAME = renew -PRIORITY = $(CONFIG_SYSTEM_DHCPC_PRIORITY) -STACKSIZE = $(CONFIG_SYSTEM_DHCPC_STACKSIZE) +RENEW_APPNAME = renew +RENEW_PRIORITY = $(CONFIG_DHCPC_RENEW_PRIORITY) +RENEW_STACKSIZE = $(CONFIG_DHCPC_RENEW_STACKSIZE) -CONFIG_SYSTEM_DHCPC_PROGNAME ?= renew$(EXEEXT) -PROGNAME = $(CONFIG_SYSTEM_DHCPC_PROGNAME) +CONFIG_DHCPC_RENEW_PROGNAME ?= renew$(EXEEXT) +RENEW_PROGNAME = $(CONFIG_DHCPC_RENEW_PROGNAME) # DHCPC address renewal -ASRCS = -CSRCS = -MAINSRC = dhcpc_main.c +RENEW_SRCS = +RENEW_MAINSRC = renew_main.c -AOBJS = $(ASRCS:.S=$(OBJEXT)) -COBJS = $(CSRCS:.c=$(OBJEXT)) -MAINOBJ = $(MAINSRC:.c=$(OBJEXT)) +RENEW_OBJS = $(RENEW_SRCS:.c=$(OBJEXT)) +RENEW_MAINOBJ = $(RENEW_MAINSRC:.c=$(OBJEXT)) -SRCS = $(ASRCS) $(CSRCS) $(MAINSRC) -OBJS = $(AOBJS) $(COBJS) +# Other DHCPC commands go here + +SRCS = $(RENEW_SRCS) $(RENEW_MAINSRC) +OBJS = $(RENEW_OBJS) ifneq ($(CONFIG_BUILD_KERNEL),y) - OBJS += $(MAINOBJ) + OBJS += $(RENEW_MAINOBJ) endif ifeq ($(CONFIG_WINDOWS_NATIVE),y) @@ -91,10 +91,7 @@ VPATH = all: .built .PHONY: clean depend distclean -$(AOBJS): %$(OBJEXT): %.S - $(call ASSEMBLE, $<, $@) - -$(COBJS) $(MAINOBJ): %$(OBJEXT): %.c +$(OBJS) $(RENEW_MAINOBJ): %$(OBJEXT): %.c $(call COMPILE, $<, $@) .built: $(OBJS) @@ -102,12 +99,12 @@ $(COBJS) $(MAINOBJ): %$(OBJEXT): %.c @touch .built ifeq ($(CONFIG_BUILD_KERNEL),y) -$(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJS) $(MAINOBJ) - @echo "LD: $(PROGNAME)" - $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME) $(ARCHCRT0OBJ) $(MAINOBJ) $(LDLIBS) - $(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(PROGNAME) +$(BIN_DIR)$(DELIM)$(RENEW_PROGNAME): $(OBJS) $(RENEW_MAINOBJ) + @echo "LD: $(RENEW_PROGNAME)" + $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(RENEW_PROGNAME) $(ARCHCRT0OBJ) $(RENEW_MAINOBJ) $(LDLIBS) + $(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(RENEW_PROGNAME) -install: $(BIN_DIR)$(DELIM)$(PROGNAME) +install: $(BIN_DIR)$(DELIM)$(RENEW_PROGNAME) else install: @@ -115,10 +112,10 @@ install: endif ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile - $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) +$(BUILTIN_REGISTRY)$(DELIM)$(RENEW_APPNAME)_main.bdat: $(DEPCONFIG) Makefile + $(call REGISTER,$(RENEW_APPNAME),$(RENEW_PRIORITY),$(RENEW_STACKSIZE),$(RENEW_APPNAME)_main) -context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +context: $(BUILTIN_REGISTRY)$(DELIM)$(RENEW_APPNAME)_main.bdat else context: endif diff --git a/system/dhcpc/dhcpc_main.c b/system/dhcpc/renew_main.c similarity index 98% rename from system/dhcpc/dhcpc_main.c rename to system/dhcpc/renew_main.c index 496a9a0e8..0e7d0c15e 100644 --- a/system/dhcpc/dhcpc_main.c +++ b/system/dhcpc/renew_main.c @@ -1,5 +1,5 @@ /**************************************************************************** - * system/dhcpc/dhcpc_main.c + * system/dhcpc/renew_main.c * * Copyright (C) 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -66,13 +66,13 @@ static void dhcpc_showusage(FAR const char *progname, int exitcode) ****************************************************************************/ /**************************************************************************** - * dhcpc_main + * renew_main ****************************************************************************/ #ifdef CONFIG_BUILD_KERNEL int main(int argc, FAR char *argv[]) #else -int dhcpc_main(int argc, char *argv[]) +int renew_main(int argc, char *argv[]) #endif { FAR const char *devname; From 3c97bfeae6815f56f1694f94f435c07af9e5a0af Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 23 Jun 2017 19:14:39 -0600 Subject: [PATCH 12/19] examples/nettest: Fixes for building with loopback device again after the last changes. --- examples/README.txt | 13 +++++++++++++ examples/nettest/Kconfig | 5 ++++- examples/nettest/nettest_client.c | 2 +- examples/nettest/nettest_server.c | 2 +- examples/nettest/nettest_target1.c | 12 ++++++++++++ examples/nettest/target_netinit.c | 11 ----------- 6 files changed, 31 insertions(+), 14 deletions(-) diff --git a/examples/README.txt b/examples/README.txt index b777737c9..a0de89082 100644 --- a/examples/README.txt +++ b/examples/README.txt @@ -960,6 +960,13 @@ examples/nettest CONFIG_EXAMPLES_NETTEST=y - Enables the nettest example CONFIG_EXAMPLES_NETLIB=y - The networking library in needed. + Configurations: + + - Server on target hardware; client on host + - Client on target hardware; Server on host + - Server and Client on different targets. + - Loopback configuration with both client and server on the same target. + See also examples/tcpecho examples/nrf24l01_term @@ -2106,6 +2113,12 @@ examples/udp CONFIG_NETUTILS_NETLIB=y + Possible configurations: + + - Server on target hardware; client on host + - Client on target hardware; Server on host + - Server and Client on different targets. + examples/udpblaster ^^^^^^^^^^^^^^^^^^^ diff --git a/examples/nettest/Kconfig b/examples/nettest/Kconfig index 67aef0954..eb6de63a8 100644 --- a/examples/nettest/Kconfig +++ b/examples/nettest/Kconfig @@ -78,14 +78,17 @@ config EXAMPLES_NETTEST_STACKSIZE2 default 2048 endif # EXAMPLES_NETTEST_TARGET2 +endif # !EXAMPLES_NETTEST_LOOPBACK +if EXAMPLES_NETTEST_LOOPBACK config EXAMPLES_NETTEST_DAEMON_STACKSIZE int "Server daemon stack size" default 2048 -config EXAMPLES_NETTEST_DEAMON_PRIORITY +config EXAMPLES_NETTEST_DAEMON_PRIORITY int "Server daemon priority" default 100 +#endif endif # EXAMPLES_NETTEST_LOOPBACK diff --git a/examples/nettest/nettest_client.c b/examples/nettest/nettest_client.c index 4883504df..8792fa527 100644 --- a/examples/nettest/nettest_client.c +++ b/examples/nettest/nettest_client.c @@ -1,5 +1,5 @@ /**************************************************************************** - * examples/nettest/nettest-client.c + * examples/nettest/nettest_client.c * * Copyright (C) 2007, 2011-2012, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/examples/nettest/nettest_server.c b/examples/nettest/nettest_server.c index 755fdf096..1f74ed2c9 100644 --- a/examples/nettest/nettest_server.c +++ b/examples/nettest/nettest_server.c @@ -120,7 +120,7 @@ void recv_server(void) #endif addrlen = sizeof(struct sockaddr_in6); - printf("Binding to IPv6 Address: %04x:04x:04x:04x:04x:04x:04x:04x\n", + printf("Binding to 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], diff --git a/examples/nettest/nettest_target1.c b/examples/nettest/nettest_target1.c index 0a5d968dc..a5ae33a13 100644 --- a/examples/nettest/nettest_target1.c +++ b/examples/nettest/nettest_target1.c @@ -49,6 +49,18 @@ #include "nettest.h" +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +#ifdef CONFIG_EXAMPLES_NETTEST_LOOPBACK +static int server_child(int argc, char *argv[]) +{ + recv_server(); + return EXIT_SUCCESS; +} +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/examples/nettest/target_netinit.c b/examples/nettest/target_netinit.c index 78193737b..ecf82d673 100644 --- a/examples/nettest/target_netinit.c +++ b/examples/nettest/target_netinit.c @@ -117,7 +117,6 @@ static const uint16_t g_ipv6_netmask[8] = * Public Functions ****************************************************************************/ -#ifdef CONFIG_EXAMPLES_NETTEST_INIT void nettest_initialize(void) { #ifndef CONFIG_EXAMPLES_NETTEST_IPv6 @@ -188,16 +187,6 @@ void nettest_initialize(void) #endif /* CONFIG_EXAMPLES_NETTEST_IPv6 */ } -#endif /*CONFIG_EXAMPLES_NETTEST_INIT */ - -#ifdef CONFIG_EXAMPLES_NETTEST_LOOPBACK -static int server_child(int argc, char *argv[]) -{ - recv_server(); - return EXIT_SUCCESS; -} -#endif - #endif /* CONFIG_EXAMPLES_NETTEST_INIT */ From b868fbe87908a369214e979ede3b21fc44d06ff0 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 24 Jun 2017 09:49:44 -0600 Subject: [PATCH 13/19] examples/nettest: The send buffer size is now a configuration option. --- examples/nettest/Kconfig | 8 ++++++++ examples/nettest/nettest.h | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/examples/nettest/Kconfig b/examples/nettest/Kconfig index eb6de63a8..5cdda3419 100644 --- a/examples/nettest/Kconfig +++ b/examples/nettest/Kconfig @@ -12,6 +12,14 @@ config EXAMPLES_NETTEST if EXAMPLES_NETTEST +config EXAMPLES_NETTEST_SENDSIZE + int "Payload size" + default 4096 + ---help--- + The test client sends well-known packets to ther server. The server + will receive and verfity those packets. This setting determines + size of each packet. + config EXAMPLES_NETTEST_PROGNAME1 string "Target1 program name" default "nettest" diff --git a/examples/nettest/nettest.h b/examples/nettest/nettest.h index a795e96e9..51996ff66 100644 --- a/examples/nettest/nettest.h +++ b/examples/nettest/nettest.h @@ -81,7 +81,11 @@ # define CONFIG_EXAMPLES_NETTEST_SERVER_PORTNO 5471 #endif -#define SENDSIZE 4096 +#ifdef CONFIG_EXAMPLES_NETTEST_SENDSIZE +# define SENDSIZE CONFIG_EXAMPLES_NETTEST_SENDSIZE +#else +# define SENDSIZE 4096 +#endif /**************************************************************************** * Public Data From 664ab42da7e2947425e4acbfae49333a04e6e9ab Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 25 Jun 2017 09:15:27 -0600 Subject: [PATCH 14/19] examples/udp and examples/nettest: Fix some naming collisions; examples/nettest: Fix some build issues with two targets. --- examples/nettest/Kconfig | 4 ++-- examples/nettest/Makefile | 14 +++++++------- examples/nettest/nettest.h | 10 +++++----- examples/nettest/nettest_client.c | 12 ++++++------ examples/nettest/nettest_cmdline.c | 14 +++++++------- examples/nettest/nettest_host.c | 4 ++-- .../{target_netinit.c => nettest_initinit.c} | 2 +- examples/nettest/nettest_server.c | 6 +++--- examples/nettest/nettest_target1.c | 8 ++++---- examples/nettest/nettest_target2.c | 6 +++--- examples/udp/Makefile | 2 +- examples/udp/udp.h | 12 ++++++------ examples/udp/udp_client.c | 6 +++--- examples/udp/udp_cmdline.c | 12 ++++++------ examples/udp/udp_host.c | 6 +++--- examples/udp/{target_netinit.c => udp_netinit.c} | 6 +++--- examples/udp/udp_server.c | 2 +- examples/udp/udp_target1.c | 8 ++++---- examples/udp/udp_target2.c | 8 ++++---- 19 files changed, 71 insertions(+), 71 deletions(-) rename examples/nettest/{target_netinit.c => nettest_initinit.c} (99%) rename examples/udp/{target_netinit.c => udp_netinit.c} (98%) diff --git a/examples/nettest/Kconfig b/examples/nettest/Kconfig index 5cdda3419..5eea86439 100644 --- a/examples/nettest/Kconfig +++ b/examples/nettest/Kconfig @@ -70,8 +70,8 @@ if EXAMPLES_NETTEST_TARGET2 config EXAMPLES_NETTEST_PROGNAME2 string "Target2 program name" - default "udpserver" if !EXAMPLES_NETTEST_SERVER2 - default "udpclient" if EXAMPLES_NETTEST_SERVER2 + default "tcpserver" if !EXAMPLES_NETTEST_SERVER2 + default "tcpclient" if EXAMPLES_NETTEST_SERVER2 depends on BUILD_KERNEL ---help--- This is the name of the Target2 program that will be use when the diff --git a/examples/nettest/Makefile b/examples/nettest/Makefile index b082fe532..ba2241cea 100644 --- a/examples/nettest/Makefile +++ b/examples/nettest/Makefile @@ -41,7 +41,7 @@ include $(APPDIR)/Make.defs TARGCMN_CSRCS = nettest_cmdline.c ifeq ($(CONFIG_EXAMPLES_NETTEST_INIT),y) -TARGCMN_CSRCS += target_netinit.c +TARGCMN_CSRCS += nettest_netinit.c endif TARGCMN_COBJS = $(TARGCMN_CSRCS:.c=$(OBJEXT)) @@ -92,7 +92,7 @@ TARG2_CSRCS += nettest_server.c endif TARG2_MAINSRC = nettest_target2.c -TARG2_COBJS = $(TARG2_CCRCS:.c=$(OBJEXT)) +TARG2_COBJS = $(TARG2_CSRCS:.c=$(OBJEXT)) TARG2_MAINOBJ = $(TARG2_MAINSRC:.c=$(OBJEXT)) # Target 2 Application Info @@ -182,10 +182,10 @@ VPATH = all: .built $(HOST_BIN) .PHONY: clean depend distclean preconfig -$(TARG1_COBJS) $(TARG1_MAINOBJ) $(TARGCMN_COBJS) : %$(OBJEXT): %.c +$(TARG1_COBJS) $(TARG1_MAINOBJ) $(TARG2_COBJS) $(TARG2_MAINOBJ) $(TARGCMN_COBJS) : %$(OBJEXT): %.c $(call COMPILE, $<, $@) -ifneq ($(CONFIG_EXAMPLES_UDP_TARGET2),y) +ifneq ($(CONFIG_EXAMPLES_NETTEST_TARGET2),y) ifneq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y) $(HOST_OBJS): %.$(HOSTOBJEXT): %.c @@ -199,7 +199,7 @@ config.h: $(TOPDIR)/include/nuttx/config.h @echo "CP: $<" $(Q) cp $< $@ -ifneq ($(CONFIG_EXAMPLES_UDP_TARGET2),y) +ifneq ($(CONFIG_EXAMPLES_NETTEST_TARGET2),y) ifneq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y) $(HOST_BIN): config.h $(HOST_OBJS) @@ -230,7 +230,7 @@ ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME1),$(PRIORITY1),$(STACKSIZE1),$(MAINNAME1)) -ifeq ($(CONFIG_EXAMPLES_UDP_TARGET2),y) +ifeq ($(CONFIG_EXAMPLES_NETTEST_TARGET2),y) $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME2)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME2),$(PRIORITY2),$(STACKSIZE2),$(MAINNAME2)) @@ -250,7 +250,7 @@ endif depend: .depend clean: -ifneq ($(CONFIG_EXAMPLES_UDP_TARGET2),y) +ifneq ($(CONFIG_EXAMPLES_NETTEST_TARGET2),y) ifneq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y) $(call DELFILE, *.$(HOSTOBJEXT)) $(call DELFILE, $(HOST_BIN)) diff --git a/examples/nettest/nettest.h b/examples/nettest/nettest.h index 51996ff66..18e78f222 100644 --- a/examples/nettest/nettest.h +++ b/examples/nettest/nettest.h @@ -92,9 +92,9 @@ ****************************************************************************/ #ifdef CONFIG_EXAMPLES_NETTEST_IPv6 -uint16_t g_server_ipv6[8]; +uint16_t g_nettestserver_ipv6[8]; #else -uint32_t g_server_ipv4; +uint32_t g_nettestserver_ipv4; #endif /**************************************************************************** @@ -105,8 +105,8 @@ uint32_t g_server_ipv4; void nettest_initialize(void); #endif -void parse_cmdline(int argc, char **argv); -extern void send_client(void); -extern void recv_server(void); +void nettest_cmdline(int argc, char **argv); +extern void nettest_client(void); +extern void nettest_server(void); #endif /* __EXAMPLES_NETTEST_H */ diff --git a/examples/nettest/nettest_client.c b/examples/nettest/nettest_client.c index 8792fa527..00035b14d 100644 --- a/examples/nettest/nettest_client.c +++ b/examples/nettest/nettest_client.c @@ -56,7 +56,7 @@ * Public Functions ****************************************************************************/ -void send_client(void) +void nettest_client(void) { #ifdef CONFIG_EXAMPLES_NETTEST_IPv6 struct sockaddr_in6 server; @@ -105,19 +105,19 @@ void send_client(void) #ifdef CONFIG_EXAMPLES_NETTEST_IPv6 server.sin6_family = AF_INET6; server.sin6_port = HTONS(CONFIG_EXAMPLES_NETTEST_SERVER_PORTNO); - memcpy(server.sin6_addr.s6_addr16, g_server_ipv6, 8 * sizeof(uint16_t)); + memcpy(server.sin6_addr.s6_addr16, g_nettestserver_ipv6, 8 * sizeof(uint16_t)); addrlen = sizeof(struct sockaddr_in6); printf("Connecting to IPv6 Address: %04x:04x:04x:04x:04x:04x:04x:04x\n", - g_server_ipv6[0], g_server_ipv6[1], g_server_ipv6[2], g_server_ipv6[3], - g_server_ipv6[4], g_server_ipv6[5], g_server_ipv6[6], g_server_ipv6[7]); + g_nettestserver_ipv6[0], g_nettestserver_ipv6[1], g_nettestserver_ipv6[2], g_nettestserver_ipv6[3], + g_nettestserver_ipv6[4], g_nettestserver_ipv6[5], g_nettestserver_ipv6[6], g_nettestserver_ipv6[7]); #else server.sin_family = AF_INET; server.sin_port = HTONS(CONFIG_EXAMPLES_NETTEST_SERVER_PORTNO); - server.sin_addr.s_addr = (in_addr_t)g_server_ipv4; + server.sin_addr.s_addr = (in_addr_t)g_nettestserver_ipv4; addrlen = sizeof(struct sockaddr_in); - printf("Connecting to IPv4 Address: %08lx\n", (unsigned long)g_server_ipv4); + printf("Connecting to IPv4 Address: %08lx\n", (unsigned long)g_nettestserver_ipv4); #endif /* Connect the socket to the server */ diff --git a/examples/nettest/nettest_cmdline.c b/examples/nettest/nettest_cmdline.c index 479e83336..7ebe57b06 100644 --- a/examples/nettest/nettest_cmdline.c +++ b/examples/nettest/nettest_cmdline.c @@ -51,7 +51,7 @@ #ifdef CONFIG_EXAMPLES_NETTEST_IPv6 -uint16_t g_server_ipv6[8] = +uint16_t g_nettestserver_ipv6[8] = { #if defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK) && defined(NET_LOOPBACK) 0 /* Use the loopback address */ @@ -77,9 +77,9 @@ uint16_t g_server_ipv6[8] = #else #if defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK) && defined(NET_LOOPBACK) -uint32_t g_server_ipv4 = HTONL(0x7f000001); +uint32_t g_nettestserver_ipv4 = HTONL(0x7f000001); #else -uint32_t g_server_ipv4 = HTONL(CONFIG_EXAMPLES_NETTEST_SERVERIP); +uint32_t g_nettestserver_ipv4 = HTONL(CONFIG_EXAMPLES_NETTEST_SERVERIP); #endif #endif @@ -103,10 +103,10 @@ static void show_usage(FAR const char *progname) ****************************************************************************/ /**************************************************************************** - * parse_cmdline + * nettest_cmdline ****************************************************************************/ -void parse_cmdline(int argc, char **argv) +void nettest_cmdline(int argc, char **argv) { /* Currently only a single command line option is supported: The server * IP address. @@ -119,9 +119,9 @@ void parse_cmdline(int argc, char **argv) /* Convert the argument into a binary address */ #ifdef CONFIG_EXAMPLES_NETTEST_IPv6 - ret = inet_pton(AF_INET6, argv[1], g_server_ipv6); + ret = inet_pton(AF_INET6, argv[1], g_nettestserver_ipv6); #else - ret = inet_pton(AF_INET, argv[1], &g_server_ipv4); + ret = inet_pton(AF_INET, argv[1], &g_nettestserver_ipv4); #endif if (ret < 0) { diff --git a/examples/nettest/nettest_host.c b/examples/nettest/nettest_host.c index f89477655..00db47603 100644 --- a/examples/nettest/nettest_host.c +++ b/examples/nettest/nettest_host.c @@ -55,9 +55,9 @@ int main(int argc, char **argv, char **envp) { #ifdef CONFIG_EXAMPLES_NETTEST_SERVER - send_client(); + nettest_client(); #else - recv_server(); + nettest_server(); #endif return 0; diff --git a/examples/nettest/target_netinit.c b/examples/nettest/nettest_initinit.c similarity index 99% rename from examples/nettest/target_netinit.c rename to examples/nettest/nettest_initinit.c index ecf82d673..8a5072104 100644 --- a/examples/nettest/target_netinit.c +++ b/examples/nettest/nettest_initinit.c @@ -1,5 +1,5 @@ /**************************************************************************** - * examples/nettest/target_netinit.c + * examples/nettest/nettest_netinit.c * * Copyright (C) 2007, 2009-2011, 2015, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/examples/nettest/nettest_server.c b/examples/nettest/nettest_server.c index 1f74ed2c9..0d690edae 100644 --- a/examples/nettest/nettest_server.c +++ b/examples/nettest/nettest_server.c @@ -57,7 +57,7 @@ * Public Functions ****************************************************************************/ -void recv_server(void) +void nettest_server(void) { #ifdef CONFIG_EXAMPLES_NETTEST_IPv6 struct sockaddr_in6 myaddr; @@ -114,7 +114,7 @@ void recv_server(void) myaddr.sin6_family = AF_INET6; myaddr.sin6_port = HTONS(CONFIG_EXAMPLES_NETTEST_SERVER_PORTNO); #if defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK) && !defined(NET_LOOPBACK) - memcpy(myaddr.sin6_addr.s6_addr16, g_server_ipv6, 8 * sizeof(uint16_t)); + memcpy(myaddr.sin6_addr.s6_addr16, g_nettestserver_ipv6, 8 * sizeof(uint16_t)); #else memset(myaddr.sin6_addr.s6_addr16, 0, 8 * sizeof(uint16_t)); #endif @@ -130,7 +130,7 @@ void recv_server(void) myaddr.sin_port = HTONS(CONFIG_EXAMPLES_NETTEST_SERVER_PORTNO); #if defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK) && !defined(NET_LOOPBACK) - myaddr.sin_addr.s_addr = (in_addr_t)g_server_ipv4; + myaddr.sin_addr.s_addr = (in_addr_t)g_nettestserver_ipv4; #else myaddr.sin_addr.s_addr = INADDR_ANY; #endif diff --git a/examples/nettest/nettest_target1.c b/examples/nettest/nettest_target1.c index a5ae33a13..2d6076708 100644 --- a/examples/nettest/nettest_target1.c +++ b/examples/nettest/nettest_target1.c @@ -56,7 +56,7 @@ #ifdef CONFIG_EXAMPLES_NETTEST_LOOPBACK static int server_child(int argc, char *argv[]) { - recv_server(); + nettest_server(); return EXIT_SUCCESS; } #endif @@ -86,7 +86,7 @@ int nettest_main(int argc, char *argv[]) /* Parse any command line options */ - parse_cmdline(argc, argv); + nettest_cmdline(argc, argv); #ifdef CONFIG_EXAMPLES_NETTEST_INIT /* Initialize the network */ @@ -111,14 +111,14 @@ int nettest_main(int argc, char *argv[]) #elif defined(CONFIG_EXAMPLES_NETTEST_SERVER) /* Then perform the server side of the test on this thread */ - recv_server(); + nettest_server(); #endif #if !defined(CONFIG_EXAMPLES_NETTEST_SERVER) || \ defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK) /* Then perform the client side of the test on this thread */ - send_client(); + nettest_client(); #endif #if defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK) && defined(CONFIG_SCHED_WAITPID) diff --git a/examples/nettest/nettest_target2.c b/examples/nettest/nettest_target2.c index aa246b3c9..277b1e1df 100644 --- a/examples/nettest/nettest_target2.c +++ b/examples/nettest/nettest_target2.c @@ -53,7 +53,7 @@ int nettest2_main(int argc, char *argv[]) { /* Parse any command line options */ - parse_cmdline(argc, argv); + nettest_cmdline(argc, argv); #ifdef CONFIG_EXAMPLES_NETTEST_INIT /* Initialize the network */ @@ -64,11 +64,11 @@ int nettest2_main(int argc, char *argv[]) #if defined(CONFIG_EXAMPLES_NETTEST_SERVER) /* Then perform the client side of the test on this thread */ - send_client(); + nettest_client(); #else /* Then perform the server side of the test on this thread */ - recv_server(); + nettest_server(); #endif return EXIT_SUCCESS; diff --git a/examples/udp/Makefile b/examples/udp/Makefile index 902d34d66..e75da5306 100644 --- a/examples/udp/Makefile +++ b/examples/udp/Makefile @@ -41,7 +41,7 @@ include $(APPDIR)/Make.defs TARGCMN_CSRCS = udp_cmdline.c ifeq ($(CONFIG_EXAMPLES_UDP_NETINIT),y) -TARGCMN_CSRCS += target_netinit.c +TARGCMN_CSRCS += udp_netinit.c endif TARGCMN_COBJS = $(TARGCMN_CSRCS:.c=$(OBJEXT)) diff --git a/examples/udp/udp.h b/examples/udp/udp.h index 193d5e2cb..b00bac9bb 100644 --- a/examples/udp/udp.h +++ b/examples/udp/udp.h @@ -99,9 +99,9 @@ ****************************************************************************/ #ifdef CONFIG_EXAMPLES_UDP_IPv6 -uint16_t g_server_ipv6[8]; +uint16_t g_udpserver_ipv6[8]; #else -uint32_t g_server_ipv4; +uint32_t g_udpserver_ipv4; #endif /**************************************************************************** @@ -109,11 +109,11 @@ uint32_t g_server_ipv4; ****************************************************************************/ #ifdef CONFIG_EXAMPLES_UDP_NETINIT -int target_netinit(void); +int udp_netinit(void); #endif -void parse_cmdline(int argc, char **argv); -void send_client(void); -void recv_server(void); +void udp_cmdline(int argc, char **argv); +void udp_client(void); +void udp_server(void); #endif /* __EXAMPLES_UDP_UDP_H */ diff --git a/examples/udp/udp_client.c b/examples/udp/udp_client.c index 89742dca8..6387963b7 100644 --- a/examples/udp/udp_client.c +++ b/examples/udp/udp_client.c @@ -130,7 +130,7 @@ static inline void fill_buffer(unsigned char *buf, int offset) * Public Functions ****************************************************************************/ -void send_client(void) +void udp_client(void) { #ifdef CONFIG_EXAMPLES_UDP_IPv6 struct sockaddr_in6 server; @@ -165,12 +165,12 @@ void send_client(void) #ifdef CONFIG_EXAMPLES_UDP_IPv6 server.sin6_family = AF_INET6; server.sin6_port = HTONS(CONFIG_EXAMPLES_UDP_SERVER_PORTNO); - memcpy(server.sin6_addr.s6_addr16, g_server_ipv6, 8 * sizeof(uint16_t)); + memcpy(server.sin6_addr.s6_addr16, g_udpserver_ipv6, 8 * sizeof(uint16_t)); addrlen = sizeof(struct sockaddr_in6); #else server.sin_family = AF_INET; server.sin_port = HTONS(CONFIG_EXAMPLES_UDP_SERVER_PORTNO); - server.sin_addr.s_addr = (in_addr_t)g_server_ipv4; + server.sin_addr.s_addr = (in_addr_t)g_udpserver_ipv4; addrlen = sizeof(struct sockaddr_in); #endif diff --git a/examples/udp/udp_cmdline.c b/examples/udp/udp_cmdline.c index 8eb93f8d8..8645b972d 100644 --- a/examples/udp/udp_cmdline.c +++ b/examples/udp/udp_cmdline.c @@ -50,7 +50,7 @@ ****************************************************************************/ #ifdef CONFIG_EXAMPLES_UDP_IPv6 -uint16_t g_server_ipv6[8] = +uint16_t g_udpserver_ipv6[8] = { HTONS(CONFIG_EXAMPLES_UDP_SERVERIPv6ADDR_1), HTONS(CONFIG_EXAMPLES_UDP_SERVERIPv6ADDR_2), @@ -62,7 +62,7 @@ uint16_t g_server_ipv6[8] = HTONS(CONFIG_EXAMPLES_UDP_SERVERIPv6ADDR_8) }; #else -uint32_t g_server_ipv4 = HTONL(CONFIG_EXAMPLES_UDP_SERVERIP); +uint32_t g_udpserver_ipv4 = HTONL(CONFIG_EXAMPLES_UDP_SERVERIP); #endif /**************************************************************************** @@ -84,10 +84,10 @@ static void show_usage(FAR const char *progname) ****************************************************************************/ /**************************************************************************** - * parse_cmdline + * udp_cmdline ****************************************************************************/ -void parse_cmdline(int argc, char **argv) +void udp_cmdline(int argc, char **argv) { /* Currently only a single command line option is supported: The server * IP address. @@ -100,9 +100,9 @@ void parse_cmdline(int argc, char **argv) /* Convert the argument into a binary address */ #ifdef CONFIG_EXAMPLES_UDP_IPv6 - ret = inet_pton(AF_INET6, argv[1], g_server_ipv6); + ret = inet_pton(AF_INET6, argv[1], g_udpserver_ipv6); #else - ret = inet_pton(AF_INET, argv[1], &g_server_ipv4); + ret = inet_pton(AF_INET, argv[1], &g_udpserver_ipv4); #endif if (ret < 0) { diff --git a/examples/udp/udp_host.c b/examples/udp/udp_host.c index 7e1aaacc5..206389205 100644 --- a/examples/udp/udp_host.c +++ b/examples/udp/udp_host.c @@ -56,14 +56,14 @@ int main(int argc, char **argv, char **envp) { /* Parse any command line options */ - parse_cmdline(argc, argv); + udp_cmdline(argc, argv); /* Run the server or client, depending upon how target1 was configured */ #ifdef CONFIG_EXAMPLES_UDP_SERVER1 - send_client(); + udp_client(); #else - recv_server(); + udp_server(); #endif return 0; diff --git a/examples/udp/target_netinit.c b/examples/udp/udp_netinit.c similarity index 98% rename from examples/udp/target_netinit.c rename to examples/udp/udp_netinit.c index d66a6d3ca..52c3d5f9d 100644 --- a/examples/udp/target_netinit.c +++ b/examples/udp/udp_netinit.c @@ -1,5 +1,5 @@ /**************************************************************************** - * examples/udp/target_netinit.c + * examples/udp/udp_netinit.c * * Copyright (C) 2007, 2011, 2015, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -117,10 +117,10 @@ static bool g_initialized; ****************************************************************************/ /**************************************************************************** - * target_netinit + * udp_netinit ****************************************************************************/ -int target_netinit(void) +int udp_netinit(void) { if (!g_initialized) { diff --git a/examples/udp/udp_server.c b/examples/udp/udp_server.c index 967b493c7..08de11a76 100644 --- a/examples/udp/udp_server.c +++ b/examples/udp/udp_server.c @@ -84,7 +84,7 @@ static inline int check_buffer(unsigned char *buf) * Public Functions ****************************************************************************/ -void recv_server(void) +void udp_server(void) { #ifdef CONFIG_EXAMPLES_UDP_IPv6 struct sockaddr_in6 server; diff --git a/examples/udp/udp_target1.c b/examples/udp/udp_target1.c index ce655aec5..2b54bd5e5 100644 --- a/examples/udp/udp_target1.c +++ b/examples/udp/udp_target1.c @@ -58,20 +58,20 @@ int udp_main(int argc, char *argv[]) { /* Parse any command line options */ - parse_cmdline(argc, argv); + udp_cmdline(argc, argv); #ifdef CONFIG_EXAMPLES_UDP_NETINIT /* Initialize the network */ - (void)target_netinit(); + (void)udp_netinit(); #endif /* Run the server or client, depending upon how we are configured */ #ifdef CONFIG_EXAMPLES_UDP_SERVER1 - recv_server(); + udp_server(); #else - send_client(); + udp_client(); #endif return 0; diff --git a/examples/udp/udp_target2.c b/examples/udp/udp_target2.c index 0fcb6e37c..59aeee28c 100644 --- a/examples/udp/udp_target2.c +++ b/examples/udp/udp_target2.c @@ -56,20 +56,20 @@ int udp2_main(int argc, char *argv[]) { /* Parse any command line options */ - parse_cmdline(argc, argv); + udp_cmdline(argc, argv); #ifdef CONFIG_EXAMPLES_UDP_NETINIT /* Initialize the network */ - (void)target_netinit(); + (void)udp_netinit(); #endif /* Run the server or client, depending upon how target1 was configured */ #ifdef CONFIG_EXAMPLES_UDP_SERVER1 - send_client(); + udp_client(); #else - recv_server(); + udp_server(); #endif return 0; From 6b25b0d65e008ebd02fbe4b8857f96e4806b47ab Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 25 Jun 2017 13:01:21 -0600 Subject: [PATCH 15/19] examples/nettest: Fix some printf output --- examples/nettest/nettest_client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/nettest/nettest_client.c b/examples/nettest/nettest_client.c index 00035b14d..2d91877ec 100644 --- a/examples/nettest/nettest_client.c +++ b/examples/nettest/nettest_client.c @@ -108,7 +108,7 @@ void nettest_client(void) memcpy(server.sin6_addr.s6_addr16, g_nettestserver_ipv6, 8 * sizeof(uint16_t)); addrlen = sizeof(struct sockaddr_in6); - printf("Connecting to IPv6 Address: %04x:04x:04x:04x:04x:04x:04x:04x\n", + printf("Connecting to IPv6 Address: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", g_nettestserver_ipv6[0], g_nettestserver_ipv6[1], g_nettestserver_ipv6[2], g_nettestserver_ipv6[3], g_nettestserver_ipv6[4], g_nettestserver_ipv6[5], g_nettestserver_ipv6[6], g_nettestserver_ipv6[7]); #else From 88e0312897115d41409521a50f4fd3a2b4dc121f Mon Sep 17 00:00:00 2001 From: Anthony Merlino Date: Wed, 21 Jun 2017 15:01:39 -0400 Subject: [PATCH 16/19] ieee802154: Changes to support beacon-enabled networks --- include/wireless/ieee802154.h | 2 + wireless/ieee802154/i8sak/i8sak_acceptassoc.c | 10 +++ wireless/ieee802154/i8sak/i8sak_startpan.c | 24 +++++-- wireless/ieee802154/libmac/Makefile | 2 +- .../libmac/ieee802154_setassocpermit.c | 64 +++++++++++++++++++ 5 files changed, 97 insertions(+), 5 deletions(-) create mode 100644 wireless/ieee802154/libmac/ieee802154_setassocpermit.c diff --git a/include/wireless/ieee802154.h b/include/wireless/ieee802154.h index 7822a4e5c..276c90ad6 100644 --- a/include/wireless/ieee802154.h +++ b/include/wireless/ieee802154.h @@ -112,6 +112,8 @@ int ieee802154_getcca(int fd, FAR struct ieee802154_cca_s *cca); int ieee802154_getdevmode(int fd, FAR enum ieee802154_devmode_e *devmode); +int ieee802154_setassocpermit(int fd, bool assocpermit); + #ifdef CONFIG_NET_6LOWPAN /* Netork driver IOCTL helpers */ diff --git a/wireless/ieee802154/i8sak/i8sak_acceptassoc.c b/wireless/ieee802154/i8sak/i8sak_acceptassoc.c index c68caa466..6a896a76b 100644 --- a/wireless/ieee802154/i8sak/i8sak_acceptassoc.c +++ b/wireless/ieee802154/i8sak/i8sak_acceptassoc.c @@ -76,6 +76,7 @@ void i8sak_acceptassoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[] bool acceptall = true; /* start off assuming we are going to allow all connections */ int option; int optcnt; + int fd; optcnt = 0; while ((option = getopt(argc, argv, ":he:")) != ERROR) @@ -115,6 +116,15 @@ void i8sak_acceptassoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[] } } + fd = open(i8sak->devname, O_RDWR); + if (fd < 0) + { + printf("cannot open %s, errno=%d\n", i8sak->devname, errno); + i8sak_cmd_error(i8sak); + } + + ieee802154_setassocpermit(fd, true); + if (!optcnt) { i8sak->acceptall = acceptall; diff --git a/wireless/ieee802154/i8sak/i8sak_startpan.c b/wireless/ieee802154/i8sak/i8sak_startpan.c index 409e83ea2..5a09a58d7 100644 --- a/wireless/ieee802154/i8sak/i8sak_startpan.c +++ b/wireless/ieee802154/i8sak/i8sak_startpan.c @@ -73,11 +73,12 @@ void i8sak_startpan_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) { struct ieee802154_reset_req_s resetreq; struct ieee802154_start_req_s startreq; + bool beaconenabled = false; int option; int fd; int i; - while ((option = getopt(argc, argv, ":h")) != ERROR) + while ((option = getopt(argc, argv, ":hb")) != ERROR) { switch (option) { @@ -85,11 +86,15 @@ void i8sak_startpan_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) fprintf(stderr, "Starts PAN as PAN Coordinator\n" "Usage: %s [-h]\n" " -h = this help menu\n" + " -b = start beacon-enabled PAN\n" , argv[0]); /* Must manually reset optind if we are going to exit early */ optind = -1; return; + case 'b': + beaconenabled = true; + break; case ':': fprintf(stderr, "ERROR: missing argument\n"); /* Must manually reset optind if we are going to exit early */ @@ -184,11 +189,22 @@ void i8sak_startpan_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) printf("i8sak: starting PAN\n"); IEEE802154_PANIDCOPY(startreq.panid, i8sak->addr.panid); - startreq.chnum = i8sak->chnum; + startreq.chnum = i8sak->chnum; startreq.chpage = i8sak->chpage; - startreq.beaconorder = 15; - startreq.pancoord = true; + + if (beaconenabled) + { + startreq.beaconorder = 6; + startreq.superframeorder = 5; + } + else + { + startreq.beaconorder = 15; + } + + startreq.pancoord = true; startreq.coordrealign = false; + startreq.battlifeext = false; ieee802154_start_req(fd, &startreq); diff --git a/wireless/ieee802154/libmac/Makefile b/wireless/ieee802154/libmac/Makefile index fe4022108..6dbf07cf4 100644 --- a/wireless/ieee802154/libmac/Makefile +++ b/wireless/ieee802154/libmac/Makefile @@ -54,7 +54,7 @@ CSRCS += ieee802154_seteaddr.c ieee802154_geteaddr.c CSRCS += ieee802154_setpromisc.c ieee802154_getpromisc.c CSRCS += ieee802154_setrxonidle.c ieee802154_getrxonidle.c CSRCS += ieee802154_settxpwr.c ieee802154_gettxpwr.c -CSRCS += ieee802154_getdevmode.c +CSRCS += ieee802154_getdevmode.c ieee802154_setassocpermit.c ifeq ($(CONFIG_NET_6LOWPAN),y) # Add Get/Set Attribute helpers diff --git a/wireless/ieee802154/libmac/ieee802154_setassocpermit.c b/wireless/ieee802154/libmac/ieee802154_setassocpermit.c new file mode 100644 index 000000000..9336e4699 --- /dev/null +++ b/wireless/ieee802154/libmac/ieee802154_setassocpermit.c @@ -0,0 +1,64 @@ +/**************************************************************************** + * apps/wireless/ieee802154/libmac/ieee802154_assocpermit.c + * + * Copyright (C) 2017 Verge Inc. All rights reserved. + * Author: Anthony Merlino + * + * 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include + +#include + +#include "wireless/ieee802154.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int ieee802154_setassocpermit(int fd, bool assocpermit) +{ + struct ieee802154_set_req_s req; + + req.attr = IEEE802154_ATTR_MAC_ASSOCIATION_PERMIT; + req.attrval.mac.assocpermit = assocpermit; + + return ieee802154_set_req(fd, &req); +} From eee82fbc99ac60bb0a8c3bb0d929a67d95e612de Mon Sep 17 00:00:00 2001 From: Anthony Merlino Date: Sun, 25 Jun 2017 20:01:16 -0400 Subject: [PATCH 17/19] ieee802154: Adds scan command --- wireless/ieee802154/i8sak/Makefile | 5 +- wireless/ieee802154/i8sak/i8sak.h | 7 +- wireless/ieee802154/i8sak/i8sak_assoc.c | 34 ++- wireless/ieee802154/i8sak/i8sak_chan.c | 139 ++++++++++ wireless/ieee802154/i8sak/i8sak_main.c | 8 +- wireless/ieee802154/i8sak/i8sak_poll.c | 6 - wireless/ieee802154/i8sak/i8sak_scan.c | 253 ++++++++++++++++++ wireless/ieee802154/i8sak/i8sak_startpan.c | 2 +- wireless/ieee802154/i8sak/i8sak_tx.c | 8 +- .../ieee802154/libmac/ieee802154_getchan.c | 4 +- .../ieee802154/libmac/ieee802154_geteaddr.c | 2 +- .../ieee802154/libmac/ieee802154_getsaddr.c | 2 +- .../ieee802154/libmac/ieee802154_setchan.c | 4 +- .../ieee802154/libmac/ieee802154_seteaddr.c | 2 +- .../ieee802154/libmac/ieee802154_setsaddr.c | 2 +- .../ieee802154/libmac/sixlowpan_getchan.c | 4 +- .../ieee802154/libmac/sixlowpan_geteaddr.c | 2 +- .../ieee802154/libmac/sixlowpan_getsaddr.c | 2 +- .../ieee802154/libmac/sixlowpan_setchan.c | 4 +- .../ieee802154/libmac/sixlowpan_seteaddr.c | 2 +- .../ieee802154/libmac/sixlowpan_setsaddr.c | 2 +- 21 files changed, 449 insertions(+), 45 deletions(-) create mode 100644 wireless/ieee802154/i8sak/i8sak_chan.c create mode 100644 wireless/ieee802154/i8sak/i8sak_scan.c diff --git a/wireless/ieee802154/i8sak/Makefile b/wireless/ieee802154/i8sak/Makefile index 530740af5..cef46ecfe 100644 --- a/wireless/ieee802154/i8sak/Makefile +++ b/wireless/ieee802154/i8sak/Makefile @@ -47,8 +47,9 @@ STACKSIZE = 4096 # IEEE 802.15.4 SAK (Swiss Army Knife) ASRCS = -CSRCS = i8sak_acceptassoc.c i8sak_assoc.c i8sak_blaster.c i8sak_poll.c -CSRCS += i8sak_sniffer.c i8sak_startpan.c i8sak_tx.c wpanlistener.c +CSRCS = i8sak_acceptassoc.c i8sak_assoc.c i8sak_scan.c i8sak_blaster.c i8sak_poll.c +CSRCS += i8sak_sniffer.c i8sak_startpan.c i8sak_tx.c i8sak_chan.c +CSRCS += wpanlistener.c MAINSRC = i8sak_main.c AOBJS = $(ASRCS:.S=$(OBJEXT)) diff --git a/wireless/ieee802154/i8sak/i8sak.h b/wireless/ieee802154/i8sak/i8sak.h index c9508ce14..0d6d1395a 100644 --- a/wireless/ieee802154/i8sak/i8sak.h +++ b/wireless/ieee802154/i8sak/i8sak.h @@ -146,7 +146,7 @@ struct i8sak_s /* Settings */ - uint8_t chnum; + uint8_t chan; uint8_t chpage; struct ieee802154_addr_s addr; struct ieee802154_addr_s ep; @@ -154,6 +154,9 @@ struct i8sak_s uint8_t payload[IEEE802154_MAX_MAC_PAYLOAD_SIZE]; uint16_t payload_len; int blasterperiod; + + struct ieee802154_pandesc_s pandescs[CONFIG_MAC802154_NPANDESC]; + uint8_t npandesc; }; /**************************************************************************** @@ -175,10 +178,12 @@ bool i8sak_str2bool(FAR const char *str); void i8sak_startpan_cmd (FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]); void i8sak_acceptassoc_cmd (FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]); void i8sak_assoc_cmd (FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]); +void i8sak_scan_cmd (FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]); void i8sak_tx_cmd (FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]); void i8sak_poll_cmd (FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]); void i8sak_sniffer_cmd (FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]); void i8sak_blaster_cmd (FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]); +void i8sak_chan_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]); /**************************************************************************** * Inline Functions diff --git a/wireless/ieee802154/i8sak/i8sak_assoc.c b/wireless/ieee802154/i8sak/i8sak_assoc.c index da34816ab..d8ef39b41 100644 --- a/wireless/ieee802154/i8sak/i8sak_assoc.c +++ b/wireless/ieee802154/i8sak/i8sak_assoc.c @@ -79,10 +79,12 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) { struct ieee802154_assoc_req_s assocreq; struct wpanlistener_eventfilter_s filter; + FAR struct ieee802154_pandesc_s *pandesc; int fd; int option; int optcnt; int ret; + uint8_t resindex; /* If the addresses has never been automatically or manually set before, set * it assuming that we are the default device address and the endpoint is the @@ -96,7 +98,7 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) } optcnt = 0; - while ((option = getopt(argc, argv, ":hs:e:")) != ERROR) + while ((option = getopt(argc, argv, ":hr:s:e:")) != ERROR) { optcnt++; switch (option) @@ -105,12 +107,31 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) fprintf(stderr, "Requests association with endpoint\n" "Usage: %s [-h]\n" " -h = this help menu\n" + " -r = use scan result index\n" , argv[0]); /* Must manually reset optind if we are going to exit early */ optind = -1; return; + case 'r': + resindex = i8sak_str2luint8(optarg); + + if (resindex >= i8sak->npandesc) + { + fprintf(stderr, "ERROR: missing argument\n"); + /* Must manually reset optind if we are going to exit early */ + + optind = -1; + i8sak_cmd_error(i8sak); /* This exits for us */ + } + + pandesc = &i8sak->pandescs[resindex]; + + i8sak->chan = pandesc->chan; + i8sak->chpage = pandesc->chpage; + memcpy(&i8sak->ep, &pandesc->coordaddr, sizeof(struct ieee802154_addr_s)); + break; case 's': /* Parse extended address and put it into the i8sak instance */ @@ -158,15 +179,6 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) i8sak_cmd_error(i8sak); } - if (argc < 2) - { - /* TODO: Perform a scan operation here, to determine addressing information - * of coordinator. - */ - - fprintf(stderr, "i8sak: scan not implemented. Using default values\n"); - } - /* Register new callback for receiving the association notifications */ memset(&filter, 0, sizeof(struct wpanlistener_eventfilter_s)); @@ -177,7 +189,7 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) printf("i8sak: issuing ASSOC. request\n"); - assocreq.chnum = i8sak->chnum; + assocreq.chan = i8sak->chan; assocreq.chpage = i8sak->chpage; memcpy(&assocreq.coordaddr, &i8sak->ep, sizeof(struct ieee802154_addr_s)); diff --git a/wireless/ieee802154/i8sak/i8sak_chan.c b/wireless/ieee802154/i8sak/i8sak_chan.c new file mode 100644 index 000000000..0c27999ef --- /dev/null +++ b/wireless/ieee802154/i8sak/i8sak_chan.c @@ -0,0 +1,139 @@ +/**************************************************************************** + * apps/wireless/ieee802154/i8sak/i8sak_chan.c + * IEEE 802.15.4 Swiss Army Knife + * + * Copyright (C) 2017 Verge Inc. All rights reserved. + * Author: Anthony Merlino + * + * 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. + * + ****************************************************************************/ + + /**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "i8sak.h" + +#include +#include +#include "wireless/ieee802154.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name : i8sak_chan_cmd + * + * Description : + * Try and extract data from the coordinator + ****************************************************************************/ + +void i8sak_chan_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) +{ + int option; + int fd; + int argind; + bool getchan = false; + uint8_t channel; + + argind = 1; + while ((option = getopt(argc, argv, ":hg")) != ERROR) + { + switch (option) + { + argind++; + case 'h': + fprintf(stderr, "Polls coordinator for data\n" + "Usage: %s [-h]\n" + " -h = this help menu\n" + , argv[0]); + /* Must manually reset optind if we are going to exit early */ + + optind = -1; + return; + case 'g': + getchan = true; + break; + + case ':': + fprintf(stderr, "ERROR: missing argument\n"); + /* Must manually reset optind if we are going to exit early */ + + optind = -1; + i8sak_cmd_error(i8sak); /* This exits for us */ + case '?': + fprintf(stderr, "ERROR: unknown argument\n"); + /* Must manually reset optind if we are going to exit early */ + + optind = -1; + i8sak_cmd_error(i8sak); /* This exits for us */ + } + } + + if (!getchan) + { + if (argc < argind + 1) + { + fprintf(stderr, "ERROR: missing channel\n"); + i8sak_cmd_error(i8sak); /* This exits for us */ + } + + channel = i8sak_str2luint8(argv[argind]); + } + + fd = open(i8sak->devname, O_RDWR); + if (fd < 0) + { + printf("cannot open %s, errno=%d\n", i8sak->devname, errno); + i8sak_cmd_error(i8sak); + } + + if (getchan) + { + ieee802154_getchan(fd, &channel); + printf("i8sak: Channel: %d\n", (int)channel); + } + else + { + printf("i8sak: Setting Channel: %d\n", (int)channel); + ieee802154_setchan(fd, channel); + } + + close(fd); +} diff --git a/wireless/ieee802154/i8sak/i8sak_main.c b/wireless/ieee802154/i8sak/i8sak_main.c index 96586778f..0e15fe48e 100644 --- a/wireless/ieee802154/i8sak/i8sak_main.c +++ b/wireless/ieee802154/i8sak/i8sak_main.c @@ -104,10 +104,12 @@ static const struct i8sak_command_s g_i8sak_commands[] = {"startpan", (CODE void *)i8sak_startpan_cmd}, {"acceptassoc", (CODE void *)i8sak_acceptassoc_cmd}, {"assoc", (CODE void *)i8sak_assoc_cmd}, + {"scan", (CODE void *)i8sak_scan_cmd}, {"tx", (CODE void *)i8sak_tx_cmd}, {"poll", (CODE void *)i8sak_poll_cmd}, {"sniffer", (CODE void *)i8sak_sniffer_cmd}, {"blaster", (CODE void *)i8sak_blaster_cmd}, + {"chan", (CODE void *)i8sak_chan_cmd}, }; #define NCOMMANDS (sizeof(g_i8sak_commands) / sizeof(struct i8sak_command_s)) @@ -559,7 +561,7 @@ static int i8sak_setup(FAR struct i8sak_s *i8sak, FAR const char *devname) i8sak->daemon_started = false; i8sak->daemon_shutdown = false; - i8sak->chnum = CONFIG_IEEE802154_I8SAK_CHNUM; + i8sak->chan = CONFIG_IEEE802154_I8SAK_CHNUM; i8sak->chpage = CONFIG_IEEE802154_I8SAK_CHPAGE; if (strlen(devname) > I8SAK_MAX_DEVNAME) @@ -730,11 +732,13 @@ static int i8sak_showusage(FAR const char *progname, int exitcode) fprintf(stderr, "Usage: %s\n" " startpan [-h]\n" " acceptassoc [-h|e ]\n" - " assoc [-h] [] \n" + " scan [-h|p|a|e] minch-maxch\n" + " assoc [-h] []\n" " tx [-h|d] \n" " poll [-h]\n" " blaster [-h|q|f |p ]\n" " sniffer [-h|q]\n" + " chan [-h|g] []" , progname); exit(exitcode); } diff --git a/wireless/ieee802154/i8sak/i8sak_poll.c b/wireless/ieee802154/i8sak/i8sak_poll.c index 7db6eaf48..e62a7f7a9 100644 --- a/wireless/ieee802154/i8sak/i8sak_poll.c +++ b/wireless/ieee802154/i8sak/i8sak_poll.c @@ -83,7 +83,6 @@ void i8sak_poll_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) int fd; int ret; - ret = OK; while ((option = getopt(argc, argv, ":h")) != ERROR) { switch (option) @@ -112,11 +111,6 @@ void i8sak_poll_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) } } - if (ret != OK) - { - i8sak_cmd_error(i8sak); - } - fd = open(i8sak->devname, O_RDWR); if (fd < 0) { diff --git a/wireless/ieee802154/i8sak/i8sak_scan.c b/wireless/ieee802154/i8sak/i8sak_scan.c new file mode 100644 index 000000000..3e22b2599 --- /dev/null +++ b/wireless/ieee802154/i8sak/i8sak_scan.c @@ -0,0 +1,253 @@ +/**************************************************************************** + * apps/wireless/ieee802154/i8sak/i8sak_scan.c + * IEEE 802.15.4 Swiss Army Knife + * + * Copyright (C) 2014-2015, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2017 Verge Inc. All rights reserved. + * + * Author: Anthony Merlino + * Author: Gregory Nuttx + * + * 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "i8sak.h" + +#include +#include +#include "wireless/ieee802154.h" + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +static void scan_eventcb(FAR struct ieee802154_notif_s *notif, FAR void *arg); + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name : i8sak_scan_cmd + * + * Description : + * Request association with the Coordinator + ****************************************************************************/ + +void i8sak_scan_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) +{ + struct ieee802154_scan_req_s scan; + struct wpanlistener_eventfilter_s filter; + int fd; + int option; + int argind; + int i; + int minchannel; + int maxchannel; + + scan.type = IEEE802154_SCANTYPE_PASSIVE; + + argind = 1; + while ((option = getopt(argc, argv, ":hpae")) != ERROR) + { + argind++; + switch (option) + { + case 'h': + fprintf(stderr, "Requests association with endpoint\n" + "Usage: %s [-h|p|a|e] minCh-maxCh\n" + " -h = this help menu\n" + " -p = passive scan (default)\n" + " -a = active scan\n" + " -e = energy scan\n" + , argv[0]); + + /* Must manually reset optind if we are going to exit early */ + + optind = -1; + return; + + case 'p': + scan.type = IEEE802154_SCANTYPE_PASSIVE; + break; + + case 'a': + scan.type = IEEE802154_SCANTYPE_ACTIVE; + break; + + case 'e': + scan.type = IEEE802154_SCANTYPE_ED; + break; + + case ':': + fprintf(stderr, "ERROR: missing argument\n"); + /* Must manually reset optind if we are going to exit early */ + + optind = -1; + i8sak_cmd_error(i8sak); /* This exits for us */ + + case '?': + fprintf(stderr, "ERROR: unknown argument\n"); + /* Must manually reset optind if we are going to exit early */ + + optind = -1; + i8sak_cmd_error(i8sak); /* This exits for us */ + } + } + + /* There should always be one argument after the list option argument */ + + if (argc != argind + 1) + { + fprintf(stderr, "ERROR: invalid channel list\n"); + i8sak_cmd_error(i8sak); + } + + scan.duration = 5; + scan.chpage = i8sak->chpage; + + /* Parse channel list */ + + sscanf(argv[argind], "%d-%d", &minchannel, &maxchannel); + + scan.numchan = maxchannel - minchannel + 1; + + if (scan.numchan > 15) + { + fprintf(stderr, "ERROR: too many channels\n"); + i8sak_cmd_error(i8sak); + } + + for (i = 0; i < scan.numchan; i++) + { + scan.channels[i] = minchannel + i; + } + + fd = open(i8sak->devname, O_RDWR); + if (fd < 0) + { + printf("i8sak: cannot open %s, errno=%d\n", i8sak->devname, errno); + i8sak_cmd_error(i8sak); + } + + /* Register new callback for receiving the scan confirmation notification */ + + memset(&filter, 0, sizeof(struct wpanlistener_eventfilter_s)); + filter.confevents.scan = true; + + wpanlistener_add_eventreceiver(&i8sak->wpanlistener, scan_eventcb, &filter, + (FAR void *)i8sak, true); + + printf("i8sak: starting scan\n"); + + ieee802154_scan_req(fd, &scan); + + close(fd); +} + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static void scan_eventcb(FAR struct ieee802154_notif_s *notif, FAR void *arg) +{ + FAR struct i8sak_s *i8sak = (FAR struct i8sak_s *)arg; + FAR struct ieee802154_scan_conf_s *scan = ¬if->u.scanconf; + int i; + + printf("\n\ni8sak: Scan complete: %s\n", + IEEE802154_STATUS_STRING[scan->status]); + + printf("Scan type: "); + + switch (scan->type) + { + case IEEE802154_SCANTYPE_ACTIVE: + printf("Active\n"); + break; + case IEEE802154_SCANTYPE_PASSIVE: + printf("Passive\n"); + break; + case IEEE802154_SCANTYPE_ED: + printf("Energy\n"); + break; + default: + printf("Unknown\n"); + break; + } + + /* Copy the results from the notification */ + + i8sak->npandesc = scan->numdesc; + memcpy(i8sak->pandescs, scan->pandescs, + sizeof(struct ieee802154_pandesc_s) * i8sak->npandesc); + + printf("Scan results: \n"); + + for (i = 0; i < scan->numdesc; i++) + { + printf("Result %d\n", i); + printf(" Channel: %u\n", scan->pandescs[i].chan); + printf(" PAN ID: %02X:%02X\n", + scan->pandescs[i].coordaddr.panid[0], + scan->pandescs[i].coordaddr.panid[1]); + + if (scan->pandescs[i].coordaddr.mode == IEEE802154_ADDRMODE_SHORT) + { + printf(" Coordinator saddr: %02X:%02X\n", + scan->pandescs[i].coordaddr.saddr[0], + scan->pandescs[i].coordaddr.saddr[1]); + } + else + { + printf(" Coordinator eaddr: %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n", + scan->pandescs[i].coordaddr.eaddr[0], + scan->pandescs[i].coordaddr.eaddr[1], + scan->pandescs[i].coordaddr.eaddr[2], + scan->pandescs[i].coordaddr.eaddr[3], + scan->pandescs[i].coordaddr.eaddr[4], + scan->pandescs[i].coordaddr.eaddr[5], + scan->pandescs[i].coordaddr.eaddr[6], + scan->pandescs[i].coordaddr.eaddr[7]); + } + } +} diff --git a/wireless/ieee802154/i8sak/i8sak_startpan.c b/wireless/ieee802154/i8sak/i8sak_startpan.c index 5a09a58d7..1f45a534b 100644 --- a/wireless/ieee802154/i8sak/i8sak_startpan.c +++ b/wireless/ieee802154/i8sak/i8sak_startpan.c @@ -189,7 +189,7 @@ void i8sak_startpan_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) printf("i8sak: starting PAN\n"); IEEE802154_PANIDCOPY(startreq.panid, i8sak->addr.panid); - startreq.chnum = i8sak->chnum; + startreq.chan = i8sak->chan; startreq.chpage = i8sak->chpage; if (beaconenabled) diff --git a/wireless/ieee802154/i8sak/i8sak_tx.c b/wireless/ieee802154/i8sak/i8sak_tx.c index 56fc83454..00a67aabe 100644 --- a/wireless/ieee802154/i8sak/i8sak_tx.c +++ b/wireless/ieee802154/i8sak/i8sak_tx.c @@ -126,15 +126,11 @@ void i8sak_tx_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) case '?': fprintf(stderr, "ERROR: unknown argument\n"); ret = ERROR; - break; + optind = -1; + i8sak_cmd_error(i8sak); } } - if (ret != OK) - { - i8sak_cmd_error(i8sak); - } - if (argc == argind + 1) { i8sak->payload_len = i8sak_str2payload(argv[1], &i8sak->payload[0]); diff --git a/wireless/ieee802154/libmac/ieee802154_getchan.c b/wireless/ieee802154/libmac/ieee802154_getchan.c index c988e373b..132e03bb9 100644 --- a/wireless/ieee802154/libmac/ieee802154_getchan.c +++ b/wireless/ieee802154/libmac/ieee802154_getchan.c @@ -58,10 +58,10 @@ int ieee802154_getchan(int fd, FAR uint8_t *chan) struct ieee802154_get_req_s req; int ret; - req.attr = IEEE802154_ATTR_PHY_CURRENT_CHANNEL; + req.attr = IEEE802154_ATTR_PHY_CHAN; ret = ieee802154_get_req(fd, &req); - *chan = req.attrval.phy.channel; + *chan = req.attrval.phy.chan; return ret; } diff --git a/wireless/ieee802154/libmac/ieee802154_geteaddr.c b/wireless/ieee802154/libmac/ieee802154_geteaddr.c index 773c7ffe8..0e7b26c41 100644 --- a/wireless/ieee802154/libmac/ieee802154_geteaddr.c +++ b/wireless/ieee802154/libmac/ieee802154_geteaddr.c @@ -58,7 +58,7 @@ int ieee802154_geteaddr(int fd, FAR uint8_t *eaddr) struct ieee802154_get_req_s req; int ret; - req.attr = IEEE802154_ATTR_MAC_EXTENDED_ADDR; + req.attr = IEEE802154_ATTR_MAC_EADDR; ret = ieee802154_get_req(fd, &req); IEEE802154_EADDRCOPY(eaddr, req.attrval.mac.eaddr); diff --git a/wireless/ieee802154/libmac/ieee802154_getsaddr.c b/wireless/ieee802154/libmac/ieee802154_getsaddr.c index cd20cc126..850e82ead 100644 --- a/wireless/ieee802154/libmac/ieee802154_getsaddr.c +++ b/wireless/ieee802154/libmac/ieee802154_getsaddr.c @@ -58,7 +58,7 @@ int ieee802154_getsaddr(int fd, FAR uint8_t *saddr) struct ieee802154_get_req_s req; int ret; - req.attr = IEEE802154_ATTR_MAC_SHORT_ADDRESS; + req.attr = IEEE802154_ATTR_MAC_SADDR; ret = ieee802154_get_req(fd, &req); IEEE802154_SADDRCOPY(saddr, req.attrval.mac.saddr); diff --git a/wireless/ieee802154/libmac/ieee802154_setchan.c b/wireless/ieee802154/libmac/ieee802154_setchan.c index bac4bc6f7..4f3488dc2 100644 --- a/wireless/ieee802154/libmac/ieee802154_setchan.c +++ b/wireless/ieee802154/libmac/ieee802154_setchan.c @@ -57,8 +57,8 @@ int ieee802154_setchan(int fd, uint8_t chan) { struct ieee802154_set_req_s req; - req.attr = IEEE802154_ATTR_PHY_CURRENT_CHANNEL; - req.attrval.phy.channel = chan; + req.attr = IEEE802154_ATTR_PHY_CHAN; + req.attrval.phy.chan = chan; return ieee802154_set_req(fd, &req); } diff --git a/wireless/ieee802154/libmac/ieee802154_seteaddr.c b/wireless/ieee802154/libmac/ieee802154_seteaddr.c index 19494eafd..d7f22d97a 100644 --- a/wireless/ieee802154/libmac/ieee802154_seteaddr.c +++ b/wireless/ieee802154/libmac/ieee802154_seteaddr.c @@ -58,7 +58,7 @@ int ieee802154_seteaddr(int fd, FAR const uint8_t *eaddr) { struct ieee802154_set_req_s req; - req.attr = IEEE802154_ATTR_MAC_EXTENDED_ADDR; + req.attr = IEEE802154_ATTR_MAC_EADDR; IEEE802154_EADDRCOPY(req.attrval.mac.eaddr, eaddr); return ieee802154_set_req(fd, &req); diff --git a/wireless/ieee802154/libmac/ieee802154_setsaddr.c b/wireless/ieee802154/libmac/ieee802154_setsaddr.c index 20f2fa544..31675cce8 100644 --- a/wireless/ieee802154/libmac/ieee802154_setsaddr.c +++ b/wireless/ieee802154/libmac/ieee802154_setsaddr.c @@ -58,7 +58,7 @@ int ieee802154_setsaddr(int fd, FAR const uint8_t *saddr) { struct ieee802154_set_req_s req; - req.attr = IEEE802154_ATTR_MAC_SHORT_ADDRESS; + req.attr = IEEE802154_ATTR_MAC_SADDR; IEEE802154_SADDRCOPY(req.attrval.mac.saddr, saddr); return ieee802154_set_req(fd, &req); diff --git a/wireless/ieee802154/libmac/sixlowpan_getchan.c b/wireless/ieee802154/libmac/sixlowpan_getchan.c index f445d421e..fddc17f77 100644 --- a/wireless/ieee802154/libmac/sixlowpan_getchan.c +++ b/wireless/ieee802154/libmac/sixlowpan_getchan.c @@ -58,10 +58,10 @@ int sixlowpan_getchan(int sock, FAR const char *ifname, FAR uint8_t *chan) struct ieee802154_get_req_s req; int ret; - req.attr = IEEE802154_ATTR_PHY_CURRENT_CHANNEL; + req.attr = IEEE802154_ATTR_PHY_CHAN; ret = sixlowpan_get_req(sock, ifname, &req); - *chan = req.attrval.phy.channel; + *chan = req.attrval.phy.chan; return ret; } diff --git a/wireless/ieee802154/libmac/sixlowpan_geteaddr.c b/wireless/ieee802154/libmac/sixlowpan_geteaddr.c index 0344d43c6..18a23d2df 100644 --- a/wireless/ieee802154/libmac/sixlowpan_geteaddr.c +++ b/wireless/ieee802154/libmac/sixlowpan_geteaddr.c @@ -58,7 +58,7 @@ int sixlowpan_geteaddr(int sock, FAR const char *ifname, FAR uint8_t *eaddr) struct ieee802154_get_req_s req; int ret; - req.attr = IEEE802154_ATTR_MAC_EXTENDED_ADDR; + req.attr = IEEE802154_ATTR_MAC_EADDR; ret = sixlowpan_get_req(sock, ifname, &req); IEEE802154_EADDRCOPY(eaddr, req.attrval.mac.eaddr); diff --git a/wireless/ieee802154/libmac/sixlowpan_getsaddr.c b/wireless/ieee802154/libmac/sixlowpan_getsaddr.c index ef221190c..e721ca3bb 100644 --- a/wireless/ieee802154/libmac/sixlowpan_getsaddr.c +++ b/wireless/ieee802154/libmac/sixlowpan_getsaddr.c @@ -58,7 +58,7 @@ int sixlowpan_getsaddr(int sock, FAR const char *ifname, FAR uint8_t *saddr) struct ieee802154_get_req_s req; int ret; - req.attr = IEEE802154_ATTR_MAC_SHORT_ADDRESS; + req.attr = IEEE802154_ATTR_MAC_SADDR; ret = sixlowpan_get_req(sock, ifname, &req); IEEE802154_SADDRCOPY(saddr, req.attrval.mac.saddr); diff --git a/wireless/ieee802154/libmac/sixlowpan_setchan.c b/wireless/ieee802154/libmac/sixlowpan_setchan.c index c4e746b8c..04d44f382 100644 --- a/wireless/ieee802154/libmac/sixlowpan_setchan.c +++ b/wireless/ieee802154/libmac/sixlowpan_setchan.c @@ -57,8 +57,8 @@ int sixlowpan_setchan(int sock, FAR const char *ifname, uint8_t chan) { struct ieee802154_set_req_s req; - req.attr = IEEE802154_ATTR_PHY_CURRENT_CHANNEL; - req.attrval.phy.channel = chan; + req.attr = IEEE802154_ATTR_PHY_CHAN; + req.attrval.phy.chan = chan; return sixlowpan_set_req(sock, ifname, &req); } diff --git a/wireless/ieee802154/libmac/sixlowpan_seteaddr.c b/wireless/ieee802154/libmac/sixlowpan_seteaddr.c index 9f3dcb46d..3aa114f95 100644 --- a/wireless/ieee802154/libmac/sixlowpan_seteaddr.c +++ b/wireless/ieee802154/libmac/sixlowpan_seteaddr.c @@ -57,7 +57,7 @@ int sixlowpan_seteaddr(int sock, FAR const char *ifname, FAR const uint8_t *eadd { struct ieee802154_set_req_s req; - req.attr = IEEE802154_ATTR_MAC_EXTENDED_ADDR; + req.attr = IEEE802154_ATTR_MAC_EADDR; IEEE802154_EADDRCOPY(req.attrval.mac.eaddr, eaddr); return sixlowpan_set_req(sock, ifname, &req); diff --git a/wireless/ieee802154/libmac/sixlowpan_setsaddr.c b/wireless/ieee802154/libmac/sixlowpan_setsaddr.c index 49c46f28b..02260d73c 100644 --- a/wireless/ieee802154/libmac/sixlowpan_setsaddr.c +++ b/wireless/ieee802154/libmac/sixlowpan_setsaddr.c @@ -57,7 +57,7 @@ int sixlowpan_setsaddr(int sock, FAR const char *ifname, FAR const uint8_t *sadd { struct ieee802154_set_req_s req; - req.attr = IEEE802154_ATTR_MAC_SHORT_ADDRESS; + req.attr = IEEE802154_ATTR_MAC_SADDR; IEEE802154_SADDRCOPY(req.attrval.mac.saddr, saddr); return sixlowpan_set_req(sock, ifname, &req); From ace5bdc7c060d6817151417527677ebfc800979c Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 26 Jun 2017 10:54:32 -0600 Subject: [PATCH 18/19] examples/nettest: Add more printf output --- examples/nettest/nettest_client.c | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/nettest/nettest_client.c b/examples/nettest/nettest_client.c index 2d91877ec..c9059d36b 100644 --- a/examples/nettest/nettest_client.c +++ b/examples/nettest/nettest_client.c @@ -213,6 +213,7 @@ void nettest_client(void) goto errout_with_socket; } + printf("client: Terminating\n"); close(sockfd); free(outbuf); #ifndef CONFIG_EXAMPLES_NETTEST_PERFORMANCE From 3563a05fcd9e5cb3c6e7856463bf80fd3cb2946a Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 26 Jun 2017 11:12:53 -0600 Subject: [PATCH 19/19] Remove dangling white space --- wireless/ieee802154/i8sak/i8sak_acceptassoc.c | 2 +- wireless/ieee802154/i8sak/i8sak_chan.c | 6 ++-- wireless/ieee802154/i8sak/i8sak_scan.c | 4 +-- wireless/ieee802154/i8sak/i8sak_tx.c | 4 +-- wireless/ieee802154/libmac/Makefile | 32 +++++++++---------- wireless/iwpan/src/Make.defs | 2 +- wireless/wapi/LICENSE | 8 ++--- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/wireless/ieee802154/i8sak/i8sak_acceptassoc.c b/wireless/ieee802154/i8sak/i8sak_acceptassoc.c index 6a896a76b..949ca0dc6 100644 --- a/wireless/ieee802154/i8sak/i8sak_acceptassoc.c +++ b/wireless/ieee802154/i8sak/i8sak_acceptassoc.c @@ -122,7 +122,7 @@ void i8sak_acceptassoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[] printf("cannot open %s, errno=%d\n", i8sak->devname, errno); i8sak_cmd_error(i8sak); } - + ieee802154_setassocpermit(fd, true); if (!optcnt) diff --git a/wireless/ieee802154/i8sak/i8sak_chan.c b/wireless/ieee802154/i8sak/i8sak_chan.c index 0c27999ef..f3f924a42 100644 --- a/wireless/ieee802154/i8sak/i8sak_chan.c +++ b/wireless/ieee802154/i8sak/i8sak_chan.c @@ -105,7 +105,7 @@ void i8sak_chan_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) i8sak_cmd_error(i8sak); /* This exits for us */ } } - + if (!getchan) { if (argc < argind + 1) @@ -113,7 +113,7 @@ void i8sak_chan_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) fprintf(stderr, "ERROR: missing channel\n"); i8sak_cmd_error(i8sak); /* This exits for us */ } - + channel = i8sak_str2luint8(argv[argind]); } @@ -124,7 +124,7 @@ void i8sak_chan_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) i8sak_cmd_error(i8sak); } - if (getchan) + if (getchan) { ieee802154_getchan(fd, &channel); printf("i8sak: Channel: %d\n", (int)channel); diff --git a/wireless/ieee802154/i8sak/i8sak_scan.c b/wireless/ieee802154/i8sak/i8sak_scan.c index 3e22b2599..afacc60a9 100644 --- a/wireless/ieee802154/i8sak/i8sak_scan.c +++ b/wireless/ieee802154/i8sak/i8sak_scan.c @@ -105,7 +105,7 @@ void i8sak_scan_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) optind = -1; return; - + case 'p': scan.type = IEEE802154_SCANTYPE_PASSIVE; break; @@ -144,7 +144,7 @@ void i8sak_scan_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) scan.duration = 5; scan.chpage = i8sak->chpage; - + /* Parse channel list */ sscanf(argv[argind], "%d-%d", &minchannel, &maxchannel); diff --git a/wireless/ieee802154/i8sak/i8sak_tx.c b/wireless/ieee802154/i8sak/i8sak_tx.c index 00a67aabe..d60668f86 100644 --- a/wireless/ieee802154/i8sak/i8sak_tx.c +++ b/wireless/ieee802154/i8sak/i8sak_tx.c @@ -109,7 +109,7 @@ void i8sak_tx_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) sendasdev = true; argind++; break; - + case 'm': sendmax = true; argind++; @@ -135,7 +135,7 @@ void i8sak_tx_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) { i8sak->payload_len = i8sak_str2payload(argv[1], &i8sak->payload[0]); } - + if (sendmax) { i8sak->payload_len = IEEE802154_MAX_SAFE_MAC_PAYLOAD_SIZE; diff --git a/wireless/ieee802154/libmac/Makefile b/wireless/ieee802154/libmac/Makefile index 6dbf07cf4..76c817573 100644 --- a/wireless/ieee802154/libmac/Makefile +++ b/wireless/ieee802154/libmac/Makefile @@ -47,16 +47,16 @@ CSRCS += ieee802154_resetreq.c ieee802154_rxenabreq.c ieee802154_scanreq.c CSRCS += ieee802154_setreq.c ieee802154_startreq.c ieee802154_syncreq.c CSRCS += ieee802154_pollreq.c ieee802154_enableevents.c # Add Get/Set Attribute helpers -CSRCS += ieee802154_setchan.c ieee802154_getchan.c -CSRCS += ieee802154_setpanid.c ieee802154_getpanid.c -CSRCS += ieee802154_setsaddr.c ieee802154_getsaddr.c -CSRCS += ieee802154_seteaddr.c ieee802154_geteaddr.c -CSRCS += ieee802154_setpromisc.c ieee802154_getpromisc.c -CSRCS += ieee802154_setrxonidle.c ieee802154_getrxonidle.c -CSRCS += ieee802154_settxpwr.c ieee802154_gettxpwr.c +CSRCS += ieee802154_setchan.c ieee802154_getchan.c +CSRCS += ieee802154_setpanid.c ieee802154_getpanid.c +CSRCS += ieee802154_setsaddr.c ieee802154_getsaddr.c +CSRCS += ieee802154_seteaddr.c ieee802154_geteaddr.c +CSRCS += ieee802154_setpromisc.c ieee802154_getpromisc.c +CSRCS += ieee802154_setrxonidle.c ieee802154_getrxonidle.c +CSRCS += ieee802154_settxpwr.c ieee802154_gettxpwr.c CSRCS += ieee802154_getdevmode.c ieee802154_setassocpermit.c -ifeq ($(CONFIG_NET_6LOWPAN),y) +ifeq ($(CONFIG_NET_6LOWPAN),y) # Add Get/Set Attribute helpers CSRCS += sixlowpan_assocreq.c sixlowpan_assocresp.c sixlowpan_disassocreq.c CSRCS += sixlowpan_getreq.c sixlowpan_gtsreq.c sixlowpan_orphanresp.c @@ -64,14 +64,14 @@ CSRCS += sixlowpan_resetreq.c sixlowpan_rxenabreq.c sixlowpan_scanreq.c CSRCS += sixlowpan_setreq.c sixlowpan_startreq.c sixlowpan_syncreq.c CSRCS += sixlowpan_pollreq.c # Add IOCTL helpers -CSRCS += sixlowpan_setchan.c sixlowpan_getchan.c -CSRCS += sixlowpan_setpanid.c sixlowpan_getpanid.c -CSRCS += sixlowpan_setsaddr.c sixlowpan_getsaddr.c -CSRCS += sixlowpan_seteaddr.c sixlowpan_geteaddr.c -CSRCS += sixlowpan_setpromisc.c sixlowpan_getpromisc.c -CSRCS += sixlowpan_setrxonidle.c sixlowpan_getrxonidle.c -CSRCS += sixlowpan_settxpwr.c sixlowpan_gettxpwr.c -endif +CSRCS += sixlowpan_setchan.c sixlowpan_getchan.c +CSRCS += sixlowpan_setpanid.c sixlowpan_getpanid.c +CSRCS += sixlowpan_setsaddr.c sixlowpan_getsaddr.c +CSRCS += sixlowpan_seteaddr.c sixlowpan_geteaddr.c +CSRCS += sixlowpan_setpromisc.c sixlowpan_getpromisc.c +CSRCS += sixlowpan_setrxonidle.c sixlowpan_getrxonidle.c +CSRCS += sixlowpan_settxpwr.c sixlowpan_gettxpwr.c +endif AOBJS = $(ASRCS:.S=$(OBJEXT)) COBJS = $(CSRCS:.c=$(OBJEXT)) diff --git a/wireless/iwpan/src/Make.defs b/wireless/iwpan/src/Make.defs index e7577e3ac..935fcb23d 100644 --- a/wireless/iwpan/src/Make.defs +++ b/wireless/iwpan/src/Make.defs @@ -36,7 +36,7 @@ ifeq ($(CONFIG_WIRELESS_IWPAN),y) -CSRCS = +CSRCS = MAINSRC = iwpan.c DEPPATH += --dep-path src diff --git a/wireless/wapi/LICENSE b/wireless/wapi/LICENSE index eeb3ddaae..cdade89e1 100644 --- a/wireless/wapi/LICENSE +++ b/wireless/wapi/LICENSE @@ -1,16 +1,16 @@ Copyright (c) 2010, Volkan YAZICI All rights reserved. - + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - + - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - + - 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. - + 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