From 08e40c8cd3080b5517939099a12039a51f9ec108 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Mon, 6 May 2013 13:08:57 +0200 Subject: [PATCH] dhcp+pppoe: Make prefix delegation configurable. --- functions.cli | 12 ++++++++++++ functions.dhclient | 13 +++++++++++++ hooks/zones/pppoe | 9 ++++++++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/functions.cli b/functions.cli index 2d35e642..3389b410 100644 --- a/functions.cli +++ b/functions.cli @@ -348,6 +348,18 @@ function cli_get_val() { echo "${@#*=}" } +function cli_get_bool() { + local value="$(cli_get_val "$@")" + + if enabled value; then + print "true" + return ${EXIT_TRUE} + fi + + print "false" + return ${EXIT_FALSE} +} + function cli_usage() { local command="$@" local basename="$(basename ${0})" diff --git a/functions.dhclient b/functions.dhclient index d94684a8..29a6d664 100644 --- a/functions.dhclient +++ b/functions.dhclient @@ -82,6 +82,7 @@ dhclient_write_config() { assert isset file local hostname=${HOSTNAME%%.*} + local prefix_delegation="false" local vendor=$(distro_get_pretty_name) while [ $# -gt 0 ]; do @@ -89,6 +90,9 @@ dhclient_write_config() { --hostname=*) hostname=$(cli_get_val ${1}) ;; + --prefix-delegation=*) + prefix_delegation="$(cli_get_bool "${1}")" + ;; --vendor=*) vendor=$(cli_get_val ${1}) ;; @@ -124,6 +128,15 @@ dhclient_write_config() { if isset hostname; then echo " send host-name \"${hostname}\";" + print + fi + + # Prefix delegation (IPv6). + if enabled prefix_delegation; then + print " # Prefix delegation" + print " also request dhcp6.ia-pd 1;" + print " send dhcp6.ia-na 1;" + print fi echo "}" diff --git a/hooks/zones/pppoe b/hooks/zones/pppoe index 02a8eec2..2b0a5451 100755 --- a/hooks/zones/pppoe +++ b/hooks/zones/pppoe @@ -22,7 +22,7 @@ . /usr/lib/network/header-zone HOOK_SETTINGS="HOOK ACCESS_CONCENTRATOR AUTH USERNAME PASSWORD" -HOOK_SETTINGS="${HOOK_SETTINGS} SERVICE_NAME MTU PORT IPV6" +HOOK_SETTINGS="${HOOK_SETTINGS} SERVICE_NAME MTU PORT IPV6 PREFIX_DELEGATION" # User credentials for the dialin. USERNAME="" @@ -51,6 +51,9 @@ PPPOE_PLUGIN="rp-pppoe.so" # Request an IPv6 address. IPV6="true" +# Use IPv6 prefix delegation. +PREFIX_DELEGATION="false" + function _check() { assert isset USERNAME assert isset PASSWORD @@ -62,6 +65,7 @@ function _check() { assert port_exists ${PORT} assert isset IPV6 + assert isset PREFIX_DELEGATION } function _parse_cmdline() { @@ -90,6 +94,9 @@ function _parse_cmdline() { --port=*) PORT=$(cli_get_val ${1}) ;; + --prefix-delegation=*) + PREFIX_DELEGATION="$(cli_get_bool "${1}")" + ;; --service-name=*) SERVICE_NAME=$(cli_get_val ${1}) ;; -- 2.39.2