From 664ab42da7e2947425e4acbfae49333a04e6e9ab Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 25 Jun 2017 09:15:27 -0600 Subject: [PATCH] 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;