Kea 2.5.8
option_data_parser.h
Go to the documentation of this file.
1// Copyright (C) 2017-2023 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
156
166 std::string extractSpace(data::ConstElementPtr parent) const;
167
172
177
180
183};
184
192public:
197 OptionDataListParser(const uint16_t address_family,
198 CfgOptionDefPtr cfg_option_def = CfgOptionDefPtr());
199
202 }
203
215 void parse(const CfgOptionPtr& cfg,
216 isc::data::ConstElementPtr option_data_list,
217 bool encapsulate = true);
218protected:
219
227 virtual boost::shared_ptr<OptionDataParser> createOptionDataParser() const;
228
231
234};
235
236
237} // end of namespace isc::dhcp
238} // end of namespace isc
239
240#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.
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.
virtual ~OptionDataListParser()
Virtual destructor.
uint16_t address_family_
Address family: AF_INET or AF_INET6.
Parser for option data value.
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.
virtual ~OptionDataParser()
Virtual destructor.
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.
A template representing an optional value.
Definition: optional.h:36
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:29
boost::shared_ptr< CfgOption > CfgOptionPtr
Non-const pointer.
Definition: cfg_option.h:803
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.