mutable_dhcp->remove("relay-supplied-options");
}
+void
+AdaptorConfig::removeAuthoritativeSubnets(ConstElementPtr subnets) {
+ if (!subnets || subnets->empty()) {
+ // nothing to do here.
+ return;
+ }
+
+ for (size_t i = 0; i < subnets->size(); ++i) {
+ ElementPtr subnet = subnets->getNonConst(i);
+ ConstElementPtr auth = subnet->get("authoritative");
+ if (auth) {
+ subnet->remove("authoritative");
+ }
+ }
+}
+
+void
+AdaptorConfig::removeAuthoritativeSharedNetworks(ConstElementPtr networks) {
+ if (!networks || networks->empty()) {
+ // nothing to do here.
+ return;
+ }
+
+ for (size_t i = 0; i < networks->size(); ++i) {
+ ElementPtr network = networks->getNonConst(i);
+ ConstElementPtr auth = network->get("authoritative");
+ if (auth) {
+ network->remove("authoritative");
+ }
+ removeAuthoritativeSubnets(network->get("subnet4"));
+ }
+}
+
+void
+AdaptorConfig::removeAuthoritative(ConstElementPtr dhcp) {
+ removeAuthoritativeSubnets(dhcp->get("subnet4"));
+ removeAuthoritativeSharedNetworks(dhcp->get("shared-networks"));
+ ConstElementPtr auth = dhcp->get("authoritative");
+ if (!auth) {
+ // Done.
+ return;
+ }
+ ElementPtr mutable_dhcp = boost::const_pointer_cast<Element>(dhcp);
+ mutable_dhcp->remove("authoritative");
+}
+
void
AdaptorConfig::preProcess(ElementPtr dhcp, const string& subsel,
const string& space) {
sanitizeDatabase(dhcp);
- if (space == DHCP6_SPACE) {
+ if (space == DHCP4_SPACE) {
+ removeAuthoritative(dhcp);
+ } else if (space == DHCP6_SPACE) {
sanitizeRelaySuppliedOptions(dhcp);
}
}
/// @param dhcp The DHCPv6 server.
static void sanitizeRelaySuppliedOptions(isc::data::ConstElementPtr dhcp);
+ /// @brief Remove authoritative flag from a subnet list.
+ ///
+ /// @param subnets The subnet list.
+ static void removeAuthoritativeSubnets(isc::data::ConstElementPtr subnets);
+
+ /// @brief Remove authoritative flag from a shared network list.
+ ///
+ /// Remove authoritative flag in each shared network and its
+ /// subnet4 children.
+ ///
+ /// @param networks The shared network list.
+ static void removeAuthoritativeSharedNetworks(isc::data::ConstElementPtr networks);
+
+ /// @brief Remove authoritative flags.
+ ///
+ /// Remove global, shared network and subnet4 authoritative flags.
+ ///
+ /// @param dhcp The DHCPv4 server.
+ static void removeAuthoritative(isc::data::ConstElementPtr dhcp);
+
/// @brief Pre process a configuration.
///
/// Assign subnet IDs, check and set default in options, etc.