17const string DHCP4_SPACE =
"dhcp4";
18const string DHCP6_SPACE =
"dhcp6";
28 if (!subnets || subnets->empty()) {
38 for (
ElementPtr const& subnet : subnets->listValue()) {
49 const string& subsel) {
50 if (!networks || networks->empty()) {
60 for (
size_t i = 0; i < networks->size(); ++i) {
64 if (!subnets->empty()) {
72 network->remove(subsel);
82 if (!subnets || subnets->empty()) {
87 for (
size_t i = 0; i < subnets->size(); ++i) {
96 const string& subsel) {
97 if (!networks || networks->empty()) {
102 for (
ElementPtr const& network : networks->listValue()) {
104 if (!subnets || subnets->empty()) {
108 for (
size_t i = 0; i < subnets->size(); ++i) {
117 if (!pools || pools->empty()) {
124 for (
size_t i = 0; i < pools->size(); ++i) {
132 if (!subnets || subnets->empty()) {
137 for (
ElementPtr const& subnet : subnets->listValue()) {
144 const string& subsel) {
145 if (!networks || networks->empty()) {
150 for (
ElementPtr const& network : networks->listValue()) {
159 if (!defs || defs->empty()) {
166 for (
size_t i = 0; i < defs->size(); ++i) {
179 if (!options || options->empty()) {
186 for (
size_t i = 0; i < options->size(); ++i) {
197 if (!classes || classes->empty()) {
203 for (
size_t i = 0; i < classes->size(); ++i) {
206 if (space == DHCP4_SPACE) {
209 if (!options->empty()) {
214 cclass->remove(
"option-def");
222 if (!options->empty()) {
227 cclass->remove(
"option-data");
236 if (!pools || pools->empty()) {
241 for (
size_t i = 0; i < pools->size(); ++i) {
245 if (!options->empty()) {
248 pool->remove(
"option-data");
257 if (!hosts || hosts->empty()) {
262 for (
size_t i = 0; i < hosts->size(); ++i) {
266 if (!options->empty()) {
269 host->remove(
"option-data");
279 if (!subnets || subnets->empty()) {
284 for (
size_t i = 0; i < subnets->size(); ++i) {
290 if (!options->empty()) {
293 subnet->remove(
"option-data");
300 if (!pools->empty()) {
303 subnet->remove(
"pools");
308 if (space == DHCP6_SPACE) {
311 if (!pd_pools->empty()) {
314 subnet->remove(
"pd-pools");
322 if (!hosts->empty()) {
325 subnet->remove(
"reservations");
335 if (!networks || networks->empty()) {
341 for (
size_t i = 0; i < networks->size(); ++i) {
342 ElementPtr network = networks->getNonConst(i);
347 if (!options->empty()) {
350 network->remove(
"option-data");
353 string subnet =
"subnet";
354 if (space == DHCP4_SPACE) {
363 if (!subnets->empty()) {
366 network->remove(subnet);
374 if (!pools || pools->empty()) {
379 for (
size_t i = 0; i < pools->size(); ++i) {
382 if (require && require->empty()) {
383 pool->remove(
"require-client-classes");
390 if (!subnets || subnets->empty()) {
395 for (
size_t i = 0; i < subnets->size(); ++i) {
400 if (require && require->empty()) {
401 subnet->remove(
"require-client-classes");
408 const string& subsel) {
409 if (!networks || networks->empty()) {
414 for (
size_t i = 0; i < networks->size(); ++i) {
415 ElementPtr network = networks->getNonConst(i);
418 if (require && require->empty()) {
419 network->remove(
"require-client-classes");
427 if (!hosts || hosts->empty()) {
432 for (
size_t i = 0; i < hosts->size(); ++i) {
441 if (!subnets || subnets->empty()) {
446 for (
ElementPtr const& subnet : subnets->listValue()) {
453 const string& space) {
454 if (!networks || networks->empty()) {
459 for (
ElementPtr const& network : networks->listValue()) {
460 if (space == DHCP4_SPACE) {
470 if (!subnets || subnets->empty()) {
475 for (
size_t i = 0; i < subnets->size(); ++i) {
483 const string& subsel) {
484 if (!networks || networks->empty()) {
489 for (
size_t i = 0; i < networks->size(); ++i) {
490 ElementPtr network = networks->getNonConst(i);
504 dhcp->remove(
"hosts-database");
506 list->add(
copy(database, 0));
507 dhcp->set(
"hosts-databases", list);
513 if (!options || !options->empty()) {
517 dhcp->remove(
"relay-supplied-options");
522 const string& space) {
526 bool have_ids =
true;
530 if (!subnets->empty()) {
535 dhcp->remove(subsel);
540 if (!networks->empty()) {
545 dhcp->remove(
"shared-networks");
559 if (!defs->empty()) {
562 dhcp->remove(
"option-def");
567 if (!options->empty()) {
570 dhcp->remove(
"option-data");
575 if (!classes->empty()) {
578 dhcp->remove(
"client-classes");
583 if (!hosts->empty()) {
587 dhcp->remove(
"reservations");
607 if (space == DHCP6_SPACE) {
620 if (config->contains(
"Logging")) {
628 preProcess(mutable_dhcp,
"subnet4", DHCP4_SPACE);
629 config->set(
"Dhcp4", mutable_dhcp);
640 if (config->contains(
"Logging")) {
648 preProcess(mutable_dhcp,
"subnet6", DHCP6_SPACE);
649 config->set(
"Dhcp6", mutable_dhcp);
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
static ElementPtr createList(const Position &pos=ZERO_POSITION())
Creates an empty ListElement type ElementPtr.
static void sanitizeRequireClassesPools(isc::data::ConstElementPtr pools)
Process require client classes in a pool list.
static void subnetsAssignID(isc::data::ConstElementPtr subnets, isc::dhcp::SubnetIDSet &set, isc::dhcp::SubnetID &next)
Assigns subnet-id to every subnet in a subnet list.
static void sanitizeOptionSharedNetworks(isc::data::ConstElementPtr networks, const std::string &space, const OptionCodes &codes)
Set missing option codes to a shared network list.
static void sharedNetworksAssignID(isc::data::ConstElementPtr networks, isc::dhcp::SubnetIDSet &set, isc::dhcp::SubnetID &next, const std::string &subsel)
Assigns subnet-id to every subnet in a shared network list.
static void sanitizeRelaySubnets(isc::data::ConstElementPtr subnets)
Sanitizes relay information in subnets in a subnet list.
static void sanitizeHostSubnets(isc::data::ConstElementPtr subnets)
Process host reservations in a subnet list.
static bool subnetsCollectID(isc::data::ConstElementPtr subnets, isc::dhcp::SubnetIDSet &set)
Collects subnet-ids on all subnets.
static void preProcess4(isc::data::ElementPtr config)
Pre process a DHCPv4 configuration.
static void sanitizeOptionPools(isc::data::ConstElementPtr pools, const std::string &space, const OptionCodes &codes)
Set missing option codes to a pool list.
static void preProcess(isc::data::ElementPtr dhcp, const std::string &subsel, const std::string &space)
Pre process a configuration.
static void sanitizePoolsInSubnets(isc::data::ConstElementPtr subnets)
Sanitizes all pools in a subnets list.
static void sanitizeDatabase(isc::data::ElementPtr dhcp)
Update (hosts) database.
static void requireClassesSharedNetworks(isc::data::ConstElementPtr networks, const std::string &subsel)
Process require client classes in a shared network list.
static void sanitizeOptionHosts(isc::data::ConstElementPtr hosts, const std::string &space, const OptionCodes &codes)
Set missing option codes to a host reservation list.
static void sanitizeHostList(isc::data::ConstElementPtr hosts)
Process host reservation list.
static void SanitizeHostsInSharedNetworks(isc::data::ConstElementPtr networks, const std::string &space)
Process host reservations in a shared network list.
static void sanitizeOptionDefList(isc::data::ConstElementPtr defs, const std::string &space, OptionCodes &codes)
Collect option definitions from an option definition list.
static void sanitizeRequireClassesSubnets(isc::data::ConstElementPtr subnets)
Process require client classes in a subnet list.
static void sanitizeOptionSubnets(isc::data::ConstElementPtr subnets, const std::string &space, const OptionCodes &codes)
Set missing option codes to a subnet list.
static void sanitizePools(isc::data::ConstElementPtr pools)
Sanitizes all pools in a pools list.
static void sanitizePoolsInSharedNetworks(isc::data::ConstElementPtr networks, const std::string &subsel)
Sanitizes all pools in all subnets in a shared network list.
static void sanitizeOptionClasses(isc::data::ConstElementPtr classes, const std::string &space, OptionCodes &codes)
Collect option definitions from a client class list and set missing option codes.
static void preProcess6(isc::data::ElementPtr config)
Pre process a DHCPv6 configuration.
static void sanitizeRelaySuppliedOptions(isc::data::ElementPtr dhcp)
Update relay supplied options.
static void sanitizeOptionDataList(isc::data::ConstElementPtr options, const std::string &space, const OptionCodes &codes)
Set missing option codes to an option data list.
static void sanitizeRelayInSharedNetworks(isc::data::ConstElementPtr networks, const std::string &subsel)
Sanitizes relay information in a shared network list.
static bool sharedNetworksCollectID(isc::data::ConstElementPtr networks, isc::dhcp::SubnetIDSet &set, const std::string &subsel)
Collects subnet-ids in all subnets in all shared network list.
static void quoteIdentifier(isc::data::ElementPtr host)
Quote when needed a host identifier.
static void setCode(isc::data::ElementPtr option, const OptionCodes &codes)
Set code from name and definitions.
static void initCodes(OptionCodes &codes, const std::string &space)
Initialize code map.
static void setSpace(isc::data::ElementPtr option, const std::string &space)
Set space.
static void checkType(isc::data::ConstElementPtr option)
Checks if type is specified in option definition.
static void collect(isc::data::ConstElementPtr option, OptionCodes &codes)
Collect definition.
static void checkCode(isc::data::ConstElementPtr option)
Check if code is specified in option defintion.
static void canonizePool(isc::data::ElementPtr pool)
Canonize pool.
static void assignID(isc::data::ElementPtr subnet, isc::dhcp::SubnetIDSet &set, isc::dhcp::SubnetID &next)
Assign subnet ID.
static bool collectID(isc::data::ConstElementPtr subnet, isc::dhcp::SubnetIDSet &set)
Collect a subnet ID.
static void updateRelay(isc::data::ElementPtr subnet)
Update relay.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
ElementPtr copy(ConstElementPtr from, int level)
Copy the data up to a nesting level.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
std::set< dhcp::SubnetID > SubnetIDSet
Ordered list aka set of subnetIDs.
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
std::unordered_map< std::string, uint16_t > OptionCodes
Map for DHCP option definitions handling code and an index built from space and name.
Defines the logger used by the top-level component of kea-lfc.