Kea 2.7.5
|
a common structure for IPv4 and IPv6 leases More...
#include <lease.h>
Public Types | |
enum | Type { TYPE_NA = 0 , TYPE_TA = 1 , TYPE_PD = 2 , TYPE_V4 = 3 } |
Type of lease or pool. More... | |
Static Public Member Functions | |
static std::string | lifetimeToText (uint32_t lifetime) |
Print lifetime. | |
static Type | textToType (const std::string &text) |
Converts type name to the actual type. | |
static std::string | typeToText (Type type) |
returns text representation of a lease type | |
Static Public Member Functions inherited from isc::data::UserContext | |
static data::ElementPtr | toElement (data::ConstElementPtr map) |
Copy an Element map. | |
Static Public Attributes | |
static const uint32_t | INFINITY_LFT = 0xffffffff |
Infinity (means static, i.e. never expire) | |
Common lease states constants. | |
static const uint32_t | STATE_DEFAULT = 0 |
A lease in the default state. | |
static const uint32_t | STATE_DECLINED = 1 |
Declined lease. | |
static const uint32_t | STATE_EXPIRED_RECLAIMED = 2 |
Expired and reclaimed lease. | |
static const uint32_t | STATE_RELEASED = 3 |
Released lease held in the database for lease affinity. | |
isc::asiolink::IOAddress | addr_ |
IPv4 ot IPv6 address. | |
uint32_t | valid_lft_ |
Valid lifetime. | |
uint32_t | current_valid_lft_ |
Current valid lifetime. | |
uint32_t | reuseable_valid_lft_ |
Remaining valid lifetime. | |
time_t | cltt_ |
Client last transmission time. | |
time_t | current_cltt_ |
Current client last transmission time. | |
SubnetID | subnet_id_ |
Subnet identifier. | |
uint32_t | pool_id_ |
The pool id. | |
std::string | hostname_ |
Client hostname. | |
bool | fqdn_fwd_ |
Forward zone updated? | |
bool | fqdn_rev_ |
Reverse zone updated? | |
HWAddrPtr | hwaddr_ |
Client's MAC/hardware address. | |
uint32_t | state_ |
Holds the lease state(s). | |
static std::string | basicStatesToText (const uint32_t state) |
Returns name(s) of the basic lease state(s). | |
static void | syncCurrentExpirationTime (const Lease &from, Lease &to) |
Sync lease current expiration time with new value from another lease, so that additional operations can be done without performing extra read from the database. | |
Lease (const isc::asiolink::IOAddress &addr, uint32_t valid_lft, SubnetID subnet_id, time_t cltt, const bool fqdn_fwd, const bool fqdn_rev, const std::string &hostname, const HWAddrPtr &hwaddr) | |
Constructor. | |
virtual | ~Lease () |
Destructor. | |
virtual Lease::Type | getType () const =0 |
Returns Lease type. | |
virtual std::string | toText () const =0 |
Convert Lease to Printable Form. | |
bool | expired () const |
returns true if the lease is expired | |
bool | stateExpiredReclaimed () const |
Indicates if the lease is in the "expired-reclaimed" state. | |
bool | stateDeclined () const |
Indicates if the lease is in the "declined" state. | |
bool | hasIdenticalFqdn (const Lease &other) const |
Returns true if the other lease has equal FQDN data. | |
const std::vector< uint8_t > & | getHWAddrVector () const |
Returns raw (as vector) hardware address. | |
int64_t | getExpirationTime () const |
Returns lease expiration time. | |
virtual void | decline (uint32_t probation_period)=0 |
Sets lease to DECLINED state. | |
void | updateCurrentExpirationTime () |
Update lease current expiration time with new value, so that additional operations can be done without performing extra read from the database. | |
static void | fromElementCommon (const LeasePtr &lease, const data::ConstElementPtr &element) |
Sets common (for v4 and v6) properties of the lease object. | |
Additional Inherited Members | |
Public Member Functions inherited from isc::data::UserContext | |
void | contextToElement (data::ElementPtr map) const |
Merge unparse a user_context object. | |
data::ConstElementPtr | getContext () const |
Returns const pointer to the user context. | |
void | setContext (const data::ConstElementPtr &ctx) |
Sets user context. | |
Public Member Functions inherited from isc::data::CfgToElement | |
virtual | ~CfgToElement () |
Destructor. | |
virtual isc::data::ElementPtr | toElement () const =0 |
Unparse a configuration object. | |
Protected Attributes inherited from isc::data::UserContext | |
data::ConstElementPtr | user_context_ |
Pointer to the user context (may be NULL) | |
a common structure for IPv4 and IPv6 leases
This structure holds all information that is common between IPv4 and IPv6 leases.
isc::dhcp::Lease::Lease | ( | const isc::asiolink::IOAddress & | addr, |
uint32_t | valid_lft, | ||
SubnetID | subnet_id, | ||
time_t | cltt, | ||
const bool | fqdn_fwd, | ||
const bool | fqdn_rev, | ||
const std::string & | hostname, | ||
const HWAddrPtr & | hwaddr ) |
Constructor.
addr | IP address |
valid_lft | Lifetime of the lease |
subnet_id | Subnet identification |
cltt | Client last transmission time |
fqdn_fwd | If true, forward DNS update is performed for a lease. |
fqdn_rev | If true, reverse DNS update is performed for a lease. |
hostname | FQDN of the client which gets the lease. |
hwaddr | Hardware/MAC address |
|
inlinevirtual |
|
static |
Returns name(s) of the basic lease state(s).
state | A numeric value holding a state information. Some states may be composite, i.e. the single state value maps to multiple logical states of the lease. |
Definition at line 93 of file lease.cc.
References STATE_DECLINED, STATE_DEFAULT, STATE_EXPIRED_RECLAIMED, and STATE_RELEASED.
Referenced by isc::dhcp::CSVLeaseFile4::append(), isc::dhcp::CSVLeaseFile6::append(), isc::dhcp::CSVLeaseFile4::next(), isc::dhcp::Lease4::statesToText(), and isc::dhcp::Lease6::statesToText().
|
pure virtual |
Sets lease to DECLINED state.
All client identifying parameters will be stripped off (HWaddr, client_id, hostname), cltt will be set to current time and valid_lft to parameter specified as probation period. Note that This method only sets fields in the structure. It is caller's responsibility to clean up DDNS, bump up stats, log, call hooks ets.
probation_period | lease lifetime will be set to this value |
Implemented in isc::dhcp::Lease4, and isc::dhcp::Lease6.
bool isc::dhcp::Lease::expired | ( | ) | const |
returns true if the lease is expired
Definition at line 113 of file lease.cc.
References getExpirationTime(), INFINITY_LFT, and valid_lft_.
|
staticprotected |
Sets common (for v4 and v6) properties of the lease object.
This method is called by the fromElement
methods of the Lease
class derivations.
[out] | lease | pointer to the lease object for which common properties should be set. |
element | pointer to the data element object to be parsed. |
Definition at line 140 of file lease.cc.
References isc::data::Element::boolean, isc::dhcp::HWAddr::fromText(), isc::dhcp::HTYPE_ETHER, isc::data::Element::integer, isc_throw, isc::data::Element::map, STATE_EXPIRED_RECLAIMED, and isc::data::Element::string.
Referenced by isc::dhcp::Lease4::fromElement(), and isc::dhcp::Lease6::fromElement().
int64_t isc::dhcp::Lease::getExpirationTime | ( | ) | const |
Returns lease expiration time.
The lease expiration time is a sum of a client last transmission time and valid lifetime.
Definition at line 128 of file lease.cc.
References cltt_, and valid_lft_.
Referenced by expired().
const std::vector< uint8_t > & isc::dhcp::Lease::getHWAddrVector | ( | ) | const |
Returns raw (as vector) hardware address.
This method is needed in multi-index container as key extractor. The const reference is only valid as long as the object that returned it. In the unlikely case when Lease4 does not have a hardware address, the function will return an empty vector.
Definition at line 351 of file lease.cc.
References hwaddr_.
|
pure virtual |
Returns Lease type.
One of normal address, temporary address, or prefix, or V4
Implemented in isc::dhcp::Lease4, and isc::dhcp::Lease6.
bool isc::dhcp::Lease::hasIdenticalFqdn | ( | const Lease & | other | ) | const |
Returns true if the other lease has equal FQDN data.
The comparison of the hostname is case insensitive.
other | Lease which FQDN data is to be compared with our lease. |
|
static |
Print lifetime.
This converts a lifetime to a string taking into account the infinity special value.
lifetime | lifetime to print |
Definition at line 33 of file lease.cc.
References INFINITY_LFT.
Referenced by isc::dhcp::Dhcpv6Srv::assignIA_NA(), isc::dhcp::Dhcpv6Srv::assignIA_PD(), isc::dhcp::Dhcpv4Srv::assignLease(), isc::dhcp::Dhcpv6Srv::extendIA_NA(), isc::dhcp::Dhcpv6Srv::extendIA_PD(), isc::dhcp::Lease4::toText(), and isc::dhcp::Lease6::toText().
bool isc::dhcp::Lease::stateDeclined | ( | ) | const |
Indicates if the lease is in the "declined" state.
Definition at line 123 of file lease.cc.
References state_, and STATE_DECLINED.
bool isc::dhcp::Lease::stateExpiredReclaimed | ( | ) | const |
Indicates if the lease is in the "expired-reclaimed" state.
Definition at line 118 of file lease.cc.
References state_, and STATE_EXPIRED_RECLAIMED.
Sync lease current expiration time with new value from another lease, so that additional operations can be done without performing extra read from the database.
from | The lease with latest value of expiration time. | |
[out] | to | The lease that needs to be updated. |
Definition at line 313 of file lease.cc.
Referenced by isc::lease_cmds::LeaseCmdsImpl::addOrUpdate4(), isc::lease_cmds::LeaseCmdsImpl::addOrUpdate6(), and updateCurrentExpirationTime().
|
static |
Converts type name to the actual type.
text | lease type as text. |
BadValue | if the text contains unsupported value. |
Definition at line 75 of file lease.cc.
References isc_throw, TYPE_NA, TYPE_PD, TYPE_TA, and TYPE_V4.
Referenced by isc::dhcp::Lease6::fromElement().
|
pure virtual |
Convert Lease to Printable Form.
Implemented in isc::dhcp::Lease4, and isc::dhcp::Lease6.
|
static |
returns text representation of a lease type
type | lease or pool type to be converted |
Definition at line 55 of file lease.cc.
References TYPE_NA, TYPE_PD, TYPE_TA, and TYPE_V4.
Referenced by isc::dhcp::Subnet::addPool(), isc::lease_cmds::LeaseCmdsImpl::createFailedLeaseMap(), isc::dhcp::Subnet::getAllocationState(), isc::dhcp::Subnet::getAllocator(), isc::dhcp::Memfile_LeaseMgr::getLease6(), isc::dhcp::Memfile_LeaseMgr::getLeases6(), isc::dhcp::Memfile_LeaseMgr::getLeases6(), isc::dhcp::Allocator::initAfterConfigure(), isc::dhcp::TrackingLeaseMgr::registerCallback(), isc::dhcp::Lease6::toElement(), isc::dhcp::Lease6::toText(), isc::dhcp::Pool::toText(), isc::dhcp::Pool6::toText(), and isc::dhcp::ResourceHandler::unLock().
void isc::dhcp::Lease::updateCurrentExpirationTime | ( | ) |
Update lease current expiration time with new value, so that additional operations can be done without performing extra read from the database.
Definition at line 308 of file lease.cc.
References syncCurrentExpirationTime().
isc::asiolink::IOAddress isc::dhcp::Lease::addr_ |
IPv4 ot IPv6 address.
IPv4, IPv6 address or, in the case of a prefix delegation, the prefix.
Definition at line 123 of file lease.h.
Referenced by isc::dhcp::Lease4::operator==(), isc::dhcp::Lease6::operator==(), isc::dhcp::Lease4::toElement(), isc::dhcp::Lease6::toElement(), isc::dhcp::Lease4::toText(), and isc::dhcp::Lease6::toText().
time_t isc::dhcp::Lease::cltt_ |
Client last transmission time.
Specifies a timestamp giving the time when the last transmission from a client was received.
Definition at line 146 of file lease.h.
Referenced by isc::dhcp::Lease6::Lease6(), isc::dhcp::Lease6::Lease6(), isc::dhcp::Lease4::decline(), isc::dhcp::Lease6::decline(), getExpirationTime(), isc::dhcp::Lease4::operator==(), isc::dhcp::Lease6::operator==(), isc::dhcp::Lease4::toElement(), isc::dhcp::Lease6::toElement(), isc::dhcp::Lease4::toText(), and isc::dhcp::Lease6::toText().
time_t isc::dhcp::Lease::current_cltt_ |
Current client last transmission time.
Specifies a timestamp giving the time when the last transmission from a client was received before update.
Definition at line 152 of file lease.h.
Referenced by isc::dhcp::Lease6::Lease6(), isc::dhcp::Lease6::Lease6(), isc::dhcp::Lease4::operator==(), and isc::dhcp::Lease6::operator==().
uint32_t isc::dhcp::Lease::current_valid_lft_ |
Current valid lifetime.
Expressed as number of seconds since cltt before update.
Definition at line 133 of file lease.h.
Referenced by isc::dhcp::Lease4::operator==(), and isc::dhcp::Lease6::operator==().
bool isc::dhcp::Lease::fqdn_fwd_ |
Forward zone updated?
Set true if the DNS AAAA record for this lease has been updated.
Definition at line 172 of file lease.h.
Referenced by isc::dhcp::Lease4::decline(), isc::dhcp::Lease6::decline(), hasIdenticalFqdn(), isc::dhcp::Lease4::operator==(), isc::dhcp::Lease6::operator==(), isc::dhcp::Lease4::toElement(), and isc::dhcp::Lease6::toElement().
bool isc::dhcp::Lease::fqdn_rev_ |
Reverse zone updated?
Set true if the DNS PTR record for this lease has been updated.
Definition at line 177 of file lease.h.
Referenced by isc::dhcp::Lease4::decline(), isc::dhcp::Lease6::decline(), hasIdenticalFqdn(), isc::dhcp::Lease4::operator==(), isc::dhcp::Lease6::operator==(), isc::dhcp::Lease4::toElement(), and isc::dhcp::Lease6::toElement().
std::string isc::dhcp::Lease::hostname_ |
Client hostname.
This field is in lower case and may be empty.
Definition at line 167 of file lease.h.
Referenced by isc::dhcp::Lease4::decline(), isc::dhcp::Lease6::decline(), hasIdenticalFqdn(), isc::dhcp::Lease4::operator==(), isc::dhcp::Lease6::operator==(), isc::dhcp::Lease4::toElement(), and isc::dhcp::Lease6::toElement().
HWAddrPtr isc::dhcp::Lease::hwaddr_ |
Client's MAC/hardware address.
This information may not be available in certain cases.
Definition at line 182 of file lease.h.
Referenced by isc::dhcp::Lease4::belongsToClient(), isc::dhcp::Lease4::decline(), isc::dhcp::Lease6::decline(), getHWAddrVector(), isc::dhcp::Lease4::operator==(), isc::dhcp::Lease6::operator==(), isc::dhcp::Lease4::toElement(), isc::dhcp::Lease6::toElement(), isc::dhcp::Lease4::toText(), and isc::dhcp::Lease6::toText().
|
static |
Infinity (means static, i.e. never expire)
Definition at line 34 of file lease.h.
Referenced by expired(), isc::dhcp::AllocEngine::getValidLft(), lifetimeToText(), isc::dhcp::Dhcpv4Srv::processRelease(), isc::dhcp::Dhcpv6Srv::releaseIA_NA(), and isc::dhcp::Dhcpv6Srv::releaseIA_PD().
uint32_t isc::dhcp::Lease::pool_id_ |
The pool id.
Specifies the identification of the pool from a subnet to which the lease belongs.
Definition at line 162 of file lease.h.
Referenced by isc::dhcp::Lease4::operator==(), isc::dhcp::Lease6::operator==(), isc::dhcp::Lease4::toElement(), isc::dhcp::Lease6::toElement(), isc::dhcp::Lease4::toText(), and isc::dhcp::Lease6::toText().
uint32_t isc::dhcp::Lease::reuseable_valid_lft_ |
Remaining valid lifetime.
Expressed as number of seconds since current time, also valid lifetime - age where age is old cltt - new cltt. The value 0 is used for the "cannot be reused" condition.
Definition at line 140 of file lease.h.
Referenced by isc::dhcp::Lease4::operator==(), and isc::dhcp::Lease6::operator==().
uint32_t isc::dhcp::Lease::state_ |
Holds the lease state(s).
This is the field that holds the lease state(s). Typically, a lease remains in a single states. However, it is possible to define a value for state which indicates that the lease remains in multiple logical states.
The defined states are represented by the "STATE_*" constants belonging to this class.
Definition at line 193 of file lease.h.
Referenced by isc::dhcp::Lease4::decline(), isc::dhcp::Lease6::decline(), isc::dhcp::Lease4::operator==(), isc::dhcp::Lease6::operator==(), stateDeclined(), stateExpiredReclaimed(), isc::dhcp::Lease4::toElement(), isc::dhcp::Lease6::toElement(), isc::dhcp::Lease4::toText(), and isc::dhcp::Lease6::toText().
|
static |
Declined lease.
Definition at line 72 of file lease.h.
Referenced by isc::dhcp::CSVLeaseFile4::append(), isc::dhcp::CSVLeaseFile6::append(), basicStatesToText(), isc::dhcp::Lease4::decline(), isc::dhcp::Lease6::decline(), isc::stat_cmds::LeaseStatCmdsImpl::makeResultSet4(), isc::stat_cmds::LeaseStatCmdsImpl::makeResultSet6(), isc::dhcp::CSVLeaseFile4::next(), isc::dhcp::CSVLeaseFile6::next(), isc::lease_cmds::Lease6Parser::parse(), isc::dhcp::LeaseMgr::recountLeaseStats4(), isc::dhcp::LeaseMgr::recountLeaseStats6(), and stateDeclined().
|
static |
A lease in the default state.
Definition at line 69 of file lease.h.
Referenced by isc::dhcp::ClassLeaseCounter::addLease(), basicStatesToText(), isc::dhcp::Dhcpv6Srv::declineIA(), isc::stat_cmds::LeaseStatCmdsImpl::makeResultSet4(), isc::stat_cmds::LeaseStatCmdsImpl::makeResultSet6(), isc::dhcp::Dhcpv4Srv::processDecline(), isc::dhcp::Memfile_LeaseMgr::recountClassLeases4(), isc::dhcp::Memfile_LeaseMgr::recountClassLeases6(), isc::dhcp::LeaseMgr::recountLeaseStats4(), isc::dhcp::LeaseMgr::recountLeaseStats6(), isc::dhcp::ClassLeaseCounter::removeLease(), and isc::dhcp::ClassLeaseCounter::updateLease().
|
static |
Expired and reclaimed lease.
Definition at line 75 of file lease.h.
Referenced by basicStatesToText(), fromElementCommon(), and stateExpiredReclaimed().
|
static |
Released lease held in the database for lease affinity.
Definition at line 78 of file lease.h.
Referenced by basicStatesToText(), isc::lease_cmds::Lease4Parser::parse(), isc::lease_cmds::Lease6Parser::parse(), isc::dhcp::Dhcpv4Srv::processRelease(), isc::dhcp::Dhcpv6Srv::releaseIA_NA(), and isc::dhcp::Dhcpv6Srv::releaseIA_PD().
SubnetID isc::dhcp::Lease::subnet_id_ |
Subnet identifier.
Specifies the identification of the subnet to which the lease belongs.
Definition at line 157 of file lease.h.
Referenced by isc::dhcp::Lease4::operator==(), isc::dhcp::Lease6::operator==(), isc::dhcp::Lease4::toElement(), isc::dhcp::Lease6::toElement(), isc::dhcp::Lease4::toText(), and isc::dhcp::Lease6::toText().
uint32_t isc::dhcp::Lease::valid_lft_ |
Valid lifetime.
Expressed as number of seconds since cltt.
Definition at line 128 of file lease.h.
Referenced by isc::dhcp::Lease4::decline(), isc::dhcp::Lease6::decline(), expired(), getExpirationTime(), isc::dhcp::Lease4::operator==(), isc::dhcp::Lease6::operator==(), isc::dhcp::Lease4::toElement(), isc::dhcp::Lease6::toElement(), isc::dhcp::Lease4::toText(), and isc::dhcp::Lease6::toText().