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>
12#include <boost/foreach.hpp>
13#include <string>
14#include <sys/types.h>
15
16using namespace isc::data;
17
18namespace isc {
19namespace dhcp {
20
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
static bool getBoolean(isc::data::ConstElementPtr scope, const std::string &name)
Returns a boolean parameter from a scope.
data::ElementPtr parse(const isc::data::ConstElementPtr &control_elem)
Parses content of the "dhcp-queue-control".
To be removed. Please use ConfigError instead.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
ElementPtr copy(ConstElementPtr from, int level)
Copy the data up to a nesting level.
Definition: data.cc:1114
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:23
boost::shared_ptr< Element > ElementPtr
Definition: data.h:22
Defines the logger used by the top-level component of kea-dhcp-ddns.