From: Michael Tremer Date: Sat, 2 May 2015 21:31:30 +0000 (+0000) Subject: Merge branch 'master' of ssh://git.ipfire.org/pub/git/network X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d1e6ce67bc7fc8a77dacec1a9f455f7d36667079;p=people%2Fstevee%2Fnetwork.git Merge branch 'master' of ssh://git.ipfire.org/pub/git/network Conflicts: src/functions/functions.dhcpd src/functions/functions.ipv6 --- d1e6ce67bc7fc8a77dacec1a9f455f7d36667079 diff --cc src/functions/functions.dhcpd index a4e10e58,05e79522..b1f87674 --- a/src/functions/functions.dhcpd +++ b/src/functions/functions.dhcpd @@@ -972,22 -898,25 +972,22 @@@ _dhcpd_write_options() key="dhcp6.${key}" fi - if isset val; then - if isinteger val; then - fmt="option %s %d;" - elif isipaddress val; then - fmt="option %s %s;" - else - fmt="option %s \"%s\";" - fi - print "${ident}${fmt}" "${key}" "${val}" + if isinteger val; then + fmt="option %s %d;" + elif enabled raw || isipaddress val; then + fmt="option %s %s;" + else + fmt="option %s \"%s\";" fi + + print "${ident}${fmt}" "${key}" "${val}" done >> ${file} - # Append an empty line when options have been written. - if [ -n "${!options[@]}" ]; then - print >> ${file} - fi + # Empty line + print >> ${file} } - function _dhcpd_read_options() { + _dhcpd_read_options() { local file=${1} assert isset file @@@ -1094,31 -1018,7 +1094,31 @@@ _dhcpd_write_subnet_options() _dhcpd_write_options ${proto} ${file} ${options_list} "\t" } +_dhcpd_write_subnet_pd() { + # Nothing to do if prefix delegation is not enabled + enabled PREFIX_DELEGATION || return ${EXIT_OK} + + local subnet_id="${1}" + assert isset subnet_id + + local file="${2}" + assert isset file + + local prefix_size="${DELEGATED_PREFIX_SIZE}" + isset prefix_size || prefix_size="${DHCP_DEFAULT_DELEGATED_PREFIX_SIZE}" + + assert ipv6_is_valid "${DELEGATED_PREFIX_FIRST}" + assert ipv6_is_valid "${DELEGATED_PREFIX_LAST}" + assert ipv6_prefix_size_is_valid_for_delegation "${prefix_size}" + + ( + print " # Prefix Delegation" + print " prefix6 ${DELEGATED_PREFIX_FIRST} ${DELEGATED_PREFIX_LAST} /${prefix_size};" + print "" + ) >> "${file}" +} + - function _dhcpd_search_routers() { + _dhcpd_search_routers() { local proto=${1} assert isset proto diff --cc src/functions/functions.ipv6 index 537819cf,5e618dc5..9026cd88 --- a/src/functions/functions.ipv6 +++ b/src/functions/functions.ipv6 @@@ -75,19 -127,7 +127,19 @@@ ipv6_prefix_is_valid() return ${EXIT_TRUE} } +ipv6_prefix_size_is_valid_for_delegation() { + local prefix_size="${1}" + assert isinteger prefix_size + + # For prefix delegation, the prefix must be between /48 and /64 + # (RFC3769, section 3.1) + [[ ${prefix_size} -lt 48 ]] && return ${EXIT_FALSE} + [[ ${prefix_size} -gt 64 ]] && return ${EXIT_FALSE} + + return ${EXIT_TRUE} +} + - function ipv6_get_prefix() { + ipv6_get_prefix() { ip_get_prefix "$@" }