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
This commit is contained in:
parent
c88cf75064
commit
a0251ae974
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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 <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 */
|
||||
|
||||
|
@ -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 <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user