return ${EXIT_ERROR}
fi
+ # Search for any overlaps
+ local overlaps=$(dhcpd_subnet_range_overlaps ${proto} ${subnet} ${range})
+ if isset overlaps; then
+ error "DHCP subnet range ${range} overlaps with ${overlaps}"
+ return ${EXIT_ERROR}
+ fi
+
# Write the configuration to file.
local file=$(dhcpd_subnet_range_path ${proto} ${subnet} ${range})
assert isset file
return ${EXIT_FALSE}
}
+dhcpd_subnet_range_overlaps() {
+ assert [ $# -eq 3 ]
+
+ local proto=${1}
+ local subnet=${2}
+ local range=${3}
+
+ local start=${range%-*}
+ local end=${range#*-}
+
+ assert isset start
+ assert isset end
+
+ local settings=$(dhcpd_subnet_range_settings ${proto})
+
+ local r ${settings}
+ for r in $(dhcpd_subnet_range_list ${proto} ${subnet}); do
+ dhcpd_subnet_range_read ${proto} ${subnet} ${r}
+
+ # Check if the new range is a sub-range of any existing range
+
+ # Check if the start address is somewhere in this range
+ if ${proto}_addr_ge ${START} ${start} && ${proto}_addr_le ${START} ${end}; then
+ print "${r}"
+ return ${EXIT_TRUE}
+ fi
+
+ # Check if the end address is somewhere in this range
+ if ${proto}_addr_ge ${END} ${start} && ${proto}_addr_le ${END} ${end}; then
+ print "${r}"
+ return ${EXIT_TRUE}
+ fi
+
+ # Check if any existing range is a sub-range of the new range
+
+ # Check if the start address is somewhere in this range
+ if ${proto}_addr_ge ${start} ${START} && ${proto}_addr_le ${start} ${END}; then
+ print "${r}"
+ return ${EXIT_TRUE}
+ fi
+
+ # Check if the end address is somewhere in this range
+ if ${proto}_addr_ge ${end} ${START} && ${proto}_addr_le ${end} ${END}; then
+ print "${r}"
+ return ${EXIT_TRUE}
+ fi
+ done
+
+ return ${EXIT_FALSE}
+}
+
dhcpd_subnet_settings() {
local proto=${1}
&& return ${EXIT_TRUE} || return ${EXIT_FALSE}
}
+ipv4_addr_ge() {
+ ipv4_addr_eq $@ || ipv4_addr_gt $@
+}
+
+ipv4_addr_lt() {
+ ! ipv4_addr_eq $@ && ! ipv4_addr_gt $@
+}
+
+ipv4_addr_le() {
+ ipv4_addr_eq $@ || ! ipv4_addr_gt $@
+}
+
ipv4_range() {
local range=${1}
&& return ${EXIT_TRUE} || return ${EXIT_FALSE}
}
+ipv6_addr_ge() {
+ ipv6_addr_eq $@ || ipv6_addr_gt $@
+}
+
+ipv6_addr_lt() {
+ ! ipv6_addr_eq $@ && ! ipv6_addr_gt $@
+}
+
+ipv6_addr_le() {
+ ipv6_addr_eq $@ || ! ipv6_addr_gt $@
+}
+
ipv6_hash() {
local address="${1}"
assert isset address