Kea 2.7.5
adaptor_subnet.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 <dhcpsrv/subnet_id.h>
10#include <yang/adaptor_subnet.h>
11
12using namespace std;
13using namespace isc::data;
14using namespace isc::dhcp;
15
16namespace isc {
17namespace yang {
18
19bool
21 ConstElementPtr id = subnet->get("id");
22 if (id) {
23 set.insert(static_cast<SubnetID>(id->intValue()));
24 return (true);
25 }
26 return (false);
27}
28
29void
31 ConstElementPtr id = subnet->get("id");
32 if (!id) {
33 // Skip already used.
34 while (set.count(next) > 0) {
35 ++next;
36 }
37 subnet->set("id", Element::create(static_cast<long long>(next)));
38 set.insert(next);
39 ++next;
40 }
41}
42
43void
45 ConstElementPtr relay = subnet->get("relay");
46 if (!relay) {
47 return;
48 }
49 ConstElementPtr addresses = relay->get("ip-addresses");
50 if (!addresses || addresses->size() == 0) {
51 subnet->remove("relay");
52 }
53}
54
55} // namespace yang
56} // namespace isc
static ElementPtr create(const Position &pos=ZERO_POSITION())
Definition data.cc:249
static void assignID(isc::data::ElementPtr subnet, isc::dhcp::SubnetIDSet &set, isc::dhcp::SubnetID &next)
Assign subnet ID.
static bool collectID(isc::data::ConstElementPtr subnet, isc::dhcp::SubnetIDSet &set)
Collect a subnet ID.
static void updateRelay(isc::data::ElementPtr subnet)
Update relay.
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
boost::shared_ptr< Element > ElementPtr
Definition data.h:28
std::set< dhcp::SubnetID > SubnetIDSet
Ordered list aka set of subnetIDs.
Definition subnet_id.h:43
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
Definition subnet_id.h:25
Defines the logger used by the top-level component of kea-lfc.