42 const Lease4Ptr& lease, std::string& value) {
43 bool using_custom_format =
false;
46 auto expression = library->getRequestFormatExpression();
47 if (expression && query) {
49 using_custom_format =
true;
52 expression = library->getResponseFormatExpression();
53 if (expression && response) {
55 using_custom_format =
true;
57 }
catch (
const std::exception& ex) {
59 .arg(lease ? lease->addr_.toText() :
"<none>")
60 .arg(lease && lease->hwaddr_ ? lease->hwaddr_->toText() :
"<none>")
66 return (using_custom_format);
117 std::stringstream stream;
120 stream <<
"Address: " << lease->addr_ <<
" has been " <<
actionToVerb(action);
130 stream <<
" a device with hardware address: " << lease->hwaddr_->toText();
133 if (lease->client_id_) {
134 stream <<
", client-id: " << lease->client_id_->toText();
137 auto bin = lease->client_id_->getClientId();
147 stream <<
" connected via relay at address: " << giaddr.
toText();
153 std::stringstream idstream;
158 idstream <<
"circuit-id: " <<
dumpAsHex(
id);
171 if (!idstream.str().empty()) {
175 idstream <<
"remote-id: " <<
dumpAsHex(
id);
188 if (!idstream.str().empty()) {
192 idstream <<
"subscriber-id: " <<
dumpAsHex(
id);
200 if (!idstream.str().empty()) {
201 stream <<
", identified by " << idstream.str();
208 stream <<
", context: " << ctx->str();
211 return (stream.str());
259 lease->addr_.toText());
262 }
catch (
const std::exception& ex) {
310 handle.
getArgument(
"deleted_leases4", deleted_leases);
311 handle.
setContext(
"deleted_leases4", deleted_leases);
334 int result = current;
337 for (
auto const& lease : *leases) {
349 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
@ RAI_OPTION_SUBSCRIBER_ID
@ RAI_OPTION_AGENT_CIRCUIT_ID
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.
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.