Kea
1.5.0
dhcp_queue_control_parser.cc
Go to the documentation of this file.
1
// Copyright (C) 2015-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
#include <
cc/data.h
>
9
#include <
dhcpsrv/cfgmgr.h
>
10
#include <
dhcpsrv/dhcpsrv_log.h
>
11
#include <
dhcpsrv/parsers/dhcp_queue_control_parser.h
>
12
#include <boost/foreach.hpp>
13
#include <string>
14
#include <sys/types.h>
15
16
using namespace
isc::data
;
17
18
namespace
isc
{
19
namespace
dhcp {
20
21
data::ElementPtr
22
DHCPQueueControlParser::parse(
const
isc::data::ConstElementPtr
& control_elem) {
23
// All we really do here is verify that it is a map that
24
// contains at least queue-type. All other content depends
25
// on the packet queue implementation of that type.
26
if
(control_elem->getType() !=
Element::map
) {
27
isc_throw
(
DhcpConfigError
,
"dhcp-queue-control must be a map"
);
28
}
29
30
// enable-queue is mandatory.
31
bool
enable_queue = getBoolean(control_elem,
"enable-queue"
);
32
33
if
(enable_queue) {
34
ConstElementPtr
elem = control_elem->get(
"queue-type"
);
35
if
(!elem) {
36
isc_throw
(
DhcpConfigError
,
"when queue is enabled, queue-type is required"
);
37
}
else
{
38
if
(elem->getType() !=
Element::string
) {
39
isc_throw
(
DhcpConfigError
,
"queue-type must be a string"
);
40
}
41
}
42
}
43
44
// Return a copy of it.
45
return
(
data::copy
(control_elem));
46
}
47
48
}
// end of namespace isc::dhcp
49
}
// end of namespace isc
isc::dhcp::DhcpConfigError
To be removed. Please use ConfigError instead.
Definition:
dhcp_config_error.h:58
isc::data::copy
ElementPtr copy(ConstElementPtr from, int level)
Copy the data up to a nesting level.
Definition:
data.cc:1114
isc::data
Definition:
cfg_to_element.h:25
isc
Defines the logger used by the top-level component of kea-dhcp-ddns.
Definition:
agent_parser.cc:144
isc_throw
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Definition:
exceptions/exceptions.h:192
dhcpsrv_log.h
dhcp_queue_control_parser.h
isc::data::Element::string
@ string
Definition:
data.h:151
cfgmgr.h
isc::data::Element::map
@ map
Definition:
data.h:151
data.h
isc::data::ElementPtr
boost::shared_ptr< Element > ElementPtr
Definition:
data.h:20
isc::data::ConstElementPtr
boost::shared_ptr< const Element > ConstElementPtr
Definition:
data.h:23
src
lib
dhcpsrv
parsers
dhcp_queue_control_parser.cc
Generated on Fri Jul 10 2020 09:12:51 for Kea by
1.8.18