Skip to content
Snippets Groups Projects
Unverified Commit dd664a88 authored by Peter Kietzmann's avatar Peter Kietzmann Committed by GitHub
Browse files

Merge pull request #10963 from brummer-simon/gnrc_tcp-fix_test_setup

gnrc_tcp: change and verify addrs in use
parents a4549f08 63ea8080
No related branches found
No related tags found
No related merge requests found
......@@ -7,8 +7,9 @@ ifeq (native,$(BOARD))
PORT ?= tap1
endif
TCP_TARGET_ADDR ?= fe80::affe%5
TCP_TARGET_PORT ?= 80
TCP_SERVER_ADDR ?= 2001:db8::affe:0001
TCP_SERVER_PORT ?= 80
TCP_CLIENT_ADDR ?= 2001:db8::affe:0002
TCP_TEST_CYCLES ?= 3
# Mark Boards with insufficient memory
......@@ -21,10 +22,13 @@ BOARD_INSUFFICIENT_MEMORY := airfy-beacon arduino-duemilanove arduino-mega2560 \
waspmote-pro wsn430-v1_3b wsn430-v1_4 yunjia-nrf51822 z1
# Target Address, Target Port and number of Test Cycles
CFLAGS += -DTARGET_ADDR=\"$(TCP_TARGET_ADDR)\"
CFLAGS += -DTARGET_PORT=$(TCP_TARGET_PORT)
CFLAGS += -DSERVER_ADDR=\"$(TCP_SERVER_ADDR)\"
CFLAGS += -DSERVER_PORT=$(TCP_SERVER_PORT)
CFLAGS += -DCLIENT_ADDR=\"$(TCP_CLIENT_ADDR)\"
CFLAGS += -DCYCLES=$(TCP_TEST_CYCLES)
CFLAGS += -DGNRC_NETIF_IPV6_GROUPS_NUMOF=3
CFLAGS += -DGNRC_IPV6_NIB_CONF_ARSM=1
CFLAGS += -DGNRC_IPV6_NIB_CONF_QUEUE_PKT=1
# Modules to include
USEMODULE += gnrc_netdev_default
......@@ -32,4 +36,7 @@ USEMODULE += auto_init_gnrc_netif
USEMODULE += gnrc_ipv6_default
USEMODULE += gnrc_tcp
# include this for IP address manipulation
USEMODULE += shell_commands
include $(RIOTBASE)/Makefile.include
......@@ -11,6 +11,7 @@
#include "thread.h"
#include "net/af.h"
#include "net/gnrc/ipv6.h"
#include "net/gnrc/netif.h"
#include "net/gnrc/tcp.h"
#define ENABLE_DEBUG (0)
......@@ -43,8 +44,26 @@ void *cli_thread(void *arg);
int main(void)
{
printf("\nStarting Client Threads. TARGET_ADDR=%s, TARGET_PORT=%d, ", TARGET_ADDR, TARGET_PORT);
printf("CONNS=%d, NBYTE=%d, CYCLES=%d\n\n", CONNS, NBYTE, CYCLES );
gnrc_netif_t *netif;
ipv6_addr_t addr;
if (!(netif = gnrc_netif_iter(NULL))) {
printf("No valid network interface found\n");
return -1;
}
if (ipv6_addr_from_str(&addr, CLIENT_ADDR) == NULL) {
printf("Can't convert given string to IPv6 Address\n");
return -1;
}
if (gnrc_netif_ipv6_addr_add(netif, &addr, 64, GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_VALID) < 0) {
printf("Can't assign given IPv6 Address\n");
return -1;
}
printf("\nStarting Client Threads. SERVER_ADDR=%s, SERVER_PORT=%d, ", SERVER_ADDR, SERVER_PORT);
printf("CONNS=%d, NBYTE=%d, CYCLES=%d\n\n", CONNS, NBYTE, CYCLES);
/* Start connection handling threads */
for (int i = 0; i < CONNS; i += 1) {
......@@ -70,8 +89,8 @@ void *cli_thread(void *arg)
/* Copy peer address information. NOTE: This test uses link-local addresses
* -> The Device identifier is removed from target_addr in each iteration! */
char target_addr[] = TARGET_ADDR;
uint16_t target_port = TARGET_PORT;
char target_addr[] = SERVER_ADDR;
uint16_t target_port = SERVER_PORT;
/* Initialize TCB */
gnrc_tcp_tcb_init(&tcb);
......
......@@ -7,8 +7,8 @@ ifeq (native,$(BOARD))
PORT ?= tap0
endif
TCP_LOCAL_ADDR ?= fe80::affe
TCP_LOCAL_PORT ?= 80
TCP_SERVER_ADDR ?= 2001:db8::affe:0001
TCP_SERVER_PORT ?= 80
TCP_TEST_CYCLES ?= 3
# Mark Boards with insufficient memory
......@@ -20,14 +20,13 @@ BOARD_INSUFFICIENT_MEMORY := airfy-beacon arduino-duemilanove arduino-mega2560 \
saml10-xpro saml11-xpro sb-430 sb-430h stm32f0discovery telosb \
waspmote-pro wsn430-v1_3b wsn430-v1_4 yunjia-nrf51822 z1
# This has to be the absolute path to the RIOT base directory:
RIOTBASE ?= $(CURDIR)/../..
# Local Address, Local Port and number of Test Cycles
CFLAGS += -DLOCAL_ADDR=\"$(TCP_LOCAL_ADDR)\"
CFLAGS += -DLOCAL_PORT=$(TCP_LOCAL_PORT)
CFLAGS += -DSERVER_ADDR=\"$(TCP_SERVER_ADDR)\"
CFLAGS += -DSERVER_PORT=$(TCP_SERVER_PORT)
CFLAGS += -DCYCLES=$(TCP_TEST_CYCLES)
CFLAGS += -DGNRC_NETIF_IPV6_GROUPS_NUMOF=3
CFLAGS += -DGNRC_IPV6_NIB_CONF_ARSM=1
CFLAGS += -DGNRC_IPV6_NIB_CONF_QUEUE_PKT=1
# Modules to include
USEMODULE += gnrc_netdev_default
......
......@@ -40,28 +40,32 @@
uint8_t bufs[CONNS][NBYTE];
uint8_t stacks[CONNS][THREAD_STACKSIZE_DEFAULT + THREAD_EXTRA_STACKSIZE_PRINTF];
/* "ifconfig" shell command */
extern int _gnrc_netif_config(int argc, char **argv);
/* Server thread */
void *srv_thread(void *arg);
int main(void)
{
/* Set pre-configured IP address */
gnrc_netif_t *netif;
ipv6_addr_t addr;
if (!(netif = gnrc_netif_iter(NULL))) {
printf("No valid network interface found\n");
return -1;
}
/* Set pre-configured IP address */
char if_pid[] = {netif->pid + '0', '\0'};
char *cmd[] = {"ifconfig", if_pid, "add", "unicast", LOCAL_ADDR};
_gnrc_netif_config(5, cmd);
if (ipv6_addr_from_str(&addr, SERVER_ADDR) == NULL) {
printf("Can't convert given string to IPv6 Address\n");
return -1;
}
if (gnrc_netif_ipv6_addr_add(netif, &addr, 64, GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_VALID) < 0) {
printf("Can't assign given IPv6 Address\n");
return -1;
}
/* Test configuration */
printf("\nStarting server: LOCAL_ADDR=%s, LOCAL_PORT=%d, ", LOCAL_ADDR, LOCAL_PORT);
printf("\nStarting server: SERVER_ADDR=%s, SERVER_PORT=%d, ", SERVER_ADDR, SERVER_PORT);
printf("CONNS=%d, NBYTE=%d, CYCLES=%d\n\n", CONNS, NBYTE, CYCLES);
/* Start Threads to handle connections */
......@@ -89,7 +93,7 @@ void *srv_thread(void *arg)
gnrc_tcp_tcb_init(&tcb);
/* Connect to peer */
int ret = gnrc_tcp_open_passive(&tcb, AF_INET6, NULL, LOCAL_PORT);
int ret = gnrc_tcp_open_passive(&tcb, AF_INET6, NULL, SERVER_PORT);
switch (ret) {
case 0:
DEBUG("TID=%d : gnrc_tcp_open_passive() : 0 : ok\n", tid);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment