Kea 1.5.0
simple_parser6.cc
Go to the documentation of this file.
1// Copyright (C) 2016-2018 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#include <config.h>
8
9#include <cc/data.h>
11#include <boost/foreach.hpp>
12
13using namespace isc::data;
14
15namespace isc {
16namespace dhcp {
31
37 { "record-types", Element::string, ""},
38 { "space", Element::string, "dhcp6"},
39 { "array", Element::boolean, "false"},
40 { "encapsulate", Element::string, "" }
41};
42
49 { "space", Element::string, "dhcp6"},
50 { "csv-format", Element::boolean, "true"},
51 { "always-send", Element::boolean, "false"}
52};
53
60 { "renew-timer", Element::integer, "900" },
61 { "rebind-timer", Element::integer, "1800" },
62 { "preferred-lifetime", Element::integer, "3600" },
63 { "valid-lifetime", Element::integer, "7200" },
64 { "decline-probation-period", Element::integer, "86400" }, // 24h
65 { "dhcp4o6-port", Element::integer, "0" },
66 { "server-tag", Element::string, "" },
67 { "reservation-mode", Element::string, "all" }
68};
69
72 { "id", Element::integer, "0" }, // 0 means autogenerate
73 { "interface", Element::string, "" },
74 { "client-class", Element::string, "" },
75 { "rapid-commit", Element::boolean, "false" }, // rapid-commit disabled by default
76 { "interface-id", Element::string, "" }
77};
78
81 { "id", Element::integer, "0" } // 0 means autogenerate
82};
83
86 { "client-class", Element::string, "" },
87 { "interface", Element::string, "" },
88 { "interface-id", Element::string, "" },
89 { "rapid-commit", Element::boolean, "false" } // rapid-commit disabled by default
90};
91
92
95 { "re-detect", Element::boolean, "true" }
96};
97
108 "client-class",
109 "interface",
110 "interface-id",
111 "preferred-lifetime",
112 "rapid-commit",
113 "rebind-timer",
114 "relay",
115 "renew-timer",
116 "reservation-mode",
117 "valid-lifetime"
118};
119
122 { "enable-queue", Element::boolean, "false"},
123 { "queue-type", Element::string, "kea-ring6"},
124 { "capacity", Element::integer, "500"}
125};
126
127
129
133
135 size_t cnt = 0;
136
137 // Set global defaults first.
138 cnt = setDefaults(global, GLOBAL6_DEFAULTS);
139
140 // Now set the defaults for each specified option definition
141 ConstElementPtr option_defs = global->get("option-def");
142 if (option_defs) {
143 BOOST_FOREACH(ElementPtr option_def, option_defs->listValue()) {
145 }
146 }
147
148 // Set the defaults for option data
149 ConstElementPtr options = global->get("option-data");
150 if (options) {
151 BOOST_FOREACH(ElementPtr single_option, options->listValue()) {
152 cnt += SimpleParser::setDefaults(single_option, OPTION6_DEFAULTS);
153 }
154 }
155
156 // Now set the defaults for defined subnets
157 ConstElementPtr subnets = global->get("subnet6");
158 if (subnets) {
159 cnt += setListDefaults(subnets, SUBNET6_DEFAULTS);
160 }
161
162 // Set the defaults for interfaces config
163 ConstElementPtr ifaces_cfg = global->get("interfaces-config");
164 if (ifaces_cfg) {
165 ElementPtr mutable_cfg = boost::const_pointer_cast<Element>(ifaces_cfg);
166 cnt += setDefaults(mutable_cfg, IFACE6_DEFAULTS);
167 }
168
169 // Set defaults for shared networks
170 ConstElementPtr shared = global->get("shared-networks");
171 if (shared) {
172 BOOST_FOREACH(ElementPtr net, shared->listValue()) {
173
175
176 ConstElementPtr subs = net->get("subnet6");
177 if (subs) {
179 }
180 }
181 }
182
183 // Set the defaults for dhcp-queue-control. If the element isn't there
184 // we'll add it.
185 ConstElementPtr queue_control = global->get("dhcp-queue-control");
186 ElementPtr mutable_cfg;
187 if (queue_control) {
188 mutable_cfg = boost::const_pointer_cast<Element>(queue_control);
189 } else {
190 mutable_cfg = Element::createMap();
191 global->set("dhcp-queue-control", mutable_cfg);
192 }
193
194 cnt += setDefaults(mutable_cfg, DHCP_QUEUE_CONTROL6_DEFAULTS);
195
196 return (cnt);
197}
198
200 size_t cnt = 0;
201 // Now derive global parameters into subnets.
202 ConstElementPtr subnets = global->get("subnet6");
203 if (subnets) {
204 BOOST_FOREACH(ElementPtr single_subnet, subnets->listValue()) {
205 cnt += SimpleParser::deriveParams(global, single_subnet,
207 }
208 }
209
210 // Deriving parameters for shared networks is a bit more involved.
211 // First, the shared-network level derives from global, and then
212 // subnets within derive from it.
213 ConstElementPtr shared = global->get("shared-networks");
214 if (shared) {
215 BOOST_FOREACH(ElementPtr net, shared->listValue()) {
216 // First try to inherit the parameters from shared network,
217 // if defined there.
218 // Then try to inherit them from global.
219 cnt += SimpleParser::deriveParams(global, net,
221
222 // Now we need to go thrugh all the subnets in this net.
223 subnets = net->get("subnet6");
224 if (subnets) {
225 BOOST_FOREACH(ElementPtr single_subnet, subnets->listValue()) {
226 cnt += SimpleParser::deriveParams(net, single_subnet,
228 }
229 }
230 }
231 }
232
233 return (cnt);
234}
235
236};
237};
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
Definition: data.cc:268
static size_t setListDefaults(isc::data::ConstElementPtr list, const SimpleDefaults &default_values)
Sets the default values for all entries in a list.
static size_t deriveParams(isc::data::ConstElementPtr parent, isc::data::ElementPtr child, const ParamsList &params)
Derives (inherits) parameters from parent scope to a child.
static size_t setDefaults(isc::data::ElementPtr scope, const SimpleDefaults &default_values)
Sets the default values.
static const isc::data::SimpleDefaults SHARED_SUBNET6_DEFAULTS
This table defines default values for each IPv6 subnet.
static const isc::data::SimpleDefaults SUBNET6_DEFAULTS
This table defines default values for each IPv6 subnet.
static const isc::data::SimpleDefaults DHCP_QUEUE_CONTROL6_DEFAULTS
This table defines default values for dhcp-queue-control in DHCPv4.
static const isc::data::SimpleDefaults GLOBAL6_DEFAULTS
This table defines default global values for DHCPv6.
static const isc::data::SimpleDefaults IFACE6_DEFAULTS
This table defines default values for interfaces for DHCPv6.
static const isc::data::SimpleDefaults OPTION6_DEF_DEFAULTS
This table defines default values for option definitions in DHCPv6.
static const isc::data::SimpleDefaults OPTION6_DEFAULTS
This table defines default values for options in DHCPv6.
static const isc::data::SimpleDefaults SHARED_NETWORK6_DEFAULTS
This table defines default values for each IPv6 shared network.
static size_t deriveParameters(isc::data::ElementPtr global)
Derives (inherits) all parameters from global to more specific scopes.
static size_t setAllDefaults(isc::data::ElementPtr global)
Sets all defaults for DHCPv6 configuration.
static const isc::data::ParamsList INHERIT_TO_SUBNET6
List of parameters that can be inherited from the global to subnet6 scope.
std::vector< std::string > ParamsList
This defines a list of all parameters that are derived (or inherited) between contexts.
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:23
std::vector< SimpleDefault > SimpleDefaults
This specifies all default values in a given scope (e.g. a subnet)
boost::shared_ptr< Element > ElementPtr
Definition: data.h:22
Defines the logger used by the top-level component of kea-dhcp-ddns.