inetcalc -n $@ && return ${EXIT_OK} || return ${EXIT_ERROR}
}
+ip_network_is_subset_of() {
+ assert [ $# -eq 2 ]
+
+ inetcalc -s $@ && return ${EXIT_TRUE} || return ${EXIT_FALSE}
+}
+
ip_address_add() {
local device=${1}
local address=${2}
return ${EXIT_ERROR}
fi
+ # Check if the gateway is part of the statically routed network
+ if ip_network_is_subset_of ${gateway} ${network}; then
+ error "The gateway is in the routed network"
+ return ${EXIT_ERROR}
+ fi
+
local network_proto=$(ip_detect_protocol ${network})
assert isset network_proto
# Must be a valid IP address.
ip_is_valid ${gateway} || return ${EXIT_ERROR}
+
+ # Check if the gateway is part of the statically routed network
+ if ip_network_is_subset_of ${gateway} ${network}; then
+ return ${EXIT_ERROR}
+ fi
else
# Check if exactly one of unreachable, prohibit or blackhole is set.
local counter=$(list_count true ${unreachable} ${prohibit} ${blackhole})