25#include <unordered_set> 
  102        return (type_str == 
"IA_PD" || type_str == 
"2");
 
 
  119    int64_t duration = 0;
 
 
  145            copied = 
copy(ctx, 0);
 
  149        copied->set(
"comment", comment);
 
  153        os << 
", context: " << ctx->str();
 
 
  167    int64_t subnet_id_value = 0;
 
  168    if (
getOptionalInt(arguments, 
"subnet-id", subnet_id_value) && (subnet_id_value > 0)) {
 
 
  204        if (origin == 
"ha-partner") {
 
  207            os << 
"Administrator";
 
  209        if ((name == 
"lease4-add") || name == 
"lease4-update") {
 
  210            if (name == 
"lease4-add") {
 
  211                os << 
" added a lease of address: ";
 
  213                os << 
" updated information on the lease of address: ";
 
  217               << 
" to a device with hardware address: " 
  222                os << 
", client-id: " << client_id;
 
  236        } 
else if (name == 
"lease4-del") {
 
  240                os << 
" deleted the lease for address: " 
  243                os << 
" deleted a lease for a device identified by: " 
  250    } 
catch (
const exception& ex) {
 
 
  268    int64_t subnet_id_value = 0;
 
  269    if (
getOptionalInt(arguments, 
"subnet-id", subnet_id_value) && (subnet_id_value > 0)) {
 
 
  305        if (origin == 
"ha-partner") {
 
  308            os << 
"Administrator";
 
  310        if ((name == 
"lease6-add") || name == 
"lease6-update") {
 
  311            if (name == 
"lease6-add") {
 
  312                os << 
" added a lease of";
 
  314                os << 
" updated information on the lease of";
 
  330            os << 
" to a device with DUID: " 
  335                os << 
", hardware address: " << hw_address;
 
  340        } 
else if (name == 
"lease6-del") {
 
  344                os << 
" deleted the lease for address: " 
  347                os << 
" deleted a lease for a device identified by: " 
  351        } 
else if (name == 
"lease6-bulk-apply") {
 
  353            auto deleted_leases = arguments->get(
"deleted-leases");
 
  354            auto leases = arguments->get(
"leases");
 
  356            if (!deleted_leases && !leases) {
 
  362            if (deleted_leases && (deleted_leases->getType() != 
Element::list)) {
 
  374            auto response_args = response->get(
"arguments");
 
  377                failed_deleted_leases = response_args->get(
"failed-deleted-leases");
 
  378                failed_leases = response_args->get(
"failed-leases");
 
  383            if (deleted_leases) {
 
  384                unordered_set<string> failed_deleted_leases_set;
 
  385                if (failed_deleted_leases) {
 
  390                    auto leases_list = failed_deleted_leases->listValue();
 
  392                    for (
auto const& lease_params : leases_list) {
 
  393                        auto address = lease_params->get(
"ip-address");
 
  395                            failed_deleted_leases_set.emplace(address->stringValue());
 
  400                auto leases_list = deleted_leases->listValue();
 
  401                for (
auto const& lease_params : leases_list) {
 
  402                    auto address = lease_params->get(
"ip-address");
 
  403                    if (address && failed_deleted_leases_set.count(address->stringValue()) == 0) {
 
  405                        if (!origin.empty()) {
 
  413                        string cmd_name(
"lease6-del");
 
  423                unordered_set<string> failed_leases_set;
 
  429                    auto leases_list = failed_leases->listValue();
 
  431                    for (
auto const& lease_params : leases_list) {
 
  432                        auto address = lease_params->get(
"ip-address");
 
  434                            failed_leases_set.emplace(address->stringValue());
 
  438                auto leases_list = leases->listValue();
 
  439                for (
auto const& lease_params : leases_list) {
 
  440                    auto address = lease_params->get(
"ip-address");
 
  441                    if (address && failed_leases_set.count(address->stringValue()) == 0) {
 
  443                        if (!origin.empty()) {
 
  451                        string cmd_name(
"lease6-update");
 
  463    } 
catch (
const exception& ex) {
 
 
  507        static unordered_set<string> 
const supported = {
 
  508            "lease4-add", 
"lease4-update",
"lease4-del", 
"lease6-add",
 
  509            "lease6-update", 
"lease6-del", 
"lease6-bulk-apply" 
  511        if (supported.count(name) == 0) {
 
  518        if (name.find(
"lease4-") != string::npos) {
 
  520        } 
else if (name.find(
"lease6-") != string::npos) {
 
  524    } 
catch (
const exception& ex) {
 
 
static ElementPtr create(const Position &pos=ZERO_POSITION())
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
static std::string getString(isc::data::ConstElementPtr scope, const std::string &name)
Returns a string parameter from a scope.
static int64_t getInteger(isc::data::ConstElementPtr scope, const std::string &name)
Returns an integer parameter from a scope.
static CfgMgr & instance()
returns a single instance of Configuration Manager
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
static ClientIdPtr fromText(const std::string &text)
Create client identifier from the textual format.
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 getArgument(const std::string &name, T &value) const
Get argument.
int getCurrentLibrary() const
Get current library index.
bool getOptionalInt(ConstElementPtr &arguments, const string &name, int64_t &value)
Fetch value for a integer element if it is an element scope.
int handleLease4Cmds(CalloutHandle &handle, string &name, ConstElementPtr &arguments, ConstElementPtr &)
Handle lease4 related commands.
bool getOptionalString(ConstElementPtr &arguments, const string &name, string &value)
Fetch value for a string element if it is an element scope.
int command_processed(CalloutHandle &handle)
This callout is called at the "command_processed" hook point.
bool isPrefix(ConstElementPtr arguments)
Returns true if an element scope describes a prefix delegation.
void addDuration(CalloutHandle &handle, ostringstream &os, ConstElementPtr &arguments)
Outputs text describing lease duration to a stream.
void addContext(ostringstream &os, ConstElementPtr &arguments)
Outputs text describing lease optional user context to a stream.
bool checkLoggingEnabledSubnet6(ConstElementPtr &arguments)
Check if command has optional subnet-id parameter and if it does, check that the respective subnet ha...
int handleLease6Cmds(CalloutHandle &handle, string &name, ConstElementPtr &arguments, ConstElementPtr &response)
Handle lease6 related commands.
bool checkLoggingEnabledSubnet4(ConstElementPtr &arguments)
Check if command has optional subnet-id parameter and if it does, check that the respective subnet ha...
This file contains several functions and constants that are used for handling commands and responses ...
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
const isc::log::MessageID LEGAL_LOG_COMMAND_NO_LEGAL_STORE
const isc::log::MessageID LEGAL_LOG_COMMAND_WRITE_ERROR
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
ElementPtr copy(ConstElementPtr from, int level)
Copy the data up to a nesting level.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
boost::shared_ptr< const Subnet6 > ConstSubnet6Ptr
A const pointer to a Subnet6 object.
boost::shared_ptr< const Subnet4 > ConstSubnet4Ptr
A const pointer to a Subnet4 object.
boost::shared_ptr< CfgSubnets6 > CfgSubnets6Ptr
Non-const pointer.
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
boost::shared_ptr< CfgSubnets4 > CfgSubnets4Ptr
Non-const pointer.
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.
bool isPrintable(const string &content)
Check if a string is printable.
Defines the logger used by the top-level component of kea-lfc.