18#include <boost/make_shared.hpp>
19#include <boost/pointer_cast.hpp>
30 : check_iface_(check_iface) {
35 bool encapsulate_options) {
45 std::string name =
getString(shared_network_data,
"name");
50 mutable_params = boost::const_pointer_cast<Element>(shared_network_data);
54 NetworkPtr network = boost::dynamic_pointer_cast<Network>(shared_network);
58 if (shared_network_data->contains(
"interface")) {
59 std::string iface =
getString(shared_network_data,
"interface");
63 shared_network_data->get(
"interface");
65 "Specified network interface name " << iface
66 <<
" for shared network " << name
67 <<
" is not present in the system ("
68 <<
error->getPosition() <<
")");
70 shared_network->setIface(iface);
74 if (shared_network_data->contains(
"option-data")) {
75 auto json = shared_network_data->get(
"option-data");
77 CfgOptionPtr cfg_option = shared_network->getCfgOption();
79 parser->parse(cfg_option, json, encapsulate_options);
82 if (shared_network_data->contains(
"subnet4")) {
83 auto json = shared_network_data->get(
"subnet4");
88 parser->parse(subnets, json);
91 for (
auto const& subnet : subnets) {
92 shared_network->add(subnet);
96 if (shared_network_data->contains(
"match-client-id")) {
97 shared_network->setMatchClientId(
getBoolean(shared_network_data,
101 if (shared_network_data->contains(
"authoritative")) {
102 shared_network->setAuthoritative(
getBoolean(shared_network_data,
107 if (shared_network_data->contains(
"next-server")) {
108 std::string next_server;
110 next_server =
getString(shared_network_data,
"next-server");
111 if (!next_server.empty()) {
112 shared_network->setSiaddr(
IOAddress(next_server));
118 pos = next->getPosition().str();
120 pos = shared_network_data->getPosition().str();
123 << next_server <<
"(" << pos <<
")");
128 if (shared_network_data->contains(
"server-hostname")) {
129 std::string sname =
getString(shared_network_data,
"server-hostname");
130 if (!sname.empty()) {
135 << sname.length() <<
" ("
136 <<
error->getPosition() <<
")");
138 shared_network->setSname(sname);
143 if (shared_network_data->contains(
"boot-file-name")) {
144 std::string filename =
getString(shared_network_data,
"boot-file-name");
145 if (!filename.empty()) {
150 << filename.length() <<
" ("
151 <<
error->getPosition() <<
")");
153 shared_network->setFilename(filename);
157 if (shared_network_data->contains(
"client-class")) {
158 std::string client_class =
getString(shared_network_data,
"client-class");
159 if (!client_class.empty()) {
160 shared_network->allowClientClass(client_class);
164 ConstElementPtr user_context = shared_network_data->get(
"user-context");
166 shared_network->setContext(user_context);
169 if (shared_network_data->contains(
"require-client-classes")) {
170 const std::vector<data::ElementPtr>& class_list =
171 shared_network_data->get(
"require-client-classes")->listValue();
172 for (
auto const& cclass : class_list) {
174 cclass->stringValue().empty()) {
176 << cclass->getPosition() <<
")");
178 shared_network->requireClientClass(cclass->stringValue());
182 if (shared_network_data->contains(
"relay")) {
183 auto relay_parms = shared_network_data->get(
"relay");
187 parser.
parse(relay_info, relay_parms);
188 shared_network->setRelayInfo(*relay_info);
204 Network4Ptr network4 = boost::dynamic_pointer_cast<Network4>(shared_network);
210 }
catch (
const std::exception& ex) {
212 << shared_network_data->getPosition() <<
")");
222 return (shared_network);
225boost::shared_ptr<OptionDataListParser>
227 auto parser = boost::make_shared<OptionDataListParser>(AF_INET);
231boost::shared_ptr<Subnets4ListConfigParser>
233 auto parser = boost::make_shared<Subnets4ListConfigParser>(
check_iface_);
238 : check_iface_(check_iface) {
243 bool encapsulate_options) {
249 shared_network_data);
253 std::string name =
getString(shared_network_data,
"name");
258 mutable_params = boost::const_pointer_cast<Element>(shared_network_data);
262 NetworkPtr network = boost::dynamic_pointer_cast<Network>(shared_network);
267 "preferred-lifetime"));
272 if (shared_network_data->contains(
"interface-id")) {
273 ifaceid =
getString(shared_network_data,
"interface-id");
278 if (shared_network_data->contains(
"interface")) {
279 iface =
getString(shared_network_data,
"interface");
288 "parser error: interface (defined for locally reachable "
289 "subnets) and interface-id (defined for subnets reachable"
290 " via relays) cannot be defined at the same time for "
291 "shared network " << name <<
"("
292 << shared_network_data->getPosition() <<
")");
297 std::string ifaceid_value = ifaceid.
get();
298 OptionBuffer tmp(ifaceid_value.begin(), ifaceid_value.end());
300 shared_network->setInterfaceId(opt);
309 "Specified network interface name " << iface
310 <<
" for shared network " << name
311 <<
" is not present in the system ("
312 <<
error->getPosition() <<
")");
314 shared_network->setIface(iface);
317 if (shared_network_data->contains(
"rapid-commit")) {
318 shared_network->setRapidCommit(
getBoolean(shared_network_data,
322 if (shared_network_data->contains(
"option-data")) {
323 auto json = shared_network_data->get(
"option-data");
325 CfgOptionPtr cfg_option = shared_network->getCfgOption();
327 parser->parse(cfg_option, json, encapsulate_options);
330 if (shared_network_data->contains(
"client-class")) {
331 std::string client_class =
getString(shared_network_data,
"client-class");
332 if (!client_class.empty()) {
333 shared_network->allowClientClass(client_class);
337 ConstElementPtr user_context = shared_network_data->get(
"user-context");
339 shared_network->setContext(user_context);
342 if (shared_network_data->contains(
"require-client-classes")) {
343 const std::vector<data::ElementPtr>& class_list =
344 shared_network_data->get(
"require-client-classes")->listValue();
345 for (
auto const& cclass : class_list) {
347 cclass->stringValue().empty()) {
349 << cclass->getPosition() <<
")");
351 shared_network->requireClientClass(cclass->stringValue());
355 if (shared_network_data->contains(
"subnet6")) {
356 auto json = shared_network_data->get(
"subnet6");
361 parser->parse(subnets, json);
364 for (
auto const& subnet : subnets) {
365 shared_network->add(subnet);
369 if (shared_network_data->contains(
"relay")) {
370 auto relay_parms = shared_network_data->get(
"relay");
374 parser.
parse(relay_info, relay_parms);
375 shared_network->setRelayInfo(*relay_info);
389 if (network->getAllocatorType() ==
"flq") {
390 isc_throw(
BadValue,
"Free Lease Queue allocator is not supported for IPv6 address pools");
394 auto network6 = boost::dynamic_pointer_cast<Network6>(shared_network);
397 }
catch (
const std::exception& ex) {
399 << shared_network_data->getPosition() <<
")");
409 return (shared_network);
412boost::shared_ptr<OptionDataListParser>
414 auto parser = boost::make_shared<OptionDataListParser>(AF_INET6);
418boost::shared_ptr<Subnets6ListConfigParser>
420 auto parser = boost::make_shared<Subnets6ListConfigParser>(
check_iface_);
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
The IOAddress class represents an IP addresses (version agnostic)
static void checkKeywords(const SimpleKeywords &keywords, isc::data::ConstElementPtr scope)
Checks acceptable keywords with their expected type.
static std::string getString(isc::data::ConstElementPtr scope, const std::string &name)
Returns a string parameter from a scope.
const isc::util::Triplet< uint32_t > parseIntTriplet(const data::ConstElementPtr &scope, const std::string &name)
Parses an integer triplet.
static bool getBoolean(isc::data::ConstElementPtr scope, const std::string &name)
Returns a boolean parameter from a scope.
void parseCacheParams(const data::ConstElementPtr &network_data, NetworkPtr &network)
Parses parameters related to lease cache settings.
void parseAllocatorParams(const data::ConstElementPtr &network_data, NetworkPtr &network)
Parses parameters pertaining to allocator selection.
void parseDdnsParams(const data::ConstElementPtr &network_data, NetworkPtr &network)
Parses parameters pertaining to DDNS behavior.
void parseCommon(const data::ConstElementPtr &network_data, NetworkPtr &network)
Parses common parameters.
static void moveReservationMode(isc::data::ElementPtr config)
Moves deprecated reservation-mode parameter to new reservations flags.
void parseTeePercents(const data::ConstElementPtr &network_data, NetworkPtr &network)
Parses parameters related to "percent" timers settings.
void parsePdAllocatorParams(const data::ConstElementPtr &network_data, Network6Ptr &network)
Parses parameters pertaining to prefix delegation allocator selection.
void parseOfferLft(const data::ConstElementPtr &network_data, Network4Ptr &network)
Parses offer-lifetime parameter (v4 only)
static CfgMgr & instance()
returns a single instance of Configuration Manager
To be removed. Please use ConfigError instead.
static IfaceMgr & instance()
IfaceMgr is a singleton class.
Holds optional information about relay.
boost::shared_ptr< Network::RelayInfo > RelayInfoPtr
Pointer to the RelayInfo structure.
static const size_t MAX_SNAME_LEN
length of the SNAME field in DHCPv4 message
static const size_t MAX_FILE_LEN
length of the FILE field in DHCPv4 message
parser for additional relay information
void parse(const isc::dhcp::Network::RelayInfoPtr &relay_info, isc::data::ConstElementPtr relay_elem)
parses the actual relay parameters
virtual boost::shared_ptr< Subnets4ListConfigParser > createSubnetsListParser() const
Returns an instance of the Subnets4ListConfigParser to be used for parsing the subnets within the sha...
SharedNetwork4Parser(bool check_iface=true)
Constructor.
virtual boost::shared_ptr< OptionDataListParser > createOptionDataListParser() const
Returns an instance of the OptionDataListParser to be used in parsing the option-data structure.
bool check_iface_
Check if the specified interface exists in the system.
SharedNetwork4Ptr parse(const data::ConstElementPtr &shared_network_data, bool encapsulate_options=true)
Parses shared configuration information for IPv4 shared network.
Shared network holding IPv4 subnets.
SharedNetwork6Parser(bool check_iface=true)
Constructor.
virtual boost::shared_ptr< Subnets6ListConfigParser > createSubnetsListParser() const
Returns an instance of the Subnets6ListConfigParser to be used for parsing the subnets within the sha...
bool check_iface_
Check if the specified interface exists in the system.
virtual boost::shared_ptr< OptionDataListParser > createOptionDataListParser() const
Returns an instance of the OptionDataListParser to be used in parsing the option-data structure.
SharedNetwork6Ptr parse(const data::ConstElementPtr &shared_network_data, bool encapsulate_options=true)
Parses shared configuration information for IPv6 shared network.
Shared network holding IPv6 subnets.
static const isc::data::SimpleKeywords SHARED_NETWORK4_PARAMETERS
This table defines all shared network parameters for DHCPv4.
static const isc::data::SimpleKeywords SHARED_NETWORK6_PARAMETERS
This table defines all shared network parameters for DHCPv6.
A template representing an optional value.
T get() const
Retrieves the encapsulated value.
bool empty() const
Checks if the encapsulated value is empty.
void unspecified(bool unspecified)
Modifies the flag that indicates whether the value is specified or unspecified.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
boost::shared_ptr< const CfgGlobals > ConstCfgGlobalsPtr
Const shared pointer to a CfgGlobals instance.
boost::shared_ptr< Network4 > Network4Ptr
Pointer to the Network4 object.
boost::shared_ptr< CfgOption > CfgOptionPtr
Non-const pointer.
boost::multi_index_container< Subnet6Ptr, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetSubnetIdIndexTag >, boost::multi_index::const_mem_fun< Subnet, SubnetID, &Subnet::getID > >, boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetPrefixIndexTag >, boost::multi_index::const_mem_fun< Subnet, std::string, &Subnet::toText > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetModificationTimeIndexTag >, boost::multi_index::const_mem_fun< data::BaseStampedElement, boost::posix_time::ptime, &data::BaseStampedElement::getModificationTime > > > > Subnet6Collection
A collection of Subnet6 objects.
boost::shared_ptr< SharedNetwork6 > SharedNetwork6Ptr
Pointer to SharedNetwork6 object.
boost::multi_index_container< Subnet4Ptr, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetSubnetIdIndexTag >, boost::multi_index::const_mem_fun< Subnet, SubnetID, &Subnet::getID > >, boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetPrefixIndexTag >, boost::multi_index::const_mem_fun< Subnet, std::string, &Subnet::toText > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetServerIdIndexTag >, boost::multi_index::const_mem_fun< Network4, asiolink::IOAddress, &Network4::getServerId > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetModificationTimeIndexTag >, boost::multi_index::const_mem_fun< data::BaseStampedElement, boost::posix_time::ptime, &data::BaseStampedElement::getModificationTime > > > > Subnet4Collection
A collection of Subnet4 objects.
boost::shared_ptr< Network > NetworkPtr
Pointer to the Network object.
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
boost::shared_ptr< SharedNetwork4 > SharedNetwork4Ptr
Pointer to SharedNetwork4 object.
boost::shared_ptr< Option > OptionPtr
Defines the logger used by the top-level component of kea-lfc.