mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
tools/usb-cdc-ecm: add support for radvd / auto_subnets
This commit is contained in:
parent
efb4b2ea61
commit
15ab9bbdcd
23
dist/tools/usb-cdc-ecm/start_network.sh
vendored
23
dist/tools/usb-cdc-ecm/start_network.sh
vendored
@ -34,7 +34,6 @@ setup_interface() {
|
|||||||
ip link set "${INTERFACE}" up
|
ip link set "${INTERFACE}" up
|
||||||
ip a a fe80::1/64 dev "${INTERFACE}"
|
ip a a fe80::1/64 dev "${INTERFACE}"
|
||||||
ip a a fd00:dead:beef::1/128 dev lo
|
ip a a fd00:dead:beef::1/128 dev lo
|
||||||
ip route add "${PREFIX}" via fe80::2 dev "${INTERFACE}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup_interface() {
|
cleanup_interface() {
|
||||||
@ -57,15 +56,25 @@ cleanup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
start_uhcpd() {
|
start_uhcpd() {
|
||||||
|
ip route add "${PREFIX}" via fe80::2 dev "${INTERFACE}"
|
||||||
${UHCPD} "${INTERFACE}" "${PREFIX}" > /dev/null &
|
${UHCPD} "${INTERFACE}" "${PREFIX}" > /dev/null &
|
||||||
UHCPD_PID=$!
|
UHCPD_PID=$!
|
||||||
}
|
}
|
||||||
|
|
||||||
start_dhcpd() {
|
start_dhcpd() {
|
||||||
|
ip route add "${PREFIX}" via fe80::2 dev "${INTERFACE}"
|
||||||
DHCPD_PIDFILE=$(mktemp)
|
DHCPD_PIDFILE=$(mktemp)
|
||||||
${DHCPD} -d -p "${DHCPD_PIDFILE}" "${INTERFACE}" "${PREFIX}" 2> /dev/null
|
${DHCPD} -d -p "${DHCPD_PIDFILE}" "${INTERFACE}" "${PREFIX}" 2> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
start_radvd() {
|
||||||
|
ADDR=$(echo "${PREFIX}" | sed -e 's/::\//::1\//')
|
||||||
|
ip a a "${ADDR}" dev "${INTERFACE}"
|
||||||
|
sysctl net.ipv6.conf."${INTERFACE}".accept_ra=2
|
||||||
|
sysctl net.ipv6.conf."${INTERFACE}".accept_ra_rt_info_max_plen=64
|
||||||
|
${RADVD} -c "${INTERFACE}" "${PREFIX}"
|
||||||
|
}
|
||||||
|
|
||||||
if [ "$1" = "-d" ] || [ "$1" = "--use-dhcpv6" ]; then
|
if [ "$1" = "-d" ] || [ "$1" = "--use-dhcpv6" ]; then
|
||||||
USE_DHCPV6=1
|
USE_DHCPV6=1
|
||||||
shift 1
|
shift 1
|
||||||
@ -73,9 +82,16 @@ 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
|
||||||
|
|
||||||
PREFIX=$1
|
PREFIX=$1
|
||||||
[ -z "${PREFIX}" ] && {
|
[ -z "${PREFIX}" ] && {
|
||||||
echo "usage: $0 [-d|--use-dhcpv6] <prefix> [<serial-port>]"
|
echo "usage: $0 [-d|--use-dhcpv6] [-r|--use-radvd ] <prefix> [<serial-port>]"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,6 +106,9 @@ setup_interface
|
|||||||
if [ ${USE_DHCPV6} -eq 1 ]; then
|
if [ ${USE_DHCPV6} -eq 1 ]; then
|
||||||
DHCPD="$(readlink -f "${USB_CDC_ECM_DIR}/../dhcpv6-pd_ia/")/dhcpv6-pd_ia.py"
|
DHCPD="$(readlink -f "${USB_CDC_ECM_DIR}/../dhcpv6-pd_ia/")/dhcpv6-pd_ia.py"
|
||||||
start_dhcpd
|
start_dhcpd
|
||||||
|
elif [ ${USE_RADVD} -eq 1 ]; then
|
||||||
|
RADVD="$(readlink -f "${USB_CDC_ECM_DIR}/../radvd/")/radvd.sh"
|
||||||
|
start_radvd
|
||||||
else
|
else
|
||||||
UHCPD="$(readlink -f "${USB_CDC_ECM_DIR}/../uhcpd/bin")/uhcpd"
|
UHCPD="$(readlink -f "${USB_CDC_ECM_DIR}/../uhcpd/bin")/uhcpd"
|
||||||
start_uhcpd
|
start_uhcpd
|
||||||
|
@ -2,8 +2,10 @@
|
|||||||
USEMODULE += auto_init_usbus
|
USEMODULE += auto_init_usbus
|
||||||
USEMODULE += usbus_cdc_ecm
|
USEMODULE += usbus_cdc_ecm
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
# Configure terminal parameters for UHCP
|
# Configure terminal parameters for UHCP
|
||||||
|
Loading…
Reference in New Issue
Block a user