Kea 2.7.5
dhcp_queue_control_parser.cc
Go to the documentation of this file.
1// Copyright (C) 2015-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#include <cc/data.h>
9#include <dhcpsrv/cfgmgr.h>
10#include <dhcpsrv/dhcpsrv_log.h>
13#include <string>
14#include <sys/types.h>
15
16using namespace isc::data;
17using namespace isc::util;
18
19namespace isc {
20namespace dhcp {
21
24 bool multi_threading_enabled) {
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 (multi_threading_enabled) {
51 // Silently disable it.
52 result->set("enable-queue", Element::create(false));
54 }
55
56 return (result);
57}
58
59} // end of namespace isc::dhcp
60} // end of namespace isc
static ElementPtr create(const Position &pos=ZERO_POSITION())
Definition data.cc:249
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, bool multi_threading_enabled)
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.
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
Definition macros.h:26
ElementPtr copy(ConstElementPtr from, int level)
Copy the data up to a nesting level.
Definition data.cc:1420
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
boost::shared_ptr< Element > ElementPtr
Definition data.h:28
isc::log::Logger dhcpsrv_logger("dhcpsrv")
DHCP server library Logger.
Definition dhcpsrv_log.h:56
const isc::log::MessageID DHCPSRV_MT_DISABLED_QUEUE_CONTROL
Defines the logger used by the top-level component of kea-lfc.