diff options
Diffstat (limited to 'src/lib/dhcpsrv')
25 files changed, 344 insertions, 299 deletions
diff --git a/src/lib/dhcpsrv/client_class_def.cc b/src/lib/dhcpsrv/client_class_def.cc index 5d3ff21e03..b94a699eef 100644 --- a/src/lib/dhcpsrv/client_class_def.cc +++ b/src/lib/dhcpsrv/client_class_def.cc @@ -27,7 +27,7 @@ ClientClassDef::ClientClassDef(const std::string& name, const ExpressionPtr& match_expr, const CfgOptionPtr& cfg_option) : UserContext(), CfgToElement(), StampedElement(), name_(name), - match_expr_(match_expr), required_(false), depend_on_known_(false), + match_expr_(match_expr), additional_(false), depend_on_known_(false), cfg_option_(cfg_option), next_server_(asiolink::IOAddress::IPV4_ZERO_ADDRESS()), valid_(), preferred_() { @@ -46,7 +46,7 @@ ClientClassDef::ClientClassDef(const std::string& name, ClientClassDef::ClientClassDef(const ClientClassDef& rhs) : UserContext(rhs), CfgToElement(rhs), StampedElement(rhs), name_(rhs.name_), - match_expr_(ExpressionPtr()), test_(rhs.test_), required_(rhs.required_), + match_expr_(ExpressionPtr()), test_(rhs.test_), additional_(rhs.additional_), depend_on_known_(rhs.depend_on_known_), cfg_option_(new CfgOption()), next_server_(rhs.next_server_), sname_(rhs.sname_), filename_(rhs.filename_), valid_(rhs.valid_), preferred_(rhs.preferred_), @@ -101,13 +101,13 @@ ClientClassDef::setTest(const std::string& test) { } bool -ClientClassDef::getRequired() const { - return (required_); +ClientClassDef::getAdditional() const { + return (additional_); } void -ClientClassDef::setRequired(bool required) { - required_ = required; +ClientClassDef::setAdditional(bool additional) { + additional_ = additional; } bool @@ -213,7 +213,7 @@ ClientClassDef::equals(const ClientClassDef& other) const { ((!cfg_option_def_ && !other.cfg_option_def_) || (cfg_option_def_ && other.cfg_option_def_ && (*cfg_option_def_ == *other.cfg_option_def_))) && - (required_ == other.required_) && + (additional_ == other.additional_) && (depend_on_known_ == other.depend_on_known_) && (next_server_ == other.next_server_) && (sname_ == other.sname_) && @@ -232,9 +232,9 @@ ClientClassDef::toElement() const { if (!test_.empty()) { result->set("test", Element::create(test_)); } - // Set only-if-required - if (required_) { - result->set("only-if-required", Element::create(required_)); + // Set only-in-additional-list + if (additional_) { + result->set("only-in-additional-list", Element::create(additional_)); } // Set option-def (used only by DHCPv4) if (cfg_option_def_ && (family == AF_INET)) { @@ -336,7 +336,7 @@ void ClientClassDictionary::addClass(const std::string& name, const ExpressionPtr& match_expr, const std::string& test, - bool required, + bool additional, bool depend_on_known, const CfgOptionPtr& cfg_option, CfgOptionDefPtr cfg_option_def, @@ -355,7 +355,7 @@ ClientClassDictionary::addClass(const std::string& name, cclass.reset(new ClientClassDef(name, match_expr, cfg_option)); } cclass->setTest(test); - cclass->setRequired(required); + cclass->setAdditional(additional); cclass->setDependOnKnown(depend_on_known); cclass->setCfgOptionDef(cfg_option_def); cclass->setContext(user_context), diff --git a/src/lib/dhcpsrv/client_class_def.h b/src/lib/dhcpsrv/client_class_def.h index c9158e1107..21f5e98792 100644 --- a/src/lib/dhcpsrv/client_class_def.h +++ b/src/lib/dhcpsrv/client_class_def.h @@ -88,13 +88,13 @@ public: /// @param test the original expression to assign the class void setTest(const std::string& test); - /// @brief Fetches the only if required flag - bool getRequired() const; + /// @brief Fetches the only if additional flag + bool getAdditional() const; - /// @brief Sets the only if required flag + /// @brief Sets the only if additional flag /// - /// @param required the value of the only if required flag - void setRequired(bool required); + /// @param additional the value of the only if additional flag + void setAdditional(bool additional); /// @brief Fetches the depend on known flag aka use host flag bool getDependOnKnown() const; @@ -261,14 +261,14 @@ private: /// this class. std::string test_; - /// @brief The only-if-required flag: when false (the default) membership + /// @brief The only-in-additional-list flag: when false (the default) membership /// is determined during classification so is available for instance for - /// subnet selection. When true, membership is evaluated only when required + /// subnet selection. When true, membership is evaluated only when additional /// and is usable only for option configuration. - bool required_; + bool additional_; /// @brief The depend on known aka use host flag: when false (the default), - /// the required flag is false and the class has a match expression + /// the additional flag is false and the class has a match expression /// the expression is evaluated in the first pass. When true and the /// two other conditions stand the expression is evaluated later when /// the host reservation membership was determined. @@ -375,7 +375,7 @@ public: /// @param name Name to assign to this class /// @param match_expr Expression the class will use to determine membership /// @param test Original version of match_expr - /// @param required Original value of the only if required flag + /// @param additional Original value of the only if additional flag /// @param depend_on_known Using host so will be evaluated later /// @param options Collection of options members should be given /// @param defs Option definitions (optional) @@ -392,7 +392,7 @@ public: /// dictionary. See @ref dhcp::ClientClassDef::ClientClassDef() for /// others. void addClass(const std::string& name, const ExpressionPtr& match_expr, - const std::string& test, bool required, bool depend_on_known, + const std::string& test, bool additional, bool depend_on_known, const CfgOptionPtr& options, CfgOptionDefPtr defs = CfgOptionDefPtr(), isc::data::ConstElementPtr user_context = isc::data::ConstElementPtr(), diff --git a/src/lib/dhcpsrv/dhcpsrv_messages.cc b/src/lib/dhcpsrv/dhcpsrv_messages.cc index af6e09c28d..b2f7b9088d 100644 --- a/src/lib/dhcpsrv/dhcpsrv_messages.cc +++ b/src/lib/dhcpsrv/dhcpsrv_messages.cc @@ -143,10 +143,12 @@ extern const isc::log::MessageID DHCPSRV_MT_DISABLED_QUEUE_CONTROL = "DHCPSRV_MT extern const isc::log::MessageID DHCPSRV_MULTIPLE_RAW_SOCKETS_PER_IFACE = "DHCPSRV_MULTIPLE_RAW_SOCKETS_PER_IFACE"; extern const isc::log::MessageID DHCPSRV_NOTYPE_DB = "DHCPSRV_NOTYPE_DB"; extern const isc::log::MessageID DHCPSRV_NO_SOCKETS_OPEN = "DHCPSRV_NO_SOCKETS_OPEN"; +extern const isc::log::MessageID DHCPSRV_ONLY_IF_REQUIRED_DEPRECATED = "DHCPSRV_ONLY_IF_REQUIRED_DEPRECATED"; extern const isc::log::MessageID DHCPSRV_OPEN_SOCKET_FAIL = "DHCPSRV_OPEN_SOCKET_FAIL"; extern const isc::log::MessageID DHCPSRV_QUEUE_NCR = "DHCPSRV_QUEUE_NCR"; extern const isc::log::MessageID DHCPSRV_QUEUE_NCR_FAILED = "DHCPSRV_QUEUE_NCR_FAILED"; extern const isc::log::MessageID DHCPSRV_QUEUE_NCR_SKIP = "DHCPSRV_QUEUE_NCR_SKIP"; +extern const isc::log::MessageID DHCPSRV_REQUIRE_CLIENT_CLASSES_DEPRECATED = "DHCPSRV_REQUIRE_CLIENT_CLASSES_DEPRECATED"; extern const isc::log::MessageID DHCPSRV_SUBNET4O6_SELECT_FAILED = "DHCPSRV_SUBNET4O6_SELECT_FAILED"; extern const isc::log::MessageID DHCPSRV_SUBNET4_SELECT_BY_ADDRESS_NO_MATCH = "DHCPSRV_SUBNET4_SELECT_BY_ADDRESS_NO_MATCH"; extern const isc::log::MessageID DHCPSRV_SUBNET4_SELECT_BY_INTERFACE_NO_MATCH = "DHCPSRV_SUBNET4_SELECT_BY_INTERFACE_NO_MATCH"; @@ -310,10 +312,12 @@ const char* values[] = { "DHCPSRV_MULTIPLE_RAW_SOCKETS_PER_IFACE", "current configuration will result in opening multiple broadcast capable sockets on some interfaces and some DHCP messages may be duplicated", "DHCPSRV_NOTYPE_DB", "no 'type' keyword to determine database backend: %1", "DHCPSRV_NO_SOCKETS_OPEN", "no interface configured to listen to DHCP traffic", + "DHCPSRV_ONLY_IF_REQUIRED_DEPRECATED", "The parameter 'only-if-required' is deprecated. Use 'only-in-additional-list' instead", "DHCPSRV_OPEN_SOCKET_FAIL", "failed to open socket: %1", "DHCPSRV_QUEUE_NCR", "%1: Name change request to %2 DNS entry queued: %3", "DHCPSRV_QUEUE_NCR_FAILED", "%1: queuing %2 name change request failed for lease %3: %4", "DHCPSRV_QUEUE_NCR_SKIP", "%1: skip queuing name change request for lease: %2", + "DHCPSRV_REQUIRE_CLIENT_CLASSES_DEPRECATED", "The parameter 'require-client-classes' is deprecated. Use 'evaluate-additional-classes' instead", "DHCPSRV_SUBNET4O6_SELECT_FAILED", "Failed to select any subnet for the DHCPv4o6 packet", "DHCPSRV_SUBNET4_SELECT_BY_ADDRESS_NO_MATCH", "No subnet matches address: %1", "DHCPSRV_SUBNET4_SELECT_BY_INTERFACE_NO_MATCH", "No subnet matches interface: %1", diff --git a/src/lib/dhcpsrv/dhcpsrv_messages.h b/src/lib/dhcpsrv/dhcpsrv_messages.h index dcb7447534..4c7bf154fa 100644 --- a/src/lib/dhcpsrv/dhcpsrv_messages.h +++ b/src/lib/dhcpsrv/dhcpsrv_messages.h @@ -144,10 +144,12 @@ extern const isc::log::MessageID DHCPSRV_MT_DISABLED_QUEUE_CONTROL; extern const isc::log::MessageID DHCPSRV_MULTIPLE_RAW_SOCKETS_PER_IFACE; extern const isc::log::MessageID DHCPSRV_NOTYPE_DB; extern const isc::log::MessageID DHCPSRV_NO_SOCKETS_OPEN; +extern const isc::log::MessageID DHCPSRV_ONLY_IF_REQUIRED_DEPRECATED; extern const isc::log::MessageID DHCPSRV_OPEN_SOCKET_FAIL; extern const isc::log::MessageID DHCPSRV_QUEUE_NCR; extern const isc::log::MessageID DHCPSRV_QUEUE_NCR_FAILED; extern const isc::log::MessageID DHCPSRV_QUEUE_NCR_SKIP; +extern const isc::log::MessageID DHCPSRV_REQUIRE_CLIENT_CLASSES_DEPRECATED; extern const isc::log::MessageID DHCPSRV_SUBNET4O6_SELECT_FAILED; extern const isc::log::MessageID DHCPSRV_SUBNET4_SELECT_BY_ADDRESS_NO_MATCH; extern const isc::log::MessageID DHCPSRV_SUBNET4_SELECT_BY_INTERFACE_NO_MATCH; diff --git a/src/lib/dhcpsrv/dhcpsrv_messages.mes b/src/lib/dhcpsrv/dhcpsrv_messages.mes index b9a6ac0633..46c543e2cf 100644 --- a/src/lib/dhcpsrv/dhcpsrv_messages.mes +++ b/src/lib/dhcpsrv/dhcpsrv_messages.mes @@ -945,3 +945,15 @@ included in the message. % DHCPSRV_UNKNOWN_DB unknown database type: %1 The database access string specified a database type (given in the message) that is unknown to the software. This is a configuration error. + +% DHCPSRV_REQUIRE_CLIENT_CLASSES_DEPRECATED The parameter 'require-client-classes' is deprecated. Use 'evaluate-additional-classes' instead +This warning message is emitted when configuration parsing detects +the use of the deprecated 'require-client-classes' parameter. It has +been replaced by 'evaluate-additional-classes'. Users should migrate +to the new parameter. + +% DHCPSRV_ONLY_IF_REQUIRED_DEPRECATED The parameter 'only-if-required' is deprecated. Use 'only-in-additional-list' instead +This warning message is emitted when configuration parsing detects +the use of the deprecated 'only-if-required' parameter. It has +been replaced by 'only-in-additional-list'. Users should migrate +to the new parameter. diff --git a/src/lib/dhcpsrv/network.cc b/src/lib/dhcpsrv/network.cc index bc447c86d2..9a13810012 100644 --- a/src/lib/dhcpsrv/network.cc +++ b/src/lib/dhcpsrv/network.cc @@ -82,15 +82,15 @@ Network::allowClientClass(const isc::dhcp::ClientClass& class_name) { } void -Network::requireClientClass(const isc::dhcp::ClientClass& class_name) { - if (!required_classes_.contains(class_name)) { - required_classes_.insert(class_name); +Network::addAdditionalClass(const isc::dhcp::ClientClass& class_name) { + if (!additional_classes_.contains(class_name)) { + additional_classes_.insert(class_name); } } const ClientClasses& -Network::getRequiredClasses() const { - return (required_classes_); +Network::getAdditionalClasses() const { + return (additional_classes_); } Optional<IOAddress> @@ -141,13 +141,13 @@ Network::toElement() const { } // Set require-client-classes - const ClientClasses& classes = getRequiredClasses(); + const ClientClasses& classes = getAdditionalClasses(); if (!classes.empty()) { ElementPtr class_list = Element::createList(); for (auto const& it : classes) { class_list->add(Element::create(it)); } - map->set("require-client-classes", class_list); + map->set("evaluate-additional-classes", class_list); } // T1, T2, and Valid are optional for SharedNetworks, and diff --git a/src/lib/dhcpsrv/network.h b/src/lib/dhcpsrv/network.h index d8f9760614..fb934c4e27 100644 --- a/src/lib/dhcpsrv/network.h +++ b/src/lib/dhcpsrv/network.h @@ -349,13 +349,18 @@ public: /// @param class_name client class to be supported by this network void allowClientClass(const isc::dhcp::ClientClass& class_name); - /// @brief Adds class class_name to classes required to be evaluated. + /// @brief Adds class class_name to the additional classes list. /// - /// @param class_name client class required to be evaluated - void requireClientClass(const isc::dhcp::ClientClass& class_name); + /// @param class_name client class to add + void addAdditionalClass(const isc::dhcp::ClientClass& class_name); - /// @brief Returns classes which are required to be evaluated - const ClientClasses& getRequiredClasses() const; + /// @brief Returns the additional classes list. + const ClientClasses& getAdditionalClasses() const; + + /// @brief Returns the mutable additional classes list. + ClientClasses& getMutableAdditionalClasses() { + return (additional_classes_); + } /// @brief returns the client class /// @@ -1147,11 +1152,12 @@ protected: /// which means that any client is allowed, regardless of its class. util::Optional<ClientClass> client_class_; - /// @brief Required classes + /// @brief Additional classes /// - /// If the network is selected these classes will be added to the - /// incoming packet and their evaluation will be required. - ClientClasses required_classes_; + /// If the network is selected these classes will be evaluated against + /// incoming packet after all other classification and the lease has + /// been assigned. + ClientClasses additional_classes_; /// @brief a isc::util::Triplet (min/default/max) holding allowed renew timer values isc::util::Triplet<uint32_t> t1_; diff --git a/src/lib/dhcpsrv/parsers/base_network_parser.cc b/src/lib/dhcpsrv/parsers/base_network_parser.cc index 8d73b7aed9..01da86dcd4 100644 --- a/src/lib/dhcpsrv/parsers/base_network_parser.cc +++ b/src/lib/dhcpsrv/parsers/base_network_parser.cc @@ -17,6 +17,7 @@ using namespace isc::util; namespace isc { namespace dhcp { + void BaseNetworkParser::parseCommon(const ConstElementPtr& network_data, NetworkPtr& network) { @@ -250,6 +251,35 @@ BaseNetworkParser::parseOfferLft(const data::ConstElementPtr& network_data, } } +void +BaseNetworkParser::getAdditionalClassesElem(ConstElementPtr params, + ClassAdderFunc adder_func) { + // Try setting up additional lient classes. + ConstElementPtr req_class_list = params->get("require-client-classes"); + ConstElementPtr class_list = params->get("evaluate-additional-classes"); + if (req_class_list) { + if (!class_list) { + LOG_WARN(dhcpsrv_logger, DHCPSRV_REQUIRE_CLIENT_CLASSES_DEPRECATED); + class_list = req_class_list; + } else { + isc_throw(isc::dhcp::DhcpConfigError, + "cannot specify both 'require-client-classes' and " + "'evaluate-additional-classes'. Use only the latter."); + } + } + + if (class_list) { + const std::vector<data::ElementPtr>& classes = class_list->listValue(); + for (auto const& cclass : classes) { + if ((cclass->getType() != Element::string) || + cclass->stringValue().empty()) { + isc_throw(DhcpConfigError, "invalid class name (" << cclass->getPosition() << ")"); + } + + (adder_func)(cclass->stringValue()); + } + } +} } // end of namespace isc::dhcp } // end of namespace isc diff --git a/src/lib/dhcpsrv/parsers/base_network_parser.h b/src/lib/dhcpsrv/parsers/base_network_parser.h index cd7b4bcbaf..c4e2a14b4e 100644 --- a/src/lib/dhcpsrv/parsers/base_network_parser.h +++ b/src/lib/dhcpsrv/parsers/base_network_parser.h @@ -126,6 +126,18 @@ protected: /// @throw DhcpConfigError if the value is less than 0. void parseOfferLft(const data::ConstElementPtr& network_data, Network4Ptr& network); +public: + typedef std::function<void(const isc::dhcp::ClientClass&)> ClassAdderFunc; + + /// @brief Fetches the element for either 'evaluate-additional-classes' or deprecated + /// 'require-client-classes' + /// + /// @param params configuration element tree to search. + /// @param adder_func function to add class names to an object's additional class list. + /// @return Element referred to or an empty pointer. + /// @throw DhcpConfigError if both entries are present. + static void getAdditionalClassesElem(data::ConstElementPtr params, + ClassAdderFunc adder_func); }; } // end of namespace isc::dhcp diff --git a/src/lib/dhcpsrv/parsers/client_class_def_parser.cc b/src/lib/dhcpsrv/parsers/client_class_def_parser.cc index e1c377671e..5d93bcd57c 100644 --- a/src/lib/dhcpsrv/parsers/client_class_def_parser.cc +++ b/src/lib/dhcpsrv/parsers/client_class_def_parser.cc @@ -8,6 +8,7 @@ #include <dhcp/libdhcp++.h> #include <dhcpsrv/cfgmgr.h> #include <dhcpsrv/client_class_def.h> +#include <dhcpsrv/dhcpsrv_log.h> #include <dhcpsrv/parsers/dhcp_parsers.h> #include <dhcpsrv/parsers/client_class_def_parser.h> #include <dhcpsrv/parsers/simple_parser4.h> @@ -170,10 +171,29 @@ ClientClassDefParser::parse(ClientClassDictionaryPtr& class_dictionary, } } - // Let's try to parse the only-if-required flag - bool required = false; - if (class_def_cfg->contains("only-if-required")) { - required = getBoolean(class_def_cfg, "only-if-required"); + // Let's try to parse the only-in-additional-list/only-if-required flag + auto required_elem = class_def_cfg->get("only-if-required"); + auto additional_elem = class_def_cfg->get("only-in-additional-list"); + if (required_elem) { + if (!additional_elem) { + LOG_WARN(dhcpsrv_logger, DHCPSRV_ONLY_IF_REQUIRED_DEPRECATED); + additional_elem = required_elem; + } else { + isc_throw(isc::dhcp::DhcpConfigError, + "cannot specify both 'only-if-required' and " + "'only-in-additional-list'. Use only the latter."); + } + } + + bool additional = false; + if (additional_elem) { + if (additional_elem->getType() == Element::boolean) { + additional = additional_elem->boolValue(); + } else { + isc_throw(isc::dhcp::DhcpConfigError, + "'only-in-additional-list' must be boolean" + << additional_elem->getPosition()); + } } // Let's try to parse the next-server field @@ -252,9 +272,9 @@ ClientClassDefParser::parse(ClientClassDictionaryPtr& class_dictionary, // Sanity checks on built-in classes for (auto const& bn : builtinNames) { if (name == bn) { - if (required) { + if (additional) { isc_throw(DhcpConfigError, "built-in class '" << name - << "' only-if-required flag must be false"); + << "' only-in-additional-list flag must be false"); } if (!test.empty()) { isc_throw(DhcpConfigError, "built-in class '" << name @@ -265,16 +285,16 @@ ClientClassDefParser::parse(ClientClassDictionaryPtr& class_dictionary, // Sanity checks on DROP if (name == "DROP") { - if (required) { + if (additional) { isc_throw(DhcpConfigError, "special class '" << name - << "' only-if-required flag must be false"); + << "' only-in-additional-list flag must be false"); } // depend_on_known is now allowed } // Add the client class definition try { - class_dictionary->addClass(name, match_expr, test, required, + class_dictionary->addClass(name, match_expr, test, additional, depend_on_known, options, defs, user_context, next_server, sname, filename, valid_lft, preferred_lft, is_template, offer_lft); @@ -302,7 +322,8 @@ ClientClassDefParser::checkParametersSupported(const ConstElementPtr& class_def_ "test", "option-data", "user-context", - "only-if-required", + "only-if-required", // deprecated + "only-in-additional-list", "valid-lifetime", "min-valid-lifetime", "max-valid-lifetime", diff --git a/src/lib/dhcpsrv/parsers/dhcp_parsers.cc b/src/lib/dhcpsrv/parsers/dhcp_parsers.cc index 1cc76d186f..f6be7c794a 100644 --- a/src/lib/dhcpsrv/parsers/dhcp_parsers.cc +++ b/src/lib/dhcpsrv/parsers/dhcp_parsers.cc @@ -37,6 +37,7 @@ using namespace std; using namespace isc::asiolink; using namespace isc::data; using namespace isc::util; +namespace ph = std::placeholders; namespace isc { namespace dhcp { @@ -522,19 +523,10 @@ PoolParser::parse(PoolStoragePtr pools, } } - // Try setting up required client classes. - ConstElementPtr class_list = pool_structure->get("require-client-classes"); - if (class_list) { - const std::vector<data::ElementPtr>& classes = class_list->listValue(); - for (auto const& cclass : classes) { - if ((cclass->getType() != Element::string) || - cclass->stringValue().empty()) { - isc_throw(DhcpConfigError, "invalid class name (" - << cclass->getPosition() << ")"); - } - pool->requireClientClass(cclass->stringValue()); - } - } + // Setup additional class list. + BaseNetworkParser::getAdditionalClassesElem(pool_structure, + std::bind(&Pool::addAdditionalClass, + pool, ph::_1)); } boost::shared_ptr<OptionDataListParser> @@ -898,19 +890,9 @@ Subnet4ConfigParser::initSubnet(data::ConstElementPtr params, } } - // Try setting up required client classes. - ConstElementPtr class_list = params->get("require-client-classes"); - if (class_list) { - const std::vector<data::ElementPtr>& classes = class_list->listValue(); - for (auto const& cclass : classes) { - if ((cclass->getType() != Element::string) || - cclass->stringValue().empty()) { - isc_throw(DhcpConfigError, "invalid class name (" - << cclass->getPosition() << ")"); - } - subnet4->requireClientClass(cclass->stringValue()); - } - } + // Setup additional class list. + getAdditionalClassesElem(params, std::bind(&Network::addAdditionalClass, + subnet4, ph::_1)); // 4o6 specific parameter: 4o6-interface. if (params->contains("4o6-interface")) { @@ -1131,8 +1113,6 @@ PdPoolParser::parse(PoolStoragePtr pools, ConstElementPtr pd_pool, client_class_ = client_class; } - ConstElementPtr class_list = pd_pool->get("require-client-classes"); - // Check the pool parameters. It will throw an exception if any // of the required parameters are invalid. try { @@ -1187,17 +1167,10 @@ PdPoolParser::parse(PoolStoragePtr pools, ConstElementPtr pd_pool, } } - if (class_list) { - const std::vector<data::ElementPtr>& classes = class_list->listValue(); - for (auto const& cclass : classes) { - if ((cclass->getType() != Element::string) || - cclass->stringValue().empty()) { - isc_throw(DhcpConfigError, "invalid class name (" - << cclass->getPosition() << ")"); - } - pool_->requireClientClass(cclass->stringValue()); - } - } + // Setup additional class list. + BaseNetworkParser::getAdditionalClassesElem(pd_pool, + std::bind(&Pool::addAdditionalClass, + pool_, ph::_1)); // Add the local pool to the external storage ptr. pools->push_back(pool_); @@ -1426,21 +1399,9 @@ Subnet6ConfigParser::initSubnet(data::ConstElementPtr params, } } - if (params->contains("require-client-classes")) { - // Try setting up required client classes. - ConstElementPtr class_list = params->get("require-client-classes"); - if (class_list) { - const std::vector<data::ElementPtr>& classes = class_list->listValue(); - for (auto const& cclass : classes) { - if ((cclass->getType() != Element::string) || - cclass->stringValue().empty()) { - isc_throw(DhcpConfigError, "invalid class name (" - << cclass->getPosition() << ")"); - } - subnet6->requireClientClass(cclass->stringValue()); - } - } - } + // Setup additional class list. + getAdditionalClassesElem(params, std::bind(&Network::addAdditionalClass, + subnet6, ph::_1)); /// client-class processing is now generic and handled in the common /// code (see isc::data::SubnetConfigParser::createSubnet) diff --git a/src/lib/dhcpsrv/parsers/shared_network_parser.cc b/src/lib/dhcpsrv/parsers/shared_network_parser.cc index 3a6915f60d..327e016c2c 100644 --- a/src/lib/dhcpsrv/parsers/shared_network_parser.cc +++ b/src/lib/dhcpsrv/parsers/shared_network_parser.cc @@ -22,6 +22,7 @@ using namespace isc::asiolink; using namespace isc::data; using namespace isc::util; +namespace ph = std::placeholders; namespace isc { namespace dhcp { @@ -164,18 +165,10 @@ SharedNetwork4Parser::parse(const data::ConstElementPtr& shared_network_data, shared_network->setContext(user_context); } - if (shared_network_data->contains("require-client-classes")) { - const std::vector<data::ElementPtr>& class_list = - shared_network_data->get("require-client-classes")->listValue(); - for (auto const& cclass : class_list) { - if ((cclass->getType() != Element::string) || - cclass->stringValue().empty()) { - isc_throw(DhcpConfigError, "invalid class name (" - << cclass->getPosition() << ")"); - } - shared_network->requireClientClass(cclass->stringValue()); - } - } + // Setup additional class list. + getAdditionalClassesElem(shared_network_data, + std::bind(&Network::addAdditionalClass, + shared_network, ph::_1)); if (shared_network_data->contains("relay")) { auto relay_parms = shared_network_data->get("relay"); @@ -335,18 +328,10 @@ SharedNetwork6Parser::parse(const data::ConstElementPtr& shared_network_data, shared_network->setContext(user_context); } - if (shared_network_data->contains("require-client-classes")) { - const std::vector<data::ElementPtr>& class_list = - shared_network_data->get("require-client-classes")->listValue(); - for (auto const& cclass : class_list) { - if ((cclass->getType() != Element::string) || - cclass->stringValue().empty()) { - isc_throw(DhcpConfigError, "invalid class name (" - << cclass->getPosition() << ")"); - } - shared_network->requireClientClass(cclass->stringValue()); - } - } + // Setup additional class list. + getAdditionalClassesElem(shared_network_data, + std::bind(&Network::addAdditionalClass, + shared_network, ph::_1)); if (shared_network_data->contains("subnet6")) { auto json = shared_network_data->get("subnet6"); diff --git a/src/lib/dhcpsrv/parsers/simple_parser4.cc b/src/lib/dhcpsrv/parsers/simple_parser4.cc index ac47dcb0b0..0319814249 100644 --- a/src/lib/dhcpsrv/parsers/simple_parser4.cc +++ b/src/lib/dhcpsrv/parsers/simple_parser4.cc @@ -224,6 +224,7 @@ const SimpleKeywords SimpleParser4::SUBNET4_PARAMETERS = { { "id", Element::integer }, { "client-class", Element::string }, { "require-client-classes", Element::list }, + { "evaluate-additional-classes", Element::list }, { "reservations", Element::list }, { "reservations-global", Element::boolean }, { "reservations-in-subnet", Element::boolean }, @@ -326,14 +327,15 @@ const ParamsList SimpleParser4::INHERIT_TO_SUBNET4 = { /// list and map types for entries. /// Order follows pool_param rules in bison grammar. const SimpleKeywords SimpleParser4::POOL4_PARAMETERS = { - { "pool", Element::string }, - { "pool-id", Element::integer }, - { "option-data", Element::list }, - { "client-class", Element::string }, - { "require-client-classes", Element::list }, - { "user-context", Element::map }, - { "comment", Element::string }, - { "metadata", Element::map } + { "pool", Element::string }, + { "pool-id", Element::integer }, + { "option-data", Element::list }, + { "client-class", Element::string }, + { "require-client-classes", Element::list }, + { "evaluate-additional-classes", Element::list }, + { "user-context", Element::map }, + { "comment", Element::string }, + { "metadata", Element::map } }; /// @brief This table defines all shared network parameters for DHCPv4. @@ -359,6 +361,7 @@ const SimpleKeywords SimpleParser4::SHARED_NETWORK4_PARAMETERS = { { "reservations-out-of-pool", Element::boolean }, { "client-class", Element::string }, { "require-client-classes", Element::list }, + { "evaluate-additional-classes", Element::list }, { "valid-lifetime", Element::integer }, { "min-valid-lifetime", Element::integer }, { "max-valid-lifetime", Element::integer }, diff --git a/src/lib/dhcpsrv/parsers/simple_parser6.cc b/src/lib/dhcpsrv/parsers/simple_parser6.cc index 6359a1e960..89fedf0a81 100644 --- a/src/lib/dhcpsrv/parsers/simple_parser6.cc +++ b/src/lib/dhcpsrv/parsers/simple_parser6.cc @@ -224,6 +224,7 @@ const SimpleKeywords SimpleParser6::SUBNET6_PARAMETERS = { { "rapid-commit", Element::boolean }, { "client-class", Element::string }, { "require-client-classes", Element::list }, + { "evaluate-additional-classes", Element::list }, { "reservations", Element::list }, { "reservations-global", Element::boolean }, { "reservations-in-subnet", Element::boolean }, @@ -317,14 +318,15 @@ const ParamsList SimpleParser6::INHERIT_TO_SUBNET6 = { /// list and map types for entries. /// Order follows pool_param rules in bison grammar. const SimpleKeywords SimpleParser6::POOL6_PARAMETERS = { - { "pool", Element::string }, - { "pool-id", Element::integer }, - { "option-data", Element::list }, - { "client-class", Element::string }, - { "require-client-classes", Element::list }, - { "user-context", Element::map }, - { "comment", Element::string }, - { "metadata", Element::map } + { "pool", Element::string }, + { "pool-id", Element::integer }, + { "option-data", Element::list }, + { "client-class", Element::string }, + { "require-client-classes", Element::list }, + { "evaluate-additional-classes", Element::list }, + { "user-context", Element::map }, + { "comment", Element::string }, + { "metadata", Element::map } }; /// @brief This table defines all prefix delegation pool parameters. @@ -333,18 +335,19 @@ const SimpleKeywords SimpleParser6::POOL6_PARAMETERS = { /// list and map types for entries. /// Order follows pd_pool_param rules in bison grammar. const SimpleKeywords SimpleParser6::PD_POOL6_PARAMETERS = { - { "prefix", Element::string }, - { "prefix-len", Element::integer }, - { "delegated-len", Element::integer }, - { "pool-id", Element::integer }, - { "option-data", Element::list }, - { "client-class", Element::string }, - { "require-client-classes", Element::list }, - { "excluded-prefix", Element::string }, - { "excluded-prefix-len", Element::integer }, - { "user-context", Element::map }, - { "comment", Element::string }, - { "metadata", Element::map } + { "prefix", Element::string }, + { "prefix-len", Element::integer }, + { "delegated-len", Element::integer }, + { "pool-id", Element::integer }, + { "option-data", Element::list }, + { "client-class", Element::string }, + { "require-client-classes", Element::list }, + { "evaluate-additional-classes", Element::list }, + { "excluded-prefix", Element::string }, + { "excluded-prefix-len", Element::integer }, + { "user-context", Element::map }, + { "comment", Element::string }, + { "metadata", Element::map } }; /// @brief This table defines all shared network parameters for DHCPv6. @@ -366,6 +369,7 @@ const SimpleKeywords SimpleParser6::SHARED_NETWORK6_PARAMETERS = { { "reservations-out-of-pool", Element::boolean }, { "client-class", Element::string }, { "require-client-classes", Element::list }, + { "evaluate-additional-classes", Element::list }, { "preferred-lifetime", Element::integer }, { "min-preferred-lifetime", Element::integer }, { "max-preferred-lifetime", Element::integer }, diff --git a/src/lib/dhcpsrv/pool.cc b/src/lib/dhcpsrv/pool.cc index f7a53f6d8d..65a71279cc 100644 --- a/src/lib/dhcpsrv/pool.cc +++ b/src/lib/dhcpsrv/pool.cc @@ -122,13 +122,13 @@ Pool::toElement() const { } // Set require-client-classes - const ClientClasses& classes = getRequiredClasses(); + const ClientClasses& classes = getAdditionalClasses(); if (!classes.empty()) { ElementPtr class_list = Element::createList(); for (auto const& it : classes) { class_list->add(Element::create(it)); } - map->set("require-client-classes", class_list); + map->set("evaluate-additional-classes", class_list); } if (id_) { diff --git a/src/lib/dhcpsrv/pool.h b/src/lib/dhcpsrv/pool.h index 0015bb1e82..e85c32c9fd 100644 --- a/src/lib/dhcpsrv/pool.h +++ b/src/lib/dhcpsrv/pool.h @@ -135,18 +135,23 @@ public: return (client_class_); } - /// @brief Adds class class_name to classes required to be evaluated + /// @brief Adds class class_name to the additional classes list. /// - /// @param class_name client class required to be evaluated - void requireClientClass(const ClientClass& class_name) { - if (!required_classes_.contains(class_name)) { - required_classes_.insert(class_name); + /// @param class_name client class to add + void addAdditionalClass(const ClientClass& class_name) { + if (!additional_classes_.contains(class_name)) { + additional_classes_.insert(class_name); } } - /// @brief Returns classes which are required to be evaluated - const ClientClasses& getRequiredClasses() const { - return (required_classes_); + /// @brief Returns the additional classes list. + const ClientClasses& getAdditionalClasses() const { + return (additional_classes_); + } + + /// @brief Returns the mutable additional classes list. + ClientClasses& getMutableAdditionalClasses() { + return (additional_classes_); } /// @brief Returns pool-specific allocation state. @@ -216,10 +221,10 @@ protected: /// @ref Network::client_class_ ClientClass client_class_; - /// @brief Required classes + /// @brief Additional classes /// - /// @ref isc::dhcp::Network::required_classes_ - ClientClasses required_classes_; + /// @ref isc::dhcp::Network::additional_classes_ + ClientClasses additional_classes_; /// @brief Pointer to the user context (may be NULL) data::ConstElementPtr user_context_; diff --git a/src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc b/src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc index cb8840a33d..42c1546b7f 100644 --- a/src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc +++ b/src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc @@ -1095,8 +1095,8 @@ TEST(CfgSubnets4Test, unparseSubnet) { subnet2->setOfferLft(99); subnet3->setIface("eth1"); - subnet3->requireClientClass("foo"); - subnet3->requireClientClass("bar"); + subnet3->addAdditionalClass("foo"); + subnet3->addAdditionalClass("bar"); subnet3->setCalculateTeeTimes(true); subnet3->setT1Percent(0.50); subnet3->setT2Percent(0.65); @@ -1190,7 +1190,7 @@ TEST(CfgSubnets4Test, unparseSubnet) { " \"reservations-out-of-pool\": false,\n" " \"option-data\": [ ],\n" " \"pools\": [ ]\n," - " \"require-client-classes\": [ \"foo\", \"bar\" ],\n" + " \"evaluate-additional-classes\": [ \"foo\", \"bar\" ],\n" " \"calculate-tee-times\": true,\n" " \"t1-percent\": 0.50,\n" " \"t2-percent\": 0.65,\n" @@ -1222,7 +1222,7 @@ TEST(CfgSubnets4Test, unparsePool) { pool1->setContext(ctx1); data::ElementPtr ctx2 = data::Element::fromJSON("{ \"foo\": \"bar\" }"); pool2->setContext(ctx2); - pool2->requireClientClass("foo"); + pool2->addAdditionalClass("foo"); subnet->addPool(pool1); subnet->addPool(pool2); @@ -1254,7 +1254,7 @@ TEST(CfgSubnets4Test, unparsePool) { " \"pool\": \"192.0.2.64/26\",\n" " \"user-context\": { \"foo\": \"bar\" },\n" " \"client-class\": \"bar\",\n" - " \"require-client-classes\": [ \"foo\" ]\n" + " \"evaluate-additional-classes\": [ \"foo\" ]\n" " }\n" " ]\n" "} ]\n"; @@ -1427,7 +1427,7 @@ TEST(CfgSubnets4Test, teeTimePercentValidation) { " \"server-hostname\": \"\", \n" " \"boot-file-name\": \"\", \n" " \"client-class\": \"\", \n" - " \"require-client-classes\": [] \n," + " \"evaluate-additional-classes\": [] \n," " \"reservations-global\": false, \n" " \"reservations-in-subnet\": true, \n" " \"reservations-out-of-pool\": false, \n" @@ -1496,7 +1496,7 @@ TEST(CfgSubnets4Test, validLifetimeValidation) { " \"server-hostname\": \"\", \n" " \"boot-file-name\": \"\", \n" " \"client-class\": \"\", \n" - " \"require-client-classes\": [] \n," + " \"evaluate-additional-classes\": [] \n," " \"reservations-global\": false, \n" " \"reservations-in-subnet\": true, \n" " \"reservations-out-of-pool\": false, \n" @@ -1758,7 +1758,7 @@ TEST(CfgSubnets4Test, hostnameSanitizierValidation) { " \"server-hostname\": \"\", \n" " \"boot-file-name\": \"\", \n" " \"client-class\": \"\", \n" - " \"require-client-classes\": [] \n," + " \"evaluate-additional-classes\": [] \n," " \"reservations-global\": false, \n" " \"reservations-in-subnet\": true, \n" " \"reservations-out-of-pool\": false, \n" @@ -1838,7 +1838,7 @@ TEST(CfgSubnets4Test, cacheParamValidation) { " \"server-hostname\": \"\", \n" " \"boot-file-name\": \"\", \n" " \"client-class\": \"\", \n" - " \"require-client-classes\": [] \n," + " \"evaluate-additional-classes\": [] \n," " \"reservations-global\": false, \n" " \"reservations-in-subnet\": true, \n" " \"reservations-out-of-pool\": false, \n" diff --git a/src/lib/dhcpsrv/tests/cfg_subnets6_unittest.cc b/src/lib/dhcpsrv/tests/cfg_subnets6_unittest.cc index fdbfa124ce..4cc07fa0ab 100644 --- a/src/lib/dhcpsrv/tests/cfg_subnets6_unittest.cc +++ b/src/lib/dhcpsrv/tests/cfg_subnets6_unittest.cc @@ -690,8 +690,8 @@ TEST(CfgSubnets6Test, unparseSubnet) { subnet2->setCacheMaxAge(80); subnet3->setIface("eth1"); - subnet3->requireClientClass("foo"); - subnet3->requireClientClass("bar"); + subnet3->addAdditionalClass("foo"); + subnet3->addAdditionalClass("bar"); subnet3->setReservationsGlobal(false); subnet3->setReservationsInSubnet(true); subnet3->setReservationsOutOfPool(false); @@ -781,7 +781,7 @@ TEST(CfgSubnets6Test, unparseSubnet) { " \"pools\": [ ],\n" " \"pd-pools\": [ ],\n" " \"option-data\": [ ],\n" - " \"require-client-classes\": [ \"foo\", \"bar\" ],\n" + " \"evaluate-additional-classes\": [ \"foo\", \"bar\" ],\n" " \"calculate-tee-times\": true,\n" " \"t1-percent\": 0.50,\n" " \"t2-percent\": 0.65,\n" @@ -816,7 +816,7 @@ TEST(CfgSubnets6Test, unparsePool) { pool1->setContext(ctx1); data::ElementPtr ctx2 = data::Element::fromJSON("{ \"foo\": \"bar\" }"); pool2->setContext(ctx2); - pool2->requireClientClass("foo"); + pool2->addAdditionalClass("foo"); subnet->addPool(pool1); subnet->addPool(pool2); @@ -847,7 +847,7 @@ TEST(CfgSubnets6Test, unparsePool) { " \"user-context\": { \"foo\": \"bar\" },\n" " \"option-data\": [ ],\n" " \"client-class\": \"bar\",\n" - " \"require-client-classes\": [ \"foo\" ]\n" + " \"evaluate-additional-classes\": [ \"foo\" ]\n" " }\n" " ],\n" " \"pd-pools\": [ ],\n" @@ -872,7 +872,7 @@ TEST(CfgSubnets6Test, unparsePdPool) { data::ElementPtr ctx1 = data::Element::fromJSON("{ \"foo\": [ \"bar\" ] }"); pdpool1->setContext(ctx1); - pdpool1->requireClientClass("bar"); + pdpool1->addAdditionalClass("bar"); pdpool2->allowClientClass("bar"); subnet->addPool(pdpool1); @@ -901,7 +901,7 @@ TEST(CfgSubnets6Test, unparsePdPool) { " \"delegated-len\": 64,\n" " \"user-context\": { \"foo\": [ \"bar\" ] },\n" " \"option-data\": [ ],\n" - " \"require-client-classes\": [ \"bar\" ]\n" + " \"evaluate-additional-classes\": [ \"bar\" ]\n" " },{\n" " \"prefix\": \"2001:db8:3::\",\n" " \"prefix-len\": 48,\n" @@ -1228,7 +1228,7 @@ TEST(CfgSubnets6Test, teeTimePercentValidation) { " \"rebind-timer\": 200, \n" " \"valid-lifetime\": 300, \n" " \"client-class\": \"\", \n" - " \"require-client-classes\": [] \n," + " \"evaluate-additional-classes\": [] \n," " \"reservations-global\": false, \n" " \"reservations-in-subnet\": true, \n" " \"reservations-out-of-pool\": false \n" @@ -1293,7 +1293,7 @@ TEST(CfgSubnets6Test, preferredLifetimeValidation) { " \"rebind-timer\": 200, \n" " \"valid-lifetime\": 300, \n" " \"client-class\": \"\", \n" - " \"require-client-classes\": [] \n," + " \"evaluate-additional-classes\": [] \n," " \"reservations-global\": false, \n" " \"reservations-in-subnet\": true, \n" " \"reservations-out-of-pool\": false \n" @@ -1548,7 +1548,7 @@ TEST(CfgSubnets6Test, hostnameSanitizierValidation) { " \"rebind-timer\": 200, \n" " \"valid-lifetime\": 300, \n" " \"client-class\": \"\", \n" - " \"require-client-classes\": [] \n," + " \"evaluate-additional-classes\": [] \n," " \"reservations-global\": false, \n" " \"reservations-in-subnet\": true, \n" " \"reservations-out-of-pool\": false \n" @@ -1620,7 +1620,7 @@ TEST(CfgSubnets6Test, cacheParamValidation) { " \"rebind-timer\": 200, \n" " \"valid-lifetime\": 300, \n" " \"client-class\": \"\", \n" - " \"require-client-classes\": [] \n," + " \"evaluate-additional-classes\": [] \n," " \"reservations-global\": false, \n" " \"reservations-in-subnet\": true, \n" " \"reservations-out-of-pool\": false \n" diff --git a/src/lib/dhcpsrv/tests/client_class_def_parser_unittest.cc b/src/lib/dhcpsrv/tests/client_class_def_parser_unittest.cc index 8795ef385a..80da5f3b3b 100644 --- a/src/lib/dhcpsrv/tests/client_class_def_parser_unittest.cc +++ b/src/lib/dhcpsrv/tests/client_class_def_parser_unittest.cc @@ -373,7 +373,7 @@ TEST_F(ClientClassDefParserTest, checkAllSupported4) { " \"option-def\": [ ],\n" " \"option-data\": [ ],\n" " \"user-context\": { },\n" - " \"only-if-required\": false,\n" + " \"only-in-additional-list\": false,\n" " \"valid-lifetime\": 1000,\n" " \"min-valid-lifetime\": 1000,\n" " \"max-valid-lifetime\": 1000,\n" @@ -399,7 +399,7 @@ TEST_F(ClientClassDefParserTest, checkAllSupported6) { " \"test\": \"member('ALL')\"," " \"option-data\": [ ],\n" " \"user-context\": { },\n" - " \"only-if-required\": false,\n" + " \"only-in-additional-list\": false,\n" " \"template-test\": \"\",\n" " \"preferred-lifetime\": 800,\n" " \"min-preferred-lifetime\": 800,\n" @@ -427,7 +427,7 @@ TEST_F(ClientClassDefParserTest, checkParams4Unsupported6) { " \"option-def\": [ ],\n" " \"option-data\": [ ],\n" " \"user-context\": { },\n" - " \"only-if-required\": false\n" + " \"only-in-additional-list\": false\n" "}\n"; testClassParamsUnsupported(cfg_text, AF_INET6); @@ -441,7 +441,7 @@ TEST_F(ClientClassDefParserTest, checkParams4Unsupported6) { " \"test\": \"member('ALL')\"," " \"option-data\": [ ],\n" " \"user-context\": { },\n" - " \"only-if-required\": false,\n" + " \"only-in-additional-list\": false,\n" " \"next-server\": \"192.0.2.3\"\n" "}\n"; @@ -456,7 +456,7 @@ TEST_F(ClientClassDefParserTest, checkParams4Unsupported6) { " \"test\": \"member('ALL')\"," " \"option-data\": [ ],\n" " \"user-context\": { },\n" - " \"only-if-required\": false,\n" + " \"only-in-additional-list\": false,\n" " \"server-hostname\": \"myhost\"\n" "}\n"; @@ -471,7 +471,7 @@ TEST_F(ClientClassDefParserTest, checkParams4Unsupported6) { " \"test\": \"member('ALL')\"," " \"option-data\": [ ],\n" " \"user-context\": { },\n" - " \"only-if-required\": false,\n" + " \"only-in-additional-list\": false,\n" " \"boot-file-name\": \"efi\"" "}\n"; @@ -494,7 +494,7 @@ TEST_F(ClientClassDefParserTest, checkParams6Unsupported4) { " \"preferred-lifetime\": 800,\n" " \"option-data\": [ ],\n" " \"user-context\": { },\n" - " \"only-if-required\": false\n" + " \"only-in-additional-list\": false\n" "}\n"; testClassParamsUnsupported(cfg_text, AF_INET); @@ -509,7 +509,7 @@ TEST_F(ClientClassDefParserTest, checkParams6Unsupported4) { " \"min-preferred-lifetime\": 800,\n" " \"option-data\": [ ],\n" " \"user-context\": { },\n" - " \"only-if-required\": false\n" + " \"only-in-additional-list\": false\n" "}\n"; testClassParamsUnsupported(cfg_text, AF_INET); @@ -524,7 +524,7 @@ TEST_F(ClientClassDefParserTest, checkParams6Unsupported4) { " \"max-preferred-lifetime\": 800,\n" " \"option-data\": [ ],\n" " \"user-context\": { },\n" - " \"only-if-required\": false\n" + " \"only-in-additional-list\": false\n" "}\n"; testClassParamsUnsupported(cfg_text, AF_INET); @@ -1887,7 +1887,7 @@ TEST_F(ClientClassDefListParserTest, builtinCheckError) { "[ \n" " { \n" " \"name\": \"ALL\", \n" - " \"only-if-required\": true \n" + " \"only-in-additional-list\": true \n" " } \n" "] \n"; @@ -1907,7 +1907,7 @@ TEST_F(ClientClassDefListParserTest, builtinCheckError) { "[ \n" " { \n" " \"name\": \"KNOWN\", \n" - " \"only-if-required\": true \n" + " \"only-in-additional-list\": true \n" " } \n" "] \n"; @@ -1927,7 +1927,7 @@ TEST_F(ClientClassDefListParserTest, builtinCheckError) { "[ \n" " { \n" " \"name\": \"UNKNOWN\", \n" - " \"only-if-required\": true \n" + " \"only-in-additional-list\": true \n" " } \n" "] \n"; @@ -1960,7 +1960,7 @@ TEST_F(ClientClassDefListParserTest, dropCheckError) { "[ \n" " { \n" " \"name\": \"DROP\", \n" - " \"only-if-required\": true \n" + " \"only-in-additional-list\": true \n" " } \n" "] \n"; diff --git a/src/lib/dhcpsrv/tests/client_class_def_unittest.cc b/src/lib/dhcpsrv/tests/client_class_def_unittest.cc index f67ce20cb5..db9c155b89 100644 --- a/src/lib/dhcpsrv/tests/client_class_def_unittest.cc +++ b/src/lib/dhcpsrv/tests/client_class_def_unittest.cc @@ -77,7 +77,7 @@ TEST(ClientClassDef, copyConstruction) { cclass->setContext(data::Element::create("my-context")); cclass->setCfgOptionDef(cfg_option_def); cclass->setTest("member('KNOWN')"); - cclass->setRequired(true); + cclass->setAdditional(true); cclass->setDependOnKnown(true); cclass->setNextServer(IOAddress("1.2.3.4")); cclass->setSname("ufo"); @@ -98,7 +98,7 @@ TEST(ClientClassDef, copyConstruction) { ASSERT_TRUE(cclass->getMatchExpr()); EXPECT_NE(cclass_copy->getMatchExpr(), cclass->getMatchExpr()); EXPECT_EQ(cclass->getTest(), cclass_copy->getTest()); - EXPECT_EQ(cclass->getRequired(), cclass_copy->getRequired()); + EXPECT_EQ(cclass->getAdditional(), cclass_copy->getAdditional()); EXPECT_EQ(cclass->getDependOnKnown(), cclass_copy->getDependOnKnown()); EXPECT_EQ(cclass->getNextServer().toText(), cclass_copy->getNextServer().toText()); EXPECT_EQ(cclass->getSname(), cclass_copy->getSname()); @@ -213,13 +213,13 @@ TEST(ClientClassDef, copyAndEquality) { EXPECT_TRUE(*cclass == *cclass2); EXPECT_FALSE(*cclass != *cclass2); - // Verify the required flag is enough to make classes not equal. - EXPECT_FALSE(cclass->getRequired()); - cclass2->setRequired(true); - EXPECT_TRUE(cclass2->getRequired()); + // Verify the additional flag is enough to make classes not equal. + EXPECT_FALSE(cclass->getAdditional()); + cclass2->setAdditional(true); + EXPECT_TRUE(cclass2->getAdditional()); EXPECT_FALSE(*cclass == *cclass2); EXPECT_TRUE(*cclass != *cclass2); - cclass2->setRequired(false); + cclass2->setAdditional(false); EXPECT_TRUE(*cclass == *cclass2); // Verify the depend on known flag is enough to make classes not equal. @@ -623,7 +623,7 @@ TEST(ClientClassDef, fixedFieldsDefaults) { ASSERT_NO_THROW(cclass.reset(new ClientClassDef(name, expr))); // Let's checks that it doesn't return any nonsense - EXPECT_FALSE(cclass->getRequired()); + EXPECT_FALSE(cclass->getAdditional()); EXPECT_FALSE(cclass->getDependOnKnown()); EXPECT_FALSE(cclass->getCfgOptionDef()); string empty; @@ -648,7 +648,7 @@ TEST(ClientClassDef, fixedFieldsBasics) { // Verify we can create a class with a name, expression, and no cfg_option ASSERT_NO_THROW(cclass.reset(new ClientClassDef(name, expr))); - cclass->setRequired(true); + cclass->setAdditional(true); cclass->setDependOnKnown(true); string sname = "This is a very long string that can be a server name"; @@ -659,7 +659,7 @@ TEST(ClientClassDef, fixedFieldsBasics) { cclass->setFilename(filename); // Let's checks that it doesn't return any nonsense - EXPECT_TRUE(cclass->getRequired()); + EXPECT_TRUE(cclass->getAdditional()); EXPECT_TRUE(cclass->getDependOnKnown()); EXPECT_EQ(IOAddress("1.2.3.4"), cclass->getNextServer()); EXPECT_EQ(sname, cclass->getSname()); @@ -681,7 +681,7 @@ TEST(ClientClassDef, unparseDef) { std::string user_context = "{ \"comment\": \"" + comment + "\", "; user_context += "\"bar\": 1 }"; cclass->setContext(isc::data::Element::fromJSON(user_context)); - cclass->setRequired(true); + cclass->setAdditional(true); // The depend on known flag in not visible cclass->setDependOnKnown(true); std::string next_server = "1.2.3.4"; @@ -695,7 +695,7 @@ TEST(ClientClassDef, unparseDef) { std::string expected = "{\n" "\"name\": \"" + name + "\",\n" "\"test\": \"" + test + "\",\n" - "\"only-if-required\": true,\n" + "\"only-in-additional-list\": true,\n" "\"next-server\": \"" + next_server + "\",\n" "\"server-hostname\": \"" + sname + "\",\n" "\"boot-file-name\": \"" + filename + "\",\n" @@ -860,7 +860,7 @@ TEST(TemplateClientClassDef, copyConstruction) { cclass->setContext(data::Element::create("my-context")); cclass->setCfgOptionDef(cfg_option_def); cclass->setTest("member('KNOWN')"); - cclass->setRequired(true); + cclass->setAdditional(true); cclass->setDependOnKnown(true); cclass->setNextServer(IOAddress("1.2.3.4")); cclass->setSname("ufo"); @@ -881,7 +881,7 @@ TEST(TemplateClientClassDef, copyConstruction) { ASSERT_TRUE(cclass->getMatchExpr()); EXPECT_NE(cclass_copy->getMatchExpr(), cclass->getMatchExpr()); EXPECT_EQ(cclass->getTest(), cclass_copy->getTest()); - EXPECT_EQ(cclass->getRequired(), cclass_copy->getRequired()); + EXPECT_EQ(cclass->getAdditional(), cclass_copy->getAdditional()); EXPECT_EQ(cclass->getDependOnKnown(), cclass_copy->getDependOnKnown()); EXPECT_EQ(cclass->getNextServer().toText(), cclass_copy->getNextServer().toText()); EXPECT_EQ(cclass->getSname(), cclass_copy->getSname()); @@ -996,13 +996,13 @@ TEST(TemplateClientClassDef, copyAndEquality) { EXPECT_TRUE(*cclass == *cclass2); EXPECT_FALSE(*cclass != *cclass2); - // Verify the required flag is enough to make classes not equal. - EXPECT_FALSE(cclass->getRequired()); - cclass2->setRequired(true); - EXPECT_TRUE(cclass2->getRequired()); + // Verify the additional flag is enough to make classes not equal. + EXPECT_FALSE(cclass->getAdditional()); + cclass2->setAdditional(true); + EXPECT_TRUE(cclass2->getAdditional()); EXPECT_FALSE(*cclass == *cclass2); EXPECT_TRUE(*cclass != *cclass2); - cclass2->setRequired(false); + cclass2->setAdditional(false); EXPECT_TRUE(*cclass == *cclass2); // Verify the depend on known flag is enough to make classes not equal. @@ -1469,7 +1469,7 @@ TEST(TemplateClientClassDef, fixedFieldsDefaults) { ASSERT_NO_THROW(cclass.reset(new TemplateClientClassDef(name, expr))); // Let's checks that it doesn't return any nonsense - EXPECT_FALSE(cclass->getRequired()); + EXPECT_FALSE(cclass->getAdditional()); EXPECT_FALSE(cclass->getDependOnKnown()); EXPECT_FALSE(cclass->getCfgOptionDef()); string empty; @@ -1493,7 +1493,7 @@ TEST(TemplateClientClassDef, fixedFieldsBasics) { // Verify we can create a class with a name, expression, and no cfg_option ASSERT_NO_THROW(cclass.reset(new TemplateClientClassDef(name, expr))); - cclass->setRequired(true); + cclass->setAdditional(true); cclass->setDependOnKnown(true); string sname = "This is a very long string that can be a server name"; @@ -1504,7 +1504,7 @@ TEST(TemplateClientClassDef, fixedFieldsBasics) { cclass->setFilename(filename); // Let's checks that it doesn't return any nonsense - EXPECT_TRUE(cclass->getRequired()); + EXPECT_TRUE(cclass->getAdditional()); EXPECT_TRUE(cclass->getDependOnKnown()); EXPECT_EQ(IOAddress("1.2.3.4"), cclass->getNextServer()); EXPECT_EQ(sname, cclass->getSname()); @@ -1526,7 +1526,7 @@ TEST(TemplateClientClassDef, unparseDef) { std::string user_context = "{ \"comment\": \"" + comment + "\", "; user_context += "\"bar\": 1 }"; cclass->setContext(isc::data::Element::fromJSON(user_context)); - cclass->setRequired(true); + cclass->setAdditional(true); // The depend on known flag in not visible cclass->setDependOnKnown(true); std::string next_server = "1.2.3.4"; @@ -1540,7 +1540,7 @@ TEST(TemplateClientClassDef, unparseDef) { std::string expected = "{\n" "\"name\": \"" + name + "\",\n" "\"template-test\": \"" + test + "\",\n" - "\"only-if-required\": true,\n" + "\"only-in-additional-list\": true,\n" "\"next-server\": \"" + next_server + "\",\n" "\"server-hostname\": \"" + sname + "\",\n" "\"boot-file-name\": \"" + filename + "\",\n" diff --git a/src/lib/dhcpsrv/tests/pool_unittest.cc b/src/lib/dhcpsrv/tests/pool_unittest.cc index 7c01098911..548d36bba8 100644 --- a/src/lib/dhcpsrv/tests/pool_unittest.cc +++ b/src/lib/dhcpsrv/tests/pool_unittest.cc @@ -236,33 +236,33 @@ TEST(Pool4Test, clientClass) { EXPECT_TRUE(pool->clientSupported(three_classes)); } -// This test checks that handling for require-client-classes is valid. -TEST(Pool4Test, requiredClasses) { +// This test checks that handling for evaluate-additional-classes is valid. +TEST(Pool4Test, additionalClasses) { // Create a pool. Pool4Ptr pool(new Pool4(IOAddress("192.0.2.0"), IOAddress("192.0.2.255"))); - // This client starts with no required classes. - EXPECT_TRUE(pool->getRequiredClasses().empty()); + // This client starts with no additional classes. + EXPECT_TRUE(pool->getAdditionalClasses().empty()); // Add the first class - pool->requireClientClass("router"); - EXPECT_EQ(1, pool->getRequiredClasses().size()); + pool->addAdditionalClass("router"); + EXPECT_EQ(1, pool->getAdditionalClasses().size()); // Add a second class - pool->requireClientClass("modem"); - EXPECT_EQ(2, pool->getRequiredClasses().size()); - EXPECT_TRUE(pool->getRequiredClasses().contains("router")); - EXPECT_TRUE(pool->getRequiredClasses().contains("modem")); - EXPECT_FALSE(pool->getRequiredClasses().contains("foo")); + pool->addAdditionalClass("modem"); + EXPECT_EQ(2, pool->getAdditionalClasses().size()); + EXPECT_TRUE(pool->getAdditionalClasses().contains("router")); + EXPECT_TRUE(pool->getAdditionalClasses().contains("modem")); + EXPECT_FALSE(pool->getAdditionalClasses().contains("foo")); // Check that it's ok to add the same class repeatedly - EXPECT_NO_THROW(pool->requireClientClass("foo")); - EXPECT_NO_THROW(pool->requireClientClass("foo")); - EXPECT_NO_THROW(pool->requireClientClass("foo")); + EXPECT_NO_THROW(pool->addAdditionalClass("foo")); + EXPECT_NO_THROW(pool->addAdditionalClass("foo")); + EXPECT_NO_THROW(pool->addAdditionalClass("foo")); - // Check that 'foo' is marked for required evaluation - EXPECT_TRUE(pool->getRequiredClasses().contains("foo")); + // Check that 'foo' is marked for additional evaluation + EXPECT_TRUE(pool->getAdditionalClasses().contains("foo")); } TEST(Pool6Test, constructorFirstLast) { @@ -640,33 +640,33 @@ TEST(Pool6Test, clientClass) { EXPECT_TRUE(pool.clientSupported(three_classes)); } -// This test checks that handling for require-client-classes is valid. -TEST(Pool6Test, requiredClasses) { +// This test checks that handling for evaluate-additional-classes is valid. +TEST(Pool6Test, additionalClasses) { // Create a pool. Pool6 pool(Lease::TYPE_NA, IOAddress("2001:db8::1"), IOAddress("2001:db8::2")); - // This client starts with no required classes. - EXPECT_TRUE(pool.getRequiredClasses().empty()); + // This client starts with no additional classes. + EXPECT_TRUE(pool.getAdditionalClasses().empty()); // Add the first class - pool.requireClientClass("router"); - EXPECT_EQ(1, pool.getRequiredClasses().size()); + pool.addAdditionalClass("router"); + EXPECT_EQ(1, pool.getAdditionalClasses().size()); // Add a second class - pool.requireClientClass("modem"); - EXPECT_EQ(2, pool.getRequiredClasses().size()); - EXPECT_TRUE(pool.getRequiredClasses().contains("router")); - EXPECT_TRUE(pool.getRequiredClasses().contains("modem")); - EXPECT_FALSE(pool.getRequiredClasses().contains("foo")); + pool.addAdditionalClass("modem"); + EXPECT_EQ(2, pool.getAdditionalClasses().size()); + EXPECT_TRUE(pool.getAdditionalClasses().contains("router")); + EXPECT_TRUE(pool.getAdditionalClasses().contains("modem")); + EXPECT_FALSE(pool.getAdditionalClasses().contains("foo")); // Check that it's ok to add the same class repeatedly - EXPECT_NO_THROW(pool.requireClientClass("foo")); - EXPECT_NO_THROW(pool.requireClientClass("foo")); - EXPECT_NO_THROW(pool.requireClientClass("foo")); + EXPECT_NO_THROW(pool.addAdditionalClass("foo")); + EXPECT_NO_THROW(pool.addAdditionalClass("foo")); + EXPECT_NO_THROW(pool.addAdditionalClass("foo")); - // Check that 'foo' is marked for required evaluation - EXPECT_TRUE(pool.getRequiredClasses().contains("foo")); + // Check that 'foo' is marked for additional evaluation + EXPECT_TRUE(pool.getAdditionalClasses().contains("foo")); } } // end of anonymous namespace diff --git a/src/lib/dhcpsrv/tests/shared_network_parser_unittest.cc b/src/lib/dhcpsrv/tests/shared_network_parser_unittest.cc index 61616c6db9..a5cfa258eb 100644 --- a/src/lib/dhcpsrv/tests/shared_network_parser_unittest.cc +++ b/src/lib/dhcpsrv/tests/shared_network_parser_unittest.cc @@ -133,7 +133,7 @@ public: " \"reservations-in-subnet\": true," " \"reservations-out-of-pool\": true," " \"server-hostname\": \"example.org\"," - " \"require-client-classes\": [ \"runner\" ]," + " \"evaluate-additional-classes\": [ \"runner\" ]," " \"user-context\": { \"comment\": \"example\" }," " \"valid-lifetime\": 399," " \"min-valid-lifetime\": 299," @@ -176,7 +176,7 @@ public: " \"server-hostname\": \"\"," " \"boot-file-name\": \"\"," " \"client-class\": \"\"," - " \"require-client-classes\": []\n," + " \"evaluate-additional-classes\": []\n," " \"reservations-global\": false," " \"reservations-in-subnet\": true," " \"reservations-out-of-pool\": false," @@ -204,7 +204,7 @@ public: " \"server-hostname\": \"\"," " \"boot-file-name\": \"\"," " \"client-class\": \"\"," - " \"require-client-classes\": []\n," + " \"evaluate-additional-classes\": []\n," " \"reservations-global\": false," " \"reservations-in-subnet\": true," " \"reservations-out-of-pool\": false," @@ -291,10 +291,10 @@ TEST_F(SharedNetwork4ParserTest, parse) { EXPECT_EQ(1, relay_info.getAddresses().size()); EXPECT_TRUE(relay_info.containsAddress(IOAddress("10.1.1.1"))); - // Required client classes. - auto required = network->getRequiredClasses(); - ASSERT_EQ(1, required.size()); - EXPECT_EQ("runner", *required.cbegin()); + // Additional client classes. + auto additional = network->getAdditionalClasses(); + ASSERT_EQ(1, additional.size()); + EXPECT_EQ("runner", *additional.cbegin()); // Check user context. ConstElementPtr context = network->getContext(); @@ -558,7 +558,7 @@ public: " \"rebind-timer\": 199," " \"relay\": { \"ip-addresses\": [ \"2001:db8:1::1\" ] }," " \"renew-timer\": 99," - " \"require-client-classes\": [ \"runner\" ]," + " \"evaluate-additional-classes\": [ \"runner\" ]," " \"reservations-global\": false," " \"reservations-in-subnet\": true," " \"reservations-out-of-pool\": true," @@ -604,7 +604,7 @@ public: " \"min-valid-lifetime\": 300," " \"max-valid-lifetime\": 500," " \"client-class\": \"\"," - " \"require-client-classes\": []\n," + " \"evaluate-additional-classes\": []\n," " \"reservations-global\": false," " \"reservations-in-subnet\": true," " \"reservations-out-of-pool\": false," @@ -623,7 +623,7 @@ public: " \"preferred-lifetime\": 30," " \"valid-lifetime\": 40," " \"client-class\": \"\"," - " \"require-client-classes\": []\n," + " \"evaluate-additional-classes\": []\n," " \"reservations-global\": false," " \"reservations-in-subnet\": true," " \"reservations-out-of-pool\": false," @@ -704,10 +704,10 @@ TEST_F(SharedNetwork6ParserTest, parse) { EXPECT_EQ(1, relay_info.getAddresses().size()); EXPECT_TRUE(relay_info.containsAddress(IOAddress("2001:db8:1::1"))); - // Required client classes. - auto required = network->getRequiredClasses(); - ASSERT_EQ(1, required.size()); - EXPECT_EQ("runner", *required.cbegin()); + // Additional client classes. + auto additional = network->getAdditionalClasses(); + ASSERT_EQ(1, additional.size()); + EXPECT_EQ("runner", *additional.cbegin()); // Check user context. ConstElementPtr context = network->getContext(); @@ -870,7 +870,7 @@ TEST_F(SharedNetwork6ParserTest, clientClass) { EXPECT_EQ("alpha", network->getClientClass().get()); } -// This test verifies that it's possible to specify require-client-classes +// This test verifies that it's possible to specify evaluate-additional-classes // on shared-network level. TEST_F(SharedNetwork6ParserTest, evalClientClasses) { IfaceMgrTestConfig ifmgr(true); @@ -881,7 +881,7 @@ TEST_F(SharedNetwork6ParserTest, evalClientClasses) { ElementPtr class_list = Element::createList(); class_list->add(Element::create("alpha")); class_list->add(Element::create("beta")); - config_element->set("require-client-classes", class_list); + config_element->set("evaluate-additional-classes", class_list); // Parse configuration specified above. SharedNetwork6Parser parser; @@ -889,12 +889,12 @@ TEST_F(SharedNetwork6ParserTest, evalClientClasses) { network = parser.parse(config_element); ASSERT_TRUE(network); - const ClientClasses& classes = network->getRequiredClasses(); + const ClientClasses& classes = network->getAdditionalClasses(); EXPECT_EQ(2, classes.size()); EXPECT_EQ("alpha, beta", classes.toText()); } -// This test verifies that bad require-client-classes configs raise +// This test verifies that bad evaluate-additional-classes configs raise // expected errors. TEST_F(SharedNetwork6ParserTest, badEvalClientClasses) { IfaceMgrTestConfig ifmgr(true); @@ -906,7 +906,7 @@ TEST_F(SharedNetwork6ParserTest, badEvalClientClasses) { ElementPtr class_list = Element::createList(); class_list->add(Element::create("alpha")); class_list->add(Element::create(1234)); - config_element->set("require-client-classes", class_list); + config_element->set("evaluate-additional-classes", class_list); // Parse configuration specified above. SharedNetwork6Parser parser; diff --git a/src/lib/dhcpsrv/tests/shared_network_unittest.cc b/src/lib/dhcpsrv/tests/shared_network_unittest.cc index 7e1fb44764..69f3e6201b 100644 --- a/src/lib/dhcpsrv/tests/shared_network_unittest.cc +++ b/src/lib/dhcpsrv/tests/shared_network_unittest.cc @@ -688,7 +688,7 @@ TEST(SharedNetwork4Test, unparse) { std::string uc = "{ \"comment\": \"bar\", \"foo\": 1}"; data::ElementPtr ctx = data::Element::fromJSON(uc); network->setContext(ctx); - network->requireClientClass("foo"); + network->addAdditionalClass("foo"); network->addRelayAddress(IOAddress("192.168.2.1")); network->setAuthoritative(false); network->setMatchClientId(false); @@ -718,7 +718,7 @@ TEST(SharedNetwork4Test, unparse) { " \"ip-addresses\": [ \"192.168.2.1\" ]\n" " },\n" " \"renew-timer\": 100,\n" - " \"require-client-classes\": [ \"foo\" ],\n" + " \"evaluate-additional-classes\": [ \"foo\" ],\n" " \"reservations-global\": false,\n" " \"reservations-in-subnet\": true,\n" " \"reservations-out-of-pool\": false,\n" @@ -1402,11 +1402,11 @@ TEST(SharedNetwork6Test, unparse) { network->setPreferred(200); network->setValid(300); network->setRapidCommit(true); - network->requireClientClass("foo"); + network->addAdditionalClass("foo"); data::ElementPtr ctx = data::Element::fromJSON("{ \"foo\": \"bar\" }"); network->setContext(ctx); - network->requireClientClass("foo"); + network->addAdditionalClass("foo"); network->addRelayAddress(IOAddress("2001:db8:1::7")); network->addRelayAddress(IOAddress("2001:db8:1::8")); @@ -1457,7 +1457,7 @@ TEST(SharedNetwork6Test, unparse) { " \"ip-addresses\": [ \"2001:db8:1::7\", \"2001:db8:1::8\" ]\n" " },\n" " \"renew-timer\": 100,\n" - " \"require-client-classes\": [ \"foo\" ],\n" + " \"evaluate-additional-classes\": [ \"foo\" ],\n" " \"reservations-global\": false,\n" " \"reservations-in-subnet\": true,\n" " \"reservations-out-of-pool\": false,\n" diff --git a/src/lib/dhcpsrv/testutils/generic_cb_dhcp4_unittest.cc b/src/lib/dhcpsrv/testutils/generic_cb_dhcp4_unittest.cc index c512c9fbd4..c7452c86b3 100644 --- a/src/lib/dhcpsrv/testutils/generic_cb_dhcp4_unittest.cc +++ b/src/lib/dhcpsrv/testutils/generic_cb_dhcp4_unittest.cc @@ -114,8 +114,8 @@ GenericConfigBackendDHCPv4Test::initTestSubnets() { subnet->addRelayAddress(IOAddress("10.2.3.4")); subnet->addRelayAddress(IOAddress("10.5.6.7")); subnet->setT1(1234); - subnet->requireClientClass("required-class1"); - subnet->requireClientClass("required-class2"); + subnet->addAdditionalClass("required-class1"); + subnet->addAdditionalClass("required-class2"); subnet->setReservationsGlobal(false); subnet->setReservationsInSubnet(false); subnet->setSname("server-hostname"); @@ -163,8 +163,8 @@ GenericConfigBackendDHCPv4Test::initTestSubnets() { IOAddress("10.0.0.60"))); pool2->allowClientClass("work"); - pool2->requireClientClass("required-class3"); - pool2->requireClientClass("required-class4"); + pool2->addAdditionalClass("required-class3"); + pool2->addAdditionalClass("required-class4"); user_context = Element::createMap(); user_context->set("bar", Element::create("foo")); pool2->setContext(user_context); @@ -209,8 +209,8 @@ GenericConfigBackendDHCPv4Test::initTestSharedNetworks() { shared_network->addRelayAddress(IOAddress("10.2.3.4")); shared_network->addRelayAddress(IOAddress("10.5.6.7")); shared_network->setT1(1234); - shared_network->requireClientClass("required-class1"); - shared_network->requireClientClass("required-class2"); + shared_network->addAdditionalClass("required-class1"); + shared_network->addAdditionalClass("required-class2"); shared_network->setReservationsGlobal(false); shared_network->setReservationsInSubnet(false); shared_network->setContext(user_context); @@ -369,7 +369,7 @@ GenericConfigBackendDHCPv4Test::initTestClientClasses() { CfgOptionPtr cfg_option = boost::make_shared<CfgOption>(); auto class1 = boost::make_shared<ClientClassDef>("foo", match_expr, cfg_option); class1->setCfgOptionDef(boost::make_shared<CfgOptionDef>()); - class1->setRequired(true); + class1->setAdditional(true); class1->setNextServer(IOAddress("1.2.3.4")); class1->setSname("cool"); class1->setFilename("epc.cfg"); @@ -4191,7 +4191,7 @@ GenericConfigBackendDHCPv4Test::getClientClass4Test() { ASSERT_NO_THROW_LOG(client_class = cbptr_->getClientClass4(ServerSelector::ALL(), class1->getName())); ASSERT_TRUE(client_class); EXPECT_EQ("foo", client_class->getName()); - EXPECT_TRUE(client_class->getRequired()); + EXPECT_TRUE(client_class->getAdditional()); EXPECT_EQ("1.2.3.4", client_class->getNextServer().toText()); EXPECT_EQ("cool", client_class->getSname()); EXPECT_EQ("epc.cfg", client_class->getFilename()); diff --git a/src/lib/dhcpsrv/testutils/generic_cb_dhcp6_unittest.cc b/src/lib/dhcpsrv/testutils/generic_cb_dhcp6_unittest.cc index c2edf63440..5130e923bc 100644 --- a/src/lib/dhcpsrv/testutils/generic_cb_dhcp6_unittest.cc +++ b/src/lib/dhcpsrv/testutils/generic_cb_dhcp6_unittest.cc @@ -112,8 +112,8 @@ GenericConfigBackendDHCPv6Test::initTestSubnets() { subnet->addRelayAddress(IOAddress("2001:db8:1::2")); subnet->addRelayAddress(IOAddress("2001:db8:3::4")); subnet->setT1(1234); - subnet->requireClientClass("required-class1"); - subnet->requireClientClass("required-class2"); + subnet->addAdditionalClass("required-class1"); + subnet->addAdditionalClass("required-class2"); subnet->setReservationsGlobal(false); subnet->setReservationsInSubnet(false); subnet->setContext(user_context); @@ -171,8 +171,8 @@ GenericConfigBackendDHCPv6Test::initTestSubnets() { subnet->addPool(pool2); pool2->allowClientClass("work"); - pool2->requireClientClass("required-class3"); - pool2->requireClientClass("required-class4"); + pool2->addAdditionalClass("required-class3"); + pool2->addAdditionalClass("required-class4"); user_context = Element::createMap(); user_context->set("bar", Element::create("foo")); pool2->setContext(user_context); @@ -190,8 +190,8 @@ GenericConfigBackendDHCPv6Test::initTestSubnets() { subnet->addPool(pdpool2); pdpool2->allowClientClass("work"); - pdpool2->requireClientClass("required-class3"); - pdpool2->requireClientClass("required-class4"); + pdpool2->addAdditionalClass("required-class3"); + pdpool2->addAdditionalClass("required-class4"); user_context = Element::createMap(); user_context->set("bar", Element::create("foo")); pdpool2->setContext(user_context); @@ -241,8 +241,8 @@ GenericConfigBackendDHCPv6Test::initTestSharedNetworks() { shared_network->addRelayAddress(IOAddress("2001:db8:1::2")); shared_network->addRelayAddress(IOAddress("2001:db8:3::4")); shared_network->setT1(1234); - shared_network->requireClientClass("required-class1"); - shared_network->requireClientClass("required-class2"); + shared_network->addAdditionalClass("required-class1"); + shared_network->addAdditionalClass("required-class2"); shared_network->setReservationsGlobal(false); shared_network->setReservationsInSubnet(false); shared_network->setContext(user_context); @@ -398,7 +398,7 @@ GenericConfigBackendDHCPv6Test::initTestClientClasses() { CfgOptionPtr cfg_option = boost::make_shared<CfgOption>(); auto class1 = boost::make_shared<ClientClassDef>("foo", match_expr, cfg_option); class1->setCfgOptionDef(boost::make_shared<CfgOptionDef>()); - class1->setRequired(true); + class1->setAdditional(true); class1->setValid(Triplet<uint32_t>(30, 60, 90)); class1->setPreferred(Triplet<uint32_t>(25, 55, 85)); test_client_classes_.push_back(class1); @@ -4339,7 +4339,7 @@ GenericConfigBackendDHCPv6Test::getClientClass6Test() { ASSERT_NO_THROW_LOG(client_class = cbptr_->getClientClass6(ServerSelector::ALL(), class1->getName())); ASSERT_TRUE(client_class); EXPECT_EQ("foo", client_class->getName()); - EXPECT_TRUE(client_class->getRequired()); + EXPECT_TRUE(client_class->getAdditional()); EXPECT_EQ(30, client_class->getValid().getMin()); EXPECT_EQ(60, client_class->getValid().get()); EXPECT_EQ(90, client_class->getValid().getMax()); |