Kea 2.2.0
dhcp_queue_control_parser.cc
Go to the documentation of this file.
1// Copyright (C) 2015-2020 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>
13#include <boost/foreach.hpp>
14#include <string>
15#include <sys/types.h>
16
17using namespace isc::data;
18using namespace isc::util;
19
20namespace isc {
21namespace dhcp {
22
25 // All we really do here is verify that it is a map that
26 // contains at least queue-type. All other content depends
27 // on the packet queue implementation of that type.
28 if (control_elem->getType() != Element::map) {
29 isc_throw(DhcpConfigError, "dhcp-queue-control must be a map");
30 }
31
32 // enable-queue is mandatory.
33 bool enable_queue = getBoolean(control_elem, "enable-queue");
34
35 if (enable_queue) {
36 ConstElementPtr elem = control_elem->get("queue-type");
37 if (!elem) {
38 isc_throw(DhcpConfigError, "when queue is enabled, queue-type is required");
39 } else {
40 if (elem->getType() != Element::string) {
41 isc_throw(DhcpConfigError, "queue-type must be a string");
42 }
43 }
44 }
45
46 // Return a copy of it.
47 ElementPtr result = data::copy(control_elem);
48
49 // Currently not compatible with multi-threading.
50 if (MultiThreadingMgr::instance().getMode()) {
51 // Silently disable it.
52 result->set("enable-queue", Element::create(false));
53 }
54
55 return (result);
56}
57
58} // end of namespace isc::dhcp
59} // end of namespace isc
static ElementPtr create(const Position &pos=ZERO_POSITION())
Definition: data.cc:241
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:1360
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:27
boost::shared_ptr< Element > ElementPtr
Definition: data.h:24
Definition: edns.h:19
Defines the logger used by the top-level component of kea-lfc.