Kea
1.5.0
cfg_4o6.cc
Go to the documentation of this file.
1
// Copyright (C) 2017-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 <config.h>
8
9
#include <
dhcp/option.h
>
10
#include <
dhcpsrv/cfg_4o6.h
>
11
#include <string>
12
#include <string.h>
13
#include <sstream>
14
#include <vector>
15
16
using namespace
isc::data
;
17
18
namespace
isc
{
19
namespace
dhcp {
20
21
ElementPtr
22
Cfg4o6::toElement()
const
{
23
ElementPtr
result =
Element::createMap
();
24
// Set 4o6-interface
25
result->set(
"4o6-interface"
,
Element::create
(iface4o6_));
26
// Set 4o6-subnet
27
if
(!subnet4o6_.first.isV6Zero() || (subnet4o6_.second != 128u)) {
28
std::ostringstream oss;
29
oss << subnet4o6_.first <<
"/"
30
<<
static_cast<
unsigned
>
(subnet4o6_.second);
31
result->set(
"4o6-subnet"
,
Element::create
(oss.str()));
32
}
else
{
33
result->set(
"4o6-subnet"
,
Element::create
(std::string()));
34
}
35
// Set 4o6-interface-id
36
if
(interface_id_) {
37
std::vector<uint8_t> bin = interface_id_->toBinary();
38
std::string iid;
39
iid.resize(bin.size());
40
if
(!bin.empty()) {
41
std::memcpy(&iid[0], &bin[0], bin.size());
42
}
43
result->set(
"4o6-interface-id"
,
Element::create
(iid));
44
}
else
{
45
result->set(
"4o6-interface-id"
,
Element::create
(std::string()));
46
}
47
return
(result);
48
}
49
50
}
// end of isc::dhcp namespace
51
}
// end of isc namespace
isc::data
Definition:
cfg_to_element.h:25
isc::data::Element::createMap
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
Definition:
data.cc:268
isc
Defines the logger used by the top-level component of kea-dhcp-ddns.
Definition:
agent_parser.cc:144
cfg_4o6.h
isc::data::ElementPtr
boost::shared_ptr< Element > ElementPtr
Definition:
data.h:20
option.h
isc::data::Element::create
static ElementPtr create(const Position &pos=ZERO_POSITION())
Definition:
data.cc:223
src
lib
dhcpsrv
cfg_4o6.cc
Generated on Fri Jul 10 2020 09:12:51 for Kea by
1.8.18