Kea 1.5.0
adaptor_subnet.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
8
9using namespace std;
10using namespace isc::data;
11using namespace isc::dhcp;
12
13namespace isc {
14namespace yang {
15
17}
18
20}
21
22bool
24 ConstElementPtr id = subnet->get("id");
25 if (id) {
26 set.insert(static_cast<SubnetID>(id->intValue()));
27 return (true);
28 }
29 return (false);
30}
31
32void
34 ConstElementPtr id = subnet->get("id");
35 if (!id) {
36 // Skip already used.
37 while (set.count(next) > 0) {
38 ++next;
39 }
40 subnet->set("id", Element::create(static_cast<long long>(next)));
41 set.insert(next);
42 ++next;
43 }
44}
45
46void
48 ConstElementPtr relay = subnet->get("relay");
49 if (!relay) {
50 return;
51 }
52 ConstElementPtr addresses = relay->get("ip-addresses");
53 if (!addresses) {
54 ConstElementPtr address = relay->get("ip-address");
55 if (!address) {
56 subnet->remove("relay");
57 return;
58 }
59 ElementPtr addr = Element::create(address->stringValue());
61 addrs->add(addr);
63 updated->set("ip-addresses", addrs);
64 subnet->set("relay", updated);
65 } else if (addresses->size() == 0) {
66 subnet->remove("relay");
67 }
68}
69
70}; // end of namespace isc::yang
71}; // end of namespace isc
static ElementPtr create(const Position &pos=ZERO_POSITION())
Definition: data.cc:223
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
Definition: data.cc:268
static ElementPtr createList(const Position &pos=ZERO_POSITION())
Creates an empty ListElement type ElementPtr.
Definition: data.cc:263
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:23
boost::shared_ptr< Element > ElementPtr
Definition: data.h:22
uint32_t SubnetID
Unique identifier for a subnet (both v4 and v6)
Definition: lease.h:24
std::set< isc::dhcp::SubnetID > SubnetIDSet
Set of SubnetIDs.
Defines the logger used by the top-level component of kea-dhcp-ddns.