HostReservationsListParser<HostReservationParser4> parser;
parser.parse(subnet_->getID(), reservations, hosts);
for (auto h = hosts.begin(); h != hosts.end(); ++h) {
+ validateResv(sn4ptr, *h);
CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(*h);
}
}
parseDdnsParams(params, network);
}
+void
+Subnet4ConfigParser::validateResv(const Subnet4Ptr& subnet, ConstHostPtr host) {
+ const IOAddress& address = host->getIPv4Reservation();
+ if (!address.isV4Zero() && !subnet->inRange(address)) {
+ isc_throw(DhcpConfigError, "specified reservation '" << address
+ << "' is not matching the IPv4 subnet prefix '"
+ << subnet->toText() << "'");
+ }
+}
+
//**************************** Subnets4ListConfigParser **********************
Subnets4ListConfigParser::Subnets4ListConfigParser(bool check_iface)
HostReservationsListParser<HostReservationParser6> parser;
parser.parse(subnet_->getID(), reservations, hosts);
for (auto h = hosts.begin(); h != hosts.end(); ++h) {
+ validateResvs(sn6ptr, *h);
CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(*h);
}
}
parseDdnsParams(params, network);
}
+void
+Subnet6ConfigParser::validateResvs(const Subnet6Ptr& subnet, ConstHostPtr host) {
+ IPv6ResrvRange range = host->getIPv6Reservations(IPv6Resrv::TYPE_NA);
+ for (auto it = range.first; it != range.second; ++it) {
+ const IOAddress& address = it->second.getPrefix();
+ if (!subnet->inRange(address)) {
+ isc_throw(DhcpConfigError, "specified reservation '" << address
+ << "' is not matching the IPv6 subnet prefix '"
+ << subnet->toText() << "'");
+ }
+ }
+}
+
//**************************** Subnet6ListConfigParser ********************
Subnets6ListConfigParser::Subnets6ListConfigParser(bool check_iface)
return (SimpleParser::setDefaults(mutable_d2, D2_CLIENT_CONFIG_DEFAULTS));
}
-}; // namespace dhcp
-}; // namespace isc
+} // namespace dhcp
+} // namespace isc
/// @param len is the prefix length
void initSubnet(data::ConstElementPtr params,
asiolink::IOAddress addr, uint8_t len);
+
+ /// @brief Verifies the host reservation address is in the subnet range
+ ///
+ /// @param subnet pointer to the subnet
+ /// @param host pointer to the host reservation
+ /// @throw DhcpConfigError when the address is not in the subnet range.
+ void validateResv(const Subnet4Ptr& subnet, ConstHostPtr host);
};
/// @brief this class parses list of DHCP4 subnets
/// @param len is the prefix length
void initSubnet(isc::data::ConstElementPtr params,
isc::asiolink::IOAddress addr, uint8_t len);
+
+ /// @brief Verifies host reservation addresses are in the subnet range
+ ///
+ /// @param subnet pointer to the subnet
+ /// @param host pointer to the host reservation
+ /// @throw DhcpConfigError when an address is not in the subnet range.
+ void validateResvs(const Subnet6Ptr& subnet, ConstHostPtr host);
};
getMode(isc::data::ConstElementPtr scope, const std::string& name);
};
-}; // end of isc::dhcp namespace
-}; // end of isc namespace
+} // end of isc::dhcp namespace
+} // end of isc namespace
#endif // DHCP_PARSERS_H