Kea  1.9.9-git
option_data_parser.h
Go to the documentation of this file.
1 // Copyright (C) 2017-2019,2021 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 <util/optional.h>
16 #include <cstdint>
17 #include <string>
18 #include <utility>
19 
20 namespace isc {
21 namespace dhcp {
22 
42 public:
47  OptionDataParser(const uint16_t address_family,
48  CfgOptionDefPtr cfg_option_def = CfgOptionDefPtr());
49 
65  std::pair<OptionDescriptor, std::string>
66  parse(isc::data::ConstElementPtr single_option);
67 
68 private:
69 
85  template<typename SearchKey>
86  OptionDefinitionPtr findOptionDefinition(const std::string& option_space,
87  const SearchKey& search_key) const;
88 
117  std::pair<OptionDescriptor, std::string>
118  createOption(isc::data::ConstElementPtr option_data);
119 
127  extractCode(data::ConstElementPtr parent) const;
128 
136  extractName(data::ConstElementPtr parent) const;
137 
141  util::Optional<bool> extractCSVFormat(data::ConstElementPtr parent) const;
142 
148  std::string extractData(data::ConstElementPtr parent) const;
149 
159  std::string extractSpace(data::ConstElementPtr parent) const;
160 
164  util::Optional<bool> extractPersistent(data::ConstElementPtr parent) const;
165 
167  uint16_t address_family_;
168 
170  CfgOptionDefPtr cfg_option_def_;
171 };
172 
180 public:
185  OptionDataListParser(const uint16_t address_family,
186  CfgOptionDefPtr cfg_option_def = CfgOptionDefPtr());
187 
196  void parse(const CfgOptionPtr& cfg,
197  isc::data::ConstElementPtr option_data_list);
198 private:
200  uint16_t address_family_;
201 
203  CfgOptionDefPtr cfg_option_def_;
204 };
205 
206 
207 } // end of namespace isc::dhcp
208 } // end of namespace isc
209 
210 #endif // OPTION_DATA_PARSER_H
void parse(const CfgOptionPtr &cfg, isc::data::ConstElementPtr option_data_list)
Parses a list of options, instantiates them and stores in cfg.
boost::shared_ptr< CfgOption > CfgOptionPtr
Non-const pointer.
Definition: cfg_option.h:706
std::pair< OptionDescriptor, std::string > parse(isc::data::ConstElementPtr single_option)
Parses ElementPtr containing option definition.
boost::shared_ptr< CfgOptionDef > CfgOptionDefPtr
Non-const pointer.
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:23
Parser for option data values within a subnet.
Defines the logger used by the top-level component of kea-dhcp-ddns.
Parser for option data value.
boost::shared_ptr< OptionDefinition > OptionDefinitionPtr
Pointer to option definition object.
OptionDataListParser(const uint16_t address_family, CfgOptionDefPtr cfg_option_def=CfgOptionDefPtr())
Constructor.
OptionDataParser(const uint16_t address_family, CfgOptionDefPtr cfg_option_def=CfgOptionDefPtr())
Constructor.