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
_dhcpd_write_options ${proto} ${file} ${options_list} "\t"
}
- function _dhcpd_search_routers() {
+_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}"
+}
+
+ _dhcpd_search_routers() {
local proto=${1}
assert isset proto
return ${EXIT_TRUE}
}
- function ipv6_get_prefix() {
+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}
+}
+
+ ipv6_get_prefix() {
ip_get_prefix "$@"
}