![]() |
Kea 3.0.0
|
#include <config.h>
#include <asiolink/asio_wrapper.h>
#include <cc/data.h>
#include <dhcp/dhcp6.h>
#include <dhcp/option_custom.h>
#include <dhcp/option6_ia.h>
#include <dhcp/option6_iaaddr.h>
#include <dhcp/option6_iaprefix.h>
#include <dhcp/pkt6.h>
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/cfg_subnets6.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.
Classes | |
class | isc::dhcp::TokenFilterIA_NA |
Filter all IA_NA so that no option is matched by the expression. More... | |
class | isc::dhcp::TokenFilterIA_NASuboption |
Filter all IA_NA so that no sub-option is matched by the expression. More... | |
class | isc::dhcp::TokenFilterIA_PD |
Filter all IA_PD so that no option is matched by the expression. More... | |
class | isc::dhcp::TokenFilterIA_PDSuboption |
Filter all IA_PD so that no sub-option is matched by the expression. More... | |
class | isc::dhcp::TokenLeaseIA_NA |
Filter the IA_NA (3) option containing the OPTION_IAADDR (5) option matching the respective lease. More... | |
class | isc::dhcp::TokenLeaseIA_NASuboption |
Filter the IA_NA (3) option containing the OPTION_IAADDR (5) option matching the respective lease. More... | |
class | isc::dhcp::TokenLeaseIA_PD |
Filter the IA_PD (25) option containing the OPTION_IAPREFIX (25) option matching the respective lease. More... | |
class | isc::dhcp::TokenLeaseIA_PDSuboption |
Filter the IA_PD (25) option containing the OPTION_IAPREFIX (25) option matching the respective lease. More... |
Namespaces | |
namespace | isc |
Defines the logger used by the top-level component of kea-lfc. | |
namespace | isc::dhcp |
Functions | |
void | filterLeaseIA_NA (isc::dhcp::Expression &expression, const Lease6Ptr &lease) |
Replace TokenOption and TokenSubOption expression tokens with the IA_NA (3) option containing the OPTION_IAADDR (5) option matching the respective lease. | |
void | filterLeaseIA_PD (isc::dhcp::Expression &expression, const Lease6Ptr &lease) |
Replace TokenOption and TokenSubOption expression tokens with the IA_PD (25) option containing the OPTION_IAPREFIX (25) option matching the respective lease. | |
std::string | genLease6Addr (const Lease6Ptr &lease) |
Creates legal store address column for a DHCPv6 Lease. | |
std::string | genLease6Entry (CalloutHandle &handle, const Pkt6Ptr &query, const Pkt6Ptr &response, const Lease6Ptr &lease, const Action &action) |
Creates legal store entry for a DHCPv6 Lease. | |
bool | getCustomEntry (CalloutHandle &handle, const Pkt6Ptr &query, const Pkt6Ptr &response, const Lease6Ptr &lease, std::string &value) |
Create custom log entry for the current lease. | |
std::string | hwaddrSourceToString (uint32_t source) |
Function which converts hardware address source to a string. | |
int | lease6_decline (CalloutHandle &handle) |
This callout is called at the "lease6_decline" hook. | |
int | lease6_release (CalloutHandle &handle) |
This callout is called at the "lease6_release" hook. | |
int | leases6_committed (CalloutHandle &handle) |
This callout is called at the "leases6_committed" hook. | |
int | legalLog6Handler (CalloutHandle &handle, const Action &action) |
Produces an DHCPv6 legal log entry from a callout handle. | |
int | pkt6_receive (CalloutHandle &handle) |
This callout is called at the "pkt6_receive" hook. | |
int | pkt6_send (CalloutHandle &handle) |
This callout is called at the "pkt6_send" hook. | |
void | replaceTokensForLease (isc::dhcp::ExpressionPtr &expression, const Lease6Ptr &lease) |
Replace TokenOption and TokenSubOption expression tokens for all IA_NA and IA_PD options and sub-options filtering by the current lease. |
void filterLeaseIA_NA | ( | isc::dhcp::Expression & | expression, |
const Lease6Ptr & | lease ) |
Replace TokenOption and TokenSubOption expression tokens with the IA_NA (3) option containing the OPTION_IAADDR (5) option matching the respective lease.
expression | The expression that needs to be updated with filtering tokens. |
lease | The lease used to match any OPTION_IAADDR option in the IA_NA packet options. |
Definition at line 394 of file lease6_callouts.cc.
References D6O_IA_NA, D6O_IA_PD, D6O_IAADDR, and D6O_IAPREFIX.
Referenced by replaceTokensForLease().
void filterLeaseIA_PD | ( | isc::dhcp::Expression & | expression, |
const Lease6Ptr & | lease ) |
Replace TokenOption and TokenSubOption expression tokens with the IA_PD (25) option containing the OPTION_IAPREFIX (25) option matching the respective lease.
expression | The expression that needs to be updated with filtering tokens. |
lease | The lease used to match any OPTION_IAPREFIX option in the IA_PD packet options. |
Definition at line 429 of file lease6_callouts.cc.
References D6O_IA_NA, D6O_IA_PD, D6O_IAADDR, and D6O_IAPREFIX.
Referenced by replaceTokensForLease().
std::string genLease6Addr | ( | const Lease6Ptr & | lease | ) |
Creates legal store address column for a DHCPv6 Lease.
lease | DHCPv6 lease for which the entry should be created |
Definition at line 72 of file lease6_callouts.cc.
References isc::dhcp::Lease::TYPE_PD.
Referenced by legalLog6Handler().
std::string genLease6Entry | ( | CalloutHandle & | handle, |
const Pkt6Ptr & | query, | ||
const Pkt6Ptr & | response, | ||
const Lease6Ptr & | lease, | ||
const Action & | action ) |
Creates legal store entry for a DHCPv6 Lease.
Creates an entry based on the given DHCPv6 queries and corresponding DHCPv6 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>{relay-info}*{user-context}*"
Where:
For example (on multiple lines for readibility):
handle | CalloutHandle which provides access to context. |
query | DHCPv6 query packet for which the lease was generated |
response | DHCPv6 response packet |
lease | DHCPv6 lease for which the entry should be created |
action | Kind of event to log. |
Definition at line 541 of file lease6_callouts.cc.
References isc::dhcp::actionToVerb(), D6O_INTERFACE_ID, D6O_REMOTE_ID, D6O_SUBSCRIBER_ID, isc::dhcp::LegalLogMgr::genDurationString(), getCustomEntry(), isc::dhcp::Pkt6::RelayInfo::hop_count_, hwaddrSourceToString(), isc::util::str::isPrintable(), isc::dhcp::Pkt6::RelayInfo::linkaddr_, isc::dhcp::Pkt6::RelayInfo::peeraddr_, isc::dhcp::Pkt6::RELAY_SEARCH_FROM_CLIENT, isc::dhcp::RELEASE, isc::asiolink::IOAddress::toText(), isc::dhcp::Lease::TYPE_PD, isc::dhcp::LegalLogMgr::vectorDump(), and isc::dhcp::LegalLogMgr::vectorHexDump().
Referenced by legalLog6Handler().
bool getCustomEntry | ( | CalloutHandle & | handle, |
const Pkt6Ptr & | query, | ||
const Pkt6Ptr & | response, | ||
const Lease6Ptr & | lease, | ||
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 483 of file lease6_callouts.cc.
References isc::dhcp::evaluateString(), isc::hooks::CalloutHandle::getCurrentLibrary(), isc::dhcp::LegalLogMgrFactory::instance(), and replaceTokensForLease().
Referenced by genLease6Entry().
std::string hwaddrSourceToString | ( | uint32_t | source | ) |
Function which converts hardware address source to a string.
source | integer value to convert |
Definition at line 40 of file lease6_callouts.cc.
References isc::dhcp::HWAddr::HWADDR_SOURCE_CLIENT_ADDR_RELAY_OPTION, isc::dhcp::HWAddr::HWADDR_SOURCE_DOCSIS_CMTS, isc::dhcp::HWAddr::HWADDR_SOURCE_DOCSIS_MODEM, isc::dhcp::HWAddr::HWADDR_SOURCE_DUID, isc::dhcp::HWAddr::HWADDR_SOURCE_IPV6_LINK_LOCAL, isc::dhcp::HWAddr::HWADDR_SOURCE_RAW, isc::dhcp::HWAddr::HWADDR_SOURCE_REMOTE_ID, and isc::dhcp::HWAddr::HWADDR_SOURCE_SUBSCRIBER_ID.
Referenced by genLease6Entry().
int lease6_decline | ( | CalloutHandle & | handle | ) |
This callout is called at the "lease6_decline" hook.
Generates an entry in the legal log for a lease decline if the callout context values "leases6" and "deleted_leases6" are not empty.
handle | CalloutHandle which provides access to context. |
Definition at line 836 of file lease6_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 lease6_release | ( | CalloutHandle & | handle | ) |
This callout is called at the "lease6_release" hook.
Generates an entry in the legal log for a lease release if the callout context values "leases6" and "deleted_leases6" are not empty.
handle | CalloutHandle which provides access to context. |
Definition at line 808 of file lease6_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 leases6_committed | ( | CalloutHandle & | handle | ) |
This callout is called at the "leases6_committed" hook.
Stores the leases so that the logging option stored on the subnet context can be available on pkt6_send hook.
handle | CalloutHandle which provides access to context. |
Definition at line 737 of file lease6_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 legalLog6Handler | ( | CalloutHandle & | handle, |
const Action & | action ) |
Produces an DHCPv6 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 671 of file lease6_callouts.cc.
References genLease6Addr(), genLease6Entry(), 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_LEASE6_NO_LEGAL_STORE, LEGAL_LOG_LEASE6_WRITE_ERROR, isc::legal_log::legal_log_logger, and LOG_ERROR.
Referenced by pkt6_send().
int pkt6_receive | ( | CalloutHandle & | handle | ) |
This callout is called at the "pkt6_receive" hook.
Creates context with empty "lease6" value.
handle | CalloutHandle which provides access to context. |
Definition at line 722 of file lease6_callouts.cc.
References isc::hooks::CalloutHandle::setContext().
int pkt6_send | ( | CalloutHandle & | handle | ) |
This callout is called at the "pkt6_send" hook.
Generates an entry in the legal log for a lease renewal if the callout context values "leases6" and "deleted_leases6" are not empty.
handle | CalloutHandle which provides access to context. |
Definition at line 762 of file lease6_callouts.cc.
References isc::dhcp::ASSIGN, isc::hooks::CalloutHandle::getContext(), isc::hooks::CalloutHandle::getStatus(), legalLog6Handler(), CalloutHandle::NEXT_STEP_DROP, CalloutHandle::NEXT_STEP_SKIP, isc::dhcp::RELEASE, and isc::hooks::CalloutHandle::setContext().
void replaceTokensForLease | ( | isc::dhcp::ExpressionPtr & | expression, |
const Lease6Ptr & | lease ) |
Replace TokenOption and TokenSubOption expression tokens for all IA_NA and IA_PD options and sub-options filtering by the current lease.
expression | The expression which is updated to contain only TokenOption and TokenSubOption expression tokens for IA_NA or IA_PD which have an OPTION_IAADDR or an OPTION_IAPREFIX that matches the respective lease. |
lease | The lease used to match any OPTION_IAADDR or OPTION_IAPREFIX option in the packet. |
Definition at line 465 of file lease6_callouts.cc.
References filterLeaseIA_NA(), filterLeaseIA_PD(), isc::dhcp::Lease::TYPE_NA, and isc::dhcp::Lease::TYPE_PD.
Referenced by getCustomEntry().