Kea 2.7.7
isc::lease_cmds::LeaseCmdsImpl Class Reference

Wrapper class around reservation command handlers. More...

+ Inheritance diagram for isc::lease_cmds::LeaseCmdsImpl:

Classes

class  Parameters
 Parameters specified for lease commands. More...
 

Public Member Functions

ElementPtr createFailedLeaseMap (const Lease::Type &lease_type, const IOAddress &lease_address, const DuidPtr &duid, const int control_result, const std::string &error_message) const
 Returns a map holding brief information about a lease which failed to be deleted, updated or added.
 
Lease6Ptr getIPv6LeaseForDelete (const Parameters &parameters) const
 Convenience function fetching IPv6 address to be used to delete a lease.
 
Parameters getParameters (bool v6, const ConstElementPtr &args)
 Extracts parameters required for reservation-get and reservation-del.
 
int lease4DelHandler (CalloutHandle &handle)
 lease4-del command handler
 
int lease4ResendDdnsHandler (CalloutHandle &handle)
 lease4-resend-ddns handler
 
int lease4UpdateHandler (CalloutHandle &handle)
 lease4-update handler
 
int lease4WipeHandler (CalloutHandle &handle)
 lease4-wipe handler
 
int lease6BulkApplyHandler (CalloutHandle &handle)
 lease6-bulk-apply command handler
 
int lease6DelHandler (CalloutHandle &handle)
 lease6-del command handler
 
int lease6ResendDdnsHandler (CalloutHandle &handle)
 lease6-resend-ddns handler
 
int lease6UpdateHandler (CalloutHandle &handle)
 lease6-update handler
 
int lease6WipeHandler (CalloutHandle &handle)
 lease6-wipe handler
 
int leaseAddHandler (CalloutHandle &handle)
 lease4-add, lease6-add command handler
 
int leaseGetAllHandler (CalloutHandle &handle)
 lease4-get-all, lease6-get-all commands handler
 
int leaseGetByClientIdHandler (hooks::CalloutHandle &handle)
 lease4-get-by-client-id command handler
 
int leaseGetByDuidHandler (hooks::CalloutHandle &handle)
 lease6-get-by-duid command handler
 
int leaseGetByHostnameHandler (hooks::CalloutHandle &handle)
 lease4-get-by-hostname and lease6-get-by-hostname commands handler
 
int leaseGetByHwAddressHandler (hooks::CalloutHandle &handle)
 lease4-get-by-hw-address command handler
 
int leaseGetHandler (CalloutHandle &handle)
 lease4-get, lease6-get command handler
 
int leaseGetPageHandler (hooks::CalloutHandle &handle)
 lease4-get-page, lease6-get-page commands handler
 
int leaseWriteHandler (CalloutHandle &handle)
 lease4-write handler, lease6-write handler
 

name of the parameter desired

Fetches an IP address parameter from a map of parameters

Parameters
mapof parameters in which to look
familyexpected protocol family of the address parameter, AF_INET or AF_INET6
Returns
IOAddress containing the value of the parameter.
Exceptions
BadValueif the parameter is missing or invalid
IOAddress getAddressParam (ConstElementPtr params, const std::string name, short family=AF_INET) const
 
static void updateStatsOnAdd (const Lease4Ptr &lease)
 Update stats when adding lease.
 
static void updateStatsOnAdd (const Lease6Ptr &lease)
 Update stats when adding lease.
 
static void updateStatsOnUpdate (const Lease4Ptr &existing, const Lease4Ptr &lease)
 Update stats when updating lease.
 
static void updateStatsOnUpdate (const Lease6Ptr &existing, const Lease6Ptr &lease)
 Update stats when updating lease.
 
static void updateStatsOnDelete (const Lease4Ptr &lease)
 Update stats when deleting lease.
 
static void updateStatsOnDelete (const Lease6Ptr &lease)
 Update stats when deleting lease.
 
static bool addOrUpdate4 (Lease4Ptr lease, bool force_create)
 Add or update lease.
 
static bool addOrUpdate6 (Lease6Ptr lease, bool force_create)
 Add or update lease.
 
static ConstElementPtr getExtendedInfo6 (const Lease6Ptr &lease)
 Get DHCPv6 extended info.
 
static void lease4Offer (CalloutHandle &callout_handle, BindingVariableMgrPtr mgr)
 lease4_offer hookpoint handler.
 
static void leases4Committed (CalloutHandle &callout_handle, BindingVariableMgrPtr mgr)
 leases4_committed hookpoint handler.
 
static void leases6Committed (CalloutHandle &callout_handle, BindingVariableMgrPtr mgr)
 leases6_committed hookpoint handler.
 

Detailed Description

Wrapper class around reservation command handlers.

Definition at line 53 of file lease_cmds.cc.

Member Function Documentation

◆ addOrUpdate4()

bool isc::lease_cmds::LeaseCmdsImpl::addOrUpdate4 ( Lease4Ptr lease,
bool force_create )
static

Add or update lease.

Parameters
leaseThe lease to be added or updated (if exists).
force_createFlag to indicate if the function should try to create the lease if it does not exists, or simply update and fail in such case.
Returns
true if lease has been successfully added, false otherwise.

Definition at line 955 of file lease_cmds.cc.

References isc::dhcp::LeaseMgr::getLease4(), isc::dhcp::LeaseMgrFactory::instance(), isc_throw, isc::dhcp::Lease::syncCurrentExpirationTime(), isc::dhcp::LeaseMgr::updateLease4(), updateStatsOnAdd(), and updateStatsOnUpdate().

Referenced by lease4UpdateHandler().

+ Here is the call graph for this function:

◆ addOrUpdate6()

bool isc::lease_cmds::LeaseCmdsImpl::addOrUpdate6 ( Lease6Ptr lease,
bool force_create )
static

Add or update lease.

Parameters
leaseThe lease to be added or updated (if exists).
force_createFlag to indicate if the function should try to create the lease if it does not exists, or simply update and fail in such case.
Returns
true if lease has been successfully added, false otherwise.

Definition at line 986 of file lease_cmds.cc.

References isc::dhcp::Lease6::ACTION_UPDATE, getExtendedInfo6(), isc::dhcp::LeaseMgr::getLease6(), isc::dhcp::LeaseMgrFactory::instance(), isc_throw, isc::dhcp::Lease::syncCurrentExpirationTime(), isc::dhcp::LeaseMgr::updateLease6(), updateStatsOnAdd(), and updateStatsOnUpdate().

Referenced by lease6BulkApplyHandler(), and lease6UpdateHandler().

+ Here is the call graph for this function:

◆ createFailedLeaseMap()

ElementPtr isc::lease_cmds::LeaseCmdsImpl::createFailedLeaseMap ( const Lease::Type & lease_type,
const IOAddress & lease_address,
const DuidPtr & duid,
const int control_result,
const std::string & error_message ) const

Returns a map holding brief information about a lease which failed to be deleted, updated or added.

The DUID is only included if it is non-null. The address is only included if it is non-zero.

Parameters
lease_typelease type.
lease_addresslease address.
duidDUID of the client.
control_resultControl result: "empty" of the lease was not found, "error" otherwise.
error_messageError message.
Returns
The JSON map of the failed leases.

Definition at line 2682 of file lease_cmds.cc.

References isc::data::Element::create(), isc::data::Element::createMap(), isc::asiolink::IOAddress::isV6Zero(), isc::asiolink::IOAddress::toText(), and isc::dhcp::Lease::typeToText().

Referenced by lease6BulkApplyHandler().

+ Here is the call graph for this function:

◆ getAddressParam()

IOAddress isc::lease_cmds::LeaseCmdsImpl::getAddressParam ( ConstElementPtr params,
const std::string name,
short family = AF_INET ) const

Definition at line 2557 of file lease_cmds.cc.

References isc::asiolink::IOAddress::getFamily(), isc_throw, and isc::data::Element::string.

Referenced by lease4ResendDdnsHandler(), and lease6ResendDdnsHandler().

+ Here is the call graph for this function:

◆ getExtendedInfo6()

static ConstElementPtr isc::lease_cmds::LeaseCmdsImpl::getExtendedInfo6 ( const Lease6Ptr & lease)
inlinestatic

Get DHCPv6 extended info.

Parameters
leaseThe lease to get extended info from.
Returns
The extended info or null.

Definition at line 464 of file lease_cmds.cc.

References isc::data::Element::map.

Referenced by addOrUpdate6().

◆ getIPv6LeaseForDelete()

Lease6Ptr isc::lease_cmds::LeaseCmdsImpl::getIPv6LeaseForDelete ( const Parameters & parameters) const

Convenience function fetching IPv6 address to be used to delete a lease.

The returned parameter depends on the query_type value stored in the passed object. Note that the HW address is not allowed and this query type results in an exception. If the query type is of the address type, the address is returned. If the type is set to DUID, this function will try to find the lease for this DUID and return the corresponding address.

Parameters
parametersparameters extracted from the command.
Returns
Lease of the lease to be deleted.
Exceptions
InvalidParameterif the DUID is not found when needed to find the lease or if the query type is by HW address.
InvalidOperationif the query type is unknown.

Definition at line 2515 of file lease_cmds.cc.

References isc::lease_cmds::LeaseCmdsImpl::Parameters::addr, isc::lease_cmds::LeaseCmdsImpl::Parameters::duid, isc::dhcp::LeaseMgr::getLease6(), isc::lease_cmds::LeaseCmdsImpl::Parameters::iaid, isc::dhcp::LeaseMgrFactory::instance(), isc_throw, isc::lease_cmds::LeaseCmdsImpl::Parameters::lease_type, isc::lease_cmds::LeaseCmdsImpl::Parameters::query_type, isc::lease_cmds::LeaseCmdsImpl::Parameters::subnet_id, isc::lease_cmds::LeaseCmdsImpl::Parameters::TYPE_ADDR, isc::lease_cmds::LeaseCmdsImpl::Parameters::TYPE_DUID, and isc::lease_cmds::LeaseCmdsImpl::Parameters::TYPE_HWADDR.

Referenced by lease6BulkApplyHandler().

+ Here is the call graph for this function:

◆ getParameters()

LeaseCmdsImpl::Parameters isc::lease_cmds::LeaseCmdsImpl::getParameters ( bool v6,
const ConstElementPtr & args )

Extracts parameters required for reservation-get and reservation-del.

See Parameters class for detailed description of what is expected in the args structure.

Parameters
v6whether addresses allowed are v4 (false) or v6 (true)
argsarguments passed to command
Returns
parsed parameters
Exceptions
BadValueif input arguments don't make sense.

Definition at line 1136 of file lease_cmds.cc.

References isc::lease_cmds::LeaseCmdsImpl::Parameters::addr, isc::data::Element::boolean, isc::lease_cmds::LeaseCmdsImpl::Parameters::client_id, isc::lease_cmds::LeaseCmdsImpl::Parameters::duid, isc::dhcp::ClientId::fromText(), isc::dhcp::DUID::fromText(), isc::dhcp::HWAddr::fromText(), isc::lease_cmds::LeaseCmdsImpl::Parameters::hwaddr, isc::lease_cmds::LeaseCmdsImpl::Parameters::iaid, isc::data::Element::integer, isc_throw, isc::asiolink::IOAddress::isV4(), isc::asiolink::IOAddress::isV6(), isc::lease_cmds::LeaseCmdsImpl::Parameters::lease_type, isc::data::Element::map, isc::lease_cmds::LeaseCmdsImpl::Parameters::query_type, isc::data::Element::string, isc::lease_cmds::LeaseCmdsImpl::Parameters::subnet_id, isc::lease_cmds::LeaseCmdsImpl::Parameters::txtToType(), isc::lease_cmds::LeaseCmdsImpl::Parameters::TYPE_ADDR, isc::lease_cmds::LeaseCmdsImpl::Parameters::TYPE_CLIENT_ID, isc::lease_cmds::LeaseCmdsImpl::Parameters::TYPE_DUID, isc::lease_cmds::LeaseCmdsImpl::Parameters::TYPE_HWADDR, isc::dhcp::Lease::TYPE_NA, isc::dhcp::Lease::TYPE_PD, isc::dhcp::Lease::TYPE_TA, isc::dhcp::Lease::TYPE_V4, and isc::lease_cmds::LeaseCmdsImpl::Parameters::updateDDNS.

Referenced by lease4DelHandler(), lease6BulkApplyHandler(), lease6DelHandler(), and leaseGetHandler().

+ Here is the call graph for this function:

◆ lease4DelHandler()

int isc::lease_cmds::LeaseCmdsImpl::lease4DelHandler ( CalloutHandle & handle)

lease4-del command handler

Provides the implementation for isc::lease_cmds::LeaseCmds::lease4DelHandler

Parameters
handleCallout context - which is expected to contain the delete command JSON text in the "command" argument
Returns
0 upon success, non-zero otherwise

Definition at line 1766 of file lease_cmds.cc.

References isc::lease_cmds::LeaseCmdsImpl::Parameters::addr, isc::dhcp_ddns::CHG_REMOVE, isc::lease_cmds::LeaseCmdsImpl::Parameters::client_id, isc::config::CmdsImpl::cmd_args_, isc::config::CONTROL_RESULT_EMPTY, isc::config::CmdsImpl::extractCommand(), isc::dhcp::LeaseMgr::getLease4(), getParameters(), isc::lease_cmds::LeaseCmdsImpl::Parameters::hwaddr, isc::dhcp::LeaseMgrFactory::instance(), isc_throw, isc::lease_cmds::LEASE_CMDS_DBG_COMMAND_DATA, LEASE_CMDS_DEL4, LEASE_CMDS_DEL4_FAILED, isc::lease_cmds::lease_cmds_logger, LOG_DEBUG, LOG_ERROR, isc::lease_cmds::LeaseCmdsImpl::Parameters::query_type, isc::dhcp::queueNCR(), isc::config::CmdsImpl::setErrorResponse(), isc::config::CmdsImpl::setSuccessResponse(), isc::lease_cmds::LeaseCmdsImpl::Parameters::subnet_id, isc::lease_cmds::LeaseCmdsImpl::Parameters::TYPE_ADDR, isc::lease_cmds::LeaseCmdsImpl::Parameters::TYPE_CLIENT_ID, isc::lease_cmds::LeaseCmdsImpl::Parameters::TYPE_DUID, isc::lease_cmds::LeaseCmdsImpl::Parameters::TYPE_HWADDR, isc::lease_cmds::LeaseCmdsImpl::Parameters::updateDDNS, and updateStatsOnDelete().

+ Here is the call graph for this function:

◆ lease4Offer()

void isc::lease_cmds::LeaseCmdsImpl::lease4Offer ( CalloutHandle & callout_handle,
BindingVariableMgrPtr mgr )
static

lease4_offer hookpoint handler.

If the offer_lifetime argument is zero, it simply returns. Otherwise it evaluates the binding variables (if any), and updates the given lease's user-context accordingly. This includes updating the lease in the lease back end.

Parameters
callout_handleCallout context - which is expected to contain the query4, response4, leases4, offer_lifetime arguments.
mgrPointer to the BindingVariableMgr singleton.
Exceptions
Unexpectedif there is no active lease or a processing error occurs. LeaseCmdsConflict if the update fails because the lease no longer exists in the back end.

Definition at line 2747 of file lease_cmds.cc.

References isc::hooks::CalloutHandle::getArgument(), isc::dhcp::LeaseMgrFactory::instance(), isc_throw, and isc::dhcp::LeaseMgr::updateLease4().

+ Here is the call graph for this function:

◆ lease4ResendDdnsHandler()

int isc::lease_cmds::LeaseCmdsImpl::lease4ResendDdnsHandler ( CalloutHandle & handle)

lease4-resend-ddns handler

Provides the implementation for isc::lease_cmds::LeaseCmds::lease4ResendDdnsHandler

Parameters
handleCallout context - which is expected to contain the lease4-resend-ddns command JSON text in the "command" argument
Returns
0 upon success, non-zero otherwise

Definition at line 2586 of file lease_cmds.cc.

References isc::dhcp_ddns::CHG_ADD, isc::config::CmdsImpl::cmd_args_, isc::config::CONTROL_RESULT_CONFLICT, isc::config::CONTROL_RESULT_EMPTY, isc::config::CONTROL_RESULT_ERROR, isc::config::CmdsImpl::extractCommand(), getAddressParam(), isc::dhcp::LeaseMgr::getLease4(), isc::dhcp::CfgMgr::instance(), isc::dhcp::LeaseMgrFactory::instance(), isc::lease_cmds::lease_cmds_logger, LEASE_CMDS_RESEND_DDNS4, LEASE_CMDS_RESEND_DDNS4_FAILED, LOG_ERROR, LOG_INFO, isc::dhcp::queueNCR(), isc::config::CmdsImpl::setErrorResponse(), isc::config::CmdsImpl::setSuccessResponse(), and isc::asiolink::IOAddress::toText().

+ Here is the call graph for this function:

◆ lease4UpdateHandler()

int isc::lease_cmds::LeaseCmdsImpl::lease4UpdateHandler ( CalloutHandle & handle)

lease4-update handler

Provides the implementation for isc::lease_cmds::LeaseCmds::lease4UpdateHandler

Parameters
handleCallout context - which is expected to contain the update command JSON text in the "command" argument
Returns
0 upon success, non-zero otherwise

Definition at line 2126 of file lease_cmds.cc.

References addOrUpdate4(), isc::config::CmdsImpl::cmd_args_, isc::config::CONTROL_RESULT_CONFLICT, isc::config::CmdsImpl::extractCommand(), isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::CfgMgr::instance(), isc::util::MultiThreadingMgr::instance(), isc_throw, isc::lease_cmds::LEASE_CMDS_DBG_COMMAND_DATA, isc::lease_cmds::lease_cmds_logger, LEASE_CMDS_UPDATE4, LEASE_CMDS_UPDATE4_CONFLICT, LEASE_CMDS_UPDATE4_FAILED, LOG_DEBUG, LOG_ERROR, LOG_WARN, isc::lease_cmds::Lease4Parser::parse(), isc::config::CmdsImpl::setErrorResponse(), isc::config::CmdsImpl::setSuccessResponse(), isc::dhcp::ResourceHandler4::tryLock4(), and isc::Exception::what().

+ Here is the call graph for this function:

◆ lease4WipeHandler()

◆ lease6BulkApplyHandler()

int isc::lease_cmds::LeaseCmdsImpl::lease6BulkApplyHandler ( CalloutHandle & handle)

lease6-bulk-apply command handler

Provides the implementation for the isc::lease_cmds::LeaseCmds::lease6BulkApplyHandler.

Parameters
handleCallout context - which is expected to contain the add command JSON text in the "command" argument
Returns
0 upon success, non-zero otherwise

Definition at line 1845 of file lease_cmds.cc.

References addOrUpdate6(), isc::lease_cmds::LeaseCmdsImpl::Parameters::addr, isc::config::CmdsImpl::cmd_args_, isc::config::CONTROL_RESULT_CONFLICT, isc::config::CONTROL_RESULT_EMPTY, isc::config::CONTROL_RESULT_ERROR, isc::config::CONTROL_RESULT_SUCCESS, isc::config::createAnswer(), createFailedLeaseMap(), isc::data::Element::createList(), isc::data::Element::createMap(), isc::lease_cmds::LeaseCmdsImpl::Parameters::duid, isc::config::CmdsImpl::extractCommand(), isc::dhcp::CfgMgr::getCurrentCfg(), getIPv6LeaseForDelete(), getParameters(), isc::dhcp::CfgMgr::instance(), isc::dhcp::LeaseMgrFactory::instance(), isc::util::MultiThreadingMgr::instance(), isc_throw, LEASE_CMDS_BULK_APPLY6, LEASE_CMDS_BULK_APPLY6_FAILED, isc::lease_cmds::LEASE_CMDS_DBG_COMMAND_DATA, isc::lease_cmds::lease_cmds_logger, isc::lease_cmds::LeaseCmdsImpl::Parameters::lease_type, isc::data::Element::list, LOG_DEBUG, LOG_ERROR, isc::data::Element::map, isc::lease_cmds::Lease6Parser::parse(), isc::config::CmdsImpl::setErrorResponse(), isc::config::CmdsImpl::setResponse(), isc::dhcp::ResourceHandler::tryLock(), updateStatsOnDelete(), and isc::Exception::what().

+ Here is the call graph for this function:

◆ lease6DelHandler()

int isc::lease_cmds::LeaseCmdsImpl::lease6DelHandler ( CalloutHandle & handle)

lease6-del command handler

Provides the implementation for isc::lease_cmds::LeaseCmds::lease6DelHandler

Parameters
handleCallout context - which is expected to contain the delete command JSON text in the "command" argument
Returns
0 upon success, non-zero otherwise

Definition at line 2055 of file lease_cmds.cc.

References isc::lease_cmds::LeaseCmdsImpl::Parameters::addr, isc::dhcp_ddns::CHG_REMOVE, isc::config::CmdsImpl::cmd_args_, isc::config::CONTROL_RESULT_EMPTY, isc::lease_cmds::LeaseCmdsImpl::Parameters::duid, isc::config::CmdsImpl::extractCommand(), isc::dhcp::LeaseMgr::getLease6(), getParameters(), isc::lease_cmds::LeaseCmdsImpl::Parameters::iaid, isc::dhcp::LeaseMgrFactory::instance(), isc::asiolink::IOAddress::IPV6_ZERO_ADDRESS(), isc_throw, isc::lease_cmds::LEASE_CMDS_DBG_COMMAND_DATA, LEASE_CMDS_DEL6, LEASE_CMDS_DEL6_FAILED, isc::lease_cmds::lease_cmds_logger, isc::lease_cmds::LeaseCmdsImpl::Parameters::lease_type, LOG_DEBUG, LOG_ERROR, isc::lease_cmds::LeaseCmdsImpl::Parameters::query_type, isc::dhcp::queueNCR(), isc::config::CmdsImpl::setErrorResponse(), isc::config::CmdsImpl::setSuccessResponse(), isc::lease_cmds::LeaseCmdsImpl::Parameters::subnet_id, isc::lease_cmds::LeaseCmdsImpl::Parameters::TYPE_ADDR, isc::lease_cmds::LeaseCmdsImpl::Parameters::TYPE_DUID, isc::lease_cmds::LeaseCmdsImpl::Parameters::TYPE_HWADDR, isc::lease_cmds::LeaseCmdsImpl::Parameters::updateDDNS, and updateStatsOnDelete().

+ Here is the call graph for this function:

◆ lease6ResendDdnsHandler()

int isc::lease_cmds::LeaseCmdsImpl::lease6ResendDdnsHandler ( CalloutHandle & handle)

lease6-resend-ddns handler

Provides the implementation for isc::lease_cmds::LeaseCmds::lease6ResendDdnsHandler

Parameters
handleCallout context - which is expected to contain the lease6-resend-ddns command JSON text in the "command" argument
Returns
0 upon success, non-zero otherwise

Definition at line 2634 of file lease_cmds.cc.

References isc::dhcp_ddns::CHG_ADD, isc::config::CmdsImpl::cmd_args_, isc::config::CONTROL_RESULT_CONFLICT, isc::config::CONTROL_RESULT_EMPTY, isc::config::CONTROL_RESULT_ERROR, isc::config::CmdsImpl::extractCommand(), getAddressParam(), isc::dhcp::LeaseMgr::getLease6(), isc::dhcp::CfgMgr::instance(), isc::dhcp::LeaseMgrFactory::instance(), isc::lease_cmds::lease_cmds_logger, LEASE_CMDS_RESEND_DDNS6, LEASE_CMDS_RESEND_DDNS6_FAILED, LOG_ERROR, LOG_INFO, isc::dhcp::queueNCR(), isc::config::CmdsImpl::setErrorResponse(), isc::config::CmdsImpl::setSuccessResponse(), isc::asiolink::IOAddress::toText(), and isc::dhcp::Lease::TYPE_NA.

+ Here is the call graph for this function:

◆ lease6UpdateHandler()

int isc::lease_cmds::LeaseCmdsImpl::lease6UpdateHandler ( CalloutHandle & handle)

lease6-update handler

Provides the implementation for isc::lease_cmds::LeaseCmds::lease6UpdateHandler

Parameters
handleCallout context - which is expected to contain the update command JSON text in the "command" argument
Returns
0 upon success, non-zero otherwise

Definition at line 2188 of file lease_cmds.cc.

References addOrUpdate6(), isc::config::CmdsImpl::cmd_args_, isc::config::CONTROL_RESULT_CONFLICT, isc::config::CmdsImpl::extractCommand(), isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::CfgMgr::instance(), isc::util::MultiThreadingMgr::instance(), isc_throw, isc::lease_cmds::LEASE_CMDS_DBG_COMMAND_DATA, isc::lease_cmds::lease_cmds_logger, LEASE_CMDS_UPDATE6, LEASE_CMDS_UPDATE6_CONFLICT, LEASE_CMDS_UPDATE6_FAILED, LOG_DEBUG, LOG_ERROR, LOG_WARN, isc::lease_cmds::Lease6Parser::parse(), isc::config::CmdsImpl::setErrorResponse(), isc::config::CmdsImpl::setSuccessResponse(), isc::dhcp::ResourceHandler::tryLock(), and isc::Exception::what().

+ Here is the call graph for this function:

◆ lease6WipeHandler()

int isc::lease_cmds::LeaseCmdsImpl::lease6WipeHandler ( CalloutHandle & handle)

lease6-wipe handler

Provides the implementation for isc::lease_cmds::LeaseCmds::lease6WipeHandler

Parameters
handleCallout context - which is expected to contain the wipe command JSON text in the "command" argument
Returns
0 upon success, non-zero otherwise
Todo
: consider extending the code with wipe-leases:
  • of specific type (v6)
  • from specific shared network
  • from specific pool

Definition at line 2367 of file lease_cmds.cc.

References isc::stats::StatsMgr::addValue(), isc::config::CmdsImpl::cmd_args_, isc::config::CONTROL_RESULT_EMPTY, isc::config::CONTROL_RESULT_SUCCESS, isc::config::createAnswer(), isc::config::CmdsImpl::extractCommand(), isc::stats::StatsMgr::generateName(), isc::dhcp::CfgMgr::getCurrentCfg(), isc::stats::StatsMgr::getObservation(), isc::data::SimpleParser::getUint32(), isc::dhcp::CfgMgr::instance(), isc::dhcp::LeaseMgrFactory::instance(), isc::stats::StatsMgr::instance(), isc::lease_cmds::lease_cmds_logger, LEASE_CMDS_WIPE6, LEASE_CMDS_WIPE6_DEPRECATED, LEASE_CMDS_WIPE6_FAILED, LOG_ERROR, LOG_INFO, LOG_WARN, isc::config::CmdsImpl::setErrorResponse(), isc::config::CmdsImpl::setResponse(), isc::stats::StatsMgr::setValue(), isc::dhcp::Lease::TYPE_NA, isc::dhcp::Lease::TYPE_PD, and isc::dhcp::LeaseMgr::wipeLeases6().

+ Here is the call graph for this function:

◆ leaseAddHandler()

◆ leaseGetAllHandler()

int isc::lease_cmds::LeaseCmdsImpl::leaseGetAllHandler ( CalloutHandle & handle)

lease4-get-all, lease6-get-all commands handler

These commands attempt to retrieve all IPv4 or IPv6 leases, or all IPv4 or all IPv6 leases belonging to the particular subnets. If no subnet identifiers are provided, it returns all IPv4 or IPv6 leases from the database.

Parameters
handleCallout context - which is expected to contain the get command JSON text in the "command" argument
Returns
0 upon success, non-zero otherwise.

Definition at line 1346 of file lease_cmds.cc.

References isc::config::CmdsImpl::cmd_args_, isc::config::CmdsImpl::cmd_name_, isc::config::CONTROL_RESULT_EMPTY, isc::config::CONTROL_RESULT_ERROR, isc::config::CONTROL_RESULT_SUCCESS, isc::config::createAnswer(), isc::data::Element::createList(), isc::data::Element::createMap(), isc::config::CmdsImpl::extractCommand(), isc::dhcp::LeaseMgr::getLeases4(), isc::dhcp::LeaseMgr::getLeases6(), isc::dhcp::LeaseMgrFactory::instance(), isc::data::Element::integer, isc_throw, isc::data::Element::list, isc::config::CmdsImpl::setErrorResponse(), and isc::config::CmdsImpl::setResponse().

+ Here is the call graph for this function:

◆ leaseGetByClientIdHandler()

int isc::lease_cmds::LeaseCmdsImpl::leaseGetByClientIdHandler ( hooks::CalloutHandle & handle)

lease4-get-by-client-id command handler

Provides the implementation for isc::lease_cmds::LeaseCmds::leaseGetByClientIdHandler

Parameters
handleCallout context - which is expected to contain the get command JSON text in the "command" argument
Returns
0 if the handler has been invoked successfully, 1 if an error occurs, 3 if no leases are returned.

Definition at line 1596 of file lease_cmds.cc.

References isc::config::CmdsImpl::cmd_args_, isc::config::CONTROL_RESULT_EMPTY, isc::config::CONTROL_RESULT_ERROR, isc::config::CONTROL_RESULT_SUCCESS, isc::config::createAnswer(), isc::data::Element::createList(), isc::data::Element::createMap(), isc::config::CmdsImpl::extractCommand(), isc::dhcp::ClientId::fromText(), isc::dhcp::LeaseMgr::getLease4(), isc::dhcp::LeaseMgrFactory::instance(), isc_throw, isc::data::Element::map, isc::config::CmdsImpl::setErrorResponse(), isc::config::CmdsImpl::setResponse(), and isc::data::Element::string.

+ Here is the call graph for this function:

◆ leaseGetByDuidHandler()

int isc::lease_cmds::LeaseCmdsImpl::leaseGetByDuidHandler ( hooks::CalloutHandle & handle)

lease6-get-by-duid command handler

Provides the implementation for isc::lease_cmds::LeaseCmds::leaseGetByDuidHandler

Parameters
handleCallout context - which is expected to contain the get command JSON text in the "command" argument
Returns
0 if the handler has been invoked successfully, 1 if an error occurs, 3 if no leases are returned.

Definition at line 1646 of file lease_cmds.cc.

References isc::config::CmdsImpl::cmd_args_, isc::config::CONTROL_RESULT_EMPTY, isc::config::CONTROL_RESULT_ERROR, isc::config::CONTROL_RESULT_SUCCESS, isc::config::createAnswer(), isc::data::Element::createList(), isc::data::Element::createMap(), isc::config::CmdsImpl::extractCommand(), isc::dhcp::DUID::fromText(), isc::dhcp::LeaseMgr::getLeases6(), isc::dhcp::LeaseMgrFactory::instance(), isc_throw, isc::data::Element::map, isc::config::CmdsImpl::setErrorResponse(), isc::config::CmdsImpl::setResponse(), and isc::data::Element::string.

+ Here is the call graph for this function:

◆ leaseGetByHostnameHandler()

int isc::lease_cmds::LeaseCmdsImpl::leaseGetByHostnameHandler ( hooks::CalloutHandle & handle)

lease4-get-by-hostname and lease6-get-by-hostname commands handler

Provides the implementation for isc::lease_cmds::LeaseCmds::leaseGetByHostnameHandler

Parameters
handleCallout context - which is expected to contain the get command JSON text in the "command" argument
Returns
0 if the handler has been invoked successfully, 1 if an error occurs, 3 if no leases are returned.

The 'hostname' argument should not be empty.

Definition at line 1696 of file lease_cmds.cc.

References isc::config::CmdsImpl::cmd_args_, isc::config::CmdsImpl::cmd_name_, isc::config::CONTROL_RESULT_EMPTY, isc::config::CONTROL_RESULT_ERROR, isc::config::CONTROL_RESULT_SUCCESS, isc::config::createAnswer(), isc::data::Element::createList(), isc::data::Element::createMap(), isc::config::CmdsImpl::extractCommand(), isc::dhcp::LeaseMgr::getLeases4(), isc::dhcp::LeaseMgr::getLeases6(), isc::dhcp::LeaseMgrFactory::instance(), isc_throw, isc::data::Element::map, isc::config::CmdsImpl::setErrorResponse(), isc::config::CmdsImpl::setResponse(), and isc::data::Element::string.

+ Here is the call graph for this function:

◆ leaseGetByHwAddressHandler()

int isc::lease_cmds::LeaseCmdsImpl::leaseGetByHwAddressHandler ( hooks::CalloutHandle & handle)

lease4-get-by-hw-address command handler

Provides the implementation for isc::lease_cmds::LeaseCmds::leaseGetByHwAddressHandler

Parameters
handleCallout context - which is expected to contain the get command JSON text in the "command" argument
Returns
0 if the handler has been invoked successfully, 1 if an error occurs, 3 if no leases are returned.

Definition at line 1546 of file lease_cmds.cc.

References isc::config::CmdsImpl::cmd_args_, isc::config::CONTROL_RESULT_EMPTY, isc::config::CONTROL_RESULT_ERROR, isc::config::CONTROL_RESULT_SUCCESS, isc::config::createAnswer(), isc::data::Element::createList(), isc::data::Element::createMap(), isc::config::CmdsImpl::extractCommand(), isc::dhcp::HWAddr::fromText(), isc::dhcp::LeaseMgr::getLease4(), isc::dhcp::LeaseMgrFactory::instance(), isc_throw, isc::data::Element::map, isc::config::CmdsImpl::setErrorResponse(), isc::config::CmdsImpl::setResponse(), and isc::data::Element::string.

+ Here is the call graph for this function:

◆ leaseGetHandler()

int isc::lease_cmds::LeaseCmdsImpl::leaseGetHandler ( CalloutHandle & handle)

lease4-get, lease6-get command handler

Provides the implementation for isc::lease_cmds::LeaseCmds::leaseGetHandler

Parameters
handleCallout context - which is expected to contain the get command JSON text in the "command" argument
Returns
0 upon success, non-zero otherwise

Definition at line 1254 of file lease_cmds.cc.

References isc::lease_cmds::LeaseCmdsImpl::Parameters::addr, isc::lease_cmds::LeaseCmdsImpl::Parameters::client_id, isc::config::CmdsImpl::cmd_args_, isc::config::CmdsImpl::cmd_name_, isc::config::CONTROL_RESULT_EMPTY, isc::config::CONTROL_RESULT_SUCCESS, isc::config::createAnswer(), isc::lease_cmds::LeaseCmdsImpl::Parameters::duid, isc::config::CmdsImpl::extractCommand(), isc::dhcp::LeaseMgr::getLease4(), isc::dhcp::LeaseMgr::getLease6(), getParameters(), isc::lease_cmds::LeaseCmdsImpl::Parameters::hwaddr, isc::lease_cmds::LeaseCmdsImpl::Parameters::iaid, isc::dhcp::LeaseMgrFactory::instance(), isc_throw, LEASE_CMDS_GET4_FAILED, LEASE_CMDS_GET6_FAILED, isc::lease_cmds::lease_cmds_logger, isc::lease_cmds::LeaseCmdsImpl::Parameters::lease_type, LOG_ERROR, isc::lease_cmds::LeaseCmdsImpl::Parameters::query_type, isc::config::CmdsImpl::setErrorResponse(), isc::config::CmdsImpl::setResponse(), isc::lease_cmds::LeaseCmdsImpl::Parameters::subnet_id, isc::lease_cmds::LeaseCmdsImpl::Parameters::TYPE_ADDR, isc::lease_cmds::LeaseCmdsImpl::Parameters::TYPE_CLIENT_ID, isc::lease_cmds::LeaseCmdsImpl::Parameters::TYPE_DUID, and isc::lease_cmds::LeaseCmdsImpl::Parameters::TYPE_HWADDR.

+ Here is the call graph for this function:

◆ leaseGetPageHandler()

int isc::lease_cmds::LeaseCmdsImpl::leaseGetPageHandler ( hooks::CalloutHandle & handle)

lease4-get-page, lease6-get-page commands handler

These commands attempt to retrieve 1 page of leases. The maximum size of the page is specified by the caller. The caller also specifies the last address returned in the previous page. The new page starts from the first address following the address specified by the caller. If the first page should be returned the IPv4 zero address, IPv6 zero address or the keyword "start" should be provided instead of the last address.

Parameters
handleCallout context - which is expected to contain the get commands JSON text in the "command" argument.
Returns
0 if the handler has been invoked successfully, 1 if an error occurs, 3 if no leases are returned.

Definition at line 1427 of file lease_cmds.cc.

References isc::config::CmdsImpl::cmd_args_, isc::config::CmdsImpl::cmd_name_, isc::config::CONTROL_RESULT_EMPTY, isc::config::CONTROL_RESULT_ERROR, isc::config::CONTROL_RESULT_SUCCESS, isc::data::Element::create(), isc::config::createAnswer(), isc::data::Element::createList(), isc::data::Element::createMap(), isc::config::CmdsImpl::extractCommand(), isc::dhcp::LeaseMgr::getLeases4(), isc::dhcp::LeaseMgr::getLeases6(), isc::dhcp::LeaseMgrFactory::instance(), isc::data::Element::integer, isc_throw, isc::config::CmdsImpl::setErrorResponse(), isc::config::CmdsImpl::setResponse(), and isc::data::Element::string.

+ Here is the call graph for this function:

◆ leases4Committed()

void isc::lease_cmds::LeaseCmdsImpl::leases4Committed ( CalloutHandle & callout_handle,
BindingVariableMgrPtr mgr )
static

leases4_committed hookpoint handler.

Evaluates the binding variables (if any), and updates the given lease's user-context accordingly. This includes updating the lease in the lease back end.

Parameters
callout_handleCallout context - which is expected to contain the query4, response4, and leases4 arguments.
mgrPointer to the BindingVariableMgr singleton.
Exceptions
Unexpectedif a processing error occurs. LeaseCmdsConflict if the update fails because the lease no longer exists in the back end.

Definition at line 2786 of file lease_cmds.cc.

References isc::dhcp::DHCPACK, isc::hooks::CalloutHandle::getArgument(), isc::dhcp::LeaseMgrFactory::instance(), isc_throw, and isc::dhcp::LeaseMgr::updateLease4().

+ Here is the call graph for this function:

◆ leases6Committed()

void isc::lease_cmds::LeaseCmdsImpl::leases6Committed ( CalloutHandle & callout_handle,
BindingVariableMgrPtr mgr )
static

leases6_committed hookpoint handler.

Evaluates the binding variables (if any), and updates the leases' user-context accordingly. This includes updating the leases in the lease back end.

Parameters
callout_handleCallout context - which is expected to contain the query6, response6, and leases6 arguments.
mgrPointer to the BindingVariableMgr singleton.
Exceptions
Unexpectedif there a processing error occurs. LeaseCmdsConflict if the update fails because the lease no longer exists in the back end.
Todo
  • Users might want to only update NA or PD leases. This could be done via adding a lease type to the variable. V4 would not use it, for V6 it would restrict a variable to only that type of lease. If unspecified (default) do both NA and PD leases.

Definition at line 2828 of file lease_cmds.cc.

References isc::hooks::CalloutHandle::getArgument(), isc::dhcp::LeaseMgrFactory::instance(), isc_throw, LEASE_CMDS_LEASES6_COMMITTED_CONFLICT, LEASE_CMDS_LEASES6_COMMITTED_LEASE_ERROR, isc::lease_cmds::lease_cmds_logger, LOG_ERROR, and isc::dhcp::LeaseMgr::updateLease6().

+ Here is the call graph for this function:

◆ leaseWriteHandler()

int isc::lease_cmds::LeaseCmdsImpl::leaseWriteHandler ( CalloutHandle & handle)

lease4-write handler, lease6-write handler

Provides the implementation for isc::lease_cmds::LeaseCmds::leaseWriteHandler

Parameters
handleCallout context - which is expected to contain the write command JSON text in the "command" argument
Returns
0 upon success, non-zero otherwise

Definition at line 2705 of file lease_cmds.cc.

References isc::config::CmdsImpl::cmd_args_, isc::config::CmdsImpl::cmd_name_, isc::config::CONTROL_RESULT_ERROR, isc::config::CONTROL_RESULT_SUCCESS, isc::config::createAnswer(), isc::config::CmdsImpl::extractCommand(), isc::dhcp::LeaseMgrFactory::instance(), isc_throw, isc::config::CmdsImpl::setErrorResponse(), isc::config::CmdsImpl::setResponse(), isc::data::Element::string, isc::dhcp::LeaseMgr::writeLeases4(), and isc::dhcp::LeaseMgr::writeLeases6().

+ Here is the call graph for this function:

◆ updateStatsOnAdd() [1/2]

void isc::lease_cmds::LeaseCmdsImpl::updateStatsOnAdd ( const Lease4Ptr & lease)
static

Update stats when adding lease.

Parameters
leaseAdded lease.

Definition at line 522 of file lease_cmds.cc.

References isc::stats::StatsMgr::addValue(), isc::stats::StatsMgr::generateName(), isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::CfgMgr::instance(), isc::stats::StatsMgr::instance(), and isc::dhcp::Lease::TYPE_V4.

Referenced by addOrUpdate4(), addOrUpdate6(), and leaseAddHandler().

+ Here is the call graph for this function:

◆ updateStatsOnAdd() [2/2]

void isc::lease_cmds::LeaseCmdsImpl::updateStatsOnAdd ( const Lease6Ptr & lease)
static

Update stats when adding lease.

Parameters
leaseAdded lease.

Definition at line 562 of file lease_cmds.cc.

References isc::stats::StatsMgr::addValue(), isc::stats::StatsMgr::generateName(), isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::CfgMgr::instance(), isc::stats::StatsMgr::instance(), and isc::dhcp::Lease::TYPE_NA.

+ Here is the call graph for this function:

◆ updateStatsOnDelete() [1/2]

void isc::lease_cmds::LeaseCmdsImpl::updateStatsOnDelete ( const Lease4Ptr & lease)
static

Update stats when deleting lease.

Parameters
leaseDeleted lease.

Definition at line 872 of file lease_cmds.cc.

References isc::stats::StatsMgr::addValue(), isc::stats::StatsMgr::generateName(), isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::CfgMgr::instance(), isc::stats::StatsMgr::instance(), and isc::dhcp::Lease::TYPE_V4.

Referenced by lease4DelHandler(), lease6BulkApplyHandler(), and lease6DelHandler().

+ Here is the call graph for this function:

◆ updateStatsOnDelete() [2/2]

void isc::lease_cmds::LeaseCmdsImpl::updateStatsOnDelete ( const Lease6Ptr & lease)
static

Update stats when deleting lease.

Parameters
leaseDeleted lease.

Definition at line 912 of file lease_cmds.cc.

References isc::stats::StatsMgr::addValue(), isc::stats::StatsMgr::generateName(), isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::CfgMgr::instance(), isc::stats::StatsMgr::instance(), and isc::dhcp::Lease::TYPE_NA.

+ Here is the call graph for this function:

◆ updateStatsOnUpdate() [1/2]

void isc::lease_cmds::LeaseCmdsImpl::updateStatsOnUpdate ( const Lease4Ptr & existing,
const Lease4Ptr & lease )
static

Update stats when updating lease.

Parameters
existingLease data before update.
leaseLease data after update.

Definition at line 605 of file lease_cmds.cc.

References isc::stats::StatsMgr::addValue(), isc::stats::StatsMgr::generateName(), isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::CfgMgr::instance(), isc::stats::StatsMgr::instance(), and isc::dhcp::Lease::TYPE_V4.

Referenced by addOrUpdate4(), and addOrUpdate6().

+ Here is the call graph for this function:

◆ updateStatsOnUpdate() [2/2]

void isc::lease_cmds::LeaseCmdsImpl::updateStatsOnUpdate ( const Lease6Ptr & existing,
const Lease6Ptr & lease )
static

Update stats when updating lease.

Parameters
existingLease data before update.
leaseLease data after update.

Definition at line 734 of file lease_cmds.cc.

References isc::stats::StatsMgr::addValue(), isc::stats::StatsMgr::generateName(), isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::CfgMgr::instance(), isc::stats::StatsMgr::instance(), and isc::dhcp::Lease::TYPE_NA.

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: