45 return (
"Raw Socket");
51 return (
"IPv6 Link Local");
54 return (
"Client Address Relay Option");
60 return (
"Subscriber ID");
63 return (
"DOCSIS CMTS");
66 return (
"DOCSIS MODEM");
76 std::stringstream stream;
78 stream << lease->addr_;
80 stream <<
"/" <<
static_cast<int>(lease->prefixlen_);
83 return (stream.str());
113 Pkt6* pkt6 =
dynamic_cast<Pkt6*
>(&pkt);
118 auto const& ia = boost::dynamic_pointer_cast<Option6IA>(it.second);
119 if (ia && ia->getIAID() == lease_->iaid_) {
121 for (
auto const& opt_it : opts) {
126 boost::dynamic_pointer_cast<Option6IAAddr>(opt_it.second);
130 if (iaaddr->getAddress() == lease_->addr_) {
132 ia_na->addOption(iaaddr);
133 for (
auto const& other_opt_it : opts) {
134 if (other_opt_it.second->getType() ==
D6O_IAADDR ||
138 ia_na->addOption(other_opt_it.second);
265 Pkt6* pkt6 =
dynamic_cast<Pkt6*
>(&pkt);
270 auto const& ia = boost::dynamic_pointer_cast<Option6IA>(it.second);
271 if (ia && ia->getIAID() == lease_->iaid_) {
273 for (
auto const& opt_it : opts) {
278 boost::dynamic_pointer_cast<Option6IAPrefix>(opt_it.second);
282 if ((iaprefix->getAddress() == lease_->addr_) &&
283 (iaprefix->getLength() == lease_->prefixlen_)) {
285 ia_pd->addOption(iaprefix);
286 for (
auto const& other_opt_it : opts) {
287 if (other_opt_it.second->getType() ==
D6O_IAADDR ||
291 ia_pd->addOption(other_opt_it.second);
405 for (
size_t i = 0; i < expression.size(); ++i) {
406 boost::shared_ptr<TokenOption> option = boost::dynamic_pointer_cast<TokenOption>(expression[i]);
408 if (option->getOptions()[0] ==
D6O_IA_NA) {
409 if (option->getOptions().size() == 2U && option->getOptions()[1] ==
D6O_IAADDR) {
411 }
else if (option->getOptions().size() == 1U) {
416 if (option->getOptions()[0] ==
D6O_IA_PD) {
417 if (option->getOptions().size() == 2U && option->getOptions()[1] ==
D6O_IAPREFIX) {
419 }
else if (option->getOptions().size() == 1U) {
436 for (
size_t i = 0; i < expression.size(); ++i) {
437 boost::shared_ptr<TokenOption> option = boost::dynamic_pointer_cast<TokenOption>(expression[i]);
439 if (option->getOptions()[0] ==
D6O_IA_NA) {
440 if (option->getOptions().size() == 2U && option->getOptions()[1] ==
D6O_IAADDR) {
442 }
else if (option->getOptions().size() == 1U) {
447 if (option->getOptions()[0] ==
D6O_IA_PD) {
448 if (option->getOptions().size() == 2U && option->getOptions()[1] ==
D6O_IAPREFIX) {
450 }
else if (option->getOptions().size() == 1U) {
486 const Lease6Ptr& lease, std::string& value) {
487 bool using_custom_format =
false;
490 auto expression = library->getRequestFormatExpression();
491 if (expression && query) {
495 using_custom_format =
true;
498 expression = library->getResponseFormatExpression();
499 if (expression && response) {
503 using_custom_format =
true;
505 }
catch (
const std::exception& ex) {
507 .arg(lease ? lease->addr_.toText() :
"<none>")
508 .arg(lease && lease->duid_ ? lease->duid_->toText() :
"<none>")
514 return (using_custom_format);
564 std::stringstream stream;
568 stream <<
"Address: " << lease->addr_;
570 stream <<
"Prefix: " << lease->addr_ <<
"/" <<
static_cast<int>(lease->prefixlen_);
583 stream <<
" a device with DUID: " << lease->duid_->toText();
585 if (lease->hwaddr_) {
586 stream <<
" and hardware address: " << lease->hwaddr_->toText()
591 if (query->relay_info_.size()) {
593 stream <<
" connected via relay at address: " << server_relay.
peeraddr_.
toText()
595 <<
", hop count: " <<
static_cast<int>(server_relay.
hop_count_);
597 std::ostringstream idstream;
604 idstream <<
"remote-id: " <<
dumpAsHex(
id);
618 if (!idstream.str().empty()) {
622 idstream <<
"subscriber-id: " <<
dumpAsHex(
id);
630 if (!idstream.str().empty()) {
631 stream <<
", identified by " << idstream.str();
635 std::ostringstream location;
641 if (!idstream.str().empty()) {
645 location <<
"interface-id: " <<
dumpAsHex(
id);
653 if (!location.str().empty()) {
654 stream <<
", connected at location " << location.str();
661 stream <<
", context: " << ctx->str();
664 return (stream.str());
714 }
catch (
const std::exception& ex) {
762 handle.
getArgument(
"deleted_leases6", deleted_leases);
763 handle.
setContext(
"deleted_leases6", deleted_leases);
786 int result = current;
789 for (
auto const& lease : *leases) {
801 for (
auto const& lease : *leases) {
835 deleted_leases->push_back(lease);
836 handle.
setContext(
"deleted_leases6", deleted_leases);
863 deleted_leases->push_back(lease);
864 handle.
setContext(
"deleted_leases6", deleted_leases);
CalloutNextStep
Specifies allowed next steps.
@ NEXT_STEP_DROP
drop the packet
@ NEXT_STEP_SKIP
skip the next processing step
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.
EvalTypeError is thrown when a value on the stack has a content with an unexpected type.
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.
Represents a DHCPv6 packet.
@ RELAY_SEARCH_FROM_CLIENT
Base class for classes representing DHCP messages.
isc::dhcp::OptionCollection getOptions(const uint16_t type)
Returns all instances of specified type.
Filter all IA_NA so that no sub-option is matched by the expression.
unsigned evaluate(Pkt &pkt, ValueStack &values)
Evaluate the expression using the TokenOption implementation.
TokenFilterIA_NASuboption(const RepresentationType &rep_type)
Constructor.
virtual OptionPtr getOption(Pkt &pkt)
Get no option regardless of what the packet contains.
Filter all IA_NA so that no option is matched by the expression.
virtual OptionPtr getOption(Pkt &)
Get no option regardless of what the packet contains.
TokenFilterIA_NA(const RepresentationType &rep_type)
Constructor.
Filter all IA_PD so that no sub-option is matched by the expression.
TokenFilterIA_PDSuboption(const RepresentationType &rep_type)
Constructor.
virtual OptionPtr getOption(Pkt &pkt)
Get no option regardless of what the packet contains.
unsigned evaluate(Pkt &pkt, ValueStack &values)
Evaluate the expression using the TokenOption implementation.
Filter all IA_PD so that no option is matched by the expression.
virtual OptionPtr getOption(Pkt &)
Get no option regardless of what the packet contains.
TokenFilterIA_PD(const RepresentationType &rep_type)
Constructor.
Filter the IA_NA (3) option containing the OPTION_IAADDR (5) option matching the respective lease.
unsigned evaluate(Pkt &pkt, ValueStack &values)
Evaluate the expression using the TokenOption implementation.
TokenLeaseIA_NASuboption(const Lease6Ptr &lease, const RepresentationType &rep_type)
Constructor.
virtual OptionPtr getOption(Pkt &pkt)
Get the IA_NA (3) option containing the OPTION_IAADDR (5) option matching the respective lease.
Filter the IA_NA (3) option containing the OPTION_IAADDR (5) option matching the respective lease.
virtual OptionPtr getOption(Pkt &pkt)
Get the IA_NA (3) option containing the OPTION_IAADDR (5) option matching the respective lease.
TokenLeaseIA_NA(const Lease6Ptr &lease, const RepresentationType &rep_type)
Constructor.
Filter the IA_PD (25) option containing the OPTION_IAPREFIX (25) option matching the respective lease...
TokenLeaseIA_PDSuboption(const Lease6Ptr &lease, const RepresentationType &rep_type)
Constructor.
unsigned evaluate(Pkt &pkt, ValueStack &values)
Evaluate the expression using the TokenOption implementation.
virtual OptionPtr getOption(Pkt &pkt)
Get the IA_PD (25) option containing the OPTION_IAPREFIX (25) option matching the respective lease.
Filter the IA_PD (25) option containing the OPTION_IAPREFIX (25) option matching the respective lease...
virtual OptionPtr getOption(Pkt &pkt)
Get the IA_PD (25) option containing the OPTION_IAPREFIX (25) option matching the respective lease.
TokenLeaseIA_PD(const Lease6Ptr &lease, const RepresentationType &rep_type)
Constructor.
Token that represents a value of an option.
TokenOption(const std::vector< uint16_t > &option_codes, const RepresentationType &rep_type)
Constructor that takes an option code as a parameter.
RepresentationType
Token representation type.
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Evaluates the values of the option.
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.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
static const uint32_t HWADDR_SOURCE_RAW
Obtained first hand from raw socket (100% reliable).
static const uint32_t HWADDR_SOURCE_REMOTE_ID
A relay can insert remote-id.
static const uint32_t HWADDR_SOURCE_CLIENT_ADDR_RELAY_OPTION
Get it from RFC6939 option.
static const uint32_t HWADDR_SOURCE_IPV6_LINK_LOCAL
Extracted from IPv6 link-local address.
static const uint32_t HWADDR_SOURCE_DOCSIS_MODEM
A cable modem (acting as DHCP client) that supports DOCSIS standard can insert DOCSIS options that co...
static const uint32_t HWADDR_SOURCE_DUID
Extracted from DUID-LL or DUID-LLT (not 100% reliable as the client can send fake DUID).
static const uint32_t HWADDR_SOURCE_DOCSIS_CMTS
A CMTS (acting as DHCP relay agent) that supports DOCSIS standard can insert DOCSIS options that cont...
static const uint32_t HWADDR_SOURCE_SUBSCRIBER_ID
A relay can insert a subscriber-id option.
void replaceTokensForLease(isc::dhcp::ExpressionPtr &expression, const Lease6Ptr &lease)
Replace TokenOption expression tokens for all IA_NA and IA_PD options and sub-options filtering by th...
int leases6_committed(CalloutHandle &handle)
This callout is called at the "leases6_committed" hook.
void filterLeaseIA_NA(isc::dhcp::Expression &expression, const Lease6Ptr &lease)
Replace TokenOption expression tokens with the IA_NA (3) option containing the OPTION_IAADDR (5) opti...
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.
int lease6_release(CalloutHandle &handle)
This callout is called at the "lease6_release" hook.
void filterLeaseIA_PD(isc::dhcp::Expression &expression, const Lease6Ptr &lease)
Replace TokenOption expression tokens with the IA_PD (25) option containing the OPTION_IAPREFIX (25) ...
std::string genLease6Addr(const Lease6Ptr &lease)
Creates legal store address column for a DHCPv6 Lease.
int pkt6_send(CalloutHandle &handle)
This callout is called at the "pkt6_send" hook.
std::string hwaddrSourceToString(uint32_t source)
Function which converts hardware address source to a string.
int pkt6_receive(CalloutHandle &handle)
This callout is called at the "pkt6_receive" hook.
bool getCustomEntry(CalloutHandle &handle, const Pkt6Ptr &query, const Pkt6Ptr &response, const Lease6Ptr &lease, std::string &value)
Create custom log entry for the current lease.
int legalLog6Handler(CalloutHandle &handle, const Action &action)
Produces an DHCPv6 legal log entry from a callout handle.
int lease6_decline(CalloutHandle &handle)
This callout is called at the "lease6_decline" hook.
const isc::log::MessageID LEGAL_LOG_LEASE6_NO_LEGAL_STORE
const isc::log::MessageID LEGAL_LOG_LEASE6_RENDER_ERROR
const isc::log::MessageID LEGAL_LOG_LEASE6_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< Token > TokenPtr
Pointer to a single Token.
boost::shared_ptr< const Subnet6 > ConstSubnet6Ptr
A const pointer to a Subnet6 object.
boost::shared_ptr< Lease6 > Lease6Ptr
Pointer to a Lease6 structure.
std::vector< Lease6Ptr > Lease6Collection
A collection of IPv6 leases.
std::multimap< unsigned int, OptionPtr > OptionCollection
A collection of DHCP (v4 or v6) options.
std::string evaluateString(const Expression &expr, Pkt &pkt)
Evaluate a RPN expression for a v4 or v6 packet and return a string value.
boost::shared_ptr< Option6IAPrefix > Option6IAPrefixPtr
Pointer to the Option6IAPrefix object.
const string actionToVerb(Action action)
Translates an Action into its corresponding verb.
boost::shared_ptr< Expression > ExpressionPtr
boost::shared_ptr< Option6IAAddr > Option6IAAddrPtr
A pointer to the isc::dhcp::Option6IAAddr object.
boost::shared_ptr< const CfgSubnets6 > ConstCfgSubnets6Ptr
Const pointer.
boost::shared_ptr< Lease6Collection > Lease6CollectionPtr
A shared pointer to the collection of IPv6 leases.
boost::shared_ptr< Pkt6 > Pkt6Ptr
A pointer to Pkt6 packet.
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
std::vector< TokenPtr > Expression
This is a structure that holds an expression converted to RPN.
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
boost::shared_ptr< Option > OptionPtr
Action
Describe what kind of event is being logged.
std::stack< std::string > ValueStack
Evaluated values are stored as a stack of strings.
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.
@ TYPE_PD
the lease contains IPv6 prefix (for prefix delegation)
@ TYPE_NA
the lease contains non-temporary IPv6 address
structure that describes a single relay information
isc::asiolink::IOAddress linkaddr_
fixed field in relay-forw/relay-reply
uint8_t hop_count_
number of traversed relays (up to 32)
isc::asiolink::IOAddress peeraddr_
fixed field in relay-forw/relay-reply