Kea  2.3.5-git
option_data_parser.h
Go to the documentation of this file.
1 // Copyright (C) 2017-2022 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #ifndef OPTION_DATA_PARSER_H
8 #define OPTION_DATA_PARSER_H
9 
10 #include <cc/data.h>
11 #include <cc/simple_parser.h>
12 #include <dhcp/option_definition.h>
13 #include <dhcpsrv/cfg_option.h>
14 #include <dhcpsrv/cfg_option_def.h>
15 #include <boost/shared_ptr.hpp>
16 #include <util/optional.h>
17 #include <cstdint>
18 #include <string>
19 #include <utility>
20 
21 namespace isc {
22 namespace dhcp {
23 
43 public:
48  OptionDataParser(const uint16_t address_family,
49  CfgOptionDefPtr cfg_option_def = CfgOptionDefPtr());
50 
52  virtual ~OptionDataParser() {
53  }
54 
70  std::pair<OptionDescriptor, std::string>
71  parse(isc::data::ConstElementPtr single_option);
72 
73 protected:
74 
90  virtual OptionDefinitionPtr
91  findOptionDefinition(const std::string& option_space,
92  const util::Optional<uint32_t>& option_code,
93  const util::Optional<std::string>& option_name) const;
94 
123  std::pair<OptionDescriptor, std::string>
125 
133  extractCode(data::ConstElementPtr parent) const;
134 
142  extractName(data::ConstElementPtr parent) const;
143 
148 
154  std::string extractData(data::ConstElementPtr parent) const;
155 
165  std::string extractSpace(data::ConstElementPtr parent) const;
166 
171 
173  uint16_t address_family_;
174 
177 };
178 
186 public:
191  OptionDataListParser(const uint16_t address_family,
192  CfgOptionDefPtr cfg_option_def = CfgOptionDefPtr());
193 
196  }
197 
206  void parse(const CfgOptionPtr& cfg,
207  isc::data::ConstElementPtr option_data_list);
208 protected:
209 
217  virtual boost::shared_ptr<OptionDataParser> createOptionDataParser() const;
218 
220  uint16_t address_family_;
221 
224 };
225 
226 
227 } // end of namespace isc::dhcp
228 } // end of namespace isc
229 
230 #endif // OPTION_DATA_PARSER_H
util::Optional< uint32_t > extractCode(data::ConstElementPtr parent) const
Retrieves parsed option code as an optional value.
boost::shared_ptr< CfgOption > CfgOptionPtr
Non-const pointer.
Definition: cfg_option.h:745
std::pair< OptionDescriptor, std::string > parse(isc::data::ConstElementPtr single_option)
Parses ElementPtr containing option definition.
std::pair< OptionDescriptor, std::string > createOption(isc::data::ConstElementPtr option_data)
Create option instance.
virtual ~OptionDataListParser()
Virtual destructor.
util::Optional< std::string > extractName(data::ConstElementPtr parent) const
Retrieves parsed option name as an optional value.
std::string extractData(data::ConstElementPtr parent) const
Retrieves option data as a string.
boost::shared_ptr< CfgOptionDef > CfgOptionDefPtr
Non-const pointer.
uint16_t address_family_
Address family: AF_INET or AF_INET6.
uint16_t address_family_
Address family: AF_INET or AF_INET6.
util::Optional< bool > extractPersistent(data::ConstElementPtr parent) const
Retrieves persistent/always-send parameter as an optional value.
CfgOptionDefPtr cfg_option_def_
Config option definitions.
std::string extractSpace(data::ConstElementPtr parent) const
Retrieves option space name.
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:27
Parser for option data values within a subnet.
virtual ~OptionDataParser()
Virtual destructor.
Defines the logger used by the top-level component of kea-lfc.
util::Optional< bool > extractCSVFormat(data::ConstElementPtr parent) const
Retrieves csv-format parameter as an optional value.
CfgOptionDefPtr cfg_option_def_
Config option definitions.
Parser for option data value.
boost::shared_ptr< OptionDefinition > OptionDefinitionPtr
Pointer to option definition object.
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.
OptionDataParser(const uint16_t address_family, CfgOptionDefPtr cfg_option_def=CfgOptionDefPtr())
Constructor.