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:
parent
53601df430
commit
8557a15c8f
23
dist/tools/zep_dispatch/start_network.sh
vendored
23
dist/tools/zep_dispatch/start_network.sh
vendored
@ -3,6 +3,7 @@
|
|||||||
ZEP_DISPATCH_DIR="$(cd "$(dirname "$0")" && pwd -P)"
|
ZEP_DISPATCH_DIR="$(cd "$(dirname "$0")" && pwd -P)"
|
||||||
UHCPD="$(cd "${ZEP_DISPATCH_DIR}/../uhcpd/bin" && pwd -P)/uhcpd"
|
UHCPD="$(cd "${ZEP_DISPATCH_DIR}/../uhcpd/bin" && pwd -P)/uhcpd"
|
||||||
DHCPD="$(cd "${ZEP_DISPATCH_DIR}/../dhcpv6-pd_ia/" && pwd -P)/dhcpv6-pd_ia.py"
|
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"
|
ZEP_DISPATCH="${ZEP_DISPATCH_DIR}/bin/zep_dispatch"
|
||||||
|
|
||||||
TAP_GLB="fdea:dbee:f::1/64"
|
TAP_GLB="fdea:dbee:f::1/64"
|
||||||
@ -16,7 +17,6 @@ create_tap() {
|
|||||||
ip link set "${TAP}" up
|
ip link set "${TAP}" up
|
||||||
ip a a fe80::1/64 dev "${TAP}"
|
ip a a fe80::1/64 dev "${TAP}"
|
||||||
ip a a ${TAP_GLB} dev "${TAP}"
|
ip a a ${TAP_GLB} dev "${TAP}"
|
||||||
ip route add "${PREFIX}" via fe80::2 dev "${TAP}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
remove_tap() {
|
remove_tap() {
|
||||||
@ -40,15 +40,25 @@ cleanup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
start_uhcpd() {
|
start_uhcpd() {
|
||||||
|
ip route add "${PREFIX}" via fe80::2 dev "${TAP}"
|
||||||
${UHCPD} "${TAP}" "${PREFIX}" > /dev/null &
|
${UHCPD} "${TAP}" "${PREFIX}" > /dev/null &
|
||||||
UHCPD_PID=$!
|
UHCPD_PID=$!
|
||||||
}
|
}
|
||||||
|
|
||||||
start_dhcpd() {
|
start_dhcpd() {
|
||||||
|
ip route add "${PREFIX}" via fe80::2 dev "${TAP}"
|
||||||
DHCPD_PIDFILE=$(mktemp)
|
DHCPD_PIDFILE=$(mktemp)
|
||||||
${DHCPD} -d -p "${DHCPD_PIDFILE}" "${TAP}" "${PREFIX}" 2> /dev/null
|
${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() {
|
start_zep_dispatch() {
|
||||||
${ZEP_DISPATCH} :: "${ZEP_PORT_BASE}" > /dev/null &
|
${ZEP_DISPATCH} :: "${ZEP_PORT_BASE}" > /dev/null &
|
||||||
ZEP_DISPATCH_PID=$!
|
ZEP_DISPATCH_PID=$!
|
||||||
@ -61,6 +71,13 @@ else
|
|||||||
USE_DHCPV6=0
|
USE_DHCPV6=0
|
||||||
fi
|
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
|
if [ "$1" = "-z" ] || [ "$1" = "--use-zep-dispatch" ]; then
|
||||||
USE_ZEP_DISPATCH=1
|
USE_ZEP_DISPATCH=1
|
||||||
ZEP_PORT_BASE=$2
|
ZEP_PORT_BASE=$2
|
||||||
@ -77,7 +94,7 @@ shift 2
|
|||||||
for TAP in "$@"; do :; done
|
for TAP in "$@"; do :; done
|
||||||
|
|
||||||
[[ -z "${ELFFILE}" || -z "${PREFIX}" || -z "${TAP}" ]] && {
|
[[ -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]"
|
"<elffile> <prefix> [elf args]"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
@ -92,6 +109,8 @@ fi
|
|||||||
|
|
||||||
if [ ${USE_DHCPV6} -eq 1 ]; then
|
if [ ${USE_DHCPV6} -eq 1 ]; then
|
||||||
start_dhcpd
|
start_dhcpd
|
||||||
|
elif [ ${USE_RADVD} -eq 1 ]; then
|
||||||
|
start_radvd
|
||||||
else
|
else
|
||||||
start_uhcpd
|
start_uhcpd
|
||||||
fi
|
fi
|
||||||
|
@ -11,6 +11,8 @@ CFLAGS += $(if $(CONFIG_KCONFIG_MODULE_DHCPV6),,-DCONFIG_DHCPV6_CLIENT_PFX_LEASE
|
|||||||
|
|
||||||
ifeq (dhcpv6,$(PREFIX_CONF))
|
ifeq (dhcpv6,$(PREFIX_CONF))
|
||||||
FLAGS_EXTRAS += --use-dhcpv6
|
FLAGS_EXTRAS += --use-dhcpv6
|
||||||
|
else ifeq (auto_subnets,$(PREFIX_CONF))
|
||||||
|
FLAGS_EXTRAS += --use-radvd
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# enable the ZEP dispatcher
|
# enable the ZEP dispatcher
|
||||||
|
Loading…
Reference in New Issue
Block a user