Kea 2.7.5
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 Types

enum  ExtendedInfoAction { ACTION_IGNORE , ACTION_DELETE , ACTION_UPDATE }
 Action on extended info tables. More...
 
- 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...
 

Public Member Functions

 Lease6 ()
 Constructor.
 
 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.
 
 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.
 
void decline (uint32_t probation_period)
 Sets IPv6 lease to declined state.
 
const std::vector< uint8_t > & getDuidVector () const
 Returns a reference to a vector representing a DUID.
 
virtual Lease::Type getType () const
 Returns Lease type.
 
bool operator!= (const Lease6 &other) const
 Compare two leases for inequality.
 
bool operator== (const Lease6 &other) const
 Compare two leases for equality.
 
virtual isc::data::ElementPtr toElement () const
 Return the JSON representation of a lease.
 
virtual std::string toText () const
 Convert Lease to Printable Form.
 
- 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.
 
virtual ~Lease ()
 Destructor.
 
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.
 
void updateCurrentExpirationTime ()
 Update lease current expiration time with new value, so that additional operations can be done without performing extra read from the database.
 
- 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.
 

Static Public Member Functions

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

Public Attributes

DuidPtr duid_
 Client identifier.
 
ExtendedInfoAction extended_info_action_
 Record the action on extended info tables in the lease.
 
uint32_t iaid_
 Identity Association Identifier (IAID)
 
uint32_t preferred_lft_
 Preferred lifetime.
 
uint8_t prefixlen_
 IPv6 prefix length.
 
uint32_t reuseable_preferred_lft_
 Remaining preferred lifetime.
 
Lease::Type type_
 Lease type.
 
- Public Attributes inherited from isc::dhcp::Lease
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).
 

Additional Inherited Members

- Static Public Attributes inherited from isc::dhcp::Lease
static const uint32_t INFINITY_LFT = 0xffffffff
 Infinity (means static, i.e. never expire)
 
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.
 
- 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.
 
- Protected Attributes inherited from isc::data::UserContext
data::ConstElementPtr user_context_
 Pointer to the user context (may be NULL)
 

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

Member Enumeration Documentation

◆ ExtendedInfoAction

Action on extended info tables.

Enumerator
ACTION_IGNORE 

ignore extended info,

ACTION_DELETE 

delete reference to the lease

ACTION_UPDATE 

update extended info tables.

Definition at line 553 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 453 of file lease.cc.

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

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

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

◆ Lease6() [3/3]

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

Constructor.

Initialize fields that don't have a default constructor.

Definition at line 499 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 522 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 662 of file lease.cc.

References Lease6(), isc::dhcp::Lease::fromElementCommon(), isc::dhcp::DUID::fromText(), isc::data::Element::integer, isc_throw, isc::data::Element::string, 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 512 of file lease.cc.

References duid_.

◆ getType()

virtual Lease::Type isc::dhcp::Lease6::getType ( ) const
inlinevirtual

Returns Lease type.

Since Lease does not define a member for lease type, we implement this so code that only has LeasePtr can see what it has.

Returns
Type of lease

Implements isc::dhcp::Lease.

Definition at line 610 of file lease.h.

References type_.

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

◆ operator==()

bool isc::dhcp::Lease6::operator== ( const Lease6 & other) const

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

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

Referenced by toText().

+ Here is the call graph for this function:

◆ toElement()

◆ toText()

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

Convert Lease to Printable Form.

Returns
String form of the lease
Todo
: print out DUID

Implements isc::dhcp::Lease.

Definition at line 535 of file lease.cc.

References isc::dhcp::Lease::addr_, isc::dhcp::Lease::cltt_, duid_, isc::data::UserContext::getContext(), isc::dhcp::Lease::hwaddr_, iaid_, isc::dhcp::Lease::lifetimeToText(), isc::dhcp::Lease::pool_id_, preferred_lft_, prefixlen_, isc::dhcp::Lease::state_, statesToText(), isc::dhcp::Lease::subnet_id_, type_, isc::dhcp::Lease::typeToText(), and isc::dhcp::Lease::valid_lft_.

+ Here is the call graph for this function:

Member Data Documentation

◆ duid_

DuidPtr isc::dhcp::Lease6::duid_

Client identifier.

Definition at line 536 of file lease.h.

Referenced by decline(), getDuidVector(), operator==(), toElement(), and toText().

◆ extended_info_action_

ExtendedInfoAction isc::dhcp::Lease6::extended_info_action_

Record the action on extended info tables in the lease.

Definition at line 560 of file lease.h.

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

Referenced by 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 542 of file lease.h.

Referenced by decline(), 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 526 of file lease.h.

Referenced by 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 550 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 521 of file lease.h.

Referenced by getType(), operator==(), toElement(), and toText().


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