examples/gnrc_border_router: add optional DHCPv6 support

This commit is contained in:
Martine S. Lenders 2020-02-20 16:42:19 +01:00
parent b929d013d8
commit a0b0724f76
No known key found for this signature in database
GPG Key ID: CCD317364F63286F
3 changed files with 77 additions and 3 deletions

View File

@ -0,0 +1,10 @@
if MODULE_ETHOS
config GNRC_DHCPV6_CLIENT_6LBR_STATIC_ROUTE
default y
depends on MODULE_GNRC_DHCPV6_CLIENT_6LBR && KCONFIG_MODULE_GNRC_DHCPV6
config GNRC_NETIF_IPV6_ADDRS_NUMOF
# CONFIG_GNRC_DHCPV6_CLIENT_6LBR_STATIC_ROUTE=1 requires one more address
# for `fe80::2`.
default 3
depends on KCONFIG_MODULE_GNRC_NETIF
endif # MODULE_ETHOS

View File

@ -50,8 +50,15 @@ USEMODULE += shell
USEMODULE += shell_commands
USEMODULE += ps
# include UHCP client
USEMODULE += gnrc_uhcpc
USE_DHCPV6 ?= 0
ifeq (1,$(USE_DHCPV6))
# include DHCPv6 client for 6LoWPAN border router
USEMODULE += gnrc_dhcpv6_client_6lbr
else
# include UHCP client
USEMODULE += gnrc_uhcpc
endif
# Optionally include RPL as a routing protocol. When includede gnrc_uhcpc will
# configure the node as a RPL DODAG root when receiving a prefix.
@ -68,24 +75,45 @@ TAP ?= tap0
IPV6_PREFIX ?= 2001:db8::/64
ifeq (native,$(BOARD))
ifneq (1,$(USE_DHCPV6))
TERMDEPS += uhcpd-daemon
.PHONY: uhcpd-daemon
uhcpd-daemon: host-tools
$(RIOTTOOLS)/uhcpd/bin/uhcpd $(TAP) $(IPV6_PREFIX) &
endif # USE_DHCPV6
else
# We override the `make term` command to use ethos
ifeq (1,$(USE_DHCPV6))
TERMPROG ?= sudo $(RIOTTOOLS)/ethos/ethos
TERMFLAGS ?= $(TAP) $(PORT) $(ETHOS_BAUDRATE)
else # USE_DHCPV6
TERMPROG ?= sudo sh $(RIOTTOOLS)/ethos/start_network.sh
TERMFLAGS ?= $(PORT) $(TAP) $(IPV6_PREFIX)
endif
STATIC_ROUTES ?= 1
# We depend on the ethos host tools to run the border router, we build them
# if necessary
TERMDEPS += host-tools
endif
# As there is an 'Kconfig' we want to explicitly disable Kconfig by setting
# the variable to empty
SHOULD_RUN_KCONFIG ?=
include $(RIOTBASE)/Makefile.include
ifndef CONFIG_GNRC_DHCPV6_CLIENT_6LBR_STATIC_ROUTE
ifeq (1,$(STATIC_ROUTES))
CFLAGS += -DCONFIG_GNRC_DHCPV6_CLIENT_6LBR_STATIC_ROUTE=1
# CONFIG_GNRC_DHCPV6_CLIENT_6LBR_STATIC_ROUTE=1 requires one more address for
# `fe80::2`.
CFLAGS += -DCONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF=3
endif
endif
.PHONY: host-tools
host-tools:

View File

@ -1,6 +1,7 @@
# gnrc_border_router using automatic configuration
This setup uses a single serial interface, ethos (Ethernet Over Serial)
and UHCP (micro Host Configuration Protocol).
and UHCP (micro Host Configuration Protocol) (using DHCPv6 alternatively is also
possible).
Ethos multiplexes serial data to separate ethernet packets from shell commands.
UHCP is in charge of configuring the wireless interface prefix
and routes on the BR.
@ -11,6 +12,34 @@ The script `start_network.sh` enables a *ready-to-use* BR in only one command.
This functionality works only on Linux machines.
Mac OSX support will be added in the future (lack of native `tap` interface).
If you want to use DHCPv6, you also need a DHCPv6 server configured for prefix
delegation from the interface facing the border router. With the [KEA] DHCPv6
server e.g. you can use the following configuration:
```json
"Dhcp6":
{
"interfaces-config": {
"interfaces": [ "tap0" ]
},
...
"subnet6": [
{ "interface": "tap0",
"subnet": "2001:db8::/16",
"pd-pools": [ { "prefix": "2001:db8::",
"prefix-len": 16,
"delegated-len": 64 } ] },
]
...
}
```
Note that when working with TAP interfaces you might need to restart your DHCPv6
server once *after* you started the border router application (see below), since
Linux might not recognize the interface as connected.
[KEA]: https://kea.isc.org/
## Setup
First, you need to compile `ethos`.
Go to `/dist/tools/ethos` and type:
@ -32,6 +61,13 @@ Afterwards, proceed to compile and flash `gnrc_border_router` to your board:
make clean all flash
```
If you want to use DHCPv6 instead of UHCP compile with the environment variable
`USE_DHCPV6` set to 1
```bash
USE_DHCPV6=1 make clean all flash
```
## Usage
Start the `start_network.sh` script by doing on `dist/tools/ethos`: