![]() |
Kea 3.3.3
|
Defines lease4_select and lease4_renew callout functions. More...
#include <config.h>#include <cc/command_interpreter.h>#include <cc/data.h>#include <cc/simple_parser.h>#include <dhcpsrv/cfg_subnets4.h>#include <dhcpsrv/cfg_subnets6.h>#include <dhcpsrv/cfgmgr.h>#include <dhcpsrv/legal_log_mgr_factory.h>#include <dhcpsrv/subnet.h>#include <forensic_log/legal_log_log.h>#include <hooks/callout_manager.h>#include <hooks/hooks.h>#include <util/str.h>#include <sstream>#include <unordered_set>#include <subnets_user_context.h>Go to the source code of this file.
Functions | |
| void | addContext (ostringstream &os, ConstElementPtr &arguments) |
| Outputs text describing lease optional user context to a stream. | |
| void | addDuration (CalloutHandle &handle, ostringstream &os, ConstElementPtr &arguments) |
| Outputs text describing lease duration to a stream. | |
| bool | checkLoggingEnabledSubnet4 (ConstElementPtr &arguments) |
| Check if command has optional subnet-id parameter and if it does, check that the respective subnet has logging enabled. | |
| bool | checkLoggingEnabledSubnet6 (ConstElementPtr &arguments) |
| Check if command has optional subnet-id parameter and if it does, check that the respective subnet has logging enabled. | |
| int | command_processed (CalloutHandle &handle) |
| This callout is called at the "command_processed" hook point. | |
| bool | getOptionalInt (ConstElementPtr &arguments, const string &name, int64_t &value) |
| Fetch value for a integer element if it is an element scope. | |
| bool | getOptionalString (ConstElementPtr &arguments, const string &name, string &value) |
| Fetch value for a string element if it is an element scope. | |
| int | handleLease4Cmds (CalloutHandle &handle, string &name, ConstElementPtr &arguments, ConstElementPtr &) |
| Handle lease4 related commands. | |
| int | handleLease6Cmds (CalloutHandle &handle, string &name, ConstElementPtr &arguments, ConstElementPtr &response) |
| Handle lease6 related commands. | |
| bool | isPrefix (ConstElementPtr arguments) |
| Returns true if an element scope describes a prefix delegation. | |
Defines lease4_select and lease4_renew callout functions.
Definition in file command_callouts.cc.
| void addContext | ( | ostringstream & | os, |
| ConstElementPtr & | arguments ) |
Outputs text describing lease optional user context to a stream.
Looks for an user context or a comment and display it
| os | output stream to which the text is output |
| arguments | element scope which may contain user context or comment |
Definition at line 140 of file command_callouts.cc.
References isc::data::copy(), and Element::createMap().
Referenced by handleLease4Cmds(), and handleLease6Cmds().
| void addDuration | ( | CalloutHandle & | handle, |
| ostringstream & | os, | ||
| ConstElementPtr & | arguments ) |
Outputs text describing lease duration to a stream.
Looks for either a lease valid lifetime or expiry from which to generate the duration text using isc::dhcp::LegalLogMgr::genDurationString().
| handle | CalloutHandle which provides access to context. |
| os | output stream to which the text is output |
| arguments | element scope which may contain duration values |
Definition at line 119 of file command_callouts.cc.
References isc::dhcp::LegalLogMgr::genDurationString(), isc::hooks::CalloutHandle::getCurrentLibrary(), getOptionalInt(), and isc::dhcp::LegalLogMgrFactory::instance().
Referenced by handleLease4Cmds(), and handleLease6Cmds().
| bool checkLoggingEnabledSubnet4 | ( | ConstElementPtr & | arguments | ) |
Check if command has optional subnet-id parameter and if it does, check that the respective subnet has logging enabled.
| arguments | The command arguments. |
Definition at line 165 of file command_callouts.cc.
References isc::dhcp::CfgMgr::getCurrentCfg(), getOptionalInt(), isc::dhcp::CfgMgr::instance(), and isc::legal_log::isLoggingDisabled().
Referenced by handleLease4Cmds().
| bool checkLoggingEnabledSubnet6 | ( | ConstElementPtr & | arguments | ) |
Check if command has optional subnet-id parameter and if it does, check that the respective subnet has logging enabled.
| arguments | The command arguments. |
Definition at line 266 of file command_callouts.cc.
References isc::dhcp::CfgMgr::getCurrentCfg(), getOptionalInt(), isc::dhcp::CfgMgr::instance(), and isc::legal_log::isLoggingDisabled().
Referenced by handleLease6Cmds().
| int command_processed | ( | CalloutHandle & | handle | ) |
This callout is called at the "command_processed" hook point.
Generates an entry in the legal log for the given control channel command.
It is possible to disable logging for selected subnets by specifying a "legal-logging" boolean parameter within the subnet's user context. If this parameter is not specified it defaults to 'true', in which case the logging is performed. When this value is set to 'false' the log is not produced and the function returns.
| handle | CalloutHandle which provides access to context. |
Definition at line 487 of file command_callouts.cc.
References isc::hooks::CalloutHandle::getArgument(), isc::hooks::CalloutHandle::getCurrentLibrary(), isc::data::SimpleParser::getInteger(), handleLease4Cmds(), handleLease6Cmds(), isc::dhcp::LegalLogMgrFactory::instance(), LEGAL_LOG_COMMAND_NO_LEGAL_STORE, LEGAL_LOG_COMMAND_WRITE_ERROR, isc::legal_log::legal_log_logger, and LOG_ERROR.
| bool getOptionalInt | ( | ConstElementPtr & | arguments, |
| const string & | name, | ||
| int64_t & | value ) |
Fetch value for a integer element if it is an element scope.
Exception safe fetcher which looks for an integer element with the given name within an given element scope. Rather than throw if the element is not found, it returns true if found, false if not.
| arguments | element scope to search, assumed to be a map | |
| name | name of the desired element | |
| [out] | value | reference to an integer in which the found value is returned. Will be set to 0 if the element is not found. |
Definition at line 80 of file command_callouts.cc.
References isc::data::SimpleParser::getInteger().
Referenced by addDuration(), checkLoggingEnabledSubnet4(), and checkLoggingEnabledSubnet6().
| bool getOptionalString | ( | ConstElementPtr & | arguments, |
| const string & | name, | ||
| string & | value ) |
Fetch value for a string element if it is an element scope.
Exception safe fetcher which looks for a string element with the given name within an given element scope. Rather than throw if the element is not found, it returns true if found, false if not.
| arguments | element scope to search, assumed to be a map | |
| name | name of the desired element | |
| [out] | value | reference to a string in which the found value is returned. Will be set to "" if the element is not found. |
Definition at line 55 of file command_callouts.cc.
References isc::data::SimpleParser::getString().
Referenced by handleLease4Cmds(), handleLease6Cmds(), and isPrefix().
| int handleLease4Cmds | ( | CalloutHandle & | handle, |
| string & | name, | ||
| ConstElementPtr & | arguments, | ||
| ConstElementPtr & | ) |
Handle lease4 related commands.
| handle | CalloutHandle which provides access to context. |
| name | The command name. |
| arguments | The command arguments. |
| 4 | The command response. |
Definition at line 191 of file command_callouts.cc.
References addContext(), addDuration(), checkLoggingEnabledSubnet4(), isc::dhcp::ClientId::fromText(), isc::hooks::CalloutHandle::getCurrentLibrary(), getOptionalString(), isc::data::SimpleParser::getString(), isc::dhcp::LegalLogMgrFactory::instance(), isc::util::str::isPrintable(), LEGAL_LOG_COMMAND_NO_LEGAL_STORE, LEGAL_LOG_COMMAND_WRITE_ERROR, isc::legal_log::legal_log_logger, LOG_ERROR, and isc::dhcp::LegalLogMgr::vectorDump().
Referenced by command_processed().
| int handleLease6Cmds | ( | CalloutHandle & | handle, |
| string & | name, | ||
| ConstElementPtr & | arguments, | ||
| ConstElementPtr & | response ) |
Handle lease6 related commands.
| handle | CalloutHandle which provides access to context. |
| name | The command name. |
| arguments | The command arguments. |
| response | The command response. |
Definition at line 292 of file command_callouts.cc.
References addContext(), addDuration(), checkLoggingEnabledSubnet6(), isc::data::copy(), Element::create(), isc::hooks::CalloutHandle::getCurrentLibrary(), isc::data::SimpleParser::getInteger(), getOptionalString(), isc::data::SimpleParser::getString(), handleLease6Cmds(), isc::dhcp::LegalLogMgrFactory::instance(), isc_throw, isPrefix(), LEGAL_LOG_COMMAND_NO_LEGAL_STORE, LEGAL_LOG_COMMAND_WRITE_ERROR, isc::legal_log::legal_log_logger, Element::list, and LOG_ERROR.
Referenced by command_processed(), and handleLease6Cmds().
| bool isPrefix | ( | ConstElementPtr | arguments | ) |
Returns true if an element scope describes a prefix delegation.
Searches the given scope of an lease type element, "type". If it exists and it's value is "IA_PD" or "2" return true, false otherwise.
| arguments | element scope to search, assumed to be a map |
Definition at line 101 of file command_callouts.cc.
References getOptionalString().
Referenced by handleLease6Cmds().