20#include <boost/make_shared.hpp> 
   37std::pair<OptionDescriptor, std::string>
 
   48    std::pair<OptionDescriptor, std::string> opt = 
createOption(single_option);
 
   50    if (!opt.first.option_) {
 
   53            "parser logic error: no option has been configured and" 
   54            " thus there is nothing to commit. Has build() been called?");
 
 
   66    } 
catch (
const std::exception&) {
 
   73        code > std::numeric_limits<uint8_t>::max()) {
 
   75                  << 
"', it must not be greater than '" 
   76                  << 
static_cast<int>(std::numeric_limits<uint8_t>::max())
 
   81               code > std::numeric_limits<uint16_t>::max()) {
 
   83                  << 
"', it must not exceed '" 
   84                  << std::numeric_limits<uint16_t>::max()
 
 
  103    if (name.find(
" ") != std::string::npos) {
 
  105                  << 
"', space character is not allowed (" 
 
  128    bool csv_format = 
true;
 
  130        csv_format = 
getBoolean(parent, 
"csv-format");
 
 
  158                      << 
"' option space name is reserved for DHCPv4 server");
 
  163                      << 
"' option space name is reserved for DHCPv6 server");
 
  166    } 
catch (
const std::exception& ex) {
 
 
  177    bool persist = 
false;
 
 
  268std::pair<OptionDescriptor, std::string>
 
  286                  " 'code' or 'name' parameters to be specified" 
  287                  << 
" (" << option_data->getPosition() << 
")");
 
  299        if (!csv_format_param.
unspecified() && csv_format_param) {
 
  301                      << space_param << 
"." << name_param
 
  302                      << 
"' having code '" << code_param
 
  303                      << 
"' does not exist (" 
  311                      << space_param << 
"." << name_param
 
  312                      << 
"' does not exist (" 
  318        if (!name_param.
unspecified() && (def->getName() != name_param.
get())) {
 
  320                      << name_param << 
"' does not match the " 
  321                      << 
"option definition: '" << space_param
 
  322                      << 
"." << def->getName() << 
"' (" 
  333            code = def->getCode();
 
  335            code = 
static_cast<uint16_t
>(code_param);
 
  338        bool persistent = !persist_param.
unspecified() && persist_param;
 
  340        return (make_pair(desc, space_param));
 
  344    std::vector<uint8_t> binary;
 
  345    std::vector<std::string> data_tokens;
 
  349    if (def && (csv_format_param.
unspecified() || csv_format_param)) {
 
  366            if (binary.empty()) {
 
  371                      << 
" string of hexadecimal digits: " << data_param
 
  386        OptionPtr option(
new Option(universe, 
static_cast<uint16_t
>(code_param),
 
  396            bool use_csv = csv_format_param.
unspecified() || csv_format_param;
 
  398                def->optionFactory(universe, def->getCode(), data_tokens) :
 
  399                def->optionFactory(universe, def->getCode(), binary);
 
  408                      << 
" option definition (space: " << space_param
 
  409                      << 
", code: " << def->getCode() << 
"): " 
  420                      << 
"reserved for PAD (" 
  421                      << option_data->getPosition() << 
")");
 
  424                      << 
"reserved for END (" 
  425                      << option_data->getPosition() << 
")");
 
  431        if (desc.
option_->getType() == 0) {
 
  433                      << 
"reserved value (" 
  434                      << option_data->getPosition() << 
")");
 
  447    if (client_classes) {
 
  448        for (
auto const& class_element : client_classes->listValue()) {
 
  455    return (make_pair(desc, space_param));
 
 
  461                                           const uint16_t address_family,
 
 
  471    for (
auto const& 
data : option_data_list->listValue()) {
 
  472        std::pair<OptionDescriptor, std::string> option =
 
  473            option_parser->parse(
data);
 
  475        cfg->add(option.first, option.second);
 
 
  482boost::shared_ptr<OptionDataParser>
 
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.
A generic exception that is thrown if a function is called in a prohibited way.
static void checkKeywords(const SimpleKeywords &keywords, isc::data::ConstElementPtr scope)
Checks acceptable keywords with their expected type.
static const data::Element::Position & getPosition(const std::string &name, const data::ConstElementPtr parent)
Utility method that returns position of an element.
static std::string getString(isc::data::ConstElementPtr scope, const std::string &name)
Returns a string parameter from a scope.
static bool getBoolean(isc::data::ConstElementPtr scope, const std::string &name)
Returns a boolean parameter from a scope.
static int64_t getInteger(isc::data::ConstElementPtr scope, const std::string &name)
Returns an integer parameter from a scope.
void fromElement(isc::data::ConstElementPtr list)
Sets contents from a ListElement.
To be removed. Please use ConfigError instead.
static OptionDefinitionPtr getOptionDef(const std::string &space, const uint16_t code)
Return the first option definition matching a particular option code.
static OptionDefinitionPtr getVendorOptionDef(const Option::Universe u, const uint32_t vendor_id, const uint16_t code)
Returns vendor option definition for a given vendor-id and code.
static uint32_t optionSpaceToVendorId(const std::string &option_space)
Converts option space name to vendor id.
static OptionDefinitionPtr getRuntimeOptionDef(const std::string &space, const uint16_t code)
Returns runtime (non-standard) option definition by space and option code.
static OptionDefinitionPtr getLastResortOptionDef(const std::string &space, const uint16_t code)
Returns last resort option definition by space and option code.
CfgOptionDefPtr cfg_option_def_
Config option definitions.
virtual boost::shared_ptr< OptionDataParser > createOptionDataParser() const
Returns an instance of the OptionDataListParser to be used in parsing options.
void parse(const CfgOptionPtr &cfg, isc::data::ConstElementPtr option_data_list, bool encapsulate=true)
Parses a list of options, instantiates them and stores in cfg.
OptionDataListParser(const uint16_t address_family, CfgOptionDefPtr cfg_option_def=CfgOptionDefPtr())
Constructor.
uint16_t address_family_
Address family: AF_INET or AF_INET6.
util::Optional< std::string > extractData(data::ConstElementPtr parent) const
Retrieves option data as a string.
std::pair< OptionDescriptor, std::string > parse(isc::data::ConstElementPtr single_option)
Parses ElementPtr containing option definition.
uint16_t address_family_
Address family: AF_INET or AF_INET6.
std::string extractSpace(data::ConstElementPtr parent) const
Retrieves option space name.
util::Optional< bool > extractPersistent(data::ConstElementPtr parent) const
Retrieves persistent/always-send parameter as an optional value.
std::pair< OptionDescriptor, std::string > createOption(isc::data::ConstElementPtr option_data)
Create option instance.
util::Optional< bool > extractCSVFormat(data::ConstElementPtr parent) const
Retrieves csv-format parameter as an optional value.
util::Optional< uint32_t > extractCode(data::ConstElementPtr parent) const
Retrieves parsed option code as an optional value.
virtual OptionDefinitionPtr findOptionDefinition(const std::string &option_space, const util::Optional< uint32_t > &option_code, const util::Optional< std::string > &option_name) const
Finds an option definition within an option space.
CfgOptionDefPtr cfg_option_def_
Config option definitions.
util::Optional< std::string > extractName(data::ConstElementPtr parent) const
Retrieves parsed option name as an optional value.
util::Optional< bool > extractCancelled(data::ConstElementPtr parent) const
Retrieves cancelled/never-send parameter as an optional value.
OptionDataParser(const uint16_t address_family, CfgOptionDefPtr cfg_option_def=CfgOptionDefPtr())
Constructor.
OptionPtr option_
Option instance.
void addClientClass(const std::string &class_name)
Adds new client class for which the option is allowed.
bool cancelled_
Cancelled flag.
std::string formatted_value_
Option value in textual (CSV) format.
ClientClasses client_classes_
Collection of classes for the which option is allowed.
bool persistent_
Persistence flag.
static bool validateName(const std::string &name)
Checks that the provided option space name is valid.
Universe
defines option universe DHCPv4 or DHCPv6
static const isc::data::SimpleKeywords OPTION4_PARAMETERS
This table defines all option parameters.
static const isc::data::SimpleKeywords OPTION6_PARAMETERS
This table defines all option parameters.
A template representing an optional value.
T get() const
Retrieves the encapsulated value.
void unspecified(bool unspecified)
Modifies the flag that indicates whether the value is specified or unspecified.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< CfgOption > CfgOptionPtr
Non-const pointer.
boost::shared_ptr< CfgOptionDef > CfgOptionDefPtr
Non-const pointer.
boost::shared_ptr< OptionDefinition > OptionDefinitionPtr
Pointer to option definition object.
boost::shared_ptr< Option > OptionPtr
void decodeFormattedHexString(const string &hex_string, vector< uint8_t > &binary)
Converts a formatted string of hexadecimal digits into a vector.
vector< string > tokens(const string &text, const string &delim, bool escape)
Split string into tokens.
vector< uint8_t > quotedStringToBinary(const string "ed_string)
Converts a string in quotes into vector.
Defines the logger used by the top-level component of kea-lfc.
#define DHCP4_OPTION_SPACE
global std option spaces
#define DHCP6_OPTION_SPACE
void setContext(const data::ConstElementPtr &ctx)
Sets user context.