diff options
| -rw-r--r-- | fw/radvd.conf | 16 | ||||
| -rwxr-xr-x | fw/simulate-network.sh | 56 | 
2 files changed, 72 insertions, 0 deletions
diff --git a/fw/radvd.conf b/fw/radvd.conf new file mode 100644 index 0000000..98c703f --- /dev/null +++ b/fw/radvd.conf @@ -0,0 +1,16 @@ +# This Source Code Form is subject to the terms of the Mozilla Public License, +# v. 2.0. If a copy of the MPL was not distributed with this file, You can +# obtain one at https://mozilla.org/MPL/2.0/. + +interface zeth +{ +	AdvSendAdvert on; +	MinRtrAdvInterval 3; +	MaxRtrAdvInterval 10; +	AdvDefaultPreference low; +	prefix 2001:db8::/64 +	{ +		AdvOnLink on; +		AdvAutonomous on; +	}; +}; diff --git a/fw/simulate-network.sh b/fw/simulate-network.sh new file mode 100755 index 0000000..7f92dab --- /dev/null +++ b/fw/simulate-network.sh @@ -0,0 +1,56 @@ +#!/bin/sh + + +# This Source Code Form is subject to the terms of the Mozilla Public License, +# v. 2.0. If a copy of the MPL was not distributed with this file, You can +# obtain one at https://mozilla.org/MPL/2.0/. + +# This script provides a simulated network environment for a simulated Zephyr +# firmware. +# +# It is based on providing a simulated layer 2 network interface (TAP) and +# providing required services as Linux processes there. One example is the +# radvd service which send router advertisements which are required for IPv6 +# stateless address auto configuration (SLAAC). +# +# Root rights are required to run this script. Use your preferred privilege +# escalation program to call this script like this: +# +#     sudo ./simulate-network.sh + + +set -euf + + +FW="$(dirname "$0")" +RADVD_CONF="${FW}/radvd.conf" + +INTERFACE='zeth' +LINUX_IP='2001:db8::2' +NETMASK='64' + +radvd_pid='' + + +cleanup() { +	if test "$radvd_pid" != "" +	then +		kill "$radvd_pid" +	fi + +	ip link delete "$INTERFACE" +} + + +trap cleanup EXIT + +set -x + +ip tuntap add "$INTERFACE" mode tap +ip link set dev "$INTERFACE" up +ip addr add "${LINUX_IP}/${NETMASK}" dev "$INTERFACE" + +radvd --nodaemon --config "$RADVD_CONF" > /dev/null 2>&1 & +radvd_pid="$!" + +wait  | 
