net: tools: Helper scripts for running socat, tunslip6 and radvd

Adding convenience scripts that help user when running socat,
radvd and tunslip6 processes. These helper scripts restart
corresponding processes when qemu stops. This way end user
does not need to manual restart the utility processes.

Change-Id: I2e8eb15ee0ffe2ac8f1cedf4431cf8b09fcbbee5
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2015-10-12 13:03:24 +03:00 committed by Anas Nashif
commit 901cadd5cd
4 changed files with 66 additions and 0 deletions

View file

@ -22,6 +22,10 @@ $ socat PTY,link=/tmp/slip.dev UNIX-LISTEN:/tmp/slip.sock
$ make PLATFORM_CONFIG=basic_cortex_m3 ARCH=arm \ $ make PLATFORM_CONFIG=basic_cortex_m3 ARCH=arm \
QEMU_EXTRA_FLAGS="-serial none -serial unix:/tmp/slip.sock" qemu QEMU_EXTRA_FLAGS="-serial none -serial unix:/tmp/slip.sock" qemu
or just simply
$ make qemu
3) Start tunslip6 3) Start tunslip6
$ sudo ./tunslip6 -s `readlink /tmp/slip.dev` 2001:db8::1/64 $ sudo ./tunslip6 -s `readlink /tmp/slip.dev` 2001:db8::1/64
@ -32,6 +36,23 @@ $ nc -u -6 2001:db8::2 4242 <<EOF
foobar foobar
EOF EOF
There are also convenience scripts for running socat, radvd and
tunslip6 processes called loop-socat.sh, loop-radvd.sh and
loop-slip.sh. So to simplify things you need three terminals
for doing this:
Terminal 1:
$ ./loop-socat.sh
Terminal 2:
$ sudo ./loop-slip.sh
Terminal 3:
$ sudo ./loop-radvd.sh
After running these scripts you do not need to manual restart
them when qemu process stops.
radvd radvd
===== =====

20
net/ip/tools/loop-radvd.sh Executable file
View file

@ -0,0 +1,20 @@
#!/bin/sh
# Run radvd in a loop. This way we can restart qemu and do not need
# to manually restart radvd process.
if [ ! -f ./radvd.conf ]; then
if [ ! -f $ZEPHYR_BASE/net/ip/tools/radvd.conf ]; then
echo "Cannot find radvd.conf file."
exit 1
fi
DIR=$ZEPHYR_BASE/net/ip/tools
else
DIR=.
fi
if [ `id -u` != 0 ]; then
echo "Run this script as a root user!"
exit 2
fi
while [ 1 ]; do radvd -d 1 -C $DIR/radvd.conf -m stderr; done

20
net/ip/tools/loop-slip.sh Executable file
View file

@ -0,0 +1,20 @@
#!/bin/sh
# Run tunslip in a loop. This way we can restart qemu and do not need
# to manually restart tunslip process that creates the tun0 device.
if [ ! -f ./tunslip6 ]; then
if [ ! -f $ZEPHYR_BASE/net/ip/tools/tunslip6 ]; then
echo "Cannot find tunslip6 executable."
exit 1
fi
DIR=$ZEPHYR_BASE/net/ip/tools
else
DIR=.
fi
if [ `id -u` != 0 ]; then
echo "Run this script as a root user!"
exit 2
fi
while [ 1 ]; do $DIR/tunslip6 -s `readlink /tmp/slip.dev` 2001:db8::1/64; done

5
net/ip/tools/loop-socat.sh Executable file
View file

@ -0,0 +1,5 @@
#!/bin/sh
# Run socat in a loop. This way we can restart qemu and do not need
# to manually restart socat.
while [ 1 ]; do socat PTY,link=/tmp/slip.dev UNIX-LISTEN:/tmp/slip.sock; done