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