Kea: isc::dhcp::Lease Struct Reference

| Kea 1.5.0

Public Types | Static Public Member Functions | List of all members
isc::dhcp::Lease Struct Referenceabstract

a common structure for IPv4 and IPv6 leases More...

`#include <lease.h>`

Inheritance diagram for isc::dhcp::Lease:
[legend]

## 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 Type | textToType (const std::string &text)
| Converts type name to the actual type. More...
static std::string | typeToText (Type type)
| returns text representation of a lease type More...
Static Public Member Functions inherited from isc::data::UserContext
static data::ElementPtr | toElement (data::ConstElementPtr map)
| Copy extracting comments an Element map. More...

## Common lease states constants.
static const uint32_t | STATE_DEFAULT = 0x0
| A lease in the default state. More...
static const uint32_t | STATE_DECLINED = 0x1
| Declined lease. More...
static const uint32_t | STATE_EXPIRED_RECLAIMED = 0x2
| Expired and reclaimed lease. More...
isc::asiolink::IOAddress | addr_
| IPv4 ot IPv6 address. More...
uint32_t | t1_
| Renewal timer. More...
uint32_t | t2_
| Rebinding timer. More...
uint32_t | valid_lft_
| Valid lifetime. More...
time_t | cltt_
| Client last transmission time. More...
SubnetID | subnet_id_
| Subnet identifier. More...
std::string | hostname_
| Client hostname. More...
bool | fqdn_fwd_
| Forward zone updated? More...
bool | fqdn_rev_
| Reverse zone updated? More...
HWAddrPtr | hwaddr_
| Client's MAC/hardware address. More...
uint32_t | state_
| Holds the lease state(s). More...
static std::string | basicStatesToText (const uint32_t state)
| Returns name(s) of the basic lease state(s). More...
| Lease (const isc::asiolink::IOAddress &addr, uint32_t t1, uint32_t t2, 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. More...
virtual | ~Lease ()
| Destructor. More...
virtual std::string | toText () const =0
| Convert Lease to Printable Form. More...
bool | expired () const
| returns true if the lease is expired More...
bool | stateExpiredReclaimed () const
| Indicates if the lease is in the "expired-reclaimed" state. More...
bool | stateDeclined () const
| Indicates if the lease is in the "declined" state. More...
bool | hasIdenticalFqdn (const Lease &other) const
| Returns true if the other lease has equal FQDN data. More...
const std::vector< uint8_t > & | getHWAddrVector () const
| Returns raw (as vector) hardware address. More...
int64_t | getExpirationTime () const
| Returns lease expiration time. More...
virtual void | decline (uint32_t probation_period)=0
| Sets lease to DECLINED state. More...
static void | fromElementCommon (const LeasePtr &lease, const data::ConstElementPtr &element)
| Sets common (for v4 and v6) properties of the lease object. More...

## Additional Inherited Members
Public Member Functions inherited from isc::data::UserContext
void | contextToElement (data::ElementPtr map) const
| Merge unparse a user_context object. More...
data::ConstElementPtr | getContext () const
| Returns const pointer to the user context. More...
void | setContext (const data::ConstElementPtr &ctx)
| Sets user context. More...
Public Member Functions inherited from isc::data::CfgToElement
virtual | ~CfgToElement ()
| Destructor. More...
virtual isc::data::ElementPtr | toElement () const =0
| Unparse a configuration object. More...
Protected Attributes inherited from isc::data::UserContext
data::ConstElementPtr | user_context_
| Pointer to the user context (may be NULL) More...

## Detailed Description

a common structure for IPv4 and IPv6 leases

This structure holds all information that is common between IPv4 and IPv6 leases.

Definition at line 35 of file lease.h.

## Member Enumeration Documentation

## ◆ Type

enum isc::dhcp::Lease::Type

Type of lease or pool.

Enumerator
TYPE_NA | the lease contains non-temporary IPv6 address
TYPE_TA | the lease contains temporary IPv6 address
TYPE_PD | the lease contains IPv6 prefix (for prefix delegation)
TYPE_V4 | IPv4 lease.

Definition at line 38 of file lease.h.

## Constructor & Destructor Documentation

## ◆ Lease()

isc::dhcp::Lease::Lease | ( | const isc::asiolink::IOAddress & | addr,
|  | uint32_t | t1,
|  | uint32_t | t2,
|  | 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.

Parameters

  addr | IP address
  t1 | renewal time
  t2 | rebinding time
  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

Definition at line 28 of file lease.cc.

## ◆ ~Lease()

virtual isc::dhcp::Lease::~Lease | ( |  | ) |
| inlinevirtual

Destructor.

Definition at line 97 of file lease.h.

## Member Function Documentation

## ◆ basicStatesToText()

std::string isc::dhcp::Lease::basicStatesToText | ( | const uint32_t | state | ) |
| static

Returns name(s) of the basic lease state(s).

Parameters

  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.

Returns
  Comma separated list of state names.

Definition at line 77 of file lease.cc.

References STATE_DECLINED, STATE_DEFAULT, and STATE_EXPIRED_RECLAIMED.

Referenced by isc::dhcp::Lease4::statesToText(), and isc::dhcp::Lease6::statesToText().

## ◆ decline()

virtual void isc::dhcp::Lease::decline | ( | uint32_t | probation_period | ) |
| pure virtual

Sets lease to DECLINED state.

All client identifying parameters will be stripped off (HWaddr, client_id, hostname), timers set to 0 (t1, t2), 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.

Parameters

  probation_period | lease lifetime will be set to this value

Implemented in isc::dhcp::Lease6, and isc::dhcp::Lease4.

## ◆ expired()

bool isc::dhcp::Lease::expired | ( |  | ) | const

returns true if the lease is expired

Returns
  true if the lease is expired

Definition at line 95 of file lease.cc.

References getExpirationTime().

Here is the call graph for this function:

## ◆ fromElementCommon()

void isc::dhcp::Lease::fromElementCommon | ( | const LeasePtr & | lease,
|  | const data::ConstElementPtr & | element
| ) |  |
| 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.

Parameters

  [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 122 of file lease.cc.

References isc::dhcp::HWAddr::fromText(), isc::dhcp::HTYPE_ETHER, isc::dhcp::HWAddr::hwaddr_, isc_throw, and STATE_EXPIRED_RECLAIMED.

Referenced by isc::dhcp::Lease4::fromElement(), and isc::dhcp::Lease6::fromElement().

Here is the call graph for this function:

## ◆ getExpirationTime()

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 110 of file lease.cc.

References cltt_, and valid_lft_.

Referenced by expired().

## ◆ getHWAddrVector()

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.

Returns
  const reference to the hardware address

Definition at line 327 of file lease.cc.

References hwaddr_.

## ◆ hasIdenticalFqdn()

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.

Parameters

  other | Lease which FQDN data is to be compared with our lease.

Returns
  Boolean value which indicates whether FQDN data of the other lease is equal to the FQDN data of our lease (true) or not (false).

Definition at line 115 of file lease.cc.

References fqdn_fwd_, fqdn_rev_, and hostname_.

## ◆ stateDeclined()

bool isc::dhcp::Lease::stateDeclined | ( |  | ) | const

Indicates if the lease is in the "declined" state.

Returns
  true if the lease is in the "declined" state, false otherwise.

Definition at line 105 of file lease.cc.

References state_, and STATE_DECLINED.

## ◆ stateExpiredReclaimed()

bool isc::dhcp::Lease::stateExpiredReclaimed | ( |  | ) | const

Indicates if the lease is in the "expired-reclaimed" state.

Returns
  true if the lease is in the "expired-reclaimed" state, false otherwise.

Definition at line 100 of file lease.cc.

References state_, and STATE_EXPIRED_RECLAIMED.

## ◆ textToType()

Lease::Type isc::dhcp::Lease::textToType | ( | const std::string & | text | ) |
| static

Converts type name to the actual type.

Parameters

  text | lease type as text.

Returns
  converted type.

Exceptions

  BadValue | if the text contains unsupported value.

Definition at line 59 of file lease.cc.

References isc_throw, TYPE_NA, TYPE_PD, TYPE_TA, and TYPE_V4.

Referenced by isc::dhcp::Lease6::fromElement().

## ◆ toText()

virtual std::string isc::dhcp::Lease::toText | ( |  | ) | const
| pure virtual

Convert Lease to Printable Form.

Returns
  String form of the lease

Implemented in isc::dhcp::Lease6, and isc::dhcp::Lease4.

Referenced by isc::dhcp::operator<<().

## ◆ typeToText()

std::string isc::dhcp::Lease::typeToText | ( | Lease::Type | type | ) |
| static

returns text representation of a lease type

Parameters

  type | lease or pool type to be converted

Returns
  text description

Definition at line 39 of file lease.cc.

References TYPE_NA, TYPE_PD, TYPE_TA, and TYPE_V4.

Referenced by isc::dhcp::Subnet::addPool(), isc::dhcp::AllocEngine::getAllocator(), isc::dhcp::Memfile_LeaseMgr::getLease6(), isc::dhcp::Memfile_LeaseMgr::getLeases6(), isc::dhcp::Lease6::toElement(), isc::dhcp::Pool::toText(), isc::dhcp::Pool6::toText(), and isc::dhcp::Lease6::toText().

## Member Data Documentation

## ◆ addr_

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 102 of file lease.h.

Referenced by isc::dhcp::CSVLeaseFile6::append(), isc::dhcp::CSVLeaseFile4::append(), isc::dhcp::AllocEngine::makeIPv6Resrv(), isc::dhcp::Lease4::operator=(), 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().

## ◆ cltt_

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 131 of file lease.h.

Referenced by isc::dhcp::CSVLeaseFile6::append(), isc::dhcp::CSVLeaseFile4::append(), isc::dhcp::Lease4::decline(), isc::dhcp::Lease6::decline(), getExpirationTime(), isc::dhcp::Lease6::Lease6(), isc::dhcp::Lease4::operator=(), 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().

## ◆ fqdn_fwd_

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 146 of file lease.h.

Referenced by isc::dhcp::CSVLeaseFile6::append(), isc::dhcp::CSVLeaseFile4::append(), isc::dhcp::Lease4::decline(), isc::dhcp::Lease6::decline(), hasIdenticalFqdn(), isc::dhcp::Lease4::operator=(), isc::dhcp::Lease4::operator==(), isc::dhcp::Lease6::operator==(), isc::dhcp::Lease4::toElement(), and isc::dhcp::Lease6::toElement().

## ◆ fqdn_rev_

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 151 of file lease.h.

Referenced by isc::dhcp::CSVLeaseFile6::append(), isc::dhcp::CSVLeaseFile4::append(), isc::dhcp::Lease4::decline(), isc::dhcp::Lease6::decline(), hasIdenticalFqdn(), isc::dhcp::Lease4::operator=(), isc::dhcp::Lease4::operator==(), isc::dhcp::Lease6::operator==(), isc::dhcp::Lease4::toElement(), and isc::dhcp::Lease6::toElement().

## ◆ hostname_

std::string isc::dhcp::Lease::hostname_

Client hostname.

This field may be empty

Definition at line 141 of file lease.h.

Referenced by isc::dhcp::CSVLeaseFile6::append(), isc::dhcp::CSVLeaseFile4::append(), isc::dhcp::Lease4::decline(), isc::dhcp::Lease6::decline(), hasIdenticalFqdn(), isc::dhcp::Lease4::operator=(), isc::dhcp::Lease4::operator==(), isc::dhcp::Lease6::operator==(), isc::dhcp::Lease4::toElement(), and isc::dhcp::Lease6::toElement().

## ◆ hwaddr_

HWAddrPtr isc::dhcp::Lease::hwaddr_

Client's MAC/hardware address.

This information may not be available in certain cases.

Definition at line 156 of file lease.h.

Referenced by isc::dhcp::CSVLeaseFile6::append(), isc::dhcp::CSVLeaseFile4::append(), isc::dhcp::Lease4::belongsToClient(), isc::dhcp::Lease4::decline(), isc::dhcp::Lease6::decline(), getHWAddrVector(), isc::dhcp::Lease4::Lease4(), isc::dhcp::Lease4::operator=(), 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().

## ◆ state_

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 167 of file lease.h.

Referenced by isc::dhcp::CSVLeaseFile6::append(), isc::dhcp::CSVLeaseFile4::append(), isc::dhcp::Lease4::decline(), isc::dhcp::Lease6::decline(), isc::dhcp::Lease4::Lease4(), isc::dhcp::Lease4::operator=(), 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().

## ◆ STATE_DECLINED

const uint32_t isc::dhcp::Lease::STATE_DECLINED = 0x1
| static

Declined lease.

Definition at line 64 of file lease.h.

Referenced by basicStatesToText(), isc::dhcp::Lease4::decline(), isc::dhcp::Lease6::decline(), isc::dhcp::CqlLeaseStatsQuery::executeSelect(), isc::stat_cmds::LeaseStatCmdsImpl::makeResultSet4(), isc::stat_cmds::LeaseStatCmdsImpl::makeResultSet6(), isc::dhcp::CSVLeaseFile6::next(), isc::dhcp::CSVLeaseFile4::next(), isc::dhcp::LeaseMgr::recountLeaseStats4(), isc::dhcp::LeaseMgr::recountLeaseStats6(), isc::dhcp::MemfileLeaseStatsQuery4::start(), isc::dhcp::MemfileLeaseStatsQuery6::start(), and stateDeclined().

## ◆ STATE_DEFAULT

const uint32_t isc::dhcp::Lease::STATE_DEFAULT = 0x0
| static

A lease in the default state.

Definition at line 61 of file lease.h.

Referenced by basicStatesToText(), isc::dhcp::CqlLeaseStatsQuery::executeSelect(), isc::dhcp::CqlLease4Exchange::getExpiredLeases(), isc::dhcp::CqlLease6Exchange::getExpiredLeases(), isc::stat_cmds::LeaseStatCmdsImpl::makeResultSet4(), isc::stat_cmds::LeaseStatCmdsImpl::makeResultSet6(), isc::dhcp::LeaseMgr::recountLeaseStats4(), isc::dhcp::LeaseMgr::recountLeaseStats6(), isc::dhcp::MemfileLeaseStatsQuery4::start(), and isc::dhcp::MemfileLeaseStatsQuery6::start().

## ◆ STATE_EXPIRED_RECLAIMED

const uint32_t isc::dhcp::Lease::STATE_EXPIRED_RECLAIMED = 0x2
| static

Expired and reclaimed lease.

Definition at line 67 of file lease.h.

Referenced by basicStatesToText(), isc::dhcp::CqlLeaseMgr::deleteExpiredReclaimedLeases4(), isc::dhcp::CqlLeaseMgr::deleteExpiredReclaimedLeases6(), fromElementCommon(), isc::dhcp::CqlLease4Exchange::getExpiredLeases(), isc::dhcp::CqlLease6Exchange::getExpiredLeases(), and stateExpiredReclaimed().

## ◆ subnet_id_

SubnetID isc::dhcp::Lease::subnet_id_

Subnet identifier.

Specifies the identification of the subnet to which the lease belongs.

Definition at line 136 of file lease.h.

Referenced by isc::dhcp::CSVLeaseFile6::append(), isc::dhcp::CSVLeaseFile4::append(), isc::dhcp::Lease4::operator=(), 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().

## ◆ t1_

uint32_t isc::dhcp::Lease::t1_

Renewal timer.

Specifies renewal time. Although technically it is a property of the IA container and not the address itself, since our data model does not define a separate IA entity, we are keeping it in the lease. In the case of multiple addresses/prefixes for the same IA, each must have consistent T1 and T2 values. This is specified in seconds since cltt.

Definition at line 111 of file lease.h.

Referenced by isc::dhcp::Lease4::decline(), isc::dhcp::Lease6::decline(), isc::dhcp::Lease4::operator=(), isc::dhcp::Lease4::operator==(), isc::dhcp::Lease6::operator==(), and isc::dhcp::Lease4::toText().

## ◆ t2_

uint32_t isc::dhcp::Lease::t2_

Rebinding timer.

Specifies rebinding time. Although technically it is a property of the IA container and not the address itself, since our data model does not define a separate IA entity, we are keeping it in the lease. In the case of multiple addresses/prefixes for the same IA, each must have consistent T1 and T2 values. This is specified in seconds since cltt.

Definition at line 120 of file lease.h.

Referenced by isc::dhcp::Lease4::decline(), isc::dhcp::Lease6::decline(), isc::dhcp::Lease4::operator=(), isc::dhcp::Lease4::operator==(), isc::dhcp::Lease6::operator==(), and isc::dhcp::Lease4::toText().

## ◆ valid_lft_

uint32_t isc::dhcp::Lease::valid_lft_

Valid lifetime.

Expressed as number of seconds since cltt.

Definition at line 125 of file lease.h.

Referenced by isc::dhcp::CSVLeaseFile6::append(), isc::dhcp::CSVLeaseFile4::append(), isc::dhcp::Lease4::decline(), isc::dhcp::Lease6::decline(), isc::dhcp::Memfile_LeaseMgr::deleteLease(), getExpirationTime(), isc::dhcp::Lease4::operator=(), 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().

The documentation for this struct was generated from the following files:

- lease.h
- lease.cc