Kea 2.2.0
adaptor_subnet.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
10
11using namespace std;
12using namespace isc::data;
13using namespace isc::dhcp;
14
15namespace isc {
16namespace yang {
17
19}
20
22}
23
24bool
26 ConstElementPtr id = subnet->get("id");
27 if (id) {
28 set.insert(static_cast<SubnetID>(id->intValue()));
29 return (true);
30 }
31 return (false);
32}
33
34void
36 ConstElementPtr id = subnet->get("id");
37 if (!id) {
38 // Skip already used.
39 while (set.count(next) > 0) {
40 ++next;
41 }
42 subnet->set("id", Element::create(static_cast<long long>(next)));
43 set.insert(next);
44 ++next;
45 }
46}
47
48void
50 ConstElementPtr relay = subnet->get("relay");
51 if (!relay) {
52 return;
53 }
54 ConstElementPtr addresses = relay->get("ip-addresses");
55 if (!addresses) {
56 ConstElementPtr address = relay->get("ip-address");
57 if (!address) {
58 subnet->remove("relay");
59 return;
60 }
61 ElementPtr addr = Element::create(address->stringValue());
62 ElementPtr addrs = Element::createList();
63 addrs->add(addr);
64 ElementPtr updated = Element::createMap();
65 updated->set("ip-addresses", addrs);
66 subnet->set("relay", updated);
67 } else if (addresses->size() == 0) {
68 subnet->remove("relay");
69 }
70}
71
72} // end of namespace isc::yang
73} // end of namespace isc
virtual ~AdaptorSubnet()
Destructor.
static bool collectID(isc::data::ConstElementPtr subnet, SubnetIDSet &set)
Collect a subnet ID.
static void updateRelay(isc::data::ElementPtr subnet)
Update relay.
static void assignID(isc::data::ElementPtr subnet, SubnetIDSet &set, isc::dhcp::SubnetID &next)
Assign subnet ID.
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:27
boost::shared_ptr< Element > ElementPtr
Definition: data.h:24
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
Definition: subnet_id.h:24
std::set< isc::dhcp::SubnetID > SubnetIDSet
Set of SubnetIDs.
Defines the logger used by the top-level component of kea-lfc.