Kea 2.2.0
adaptor_pool.cc
Go to the documentation of this file.
1// Copyright (C) 2018-2022 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 <yang/adaptor_pool.h>
10#include <yang/yang_models.h>
11
12using namespace std;
13using namespace isc::data;
14
15namespace isc {
16namespace yang {
17
19}
20
22}
23
24void
26 const string& orig = pool->get("pool")->stringValue();
27 vector<char> v;
28 for (char ch : orig) {
29 if ((ch == ' ') || (ch == '\t') || (ch == '\n')) {
30 continue;
31 } else if (ch == '-') {
32 v.push_back(' ');
33 v.push_back(ch);
34 v.push_back(' ');
35 } else {
36 v.push_back(ch);
37 }
38 }
39 string canon;
40 canon.assign(v.begin(), v.end());
41 if (orig != canon) {
42 pool->set("pool", Element::create(canon));
43 }
44}
45
46void
47AdaptorPool::fromSubnet(const string& model, ConstElementPtr subnet,
48 ConstElementPtr pools) {
49 if (model == IETF_DHCPV6_SERVER) {
50 fromSubnetIetf6(subnet, pools);
51 } else if ((model != KEA_DHCP4_SERVER) &&
52 (model != KEA_DHCP6_SERVER)) {
54 "fromSubnet not implemented for the model: " << model);
55 }
56}
57
58void
60 Adaptor::fromParent("valid-lifetime", subnet, pools);
61 Adaptor::fromParent("preferred-lifetime", subnet, pools);
62 Adaptor::fromParent("renew-timer", subnet, pools);
63 Adaptor::fromParent("rebind-timer", subnet, pools);
64}
65
66void
67AdaptorPool::toSubnet(const string& model, ElementPtr subnet,
68 ConstElementPtr pools) {
69 if (model == IETF_DHCPV6_SERVER) {
70 toSubnetIetf6(subnet, pools);
71 } else if ((model != KEA_DHCP4_SERVER) &&
72 (model != KEA_DHCP6_SERVER)) {
74 "toSubnet not implemented for the model: " << model);
75 }
76}
77
78void
80 Adaptor::toParent("valid-lifetime", subnet, pools);
81 Adaptor::toParent("preferred-lifetime", subnet, pools);
82 Adaptor::toParent("renew-timer", subnet, pools);
83 Adaptor::toParent("rebind-timer", subnet, pools);
84}
85
86} // end of namespace isc::yang
87} // end of namespace isc
A generic exception that is thrown when a function is not implemented.
static void toSubnetIetf6(isc::data::ElementPtr subnet, isc::data::ConstElementPtr pools)
To subnet for ietf-dhcpv6-server.
Definition: adaptor_pool.cc:79
static void fromSubnetIetf6(isc::data::ConstElementPtr subnet, isc::data::ConstElementPtr pools)
From subnets for ietf-dhcpv6-server.
Definition: adaptor_pool.cc:59
AdaptorPool()
Constructor.
Definition: adaptor_pool.cc:18
static void toSubnet(const std::string &model, isc::data::ElementPtr subnet, isc::data::ConstElementPtr pools)
Move parameters from pools to the subnet.
Definition: adaptor_pool.cc:67
virtual ~AdaptorPool()
Destructor.
Definition: adaptor_pool.cc:21
static void fromSubnet(const std::string &model, isc::data::ConstElementPtr subnet, isc::data::ConstElementPtr pools)
Moves parameters from subnets to pools.
Definition: adaptor_pool.cc:47
static void canonizePool(isc::data::ElementPtr pool)
Canonize pool.
Definition: adaptor_pool.cc:25
static void fromParent(const std::string &name, isc::data::ConstElementPtr parent, isc::data::ConstElementPtr list)
Moves a parameter from parent to a list of children.
Definition: adaptor.cc:45
static void toParent(const std::string &name, isc::data::ElementPtr parent, isc::data::ConstElementPtr list)
Moves a parameter to a parent.
Definition: adaptor.cc:61
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:27
boost::shared_ptr< Element > ElementPtr
Definition: data.h:24
Defines the logger used by the top-level component of kea-lfc.