Kea 3.1.1
limits/load_unload.cc
Go to the documentation of this file.
1// Copyright (C) 2022-2025 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
10#include <dhcpsrv/cfgmgr.h>
12#include <dhcpsrv/srv_config.h>
16#include <process/daemon.h>
17
18namespace isc {
19namespace limits {
20
21using namespace isc::dhcp;
22using namespace isc::process;
23
24// Functions accessed by the hooks framework use C linkage to avoid the name
25// mangling that accompanies use of the C++ compiler as well as to avoid
26// issues related to namespaces
27extern "C" {
28
34int
36 // Make the hook library not loadable by d2 or ca.
37 uint16_t family = CfgMgr::instance().getFamily();
38 const std::string& proc_name = Daemon::getProcName();
39 if (family == AF_INET) {
40 if (proc_name != "kea-dhcp4") {
41 isc_throw(isc::Unexpected, "Bad process name: " << proc_name
42 << ", expected kea-dhcp4");
43 }
44 } else {
45 if (proc_name != "kea-dhcp6") {
46 isc_throw(isc::Unexpected, "Bad process name: " << proc_name
47 << ", expected kea-dhcp6");
48 }
49 }
50
51 if (handle.getParameters()) {
52 isc_throw(ConfigError, "expected no parameters for libdhcp_limits.so, found "
53 << handle.getParameters()->str());
54 }
55
56 // Parse the configuration to get the limits of interest. Take them from the
57 // staging configuration since we are still in the hook library load phase.
59
60 return (0);
61}
62
66int
68 // Parse an empty config to clear configuration and packet counters.
70
71 // Clear the class lease counters.
73 LeaseMgrFactory::instance().getType() == "memfile") {
75 }
76
77 return (0);
78}
79
83int
85 return (1);
86}
87
88} // extern "C"
89
90} // namespace limits
91} // namespace isc
An exception that is thrown if an error occurs while configuring any server.
A generic exception that is thrown when an unexpected error condition occurs.
uint16_t getFamily() const
Returns address family.
Definition cfgmgr.h:246
static CfgMgr & instance()
returns a single instance of Configuration Manager
Definition cfgmgr.cc:29
static TrackingLeaseMgr & instance()
Return current lease manager.
static bool haveInstance()
Indicates if the lease manager has been instantiated.
virtual void clearClassLeaseCounts()=0
Clears the class-lease count map.
isc::data::ConstElementPtr getParameters()
Get configuration parameter common code.
static std::string getProcName()
returns the process name This value is used as when forming the default PID file name
Definition daemon.cc:151
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< SrvConfig > SrvConfigPtr
Non-const pointer to the SrvConfig.
int load(isc::hooks::LibraryHandle &handle)
Called by the hooks library manager when the library is loaded.
int unload()
Called by the hooks library manager when the library is unloaded.
int multi_threading_compatible()
Return multi-threading compatibility.
Defines the logger used by the top-level component of kea-lfc.
void initialize(isc::dhcp::SrvConfigPtr const &config)
Reinitialize data structures required for limiting.
static LimitManager & instance()
singleton access function