40 const Lease4Ptr& lease, std::string& value) {
41 bool using_custom_format =
false;
44 auto expression = library->getRequestFormatExpression();
45 if (expression && query) {
47 using_custom_format =
true;
50 expression = library->getResponseFormatExpression();
51 if (expression && response) {
53 using_custom_format =
true;
55 }
catch (
const std::exception& ex) {
57 .arg(lease ? lease->addr_.toText() :
"<none>")
58 .arg(lease && lease->hwaddr_ ? lease->hwaddr_->toText() :
"<none>")
64 return (using_custom_format);
115 std::stringstream stream;
118 stream <<
"Address: " << lease->addr_ <<
" has been " <<
actionToVerb(action);
128 stream <<
" a device with hardware address: " << lease->hwaddr_->toText();
131 if (lease->client_id_) {
132 stream <<
", client-id: " << lease->client_id_->toText();
135 auto bin = lease->client_id_->getClientId();
145 stream <<
" connected via relay at address: " << giaddr.
toText();
151 std::stringstream idstream;
156 idstream <<
"circuit-id: " <<
dumpAsHex(
id);
169 if (!idstream.str().empty()) {
173 idstream <<
"remote-id: " <<
dumpAsHex(
id);
186 if (!idstream.str().empty()) {
190 idstream <<
"subscriber-id: " <<
dumpAsHex(
id);
198 if (!idstream.str().empty()) {
199 stream <<
", identified by " << idstream.str();
206 stream <<
", context: " << ctx->str();
209 return (stream.str());
257 lease->addr_.toText());
260 }
catch (
const std::exception& ex) {
308 handle.
getArgument(
"deleted_leases4", deleted_leases);
309 handle.
setContext(
"deleted_leases4", deleted_leases);
332 int result = current;
335 for (
auto const& lease : *leases) {
347 for (
auto const& lease : *leases) {
CalloutNextStep
Specifies allowed next steps.
@ NEXT_STEP_DROP
drop the packet
@ NEXT_STEP_SKIP
skip the next processing step
The IOAddress class represents an IP addresses (version agnostic).
bool isV4Zero() const
Convenience function to check if it is an IPv4 zero address.
std::string toText() const
Convert the address to a string.
static CfgMgr & instance()
returns a single instance of Configuration Manager
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
static LegalLogMgrPtr & instance(ManagerID id=0)
Returns the forensic backend manager with specified ID.
static std::string genDurationString(const uint32_t secs)
Translates seconds into a text string of days, hours, minutes and seconds.
static std::string vectorDump(const std::vector< uint8_t > &bytes)
Creates a string from a vector of printable bytes.
Per-packet callout handle.
void getContext(const std::string &name, T &value) const
Get context.
void setContext(const std::string &name, T value)
Set context.
CalloutNextStep getStatus() const
Returns the next processing step.
void getArgument(const std::string &name, T &value) const
Get argument.
int getCurrentLibrary() const
Get current library index.
void setArgument(const std::string &name, T value)
Set argument.
int lease4_release(CalloutHandle &handle)
This callout is called at the "lease4_release" hook.
int lease4_decline(CalloutHandle &handle)
This callout is called at the "lease4_decline" hook.
int leases4_committed(CalloutHandle &handle)
This callout is called at the "leases4_committed" 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.
bool getCustomEntry(CalloutHandle &handle, const Pkt4Ptr &query, const Pkt4Ptr &response, const Lease4Ptr &lease, std::string &value)
Create custom log entry for the current lease.
int pkt4_send(CalloutHandle &handle)
This callout is called at the "pkt4_send" hook.
int pkt4_receive(CalloutHandle &handle)
This callout is called at the "pkt4_receive" hook.
int legalLog4Handler(CalloutHandle &handle, const Action &action)
Produces an DHCPv4 legal log entry from a callout handle.
const isc::log::MessageID LEGAL_LOG_LEASE4_RENDER_ERROR
const isc::log::MessageID LEGAL_LOG_LEASE4_NO_LEGAL_STORE
const isc::log::MessageID LEGAL_LOG_LEASE4_WRITE_ERROR
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Lease4Collection > Lease4CollectionPtr
A shared pointer to the collection of IPv4 leases.
boost::shared_ptr< const Subnet4 > ConstSubnet4Ptr
A const pointer to a Subnet4 object.
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
std::string evaluateString(const Expression &expr, Pkt &pkt)
Evaluate a RPN expression for a v4 or v6 packet and return a string value.
const string actionToVerb(Action action)
Translates an Action into its corresponding verb.
boost::shared_ptr< const CfgSubnets4 > ConstCfgSubnets4Ptr
Const pointer.
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
@ RAI_OPTION_SUBSCRIBER_ID
@ RAI_OPTION_AGENT_CIRCUIT_ID
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
boost::shared_ptr< Option > OptionPtr
Action
Describe what kind of event is being logged.
isc::log::Logger legal_log_logger("legal-log-hooks")
Legal Log Logger.
bool isLoggingDisabled(const SubnetPtrType &subnet)
Checks if legal logging is disabled for a subnet.
string dumpAsHex(const uint8_t *data, size_t length)
Dumps a buffer of bytes as a string of hexadecimal digits.
bool isPrintable(const string &content)
Check if a string is printable.
Defines the logger used by the top-level component of kea-lfc.