Kea 2.2.0
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>
13#include <dhcpsrv/cfg_option.h>
15#include <boost/shared_ptr.hpp>
16#include <util/optional.h>
17#include <cstdint>
18#include <string>
19#include <utility>
20
21namespace isc {
22namespace dhcp {
23
43public:
48 OptionDataParser(const uint16_t address_family,
49 CfgOptionDefPtr cfg_option_def = CfgOptionDefPtr());
50
53 }
54
70 std::pair<OptionDescriptor, std::string>
71 parse(isc::data::ConstElementPtr single_option);
72
73protected:
74
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
134
143
148
154 std::string extractData(data::ConstElementPtr parent) const;
155
165 std::string extractSpace(data::ConstElementPtr parent) const;
166
171
174
177};
178
186public:
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);
208protected:
209
217 virtual boost::shared_ptr<OptionDataParser> createOptionDataParser() const;
218
221
224};
225
226
227} // end of namespace isc::dhcp
228} // end of namespace isc
229
230#endif // OPTION_DATA_PARSER_H
Parser for option data values within a subnet.
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.
virtual ~OptionDataListParser()
Virtual destructor.
OptionDataListParser(const uint16_t address_family, CfgOptionDefPtr cfg_option_def=CfgOptionDefPtr())
Constructor.
uint16_t address_family_
Address family: AF_INET or AF_INET6.
void parse(const CfgOptionPtr &cfg, isc::data::ConstElementPtr option_data_list)
Parses a list of options, instantiates them and stores in cfg.
Parser for option data value.
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.
std::string extractData(data::ConstElementPtr parent) const
Retrieves option data as a string.
CfgOptionDefPtr cfg_option_def_
Config option definitions.
virtual ~OptionDataParser()
Virtual destructor.
util::Optional< std::string > extractName(data::ConstElementPtr parent) const
Retrieves parsed option name as an optional value.
OptionDataParser(const uint16_t address_family, CfgOptionDefPtr cfg_option_def=CfgOptionDefPtr())
Constructor.
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:27
boost::shared_ptr< CfgOption > CfgOptionPtr
Non-const pointer.
Definition: cfg_option.h:706
boost::shared_ptr< CfgOptionDef > CfgOptionDefPtr
Non-const pointer.
boost::shared_ptr< OptionDefinition > OptionDefinitionPtr
Pointer to option definition object.
Defines the logger used by the top-level component of kea-lfc.