net: apps: Connect echo-server and echo-client tests together
It is now possible to loop echo-server and echo-client test applications together when they are running in qemu. Start echo-server with "make server" and echo-client using "make client" in the corresponding samples directory. Change-Id: Ic852735f7bebc93e42873e98427e282902b3ca03 Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
40638b3ad4
commit
9368afd336
4 changed files with 139 additions and 4 deletions
|
@ -35,6 +35,5 @@ KERNEL_TYPE = nano
|
|||
PLATFORM_CONFIG ?= basic_atom
|
||||
CONF_FILE = prj_$(ARCH).conf
|
||||
|
||||
QEMU_EXTRA_FLAGS = -serial none -serial unix:/tmp/slip.sock
|
||||
|
||||
include $(ZEPHYR_BASE)/Makefile.inc
|
||||
include $(ZEPHYR_BASE)/samples/network/echo_server/Makefile.ipstack
|
||||
|
|
|
@ -80,6 +80,13 @@ static const char *lorem_ipsum =
|
|||
static int expecting;
|
||||
static int ipsum_len;
|
||||
|
||||
#ifdef CONFIG_NETWORKING_WITH_15_4_LOOPBACK_UART
|
||||
/* If we are running this with echo-server running in another
|
||||
* qemu, then set the mac addresses differently.
|
||||
*/
|
||||
static uint8_t peer_mac[] = { 0x0a, 0xbe, 0xef, 0x15, 0xf0, 0x0d };
|
||||
static uint8_t my_mac[] = { 0x15, 0x0a, 0xbe, 0xef, 0xf0, 0x0d };
|
||||
#else
|
||||
/* The peer is the server in our case. Just invent a mac
|
||||
* address for it because lower parts of the stack cannot set it
|
||||
* in this test as we do not have any radios.
|
||||
|
@ -89,12 +96,22 @@ static uint8_t peer_mac[] = { 0x15, 0x0a, 0xbe, 0xef, 0xf0, 0x0d };
|
|||
/* This is my mac address
|
||||
*/
|
||||
static uint8_t my_mac[] = { 0x0a, 0xbe, 0xef, 0x15, 0xf0, 0x0d };
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NETWORKING_WITH_IPV6
|
||||
|
||||
#ifdef CONFIG_NETWORKING_WITH_15_4_LOOPBACK_UART
|
||||
/* Reverse the addresses if we are connected to echo-server that is
|
||||
* running in qemu
|
||||
*/
|
||||
#define PEER_IPADDR { { { 0x20,0x01,0x0d,0xb8,0,0,0,0,0,0,0,0,0,0,0,0x2 } } }
|
||||
#define MY_IPADDR { { { 0x20,0x01,0x0d,0xb8,0,0,0,0,0,0,0,0,0,0,0,0x1 } } }
|
||||
#else
|
||||
/* The 2001:db8::/32 is the private address space for documentation RFC 3849 */
|
||||
#define MY_IPADDR { { { 0x20,0x01,0x0d,0xb8,0,0,0,0,0,0,0,0,0,0,0,0x2 } } }
|
||||
|
||||
#define PEER_IPADDR { { { 0x20,0x01,0x0d,0xb8,0,0,0,0,0,0,0,0,0,0,0,0x1 } } }
|
||||
#endif /* CONFIG_NETWORKING_WITH_15_4_LOOPBACK_UART */
|
||||
|
||||
/* admin-local, dynamically allocated multicast address */
|
||||
#define MCAST_IPADDR { { { 0xff,0x84,0,0,0,0,0,0,0,0,0,0,0,0,0,0x2 } } }
|
||||
|
|
|
@ -35,6 +35,5 @@ KERNEL_TYPE = nano
|
|||
PLATFORM_CONFIG ?= basic_atom
|
||||
CONF_FILE = prj_$(ARCH).conf
|
||||
|
||||
QEMU_EXTRA_FLAGS = -serial none -serial unix:/tmp/slip.sock
|
||||
|
||||
include $(ZEPHYR_BASE)/Makefile.inc
|
||||
include $(ZEPHYR_BASE)/samples/network/echo_server/Makefile.ipstack
|
||||
|
|
120
samples/network/echo_server/Makefile.ipstack
Normal file
120
samples/network/echo_server/Makefile.ipstack
Normal file
|
@ -0,0 +1,120 @@
|
|||
# Makefile - IP network stack Makefile for nano and micro kernel
|
||||
|
||||
#
|
||||
# Copyright (c) 2015 Intel Corporation
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1) Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2) Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# 3) Neither the name of Wind River Systems nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
PIPE_BASE=/tmp/ip-stack
|
||||
|
||||
ifeq ($(MAKECMDGOALS),server)
|
||||
QEMU_NUM=server
|
||||
endif
|
||||
ifeq ($(MAKECMDGOALS),client)
|
||||
QEMU_NUM=client
|
||||
endif
|
||||
ifdef QEMU_NUM
|
||||
QEMU_EXTRA_FLAGS += -serial none -serial pipe:${PIPE_BASE}-${QEMU_NUM} -pidfile qemu-${QEMU_NUM}.pid
|
||||
else
|
||||
QEMU_EXTRA_FLAGS = -serial none -serial unix:/tmp/slip.sock
|
||||
endif
|
||||
|
||||
PIPE_SERVER_IN=${PIPE_BASE}-server.in
|
||||
PIPE_SERVER_OUT=${PIPE_BASE}-server.out
|
||||
PIPE_CLIENT_IN=${PIPE_BASE}-client.in
|
||||
PIPE_CLIENT_OUT=${PIPE_BASE}-client.out
|
||||
|
||||
.PHONY: remove_pipes
|
||||
remove_pipes:
|
||||
rm -f ${PIPE_SERVER_IN} ${PIPE_SERVER_OUT} ${PIPE_CLIENT_IN} \
|
||||
${PIPE_CLIENT_OUT}
|
||||
|
||||
${PIPE_SERVER_IN}:
|
||||
mkfifo $@
|
||||
${PIPE_SERVER_OUT}:
|
||||
mkfifo $@
|
||||
${PIPE_CLIENT_IN}:
|
||||
mkfifo $@
|
||||
${PIPE_CLIENT_OUT}:
|
||||
mkfifo $@
|
||||
|
||||
.PHONY: PIPE_CLIENT_IN_LINK
|
||||
PIPE_CLIENT_IN_LINK: ${PIPE_SERVER_IN}
|
||||
-ln ${PIPE_SERVER_IN} ${PIPE_CLIENT_OUT}
|
||||
|
||||
.PHONY: PIPE_CLIENT_OUT_LINK
|
||||
PIPE_CLIENT_OUT_LINK: ${PIPE_SERVER_OUT}
|
||||
-ln ${PIPE_SERVER_OUT} ${PIPE_CLIENT_IN}
|
||||
|
||||
# Setup the dual qemu test case with pcap support (two qemus passing data
|
||||
# between them and saving data to pcap via help of monitor applicaiton)
|
||||
.PHONY: setup_pipes_dual_monitor
|
||||
setup_pipes_dual_monitor: ${PIPE_SERVER_IN} ${PIPE_SERVER_OUT} ${PIPE_CLIENT_IN} ${PIPE_CLIENT_OUT}
|
||||
|
||||
CONFIG_OPTIONS_1="CONFIG_NETWORKING_WITH_15_4=y"
|
||||
CONFIG_OPTIONS_2="CONFIG_NETWORKING_WITH_15_4_LOOPBACK_UART=y"
|
||||
CONFIG_OPTIONS_3="CONFIG_NETWORKING_WITH_6LOWPAN=y"
|
||||
CONFIG_OPTIONS_4="CONFIG_NETWORKING_STATISTICS=y"
|
||||
|
||||
.PHONY: set_options
|
||||
set_options:
|
||||
# Network uart must be turned off as that will prevent communication
|
||||
cp -f ${DOTCONFIG} ${DOTCONFIG}.orig ; true
|
||||
grep -v CONFIG_NETWORKING_UART=y ${DOTCONFIG}.orig > ${DOTCONFIG}
|
||||
echo "${CONFIG_OPTIONS_1}" >> ${DOTCONFIG}
|
||||
echo "${CONFIG_OPTIONS_2}" >> ${DOTCONFIG}
|
||||
echo "${CONFIG_OPTIONS_3}" >> ${DOTCONFIG}
|
||||
echo "${CONFIG_OPTIONS_4}" >> ${DOTCONFIG}
|
||||
|
||||
export QEMU_NUM
|
||||
export QEMU_EXTRA_FLAGS
|
||||
|
||||
PID_FILE=/tmp/monitor_15_4.pid
|
||||
|
||||
hosttoolsmake = @$(MAKE) -C $(ZEPHYR_BASE)/net/ip/tools $1
|
||||
|
||||
${ZEPHYR_BASE}/net/ip/tools/monitor_15_4:
|
||||
$(Q)$(call hosttoolsmake,monitor_15_4)
|
||||
|
||||
.PHONY: start_monitor
|
||||
start_monitor: ${ZEPHYR_BASE}/net/ip/tools/monitor_15_4
|
||||
${ZEPHYR_BASE}/net/ip/tools/monitor_15_4 \
|
||||
server-client-monitor.pcap \
|
||||
${PIPE_BASE}-server ${PIPE_BASE}-client > /dev/null & \
|
||||
echo "$$!" > ${PID_FILE}
|
||||
|
||||
server: remove_pipes setup_pipes_dual_monitor $(DOTCONFIG) set_options start_monitor
|
||||
$(Q)$(call zephyrmake,$(O),qemu); true
|
||||
$(Q)kill `cat ${PID_FILE}`
|
||||
$(Q)rm -f ${PID_FILE}
|
||||
-@killall monitor_15_4 > /dev/null 2>&1 ; true
|
||||
$(Q)stty sane
|
||||
|
||||
client: setup_pipes_dual_monitor $(DOTCONFIG) set_options
|
||||
$(Q)$(call zephyrmake,$(O),qemu); true
|
||||
$(Q)stty sane
|
Loading…
Add table
Add a link
Reference in a new issue