diff --git a/dist/tools/zep_dispatch/start_network.sh b/dist/tools/zep_dispatch/start_network.sh index f98cd93b87..8e7f4ee33d 100755 --- a/dist/tools/zep_dispatch/start_network.sh +++ b/dist/tools/zep_dispatch/start_network.sh @@ -3,6 +3,7 @@ ZEP_DISPATCH_DIR="$(cd "$(dirname "$0")" && pwd -P)" UHCPD="$(cd "${ZEP_DISPATCH_DIR}/../uhcpd/bin" && pwd -P)/uhcpd" DHCPD="$(cd "${ZEP_DISPATCH_DIR}/../dhcpv6-pd_ia/" && pwd -P)/dhcpv6-pd_ia.py" +RADVD="$(cd "${ZEP_DISPATCH_DIR}/../radvd/" && pwd -P)/radvd.sh" ZEP_DISPATCH="${ZEP_DISPATCH_DIR}/bin/zep_dispatch" TAP_GLB="fdea:dbee:f::1/64" @@ -16,7 +17,6 @@ create_tap() { ip link set "${TAP}" up ip a a fe80::1/64 dev "${TAP}" ip a a ${TAP_GLB} dev "${TAP}" - ip route add "${PREFIX}" via fe80::2 dev "${TAP}" } remove_tap() { @@ -40,15 +40,25 @@ cleanup() { } start_uhcpd() { + ip route add "${PREFIX}" via fe80::2 dev "${TAP}" ${UHCPD} "${TAP}" "${PREFIX}" > /dev/null & UHCPD_PID=$! } start_dhcpd() { + ip route add "${PREFIX}" via fe80::2 dev "${TAP}" DHCPD_PIDFILE=$(mktemp) ${DHCPD} -d -p "${DHCPD_PIDFILE}" "${TAP}" "${PREFIX}" 2> /dev/null } +start_radvd() { + ADDR=$(echo "${PREFIX}" | sed -e 's/::\//::1\//') + ip a a "${ADDR}" dev "${TAP}" + sysctl net.ipv6.conf."${TAP}".accept_ra=2 + sysctl net.ipv6.conf."${TAP}".accept_ra_rt_info_max_plen=64 + ${RADVD} -c "${TAP}" "${PREFIX}" +} + start_zep_dispatch() { ${ZEP_DISPATCH} :: "${ZEP_PORT_BASE}" > /dev/null & ZEP_DISPATCH_PID=$! @@ -61,6 +71,13 @@ else USE_DHCPV6=0 fi +if [ "$1" = "-r" ] || [ "$1" = "--use-radvd" ]; then + USE_RADVD=1 + shift 1 +else + USE_RADVD=0 +fi + if [ "$1" = "-z" ] || [ "$1" = "--use-zep-dispatch" ]; then USE_ZEP_DISPATCH=1 ZEP_PORT_BASE=$2 @@ -77,7 +94,7 @@ shift 2 for TAP in "$@"; do :; done [[ -z "${ELFFILE}" || -z "${PREFIX}" || -z "${TAP}" ]] && { - echo "usage: $0 [-d|--use-dhcp] [-z|--use-zep ] " \ + echo "usage: $0 [-d|--use-dhcp] [-r|--use-radvd] [-z|--use-zep ] " \ " [elf args]" exit 1 } @@ -92,6 +109,8 @@ fi if [ ${USE_DHCPV6} -eq 1 ]; then start_dhcpd +elif [ ${USE_RADVD} -eq 1 ]; then + start_radvd else start_uhcpd fi diff --git a/examples/gnrc_border_router/Makefile.native.conf b/examples/gnrc_border_router/Makefile.native.conf index 3631a5e485..5dc9810698 100644 --- a/examples/gnrc_border_router/Makefile.native.conf +++ b/examples/gnrc_border_router/Makefile.native.conf @@ -11,6 +11,8 @@ CFLAGS += $(if $(CONFIG_KCONFIG_MODULE_DHCPV6),,-DCONFIG_DHCPV6_CLIENT_PFX_LEASE ifeq (dhcpv6,$(PREFIX_CONF)) FLAGS_EXTRAS += --use-dhcpv6 +else ifeq (auto_subnets,$(PREFIX_CONF)) + FLAGS_EXTRAS += --use-radvd endif # enable the ZEP dispatcher