1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243 | // Copyright (C) 2014-2023 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef HOST_RESERVATION_PARSER_H
#define HOST_RESERVATION_PARSER_H
#include <cc/data.h>
#include <cc/simple_parser.h>
#include <dhcpsrv/host.h>
namespace isc {
namespace dhcp {
/// @brief Parser for a single host reservation entry.
class HostReservationParser : public isc::data::SimpleParser {
public:
/// @brief Destructor.
virtual ~HostReservationParser() { }
/// @brief Parses a single entry for host reservation.
///
/// @param subnet_id Identifier of the subnet that the host is
/// connected to.
/// @param reservation_data Data element holding map with a host
/// reservation configuration.
/// @param encapsulate_options a boolean parameter indicating if the
/// parsed options should be encapsulated with suboptions.
///
/// @return Pointer to the object representing parsed host.
/// @throw DhcpConfigError If the configuration is invalid.
virtual HostPtr
parse(const SubnetID& subnet_id,
isc::data::ConstElementPtr reservation_data,
bool encapsulate_options = true) final;
protected:
/// @brief Parses a single entry for host reservation.
///
/// This method is called by @ref parse and it can be overridden in the
/// derived classes to provide class specific parsing logic.
///
/// @param subnet_id Identifier of the subnet that the host is
/// connected to.
/// @param reservation_data Data element holding map with a host
/// reservation configuration.
/// @param encapsulate_options a boolean parameter indicating if the
/// parsed options should be encapsulated with suboptions.
///
/// @return Pointer to the object representing parsed host.
/// @throw DhcpConfigError If the configuration is invalid.
virtual HostPtr parseInternal(const SubnetID& subnet_id,<--- Virtual function in base class<--- Virtual function in base class
isc::data::ConstElementPtr reservation_data,
bool encapsulate_options);
/// @brief Checks if the specified parameter is a host identifier.
///
/// @param param_name Parameter name.
///
/// @return true if the parameter specifies host identifier, false
/// otherwise.
virtual bool isIdentifierParameter(const std::string& param_name) const;
/// @brief Checks if the specified parameter is supported by the parser.
///
/// @param param_name Parameter name.
///
/// @return true if the parameter is supported, false otherwise.
virtual bool isSupportedParameter(const std::string& param_name) const;
/// @brief Returns set of the supported parameters.
///
/// @param identifiers_only Indicates if the function should only
/// return supported host identifiers (if true) or all supported
/// parameters (if false).
///
/// @return Set of supported parameter names.
virtual const std::set<std::string>&
getSupportedParameters(const bool identifiers_only) const = 0;<--- Virtual function in base class<--- Virtual function in base class
};
/// @brief Parser for a single host reservation for DHCPv4.
class HostReservationParser4 : public HostReservationParser {
protected:
/// @brief Parses a single host reservation for DHCPv4.
///
/// @param subnet_id Identifier of the subnet that the host is
/// connected to.
/// @param reservation_data Data element holding map with a host
/// reservation configuration.
/// @param encapsulate_options a boolean parameter indicating if the
/// parsed options should be encapsulated with suboptions.
///
/// @return Pointer to the object representing parsed host.
/// @throw DhcpConfigError If the configuration is invalid.
virtual HostPtr parseInternal(const SubnetID& subnet_id,<--- Function in derived class
isc::data::ConstElementPtr reservation_data,
bool encapsulate_options);
/// @brief Returns set of the supported parameters for DHCPv4.
///
/// @param identifiers_only Indicates if the function should only
/// return supported host identifiers (if true) or all supported
/// parameters (if false).
///
/// @return Set of supported parameter names.
virtual const std::set<std::string>&
getSupportedParameters(const bool identifiers_only) const;<--- Function in derived class
};
/// @brief Parser for a single host reservation for DHCPv6.
class HostReservationParser6 : public HostReservationParser {
protected:
/// @brief Parses a single host reservation for DHCPv6.
///
/// @param subnet_id Identifier of the subnet that the host is
/// connected to.
/// @param reservation_data Data element holding map with a host
/// reservation configuration.
/// @param encapsulate_options a boolean parameter indicating if the
/// parsed options should be encapsulated with suboptions.
///
/// @return Pointer to the object representing parsed host.
/// @throw DhcpConfigError If the configuration is invalid.
virtual HostPtr parseInternal(const SubnetID& subnet_id,<--- Function in derived class
isc::data::ConstElementPtr reservation_data,
bool encapsulate_options);
/// @brief Returns set of the supported parameters for DHCPv6.
///
/// @param identifiers_only Indicates if the function should only
/// return supported host identifiers (if true) or all supported
/// parameters (if false).
///
/// @return Set of supported parameter names.
virtual const std::set<std::string>&
getSupportedParameters(const bool identifiers_only) const;<--- Function in derived class
};
/// @brief Parser for a list of host identifiers.
///
/// This is a parent parser class for parsing "host-reservation-identifiers"
/// global configuration parameter. The DHCPv4 and DHCPv6 specific parsers
/// derive from this class.
class HostReservationIdsParser : public isc::data::SimpleParser {
public:
/// @brief Constructor.
HostReservationIdsParser();
/// @brief Destructor.
virtual ~HostReservationIdsParser() { }
/// @brief Parses a list of host identifiers.
///
/// @param ids_list Data element pointing to an ordered list of host
/// identifier names.
///
/// @throw DhcpConfigError If specified configuration is invalid.
void parse(isc::data::ConstElementPtr ids_list);
protected:
/// @brief Parses a list of host identifiers.
///
/// This method is called by @ref parse and it can be overridden in the
/// derived classes to provide class specific parsing logic.
///
/// @param ids_list Data element pointing to an ordered list of host
/// identifier names.
///
/// @throw DhcpConfigError If specified configuration is invalid.
virtual void parseInternal(isc::data::ConstElementPtr ids_list);
/// @brief Checks if specified identifier name is supported in the
/// context of the parser.
///
/// This is abstract method which must be implemented in the derived
/// parser classes for DHCPv4 and DHCPv6.
///
/// @param id_name Identifier name.
/// @return true if the specified identifier is supported, false
/// otherwise.
virtual bool isSupportedIdentifier(const std::string& id_name) const = 0;<--- Virtual function in base class<--- Virtual function in base class
/// @brief Pointer to the object holding configuration.
CfgHostOperationsPtr staging_cfg_;
};
/// @brief Parser for a list of host identifiers for DHCPv4.
class HostReservationIdsParser4 : public HostReservationIdsParser {
public:
/// @brief Constructor.
///
/// Initializes staging configuration pointer to the one used for DHCPv4
/// configuration.
HostReservationIdsParser4();
protected:
/// @brief Checks if specified identifier name is supported for DHCPv4.
///
/// @param id_name Identifier name.
/// @return true if the specified identifier is supported, false
/// otherwise.
virtual bool isSupportedIdentifier(const std::string& id_name) const;<--- Function in derived class
};
/// @brief Parser for a list of host identifiers for DHCPv6.
class HostReservationIdsParser6 : public HostReservationIdsParser {
public:
/// @brief Constructor.
///
/// Initializes staging configuration pointer to the one used for DHCPv6
/// configuration.
HostReservationIdsParser6();
protected:
/// @brief Checks if specified identifier name is supported for DHCPv6.
///
/// @param id_name Identifier name.
/// @return true if the specified identifier is supported, false
/// otherwise.
virtual bool isSupportedIdentifier(const std::string& id_name) const;<--- Function in derived class
};
}
} // end of namespace isc
#endif // HOST_RESERVATION_PARSER_H
|