]> git.ipfire.org Git - people/stevee/network.git/commitdiff
dhcp+pppoe: Make prefix delegation configurable.
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 6 May 2013 11:08:57 +0000 (13:08 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 6 May 2013 11:08:57 +0000 (13:08 +0200)
functions.cli
functions.dhclient
hooks/zones/pppoe

index 2d35e6420354108c82f203f31033940360cf3337..3389b4106898d22c15a399978061e963b746d23d 100644 (file)
@@ -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})"
index d94684a83a50fd5644347ccf9a7b1c7a0493a5f2..29a6d664c00cd293c05418b5a9711d69b99dd1f1 100644 (file)
@@ -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 "}"
index 02a8eec2cc0df8d99493e801d83a89313506db1a..2b0a5451b13a4e74bff19f379bee04197efd55e4 100755 (executable)
@@ -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})
                                ;;