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