1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

tools/zep_dispatch: add support for radvd / auto_subnets

This commit is contained in:
Benjamin Valentin 2021-10-15 13:16:37 +02:00
parent 53601df430
commit 8557a15c8f
2 changed files with 23 additions and 2 deletions

View File

@ -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 <port>] " \
echo "usage: $0 [-d|--use-dhcp] [-r|--use-radvd] [-z|--use-zep <port>] " \
"<elffile> <prefix> [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

View File

@ -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