examples/udp and examples/nettest: Fix some naming collisions; examples/nettest: Fix some build issues with two targets.

This commit is contained in:
Gregory Nutt 2017-06-25 09:15:27 -06:00
parent b868fbe879
commit 664ab42da7
19 changed files with 71 additions and 71 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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 <gnutt@nuttx.org>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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 <gnutt@nuttx.org>
@ -117,10 +117,10 @@ static bool g_initialized;
****************************************************************************/
/****************************************************************************
* target_netinit
* udp_netinit
****************************************************************************/
int target_netinit(void)
int udp_netinit(void)
{
if (!g_initialized)
{

View File

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

View File

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

View File

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