From e305592ce620efbfee484b5a71d713125ec2758a Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 8 Dec 2019 17:11:07 -0600 Subject: [PATCH] apps/examples/tcpblaster: Fix several problems with the host is the client and the target in the server. Basic problem was that the host did not know the IP address of the target server due to several bugs and build issues that only seemed to affect this configuration. --- examples/tcpblaster/Makefile | 4 +-- examples/tcpblaster/tcpblaster.h | 42 ++++++++++++++++++++++----- examples/tcpblaster/tcpblaster_host.c | 4 +++ 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/examples/tcpblaster/Makefile b/examples/tcpblaster/Makefile index 585b9c9e5..099c2b91e 100644 --- a/examples/tcpblaster/Makefile +++ b/examples/tcpblaster/Makefile @@ -85,10 +85,10 @@ ifneq ($(CONFIG_EXAMPLES_TCPBLASTER_LOOPBACK),y) HOSTCFLAGS += -DTCPBLASTER_HOST=1 ifeq ($(CONFIG_EXAMPLES_TCPBLASTER_SERVER),y) - HOSTCFLAGS += -DCONFIG_EXAMPLES_TCPBLASTER_SERVER=1 -DCONFIG_EXAMPLES_TCPBLASTER_SERVERIP="$(CONFIG_EXAMPLES_TCPBLASTER_SERVERIP)" + HOSTCFLAGS += -DCONFIG_EXAMPLES_TCPBLASTER_SERVER=1 -DCONFIG_EXAMPLES_TCPBLASTER_SERVERIP=$(CONFIG_EXAMPLES_TCPBLASTER_SERVERIP) endif - HOST_SRCS = tcpblaster_host.c + HOST_SRCS = tcpblaster_host.c tcpblaster_cmdline.c ifeq ($(CONFIG_EXAMPLES_TCPBLASTER_SERVER),y) HOST_SRCS += tcpblaster_client.c HOST_BIN = tcpclient$(EXEEXT) diff --git a/examples/tcpblaster/tcpblaster.h b/examples/tcpblaster/tcpblaster.h index 28abcdc84..eafdf448f 100644 --- a/examples/tcpblaster/tcpblaster.h +++ b/examples/tcpblaster/tcpblaster.h @@ -51,14 +51,42 @@ * Pre-processor Definitions ****************************************************************************/ +#ifndef HTONS +# ifdef CONFIG_ENDIAN_BIG +# define HTONS(ns) (ns) +# else +# define HTONS(ns) \ + (unsigned short) \ + (((((unsigned short)(ns)) & 0x00ff) << 8) | \ + ((((unsigned short)(ns)) >> 8) & 0x00ff)) +# endif +#endif + +#ifndef HTONL +# ifdef CONFIG_ENDIAN_BIG +# define HTONL(nl) (nl) +# else +# define HTONL(nl) \ + (unsigned long) \ + (((((unsigned long)(nl)) & 0x000000ffUL) << 24) | \ + ((((unsigned long)(nl)) & 0x0000ff00UL) << 8) | \ + ((((unsigned long)(nl)) & 0x00ff0000UL) >> 8) | \ + ((((unsigned long)(nl)) & 0xff000000UL) >> 24)) +# endif +#endif + +#ifndef NTOHS +# define NTOHS(hs) HTONS(hs) +#endif + +#ifndef NTOHL +# define NTOHL(hl) HTONL(hl) +#endif + #ifdef TCPBLASTER_HOST - /* HTONS/L macros are unique to uIP */ - -# define HTONS(a) htons(a) -# define HTONL(a) htonl(a) - /* Have SO_LINGER */ +# define FAR # define TCPBLASTER_HAVE_SOLINGER 1 #else @@ -92,9 +120,9 @@ ****************************************************************************/ #ifdef CONFIG_EXAMPLES_TCPBLASTER_IPv6 -uint16_t g_tcpblasterserver_ipv6[8]; +extern uint16_t g_tcpblasterserver_ipv6[8]; #else -uint32_t g_tcpblasterserver_ipv4; +extern uint32_t g_tcpblasterserver_ipv4; #endif /**************************************************************************** diff --git a/examples/tcpblaster/tcpblaster_host.c b/examples/tcpblaster/tcpblaster_host.c index d1b52549b..79b8509d5 100644 --- a/examples/tcpblaster/tcpblaster_host.c +++ b/examples/tcpblaster/tcpblaster_host.c @@ -54,6 +54,10 @@ int main(int argc, char **argv, char **envp) { + /* Parse any command line options */ + + tcpblaster_cmdline(argc, argv); + #ifdef CONFIG_EXAMPLES_TCPBLASTER_SERVER tcpblaster_client(); #else