7#ifndef CLIENT_CLASS_DEF_H
8#define CLIENT_CLASS_DEF_H
21#include <unordered_map>
73 void setName(
const std::string& name);
152 return (!(
equals(other)));
161 return (next_server_);
188 filename_ = filename;
222 preferred_ = preferred;
229 offer_lft_ = offer_lft;
278 bool depend_on_known_;
301 std::string filename_;
395 const std::string& test,
bool additional,
bool depend_on_known,
400 const std::string& sname = std::string(),
401 const std::string& filename = std::string(),
404 bool is_template =
false,
453 bool dependOnClass(
const std::string& name, std::string& dependent_class)
const;
545 bool& depend_on_known,
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
The IOAddress class represents an IP addresses (version agnostic)
This class represents configuration element which is associated with database identifier,...
Embodies a single client class definition.
util::Optional< uint32_t > getOfferLft() const
Returns offer lifetime for the class.
void setAdditional(bool additional)
Sets the only if additional flag.
bool equals(const ClientClassDef &other) const
Compares two ClientClassDef objects for equality.
void setCfgOption(const CfgOptionPtr &cfg_option)
Sets the class's option collection.
void setName(const std::string &name)
Sets the class's name.
bool dependOnClass(const std::string &name) const
Checks direct dependency.
bool getDependOnKnown() const
Fetches the depend on known flag aka use host flag.
void setPreferred(const util::Triplet< uint32_t > &preferred)
Sets new preferred lifetime.
void setFilename(const std::string &filename)
sets the boot-file-name value
virtual void test(PktPtr pkt, const ExpressionPtr &expr_ptr)
Test method which checks if the packet belongs to the class.
void setNextServer(const asiolink::IOAddress &addr)
sets the next-server value
const CfgOptionDefPtr & getCfgOptionDef() const
Fetches the class's option definitions.
ClientClassDef(const std::string &name, const ExpressionPtr &match_expr, const CfgOptionPtr &options=CfgOptionPtr())
Constructor.
const ExpressionPtr & getMatchExpr() const
Fetches the class's match expression.
void setCfgOptionDef(const CfgOptionDefPtr &cfg_option_def)
Sets the class's option definition collection.
virtual ~ClientClassDef()
Destructor.
const std::string & getSname() const
returns server-hostname value
const asiolink::IOAddress & getNextServer() const
returns next-server value
void setSname(const std::string &sname)
sets the server-name value
bool operator==(const ClientClassDef &other) const
Equality operator.
void setOfferLft(const util::Optional< uint32_t > &offer_lft)
Sets offer lifetime for the class.
std::string getName() const
Fetches the class's name.
friend std::ostream & operator<<(std::ostream &os, const ClientClassDef &x)
Provides a convenient text representation of the class.
bool operator!=(const ClientClassDef &other) const
Inequality operator.
const CfgOptionPtr & getCfgOption() const
Fetches the class's option collection.
util::Triplet< uint32_t > getValid() const
Return valid-lifetime value.
void setMatchExpr(const ExpressionPtr &match_expr)
Sets the class's match expression.
void setTest(const std::string &test)
Sets the class's original match expression.
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
std::string getTest() const
Fetches the class's original match expression.
bool getAdditional() const
Fetches the only if additional flag.
void setDependOnKnown(bool depend_on_known)
Sets the depend on known flag aka use host flag.
util::Triplet< uint32_t > getPreferred() const
Return preferred-lifetime value.
const std::string & getFilename() const
returns boot-file-name value
void setValid(const util::Triplet< uint32_t > &valid)
Sets new valid lifetime.
Maintains a list of ClientClassDef's.
void addClass(const std::string &name, const ExpressionPtr &match_expr, const std::string &test, bool additional, bool depend_on_known, const CfgOptionPtr &options, CfgOptionDefPtr defs=CfgOptionDefPtr(), isc::data::ConstElementPtr user_context=isc::data::ConstElementPtr(), asiolink::IOAddress next_server=asiolink::IOAddress("0.0.0.0"), const std::string &sname=std::string(), const std::string &filename=std::string(), const util::Triplet< uint32_t > &valid=util::Triplet< uint32_t >(), const util::Triplet< uint32_t > &preferred=util::Triplet< uint32_t >(), bool is_template=false, const util::Optional< uint32_t > &offer_lft=util::Optional< uint32_t >())
Adds a new class to the list.
ClientClassDefPtr findClass(const std::string &name) const
Fetches the class definition for a given class name.
bool equals(const ClientClassDictionary &other) const
Compares two ClientClassDictionary objects for equality.
void removeClass(const std::string &name)
Removes a given class definition from the dictionary.
bool operator!=(const ClientClassDictionary &other) const
Inequality operator.
bool empty() const
Checks if the class dictionary is empty.
bool dependOnClass(const std::string &name, std::string &dependent_class) const
Checks direct dependency.
ClientClassDictionary()
Constructor.
const ClientClassDefListPtr & getClasses() const
Fetches the dictionary's list of classes.
ClientClassDictionary & operator=(const ClientClassDictionary &rhs)
Copy assignment operator.
~ClientClassDictionary()
Destructor.
void encapsulateOptions() const
Iterates over the classes in the dictionary and encapsulates suboptions.
void createOptions(const CfgOptionDefPtr &cfg_option_def)
Iterates over the classes in the dictionary and recreates the options.
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
bool operator==(const ClientClassDictionary &other) const
Equality operator.
void initMatchExpr(uint16_t family)
Iterates over the classes in the dictionary and ensures that that match expressions are initialized.
Error that occurs when an attempt is made to add a duplicate class to a class dictionary.
DuplicateClientClassDef(const char *file, size_t line, const char *what)
static const std::string SPAWN_CLASS_PREFIX
This is a prefix added to the spawned class name.
TemplateClientClassDef(const std::string &name, const ExpressionPtr &match_expr, const CfgOptionPtr &options=CfgOptionPtr())
Constructor.
virtual void test(PktPtr pkt, const ExpressionPtr &expr_ptr) override
Test method which checks if the packet belongs to the class.
virtual isc::data::ElementPtr toElement() const override
Unparse a configuration object.
A template representing an optional value.
This template specifies a parameter value.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
boost::shared_ptr< isc::dhcp::Pkt > PktPtr
A pointer to either Pkt4 or Pkt6 packet.
std::string ClientClass
Defines a single class name.
std::vector< ClientClassDefPtr > ClientClassDefList
Defines a list of ClientClassDefPtr's, using insert order.
boost::shared_ptr< CfgOption > CfgOptionPtr
Non-const pointer.
boost::shared_ptr< CfgOptionDef > CfgOptionDefPtr
Non-const pointer.
boost::shared_ptr< ClientClassDef > ClientClassDefPtr
a pointer to an ClientClassDef
std::list< std::string > builtinPrefixes
The prefixes used to check if a class is BuiltIn class.
boost::shared_ptr< ClientClassDefMap > ClientClassDefMapPtr
Defines a pointer to a ClientClassDefMap.
boost::shared_ptr< Expression > ExpressionPtr
boost::shared_ptr< ClientClassDictionary > ClientClassDictionaryPtr
Defines a pointer to a ClientClassDictionary.
boost::shared_ptr< ClientClassDefList > ClientClassDefListPtr
Defines a pointer to a ClientClassDefList.
bool isClientClassDefined(ClientClassDictionaryPtr &class_dictionary, bool &depend_on_known, const ClientClass &client_class)
Check if a client class name is already defined, i.e.
bool isClientClassBuiltIn(const ClientClass &client_class)
Check if a client class name is builtin.
std::list< std::string > builtinNames
List of classes for which test expressions cannot be defined.
std::unordered_map< std::string, ClientClassDefPtr > ClientClassDefMap
Defines a map of ClientClassDef's, keyed by the class name.
Defines the logger used by the top-level component of kea-lfc.
Abstract class for configuration Cfg_* classes.
Base class for user context.