![]() |
Kea 3.1.1
|
#include <config.h>
#include <asiolink/asio_wrapper.h>
#include <cc/data.h>
#include <dhcp/pkt4.h>
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/cfg_subnets4.h>
#include <dhcpsrv/lease.h>
#include <eval/evaluate.h>
#include <hooks/hooks.h>
#include <util/str.h>
#include <legal_log_log.h>
#include <dhcpsrv/legal_log_mgr_factory.h>
#include <subnets_user_context.h>
#include <sstream>
Go to the source code of this file.
Functions | |
std::string | genLease4Entry (CalloutHandle &handle, const Pkt4Ptr &query, const Pkt4Ptr &response, const Lease4Ptr &lease, const Action &action) |
Creates legal store entry for a DHCPv4 Lease. | |
bool | getCustomEntry (CalloutHandle &handle, const Pkt4Ptr &query, const Pkt4Ptr &response, const Lease4Ptr &, std::string &value) |
Create custom log entry for the current lease. | |
int | lease4_decline (CalloutHandle &handle) |
This callout is called at the "lease4_decline" hook. | |
int | lease4_release (CalloutHandle &handle) |
This callout is called at the "lease4_release" hook. | |
int | leases4_committed (CalloutHandle &handle) |
This callout is called at the "leases4_committed" hook. | |
int | legalLog4Handler (CalloutHandle &handle, const Action &action) |
Produces an DHCPv4 legal log entry from a callout handle. | |
int | pkt4_receive (CalloutHandle &handle) |
This callout is called at the "pkt4_receive" hook. | |
int | pkt4_send (CalloutHandle &handle) |
This callout is called at the "pkt4_send" hook. | |
std::string genLease4Entry | ( | CalloutHandle & | handle, |
const Pkt4Ptr & | query, | ||
const Pkt4Ptr & | response, | ||
const Lease4Ptr & | lease, | ||
const Action & | action ) |
Creates legal store entry for a DHCPv4 Lease.
Creates an entry based on the given DHCPREQUEST and corresponding DHCPv4 lease. The entry is returned as a single string with no embedded EOL markers, a prepended timestamp and has the following sections:
"<timestamp><address><duration><device-id>{client-info}{relay-info}{user-context}"
Where:
For example (on multiple lines for readibility):
handle | CalloutHandle which provides access to context. |
query | DHCPv4 query packet for which the lease was generated |
response | DHCPv4 response packet |
lease | DHCPv4 lease for which the entry should be created |
action | Kind of event to log. |
Definition at line 93 of file lease4_callouts.cc.
References isc::dhcp::actionToVerb(), isc::dhcp::DHO_DHCP_AGENT_OPTIONS, isc::dhcp::LegalLogMgr::genDurationString(), getCustomEntry(), isc::util::str::isPrintable(), isc::asiolink::IOAddress::isV4Zero(), isc::dhcp::RAI_OPTION_AGENT_CIRCUIT_ID, isc::dhcp::RAI_OPTION_REMOTE_ID, isc::dhcp::RAI_OPTION_SUBSCRIBER_ID, isc::dhcp::RELEASE, isc::asiolink::IOAddress::toText(), isc::dhcp::LegalLogMgr::vectorDump(), and isc::dhcp::LegalLogMgr::vectorHexDump().
Referenced by legalLog4Handler().
bool getCustomEntry | ( | CalloutHandle & | handle, |
const Pkt4Ptr & | query, | ||
const Pkt4Ptr & | response, | ||
const Lease4Ptr & | , | ||
std::string & | value ) |
Create custom log entry for the current lease.
handle | CalloutHandle which provides access to context. | |
query | The query received by the server. | |
response | The response of the server. | |
lease | The current lease generating this log entry. | |
[out] | value | The value of the custom log entry after parser execution. |
Definition at line 38 of file lease4_callouts.cc.
References isc::dhcp::evaluateString(), isc::hooks::CalloutHandle::getCurrentLibrary(), and isc::dhcp::LegalLogMgrFactory::instance().
Referenced by genLease4Entry().
int lease4_decline | ( | CalloutHandle & | handle | ) |
This callout is called at the "lease4_decline" hook.
Generates an entry in the legal log for a lease decline if the callout context value "lease4" is not an empty pointer.
handle | CalloutHandle which provides access to context. |
Definition at line 380 of file lease4_callouts.cc.
References isc::hooks::CalloutHandle::getArgument(), isc::hooks::CalloutHandle::getStatus(), legalLog4Handler(), CalloutHandle::NEXT_STEP_DROP, CalloutHandle::NEXT_STEP_SKIP, isc::dhcp::RELEASE, isc::hooks::CalloutHandle::setArgument(), and isc::hooks::CalloutHandle::setContext().
int lease4_release | ( | CalloutHandle & | handle | ) |
This callout is called at the "lease4_release" hook.
Generates an entry in the legal log for a lease release if the callout context value "lease4" is not an empty pointer.
handle | CalloutHandle which provides access to context. |
Definition at line 355 of file lease4_callouts.cc.
References isc::hooks::CalloutHandle::getArgument(), isc::hooks::CalloutHandle::getStatus(), legalLog4Handler(), CalloutHandle::NEXT_STEP_DROP, CalloutHandle::NEXT_STEP_SKIP, isc::dhcp::RELEASE, isc::hooks::CalloutHandle::setArgument(), and isc::hooks::CalloutHandle::setContext().
int leases4_committed | ( | CalloutHandle & | handle | ) |
This callout is called at the "leases4_committed" hook.
Stores the leases so that the logging option stored on the subnet context can be available on pkt4_send hook.
handle | CalloutHandle which provides access to context. |
Definition at line 284 of file lease4_callouts.cc.
References isc::hooks::CalloutHandle::getArgument(), isc::hooks::CalloutHandle::getStatus(), CalloutHandle::NEXT_STEP_DROP, CalloutHandle::NEXT_STEP_SKIP, and isc::hooks::CalloutHandle::setContext().
int legalLog4Handler | ( | CalloutHandle & | handle, |
const Action & | action ) |
Produces an DHCPv4 legal log entry from a callout handle.
Extracts the inbound packet and lease from the Callout, generates the log entry text and writes it to the legal store. If the the legal store has not been instantiated or writing to it fails, the function log the error and return failure.
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. |
action | Kind of event to log. |
Definition at line 217 of file lease4_callouts.cc.
References genLease4Entry(), isc::hooks::CalloutHandle::getArgument(), isc::hooks::CalloutHandle::getContext(), isc::dhcp::CfgMgr::getCurrentCfg(), isc::hooks::CalloutHandle::getCurrentLibrary(), isc::dhcp::CfgMgr::instance(), isc::dhcp::LegalLogMgrFactory::instance(), isc::legal_log::isLoggingDisabled(), LEGAL_LOG_LEASE4_NO_LEGAL_STORE, LEGAL_LOG_LEASE4_WRITE_ERROR, isc::legal_log::legal_log_logger, and LOG_ERROR.
Referenced by lease4_decline(), lease4_release(), and pkt4_send().
int pkt4_receive | ( | CalloutHandle & | handle | ) |
This callout is called at the "pkt4_receive" hook.
Creates context with empty "lease4" value.
handle | CalloutHandle which provides access to context. |
Definition at line 269 of file lease4_callouts.cc.
References isc::hooks::CalloutHandle::setContext().
int pkt4_send | ( | CalloutHandle & | handle | ) |
This callout is called at the "pkt4_send" hook.
Generates an entry in the legal log for a lease renewal if the callout context values "leases4" and "deleted_leases4" are not empty.
handle | CalloutHandle which provides access to context. |
Definition at line 309 of file lease4_callouts.cc.
References isc::dhcp::ASSIGN, isc::hooks::CalloutHandle::getContext(), isc::hooks::CalloutHandle::getStatus(), legalLog4Handler(), CalloutHandle::NEXT_STEP_DROP, CalloutHandle::NEXT_STEP_SKIP, isc::dhcp::RELEASE, and isc::hooks::CalloutHandle::setContext().