Kea  2.1.7-git
isc::dhcp::Lease6 Struct Reference

Structure that holds a lease for IPv6 address and/or prefix. More...

#include <lease.h>

+ Inheritance diagram for isc::dhcp::Lease6:

Public Member Functions

 Lease6 (Lease::Type type, const isc::asiolink::IOAddress &addr, DuidPtr duid, uint32_t iaid, uint32_t preferred, uint32_t valid, SubnetID subnet_id, const HWAddrPtr &hwaddr=HWAddrPtr(), uint8_t prefixlen=128)
 Constructor. More...
 
 Lease6 (Lease::Type type, const isc::asiolink::IOAddress &addr, DuidPtr duid, uint32_t iaid, uint32_t preferred, uint32_t valid, SubnetID subnet_id, const bool fqdn_fwd, const bool fqdn_rev, const std::string &hostname, const HWAddrPtr &hwaddr=HWAddrPtr(), uint8_t prefixlen=128)
 Constructor, including FQDN data. More...
 
 Lease6 ()
 Constructor. More...
 
void decline (uint32_t probation_period)
 Sets IPv6 lease to declined state. More...
 
const std::vector< uint8_t > & getDuidVector () const
 Returns a reference to a vector representing a DUID. More...
 
bool operator!= (const Lease6 &other) const
 Compare two leases for inequality. More...
 
bool operator== (const Lease6 &other) const
 Compare two leases for equality. More...
 
virtual isc::data::ElementPtr toElement () const
 Return the JSON representation of a lease. More...
 
virtual std::string toText () const
 Convert Lease to Printable Form. More...
 
- Public Member Functions inherited from 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. More...
 
virtual ~Lease ()
 Destructor. 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...
 
void updateCurrentExpirationTime ()
 Update lease current expiration time with new value, so that additional operations can be done without performing extra read from the database. More...
 
- 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...
 

Static Public Member Functions

static Lease6Ptr fromElement (const data::ConstElementPtr &element)
 Returns pointer to the IPv6 lease created from JSON representation. More...
 
static std::string statesToText (const uint32_t state)
 Returns name of the lease states specific to DHCPv6. More...
 
- Static Public Member Functions inherited from isc::dhcp::Lease
static std::string lifetimeToText (uint32_t lifetime)
 Print lifetime. More...
 
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 std::string basicStatesToText (const uint32_t state)
 Returns name(s) of the basic lease state(s). More...
 
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. More...
 
- Static Public Member Functions inherited from isc::data::UserContext
static data::ElementPtr toElement (data::ConstElementPtr map)
 Copy an Element map. More...
 

Public Attributes

DuidPtr duid_
 Client identifier. More...
 
uint32_t iaid_
 Identity Association Identifier (IAID) More...
 
uint32_t preferred_lft_
 Preferred lifetime. More...
 
uint8_t prefixlen_
 IPv6 prefix length. More...
 
uint32_t reuseable_preferred_lft_
 Remaining preferred lifetime. More...
 
Lease::Type type_
 Lease type. More...
 
- Public Attributes inherited from isc::dhcp::Lease
isc::asiolink::IOAddress addr_
 IPv4 ot IPv6 address. More...
 
uint32_t valid_lft_
 Valid lifetime. More...
 
uint32_t current_valid_lft_
 Current valid lifetime. More...
 
uint32_t reuseable_valid_lft_
 Remaining valid lifetime. More...
 
time_t cltt_
 Client last transmission time. More...
 
time_t current_cltt_
 Current 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...
 

Additional Inherited Members

- Public Types inherited from isc::dhcp::Lease
enum  Type { TYPE_NA = 0, TYPE_TA = 1, TYPE_PD = 2, TYPE_V4 = 3 }
 Type of lease or pool. More...
 
- Static Public Attributes inherited from isc::dhcp::Lease
static const uint32_t INFINITY_LFT = 0xffffffff
 Infinity (means static, i.e. never expire) More...
 
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...
 
- Static Protected Member Functions inherited from isc::dhcp::Lease
static void fromElementCommon (const LeasePtr &lease, const data::ConstElementPtr &element)
 Sets common (for v4 and v6) properties of the lease object. More...
 
- Protected Attributes inherited from isc::data::UserContext
data::ConstElementPtr user_context_
 Pointer to the user context (may be NULL) More...
 

Detailed Description

Structure that holds a lease for IPv6 address and/or prefix.

For performance reasons it is a simple structure, not a class. If we chose make it a class, all fields would have to made private and getters/setters would be required. As this is a critical part of the code that will be used extensively, direct access is warranted.

Definition at line 498 of file lease.h.

Constructor & Destructor Documentation

◆ Lease6() [1/3]

isc::dhcp::Lease6::Lease6 ( Lease::Type  type,
const isc::asiolink::IOAddress addr,
DuidPtr  duid,
uint32_t  iaid,
uint32_t  preferred,
uint32_t  valid,
SubnetID  subnet_id,
const HWAddrPtr hwaddr = HWAddrPtr(),
uint8_t  prefixlen = 128 
)

Constructor.

Todo:
: Add DHCPv6 failover related fields here
Parameters
typeLease type.
addrAssigned address.
duidA pointer to an object representing DUID.
iaidIAID.
preferredPreferred lifetime.
validValid lifetime.
subnet_idA Subnet identifier.
hwaddrhardware/MAC address (optional)
prefixlenAn address prefix length (optional, defaults to 128)

Definition at line 490 of file lease.cc.

References isc::dhcp::Lease::cltt_, isc::dhcp::Lease::current_cltt_, and isc_throw.

◆ Lease6() [2/3]

isc::dhcp::Lease6::Lease6 ( Lease::Type  type,
const isc::asiolink::IOAddress addr,
DuidPtr  duid,
uint32_t  iaid,
uint32_t  preferred,
uint32_t  valid,
SubnetID  subnet_id,
const bool  fqdn_fwd,
const bool  fqdn_rev,
const std::string &  hostname,
const HWAddrPtr hwaddr = HWAddrPtr(),
uint8_t  prefixlen = 128 
)

Constructor, including FQDN data.

Parameters
typeLease type.
addrAssigned address.
duidA pointer to an object representing DUID.
iaidIAID.
preferredPreferred lifetime.
validValid lifetime.
subnet_idA Subnet identifier.
fqdn_fwdIf true, forward DNS update is performed for a lease.
fqdn_revIf true, reverse DNS update is performed for a lease.
hostnameFQDN of the client which gets the lease.
hwaddrhardware address (MAC), may be NULL
prefixlenAn address prefix length (optional, defaults to 128)

Definition at line 504 of file lease.cc.

References isc::dhcp::Lease::cltt_, isc::dhcp::Lease::current_cltt_, and isc_throw.

◆ Lease6() [3/3]

isc::dhcp::Lease6::Lease6 ( )

Constructor.

Initialize fields that don't have a default constructor.

Definition at line 521 of file lease.cc.

Referenced by fromElement().

Member Function Documentation

◆ decline()

void isc::dhcp::Lease6::decline ( uint32_t  probation_period)
virtual

Sets IPv6 lease to declined state.

See Lease::decline for detailed description.

Parameters
probation_periodvalid lifetime will be set to this value

Implements isc::dhcp::Lease.

Definition at line 543 of file lease.cc.

References isc::dhcp::Lease::cltt_, duid_, isc::dhcp::DUID::EMPTY(), isc::dhcp::Lease::fqdn_fwd_, isc::dhcp::Lease::fqdn_rev_, isc::dhcp::Lease::hostname_, isc::dhcp::Lease::hwaddr_, preferred_lft_, isc::dhcp::Lease::state_, isc::dhcp::Lease::STATE_DECLINED, and isc::dhcp::Lease::valid_lft_.

+ Here is the call graph for this function:

◆ fromElement()

Lease6Ptr isc::dhcp::Lease6::fromElement ( const data::ConstElementPtr element)
static

Returns pointer to the IPv6 lease created from JSON representation.

Parameters
elementpointer to the data element object to be parsed.
Returns
Pointer to the created lease.

Definition at line 673 of file lease.cc.

References isc::dhcp::DUID::duid_, isc::dhcp::Lease::fromElementCommon(), isc::dhcp::DUID::fromText(), isc::dhcp::DUID::getDuid(), isc_throw, Lease6(), isc::dhcp::Lease::textToType(), and isc::dhcp::Lease::TYPE_PD.

+ Here is the call graph for this function:

◆ getDuidVector()

const std::vector< uint8_t > & isc::dhcp::Lease6::getDuidVector ( ) const

Returns a reference to a vector representing a DUID.

Warning
Since the function returns the reference to a vector (not a copy), the returned object should be used with caution because it will remain valid only for the period of time when an object which returned it exists.
Returns
A reference to a vector holding a DUID.

Definition at line 533 of file lease.cc.

References duid_.

◆ operator!=()

bool isc::dhcp::Lease6::operator!= ( const Lease6 other) const
inline

Compare two leases for inequality.

Parameters
otherlease6 object with which to compare

Definition at line 611 of file lease.h.

References isc::data::CfgToElement::toElement(), and isc::dhcp::Lease::toText().

+ Here is the call graph for this function:

◆ operator==()

◆ statesToText()

std::string isc::dhcp::Lease6::statesToText ( const uint32_t  state)
static

Returns name of the lease states specific to DHCPv6.

Todo:
Currently it simply returns common states for DHCPv4 and DHCPv6. This method will have to be extended to handle DHCPv6 specific states when they are defined.
Parameters
stateNumeric value holding lease states.
Returns
Comma separated list of lease state names.

Definition at line 528 of file lease.cc.

References isc::dhcp::Lease::basicStatesToText().

Referenced by isc::dhcp::Lease4::toText(), and toText().

+ Here is the call graph for this function:

◆ toElement()

◆ toText()

std::string isc::dhcp::Lease6::toText ( ) const
virtual

Member Data Documentation

◆ duid_

DuidPtr isc::dhcp::Lease6::duid_

Client identifier.

Definition at line 518 of file lease.h.

Referenced by isc::dhcp::CSVLeaseFile6::append(), decline(), getDuidVector(), operator==(), toElement(), and toText().

◆ iaid_

uint32_t isc::dhcp::Lease6::iaid_

Identity Association Identifier (IAID)

DHCPv6 stores all addresses and prefixes in IA containers (IA_NA, IA_TA, IA_PD). All containers may appear more than once in a message. To differentiate between them, the IAID field is present

Definition at line 515 of file lease.h.

Referenced by isc::dhcp::CSVLeaseFile6::append(), operator==(), toElement(), and toText().

◆ preferred_lft_

uint32_t isc::dhcp::Lease6::preferred_lft_

Preferred lifetime.

This parameter specifies the preferred lifetime since the lease was assigned or renewed (cltt), expressed in seconds.

Definition at line 524 of file lease.h.

Referenced by isc::dhcp::CSVLeaseFile6::append(), decline(), isc::dhcp::Memfile_LeaseMgr::deleteLease(), operator==(), toElement(), and toText().

◆ prefixlen_

uint8_t isc::dhcp::Lease6::prefixlen_

IPv6 prefix length.

This is used only for prefix delegations and is ignored otherwise.

Definition at line 508 of file lease.h.

Referenced by isc::dhcp::CSVLeaseFile6::append(), isc::dhcp::AllocEngine::makeIPv6Resrv(), operator==(), toElement(), and toText().

◆ reuseable_preferred_lft_

uint32_t isc::dhcp::Lease6::reuseable_preferred_lft_

Remaining preferred lifetime.

Expressed as number of seconds since current time, also preferred lifetime - age where age is old cltt - new cltt. This parameter is used only when reuseable_valid_lft_ is not zero, i.e. when the lease can be reused.

Definition at line 532 of file lease.h.

Referenced by operator==().

◆ type_

Lease::Type isc::dhcp::Lease6::type_

Lease type.

One of normal address, temporary address, or prefix.

Definition at line 503 of file lease.h.

Referenced by isc::dhcp::CSVLeaseFile6::append(), isc::dhcp::AllocEngine::makeIPv6Resrv(), operator==(), toElement(), and toText().


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