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