Kea 3.1.1
run_script.h
Go to the documentation of this file.
1// Copyright (C) 2021-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#ifndef RUN_SCRIPT_H
8#define RUN_SCRIPT_H
9
11#include <dhcp/dhcp4.h>
12#include <dhcp/dhcp6.h>
13#include <dhcp/duid.h>
14#include <dhcp/hwaddr.h>
15#include <dhcp/option6_ia.h>
16#include <dhcp/pkt4.h>
17#include <dhcp/pkt6.h>
18#include <dhcpsrv/lease.h>
19#include <dhcpsrv/subnet.h>
21#include <hooks/hooks_parser.h>
22#include <string>
23
24namespace isc {
25namespace run_script {
26
29public:
32
34 ~RunScriptImpl() = default;
35
43 const bool value,
44 const std::string& prefix = "",
45 const std::string& suffix = "");
46
54 const uint64_t value,
55 const std::string& prefix = "",
56 const std::string& suffix = "");
57
65 const std::string& value,
66 const std::string& prefix = "",
67 const std::string& suffix = "");
68
76 const isc::dhcp::HWAddrPtr& hwaddr,
77 const std::string& prefix = "",
78 const std::string& suffix = "");
79
87 const isc::dhcp::ClientIdPtr client_id,
88 const std::string& prefix = "",
89 const std::string& suffix = "");
90
98 const isc::dhcp::DuidPtr duid,
99 const std::string& prefix = "",
100 const std::string& suffix = "");
101
109 const isc::dhcp::OptionPtr option,
110 const std::string& prefix = "",
111 const std::string& suffix = "");
112
122 const isc::dhcp::OptionPtr option,
123 uint16_t code,
124 const std::string& prefix = "",
125 const std::string& suffix = "");
126
134 const isc::dhcp::Option6IAPtr option6IA,
135 const std::string& prefix = "",
136 const std::string& suffix = "");
137
145 const isc::dhcp::ConstSubnet4Ptr subnet4,
146 const std::string& prefix = "",
147 const std::string& suffix = "");
148
156 const isc::dhcp::ConstSubnet6Ptr subnet6,
157 const std::string& prefix = "",
158 const std::string& suffix = "");
159
167 const isc::dhcp::Lease4Ptr& lease4,
168 const std::string& prefix = "",
169 const std::string& suffix = "");
170
178 const isc::dhcp::Lease6Ptr& lease6,
179 const std::string& prefix = "",
180 const std::string& suffix = "");
181
189 const isc::dhcp::Lease4CollectionPtr& leases4,
190 const std::string& prefix = "",
191 const std::string& suffix = "");
192
200 const isc::dhcp::Lease6CollectionPtr& leases6,
201 const std::string& prefix = "",
202 const std::string& suffix = "");
203
211 const isc::dhcp::Pkt4Ptr& pkt4,
212 const std::string& prefix = "",
213 const std::string& suffix = "");
214
222 const isc::dhcp::Pkt6Ptr& pkt6,
223 const std::string& prefix = "",
224 const std::string& suffix = "");
225
231 void runScript(const isc::asiolink::ProcessArgs& args,
233
237 void setName(const std::string& name) {
239 name_ = name;
240 }
241
245 std::string getName() const {
246 return (name_);
247 }
248
252 void setSync(const bool sync) {
253 sync_ = sync;
254 }
255
259 bool getSync() const {
260 return (sync_);
261 }
262
265
266private:
267
269 isc::asiolink::IOServicePtr io_context_;
270
272 std::string name_;
273
279 bool sync_;
280};
281
283typedef boost::shared_ptr<RunScriptImpl> RunScriptImplPtr;
284
285} // namespace run_script
286} // namespace isc
287#endif
static std::string validatePath(const std::string libpath)
Validates a script path (script loaded by a hook) against the supported path.
static void extractBoolean(isc::asiolink::ProcessEnvVars &vars, const bool value, const std::string &prefix="", const std::string &suffix="")
Extract boolean data and append to environment.
Definition run_script.cc:55
static void extractInteger(isc::asiolink::ProcessEnvVars &vars, const uint64_t value, const std::string &prefix="", const std::string &suffix="")
Extract integer data and append to environment.
Definition run_script.cc:70
std::string getName() const
Get name of the target script.
Definition run_script.h:245
void configure(isc::hooks::LibraryHandle &handle)
This function parses and applies configuration parameters.
Definition run_script.cc:25
static void extractLease4(isc::asiolink::ProcessEnvVars &vars, const isc::dhcp::Lease4Ptr &lease4, const std::string &prefix="", const std::string &suffix="")
Extract Lease4 data and append to environment.
static void extractString(isc::asiolink::ProcessEnvVars &vars, const std::string &value, const std::string &prefix="", const std::string &suffix="")
Extract string data and append to environment.
Definition run_script.cc:79
static void extractSubnet4(isc::asiolink::ProcessEnvVars &vars, const isc::dhcp::ConstSubnet4Ptr subnet4, const std::string &prefix="", const std::string &suffix="")
Extract Subnet4 data and append to environment.
void setSync(const bool sync)
Set the synchronous call mode for the target script.
Definition run_script.h:252
static void extractDUID(isc::asiolink::ProcessEnvVars &vars, const isc::dhcp::DuidPtr duid, const std::string &prefix="", const std::string &suffix="")
Extract DUID data and append to environment.
~RunScriptImpl()=default
Destructor.
static void extractSubnet6(isc::asiolink::ProcessEnvVars &vars, const isc::dhcp::ConstSubnet6Ptr subnet6, const std::string &prefix="", const std::string &suffix="")
Extract Subnet6 data and append to environment.
bool getSync() const
Get the synchronous call mode for the target script.
Definition run_script.h:259
static void extractHWAddr(isc::asiolink::ProcessEnvVars &vars, const isc::dhcp::HWAddrPtr &hwaddr, const std::string &prefix="", const std::string &suffix="")
Extract HWAddr data and append to environment.
Definition run_script.cc:88
void setName(const std::string &name)
Set name of the target script.
Definition run_script.h:237
static void extractOptionIA(isc::asiolink::ProcessEnvVars &vars, const isc::dhcp::Option6IAPtr option6IA, const std::string &prefix="", const std::string &suffix="")
Extract Option6IA data and append to environment.
void runScript(const isc::asiolink::ProcessArgs &args, const isc::asiolink::ProcessEnvVars &vars)
Run Script with specified arguments and environment parameters.
Definition run_script.cc:49
static void extractLeases6(isc::asiolink::ProcessEnvVars &vars, const isc::dhcp::Lease6CollectionPtr &leases6, const std::string &prefix="", const std::string &suffix="")
Extract Lease6Collection data and append to environment.
static void extractLease6(isc::asiolink::ProcessEnvVars &vars, const isc::dhcp::Lease6Ptr &lease6, const std::string &prefix="", const std::string &suffix="")
Extract Lease6 data and append to environment.
static void extractClientId(isc::asiolink::ProcessEnvVars &vars, const isc::dhcp::ClientIdPtr client_id, const std::string &prefix="", const std::string &suffix="")
Extract ClientId data and append to environment.
static void extractPkt6(isc::asiolink::ProcessEnvVars &vars, const isc::dhcp::Pkt6Ptr &pkt6, const std::string &prefix="", const std::string &suffix="")
Extract Pkt6 data and append to environment.
static void extractSubOption(isc::asiolink::ProcessEnvVars &vars, const isc::dhcp::OptionPtr option, uint16_t code, const std::string &prefix="", const std::string &suffix="")
Extract Option SubOption data and append to environment.
static void extractPkt4(isc::asiolink::ProcessEnvVars &vars, const isc::dhcp::Pkt4Ptr &pkt4, const std::string &prefix="", const std::string &suffix="")
Extract Pkt4 data and append to environment.
static void extractOption(isc::asiolink::ProcessEnvVars &vars, const isc::dhcp::OptionPtr option, const std::string &prefix="", const std::string &suffix="")
Extract Option data and append to environment.
static void extractLeases4(isc::asiolink::ProcessEnvVars &vars, const isc::dhcp::Lease4CollectionPtr &leases4, const std::string &prefix="", const std::string &suffix="")
Extract Lease4Collection data and append to environment.
boost::shared_ptr< Lease4Collection > Lease4CollectionPtr
A shared pointer to the collection of IPv4 leases.
Definition lease.h:523
boost::shared_ptr< const Subnet6 > ConstSubnet6Ptr
A const pointer to a Subnet6 object.
Definition subnet.h:623
boost::shared_ptr< const Subnet4 > ConstSubnet4Ptr
A const pointer to a Subnet4 object.
Definition subnet.h:458
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
Definition pkt4.h:556
boost::shared_ptr< DUID > DuidPtr
Definition duid.h:136
boost::shared_ptr< Lease6 > Lease6Ptr
Pointer to a Lease6 structure.
Definition lease.h:528
boost::shared_ptr< Option6IA > Option6IAPtr
A pointer to the Option6IA object.
Definition option6_ia.h:20
boost::shared_ptr< HWAddr > HWAddrPtr
Shared pointer to a hardware address structure.
Definition hwaddr.h:154
boost::shared_ptr< ClientId > ClientIdPtr
Shared pointer to a Client ID.
Definition duid.h:216
boost::shared_ptr< Lease6Collection > Lease6CollectionPtr
A shared pointer to the collection of IPv6 leases.
Definition lease.h:696
boost::shared_ptr< Pkt6 > Pkt6Ptr
A pointer to Pkt6 packet.
Definition pkt6.h:31
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
Definition lease.h:315
boost::shared_ptr< Option > OptionPtr
Definition option.h:37
boost::shared_ptr< RunScriptImpl > RunScriptImplPtr
The type of shared pointers to Run Script implementations.
Definition run_script.h:283
Defines the logger used by the top-level component of kea-lfc.