Kea  2.1.7-git
isc::dhcp::CfgHosts Class Reference

Represents the host reservations specified in the configuration file. More...

#include <cfg_hosts.h>

+ Inheritance diagram for isc::dhcp::CfgHosts:

Public Member Functions

virtual ~CfgHosts ()
 Destructor. More...
 
virtual void add (const HostPtr &host)
 Adds a new host to the collection. More...
 
virtual bool del (const SubnetID &subnet_id, const asiolink::IOAddress &addr)
 Attempts to delete a hosts by address. More...
 
virtual bool del4 (const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len)
 Attempts to delete a host by (subnet4-id, identifier, identifier-type) More...
 
virtual bool del6 (const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len)
 Attempts to delete a host by (subnet6-id, identifier, identifier-type) More...
 
virtual size_t delAll4 (const SubnetID &subnet_id)
 Attempts to delete all hosts for a given IPv4 subnet. More...
 
virtual size_t delAll6 (const SubnetID &subnet_id)
 Attempts to delete all hosts for a given IPv6 subnet. More...
 
virtual ConstHostPtr get4 (const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const
 Returns a host connected to the IPv4 subnet. More...
 
virtual HostPtr get4 (const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len)
 Returns a host connected to the IPv4 subnet. More...
 
virtual ConstHostPtr get4 (const SubnetID &subnet_id, const asiolink::IOAddress &address) const
 Returns a host connected to the IPv4 subnet and having a reservation for a specified IPv4 address. More...
 
virtual ConstHostPtr get6 (const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const
 Returns a host connected to the IPv6 subnet. More...
 
virtual HostPtr get6 (const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len)
 Returns a host connected to the IPv6 subnet. More...
 
virtual ConstHostPtr get6 (const asiolink::IOAddress &prefix, const uint8_t prefix_len) const
 Returns a host using the specified IPv6 prefix. More...
 
virtual HostPtr get6 (const asiolink::IOAddress &prefix, const uint8_t prefix_len)
 Returns a host using the specified IPv6 prefix. More...
 
virtual ConstHostPtr get6 (const SubnetID &subnet_id, const asiolink::IOAddress &address) const
 Returns a host connected to the IPv6 subnet and having a reservation for a specified IPv6 address. More...
 
virtual HostPtr get6 (const SubnetID &subnet_id, const asiolink::IOAddress &address)
 Returns a host connected to the IPv6 subnet and having a reservation for a specified IPv6 address. More...
 
virtual ConstHostCollection getAll (const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const
 Return all hosts connected to any subnet for which reservations have been made using a specified identifier. More...
 
virtual HostCollection getAll (const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len)
 Non-const version of the getAll const method. More...
 
virtual ConstHostCollection getAll4 (const SubnetID &subnet_id) const
 Return all hosts in a DHCPv4 subnet. More...
 
virtual HostCollection getAll4 (const SubnetID &subnet_id)
 Return all hosts in a DHCPv4 subnet. More...
 
virtual ConstHostCollection getAll4 (const asiolink::IOAddress &address) const
 Returns a collection of hosts using the specified IPv4 address. More...
 
virtual HostCollection getAll4 (const asiolink::IOAddress &address)
 Returns a collection of hosts using the specified IPv4 address. More...
 
virtual ConstHostCollection getAll4 (const SubnetID &subnet_id, const asiolink::IOAddress &address) const
 Returns all hosts connected to the IPv4 subnet and having a reservation for a specified address. More...
 
virtual ConstHostCollection getAll6 (const SubnetID &subnet_id) const
 Return all hosts in a DHCPv6 subnet. More...
 
virtual HostCollection getAll6 (const SubnetID &subnet_id)
 Return all hosts in a DHCPv6 subnet. More...
 
virtual ConstHostCollection getAll6 (const asiolink::IOAddress &address) const
 Returns a collection of hosts using the specified IPv6 address. More...
 
virtual HostCollection getAll6 (const asiolink::IOAddress &address)
 Returns a collection of hosts using the specified IPv6 address. More...
 
virtual ConstHostCollection getAll6 (const SubnetID &subnet_id, const asiolink::IOAddress &address) const
 Returns all hosts connected to the IPv6 subnet and having a reservation for a specified address or delegated prefix (lease). More...
 
virtual ConstHostCollection getAllbyHostname (const std::string &hostname) const
 Return all hosts with a hostname. More...
 
virtual HostCollection getAllbyHostname (const std::string &hostname)
 Return all hosts with a hostname. More...
 
virtual ConstHostCollection getAllbyHostname4 (const std::string &hostname, const SubnetID &subnet_id) const
 Return all hosts with a hostname in a DHCPv4 subnet. More...
 
virtual HostCollection getAllbyHostname4 (const std::string &hostname, const SubnetID &subnet_id)
 Return all hosts with a hostname in a DHCPv4 subnet. More...
 
virtual ConstHostCollection getAllbyHostname6 (const std::string &hostname, const SubnetID &subnet_id) const
 Return all hosts with a hostname in a DHCPv6 subnet. More...
 
virtual HostCollection getAllbyHostname6 (const std::string &hostname, const SubnetID &subnet_id)
 Return all hosts with a hostname in a DHCPv6 subnet. More...
 
virtual ConstHostCollection getPage4 (const SubnetID &subnet_id, size_t &source_index, uint64_t lower_host_id, const HostPageSize &page_size) const
 Returns range of hosts in a DHCPv4 subnet. More...
 
virtual HostCollection getPage4 (const SubnetID &subnet_id, size_t &source_index, uint64_t lower_host_id, const HostPageSize &page_size)
 Returns range of hosts in a DHCPv4 subnet. More...
 
virtual ConstHostCollection getPage4 (size_t &source_index, uint64_t lower_host_id, const HostPageSize &page_size) const
 Returns range of hosts. More...
 
virtual HostCollection getPage4 (size_t &source_index, uint64_t lower_host_id, const HostPageSize &page_size)
 Returns range of hosts. More...
 
virtual ConstHostCollection getPage6 (const SubnetID &subnet_id, size_t &source_index, uint64_t lower_host_id, const HostPageSize &page_size) const
 Returns range of hosts in a DHCPv6 subnet. More...
 
virtual HostCollection getPage6 (const SubnetID &subnet_id, size_t &source_index, uint64_t lower_host_id, const HostPageSize &page_size)
 Returns range of hosts in a DHCPv6 subnet. More...
 
virtual ConstHostCollection getPage6 (size_t &source_index, uint64_t lower_host_id, const HostPageSize &page_size) const
 Returns range of hosts. More...
 
virtual HostCollection getPage6 (size_t &source_index, uint64_t lower_host_id, const HostPageSize &page_size)
 Returns range of hosts. More...
 
virtual std::string getType () const
 Return backend type. More...
 
virtual bool setIPReservationsUnique (const bool unique)
 Controls whether IP reservations are unique or non-unique. More...
 
isc::data::ElementPtr toElement () const
 Unparse a configuration object. More...
 
- Public Member Functions inherited from isc::dhcp::BaseHostDataSource
virtual ~BaseHostDataSource ()
 Default destructor implementation. More...
 
virtual void commit ()
 Commit Transactions. More...
 
virtual isc::db::DatabaseConnection::ParameterMap getParameters () const
 Return backend parameters. More...
 
virtual bool isUnusable ()
 Flag which indicates if the host manager has at least one unusable connection. More...
 
virtual void rollback ()
 Rollback Transactions. More...
 
- Public Member Functions inherited from isc::dhcp::WritableHostDataSource
virtual ~WritableHostDataSource ()
 Default destructor implementation. More...
 
- Public Member Functions inherited from isc::data::CfgToElement
virtual ~CfgToElement ()
 Destructor. More...
 

Additional Inherited Members

- Public Types inherited from isc::dhcp::BaseHostDataSource
enum  IdType { ID_HWADDR = 0, ID_DUID = 1 }
 Specifies the type of an identifier. More...
 

Detailed Description

Represents the host reservations specified in the configuration file.

This class holds a collection of the host reservations (Host objects) which can be retrieved using different search criteria.

In the typical case the reservations are searched using the client's MAC address or DUID and a subnet that the client is connected to. The reservations can be also retrieved using other parameters, such as reserved IP address.

The reservations are added to this object by the configuration parsers, when the new configuration is applied for the server. The reservations are retrieved by the HostMgr class when the server is allocating or renewing an address or prefix for the particular client.

Definition at line 37 of file cfg_hosts.h.

Constructor & Destructor Documentation

◆ ~CfgHosts()

virtual isc::dhcp::CfgHosts::~CfgHosts ( )
inlinevirtual

Destructor.

Definition at line 42 of file cfg_hosts.h.

References add(), del(), del4(), del6(), delAll4(), delAll6(), get4(), get6(), getAll(), getAll4(), getAll6(), getAllbyHostname(), getAllbyHostname4(), getAllbyHostname6(), getPage4(), and getPage6().

+ Here is the call graph for this function:

Member Function Documentation

◆ add()

void isc::dhcp::CfgHosts::add ( const HostPtr host)
virtual

Adds a new host to the collection.

Parameters
hostPointer to the new Host object being added.
Exceptions
DuplicateHostIf a host for a particular HW address or DUID has already been added to the IPv4 or IPv6 subnet.

Implements isc::dhcp::BaseHostDataSource.

Definition at line 952 of file cfg_hosts.cc.

References isc::dhcp::HOSTS_CFG_ADD_HOST, isc::dhcp::HOSTS_DBG_TRACE, isc::dhcp::hosts_logger, isc_throw, and LOG_DEBUG.

Referenced by ~CfgHosts().

◆ del()

bool isc::dhcp::CfgHosts::del ( const SubnetID subnet_id,
const asiolink::IOAddress addr 
)
virtual

Attempts to delete a hosts by address.

This method supports both v4 and v6.

Todo:
: Not implemented.
Parameters
subnet_idsubnet identifier.
addrspecified address.
Todo:
: Implement host removal

Implements isc::dhcp::BaseHostDataSource.

Definition at line 1113 of file cfg_hosts.cc.

References isc_throw.

Referenced by ~CfgHosts().

◆ del4()

bool isc::dhcp::CfgHosts::del4 ( const SubnetID subnet_id,
const Host::IdentifierType identifier_type,
const uint8_t *  identifier_begin,
const size_t  identifier_len 
)
virtual

Attempts to delete a host by (subnet4-id, identifier, identifier-type)

This method supports v4 only.

Todo:
: Not implemented.
Parameters
subnet_idIPv4 Subnet identifier.
identifier_typeIdentifier type.
identifier_beginPointer to a beginning of a buffer containing an identifier.
identifier_lenIdentifier length.
Returns
true if deletion was successful, false otherwise.
Todo:
: Implement host removal

Implements isc::dhcp::BaseHostDataSource.

Definition at line 1132 of file cfg_hosts.cc.

References isc_throw.

Referenced by ~CfgHosts().

◆ del6()

bool isc::dhcp::CfgHosts::del6 ( const SubnetID subnet_id,
const Host::IdentifierType identifier_type,
const uint8_t *  identifier_begin,
const size_t  identifier_len 
)
virtual

Attempts to delete a host by (subnet6-id, identifier, identifier-type)

This method supports v6 only.

Todo:
: Not implemented.
Parameters
subnet_idIPv6 Subnet identifier.
identifier_typeIdentifier type.
identifier_beginPointer to a beginning of a buffer containing an identifier.
identifier_lenIdentifier length.
Returns
true if deletion was successful, false otherwise.
Todo:
: Implement host removal

Implements isc::dhcp::BaseHostDataSource.

Definition at line 1160 of file cfg_hosts.cc.

References isc_throw.

Referenced by ~CfgHosts().

◆ delAll4()

size_t isc::dhcp::CfgHosts::delAll4 ( const SubnetID subnet_id)
virtual

Attempts to delete all hosts for a given IPv4 subnet.

Parameters
subnet_idIdentifier of the subnet for which reservation should be deleted.
Returns
Number of deleted hosts.

Definition at line 1120 of file cfg_hosts.cc.

References isc::dhcp::HOSTS_CFG_DEL_ALL_SUBNET4, isc::dhcp::HOSTS_DBG_TRACE, isc::dhcp::hosts_logger, and LOG_DEBUG.

Referenced by ~CfgHosts().

◆ delAll6()

size_t isc::dhcp::CfgHosts::delAll6 ( const SubnetID subnet_id)
virtual

Attempts to delete all hosts for a given IPv6 subnet.

Parameters
subnet_idIdentifier of the subnet for which reservation should be deleted.
Returns
Number of deleted hosts.

Definition at line 1142 of file cfg_hosts.cc.

References isc::dhcp::HOSTS_CFG_DEL_ALL_SUBNET6, isc::dhcp::HOSTS_DBG_TRACE, isc::dhcp::hosts_logger, and LOG_DEBUG.

Referenced by ~CfgHosts().

◆ get4() [1/3]

ConstHostPtr isc::dhcp::CfgHosts::get4 ( const SubnetID subnet_id,
const Host::IdentifierType identifier_type,
const uint8_t *  identifier_begin,
const size_t  identifier_len 
) const
virtual

Returns a host connected to the IPv4 subnet.

Parameters
subnet_idSubnet identifier.
identifier_typeIdentifier type.
identifier_beginPointer to a beginning of a buffer containing an identifier.
identifier_lenIdentifier length.
Returns
Const Host object for which reservation has been made using the specified identifier.

Implements isc::dhcp::BaseHostDataSource.

Definition at line 664 of file cfg_hosts.cc.

Referenced by ~CfgHosts().

◆ get4() [2/3]

HostPtr isc::dhcp::CfgHosts::get4 ( const SubnetID subnet_id,
const Host::IdentifierType identifier_type,
const uint8_t *  identifier_begin,
const size_t  identifier_len 
)
virtual

Returns a host connected to the IPv4 subnet.

Parameters
subnet_idSubnet identifier.
identifier_typeIdentifier type.
identifier_beginPointer to a beginning of a buffer containing an identifier.
identifier_lenIdentifier length.
Returns
Non-const Host object for which reservation has been made using the specified identifier.

Implements isc::dhcp::WritableHostDataSource.

Definition at line 673 of file cfg_hosts.cc.

◆ get4() [3/3]

ConstHostPtr isc::dhcp::CfgHosts::get4 ( const SubnetID subnet_id,
const asiolink::IOAddress address 
) const
virtual

Returns a host connected to the IPv4 subnet and having a reservation for a specified IPv4 address.

Parameters
subnet_idSubnet identifier.
addressreserved IPv4 address.
Returns
Const Host object using a specified IPv4 address.

Implements isc::dhcp::BaseHostDataSource.

Definition at line 682 of file cfg_hosts.cc.

References isc::dhcp::HOSTS_CFG_GET_ONE_SUBNET_ID_ADDRESS4, isc::dhcp::HOSTS_CFG_GET_ONE_SUBNET_ID_ADDRESS4_HOST, isc::dhcp::HOSTS_CFG_GET_ONE_SUBNET_ID_ADDRESS4_NULL, isc::dhcp::HOSTS_DBG_RESULTS, isc::dhcp::HOSTS_DBG_TRACE, isc::dhcp::hosts_logger, LOG_DEBUG, and isc::asiolink::IOAddress::toText().

+ Here is the call graph for this function:

◆ get6() [1/6]

ConstHostPtr isc::dhcp::CfgHosts::get6 ( const SubnetID subnet_id,
const Host::IdentifierType identifier_type,
const uint8_t *  identifier_begin,
const size_t  identifier_len 
) const
virtual

Returns a host connected to the IPv6 subnet.

Parameters
subnet_idSubnet identifier.
identifier_typeIdentifier type.
identifier_beginPointer to a beginning of a buffer containing an identifier.
identifier_lenIdentifier length.
Returns
Const Host object for which reservation has been made using the specified identifier.

Implements isc::dhcp::BaseHostDataSource.

Definition at line 730 of file cfg_hosts.cc.

Referenced by ~CfgHosts().

◆ get6() [2/6]

HostPtr isc::dhcp::CfgHosts::get6 ( const SubnetID subnet_id,
const Host::IdentifierType identifier_type,
const uint8_t *  identifier_begin,
const size_t  identifier_len 
)
virtual

Returns a host connected to the IPv6 subnet.

Parameters
subnet_idSubnet identifier.
identifier_typeIdentifier type.
identifier_beginPointer to a beginning of a buffer containing an identifier.
identifier_lenIdentifier length.
Returns
Non-const Host object for which reservation has been made using the specified identifier.

Implements isc::dhcp::WritableHostDataSource.

Definition at line 739 of file cfg_hosts.cc.

◆ get6() [3/6]

ConstHostPtr isc::dhcp::CfgHosts::get6 ( const asiolink::IOAddress prefix,
const uint8_t  prefix_len 
) const
virtual

Returns a host using the specified IPv6 prefix.

Parameters
prefixIPv6 prefix for which the Host object is searched.
prefix_lenIPv6 prefix length.
Returns
Const Host object for which specified prefix is reserved.

Implements isc::dhcp::BaseHostDataSource.

Definition at line 748 of file cfg_hosts.cc.

◆ get6() [4/6]

HostPtr isc::dhcp::CfgHosts::get6 ( const asiolink::IOAddress prefix,
const uint8_t  prefix_len 
)
virtual

Returns a host using the specified IPv6 prefix.

Parameters
prefixIPv6 prefix for which the Host object is searched.
prefix_lenIPv6 prefix length.
Returns
Non-const Host object for which specified prefix is reserved.

Implements isc::dhcp::WritableHostDataSource.

Definition at line 753 of file cfg_hosts.cc.

◆ get6() [5/6]

ConstHostPtr isc::dhcp::CfgHosts::get6 ( const SubnetID subnet_id,
const asiolink::IOAddress address 
) const
virtual

Returns a host connected to the IPv6 subnet and having a reservation for a specified IPv6 address.

Parameters
subnet_idSubnet identifier.
addressreserved IPv6 address.
Returns
Const Host object using a specified IPv6 address.

Implements isc::dhcp::BaseHostDataSource.

Definition at line 758 of file cfg_hosts.cc.

◆ get6() [6/6]

HostPtr isc::dhcp::CfgHosts::get6 ( const SubnetID subnet_id,
const asiolink::IOAddress address 
)
virtual

Returns a host connected to the IPv6 subnet and having a reservation for a specified IPv6 address.

Parameters
subnet_idSubnet identifier.
addressreserved IPv6 address.
Returns
Const Host object using a specified IPv6 address.

Implements isc::dhcp::WritableHostDataSource.

Definition at line 765 of file cfg_hosts.cc.

◆ getAll() [1/2]

ConstHostCollection isc::dhcp::CfgHosts::getAll ( const Host::IdentifierType identifier_type,
const uint8_t *  identifier_begin,
const size_t  identifier_len 
) const
virtual

Return all hosts connected to any subnet for which reservations have been made using a specified identifier.

This method returns all Host objects which represent reservations for a specified identifier. This method may return multiple hosts because a particular client may have reservations in multiple subnets.

Parameters
identifier_typeOne of the supported identifier types.
identifier_beginPointer to a beginning of a buffer containing an identifier.
identifier_lenIdentifier length.
Returns
Collection of const Host objects.

Implements isc::dhcp::BaseHostDataSource.

Definition at line 27 of file cfg_hosts.cc.

Referenced by ~CfgHosts().

◆ getAll() [2/2]

HostCollection isc::dhcp::CfgHosts::getAll ( const Host::IdentifierType identifier_type,
const uint8_t *  identifier_begin,
const size_t  identifier_len 
)
virtual

Non-const version of the getAll const method.

This method returns all Host objects which represent reservations for a specified identifier. This method may return multiple hosts because a particular client may have reservations in multiple subnets.

Parameters
identifier_typeOne of the supported identifier types.
identifier_beginPointer to a beginning of a buffer containing an identifier.
identifier_lenIdentifier length.
Returns
Collection of non-const Host objects.

Implements isc::dhcp::WritableHostDataSource.

Definition at line 39 of file cfg_hosts.cc.

◆ getAll4() [1/5]

ConstHostCollection isc::dhcp::CfgHosts::getAll4 ( const SubnetID subnet_id) const
virtual

Return all hosts in a DHCPv4 subnet.

This method returns all Host objects which represent reservations in a specified subnet.

Parameters
subnet_idSubnet identifier.
Returns
Collection of const Host objects.

Implements isc::dhcp::BaseHostDataSource.

Definition at line 50 of file cfg_hosts.cc.

Referenced by ~CfgHosts().

◆ getAll4() [2/5]

HostCollection isc::dhcp::CfgHosts::getAll4 ( const SubnetID subnet_id)
virtual

Return all hosts in a DHCPv4 subnet.

This method returns all Host objects which represent reservations in a specified subnet.

Parameters
subnet_idSubnet identifier.
Returns
Collection of non-const Host objects.

Implements isc::dhcp::WritableHostDataSource.

Definition at line 59 of file cfg_hosts.cc.

◆ getAll4() [3/5]

ConstHostCollection isc::dhcp::CfgHosts::getAll4 ( const asiolink::IOAddress address) const
virtual

Returns a collection of hosts using the specified IPv4 address.

This method may return multiple Host objects if they are connected to different subnets.

Parameters
addressIPv4 address for which the Host object is searched.
Returns
Collection of const Host objects.

Implements isc::dhcp::BaseHostDataSource.

Definition at line 256 of file cfg_hosts.cc.

◆ getAll4() [4/5]

HostCollection isc::dhcp::CfgHosts::getAll4 ( const asiolink::IOAddress address)
virtual

Returns a collection of hosts using the specified IPv4 address.

This method may return multiple Host objects if they are connected to different subnets.

Parameters
addressIPv4 address for which the Host object is searched.
Returns
Collection of const Host objects.

Implements isc::dhcp::WritableHostDataSource.

Definition at line 265 of file cfg_hosts.cc.

◆ getAll4() [5/5]

ConstHostCollection isc::dhcp::CfgHosts::getAll4 ( const SubnetID subnet_id,
const asiolink::IOAddress address 
) const
virtual

Returns all hosts connected to the IPv4 subnet and having a reservation for a specified address.

In most cases it is desired that there is at most one reservation for a given IPv4 address within a subnet. In a default configuration, the backend does not allow for inserting more than one host with the same IPv4 reservation. In that case, the number of hosts returned by this function is 0 or 1.

If the backend is configured to allow multiple hosts with reservations for the same IPv4 address in the given subnet, this method can return more than one host.

The typical use case when a single IPv4 address is reserved for multiple hosts is when these hosts represent different interfaces of the same machine and each interface comes with a different MAC address. In that case, the same IPv4 address is assigned regardless of which interface is used by the DHCP client to communicate with the server.

Parameters
subnet_idSubnet identifier.
addressreserved IPv4 address.
Returns
Collection of const Host objects.

Implements isc::dhcp::BaseHostDataSource.

Definition at line 705 of file cfg_hosts.cc.

References isc::dhcp::HOSTS_CFG_GET_ALL_SUBNET_ID_ADDRESS4, isc::dhcp::HOSTS_CFG_GET_ALL_SUBNET_ID_ADDRESS4_COUNT, isc::dhcp::HOSTS_CFG_GET_ALL_SUBNET_ID_ADDRESS4_HOST, isc::dhcp::HOSTS_DBG_RESULTS, isc::dhcp::HOSTS_DBG_TRACE, isc::dhcp::HOSTS_DBG_TRACE_DETAIL_DATA, isc::dhcp::hosts_logger, LOG_DEBUG, and isc::asiolink::IOAddress::toText().

+ Here is the call graph for this function:

◆ getAll6() [1/5]

ConstHostCollection isc::dhcp::CfgHosts::getAll6 ( const SubnetID subnet_id) const
virtual

Return all hosts in a DHCPv6 subnet.

This method returns all Host objects which represent reservations in a specified subnet.

Parameters
subnet_idSubnet identifier.
Returns
Collection of const Host objects.

Implements isc::dhcp::BaseHostDataSource.

Definition at line 68 of file cfg_hosts.cc.

Referenced by ~CfgHosts().

◆ getAll6() [2/5]

HostCollection isc::dhcp::CfgHosts::getAll6 ( const SubnetID subnet_id)
virtual

Return all hosts in a DHCPv6 subnet.

This method returns all Host objects which represent reservations in a specified subnet.

Parameters
subnet_idSubnet identifier.
Returns
Collection of non-const Host objects.

Implements isc::dhcp::WritableHostDataSource.

Definition at line 77 of file cfg_hosts.cc.

◆ getAll6() [3/5]

ConstHostCollection isc::dhcp::CfgHosts::getAll6 ( const asiolink::IOAddress address) const
virtual

Returns a collection of hosts using the specified IPv6 address.

This method may return multiple Host objects if they are connected to different subnets.

Parameters
addressIPv6 address for which the Host object is searched.
Returns
Collection of const Host objects.

Definition at line 274 of file cfg_hosts.cc.

◆ getAll6() [4/5]

HostCollection isc::dhcp::CfgHosts::getAll6 ( const asiolink::IOAddress address)
virtual

Returns a collection of hosts using the specified IPv6 address.

This method may return multiple Host objects if they are connected to different subnets.

Parameters
addressIPv6 address for which the Host object is searched.
Returns
Collection of const Host objects.

Definition at line 283 of file cfg_hosts.cc.

References isc::dhcp::HOSTS_CFG_GET_ALL, isc::dhcp::HOSTS_CFG_GET_ALL_ADDRESS4, isc::dhcp::HOSTS_CFG_GET_ALL_ADDRESS4_COUNT, isc::dhcp::HOSTS_CFG_GET_ALL_ADDRESS4_HOST, isc::dhcp::HOSTS_CFG_GET_ALL_ADDRESS6, isc::dhcp::HOSTS_CFG_GET_ALL_ADDRESS6_COUNT, isc::dhcp::HOSTS_CFG_GET_ALL_ADDRESS6_HOST, isc::dhcp::HOSTS_CFG_GET_ALL_COUNT, isc::dhcp::HOSTS_CFG_GET_ALL_HOST, isc::dhcp::HOSTS_CFG_GET_ALL_HOSTNAME, isc::dhcp::HOSTS_CFG_GET_ALL_HOSTNAME_COUNT, isc::dhcp::HOSTS_CFG_GET_ALL_HOSTNAME_HOST, isc::dhcp::HOSTS_CFG_GET_ALL_HOSTNAME_SUBNET_ID4, isc::dhcp::HOSTS_CFG_GET_ALL_HOSTNAME_SUBNET_ID4_COUNT, isc::dhcp::HOSTS_CFG_GET_ALL_HOSTNAME_SUBNET_ID4_HOST, isc::dhcp::HOSTS_CFG_GET_ALL_HOSTNAME_SUBNET_ID6, isc::dhcp::HOSTS_CFG_GET_ALL_HOSTNAME_SUBNET_ID6_COUNT, isc::dhcp::HOSTS_CFG_GET_ALL_HOSTNAME_SUBNET_ID6_HOST, isc::dhcp::HOSTS_CFG_GET_ALL_IDENTIFIER, isc::dhcp::HOSTS_CFG_GET_ALL_IDENTIFIER_COUNT, isc::dhcp::HOSTS_CFG_GET_ALL_IDENTIFIER_HOST, isc::dhcp::HOSTS_CFG_GET_ALL_SUBNET_ID4, isc::dhcp::HOSTS_CFG_GET_ALL_SUBNET_ID4_COUNT, isc::dhcp::HOSTS_CFG_GET_ALL_SUBNET_ID4_HOST, isc::dhcp::HOSTS_CFG_GET_ALL_SUBNET_ID6, isc::dhcp::HOSTS_CFG_GET_ALL_SUBNET_ID6_COUNT, isc::dhcp::HOSTS_CFG_GET_ALL_SUBNET_ID6_HOST, isc::dhcp::HOSTS_DBG_RESULTS, isc::dhcp::HOSTS_DBG_TRACE, isc::dhcp::HOSTS_DBG_TRACE_DETAIL_DATA, isc::dhcp::hosts_logger, isc_throw, isc::asiolink::IOAddress::isV4(), isc::asiolink::IOAddress::isV6(), LOG_DEBUG, isc::dhcp::HostPageSize::page_size_, and isc::asiolink::IOAddress::toText().

+ Here is the call graph for this function:

◆ getAll6() [5/5]

ConstHostCollection isc::dhcp::CfgHosts::getAll6 ( const SubnetID subnet_id,
const asiolink::IOAddress address 
) const
virtual

Returns all hosts connected to the IPv6 subnet and having a reservation for a specified address or delegated prefix (lease).

In most cases it is desired that there is at most one reservation for a given IPv6 lease within a subnet. In a default configuration, the backend does not allow for inserting more than one host with the same IPv6 address or prefix. In that case, the number of hosts returned by this function is 0 or 1.

If the backend is configured to allow multiple hosts with reservations for the same IPv6 lease in the given subnet, this method can return more than one host.

The typical use case when a single IPv6 lease is reserved for multiple hosts is when these hosts represent different interfaces of the same machine and each interface comes with a different MAC address. In that case, the same IPv6 lease is assigned regardless of which interface is used by the DHCP client to communicate with the server.

Parameters
subnet_idSubnet identifier.
addressreserved IPv6 address/prefix.
Returns
Collection of const Host objects.

Implements isc::dhcp::BaseHostDataSource.

Definition at line 772 of file cfg_hosts.cc.

References isc::dhcp::HOSTS_CFG_GET_ALL_SUBNET_ID_ADDRESS6, isc::dhcp::HOSTS_CFG_GET_ALL_SUBNET_ID_ADDRESS6_COUNT, isc::dhcp::HOSTS_CFG_GET_ALL_SUBNET_ID_ADDRESS6_HOST, isc::dhcp::HOSTS_CFG_GET_ONE_PREFIX, isc::dhcp::HOSTS_CFG_GET_ONE_PREFIX_HOST, isc::dhcp::HOSTS_CFG_GET_ONE_PREFIX_NULL, isc::dhcp::HOSTS_CFG_GET_ONE_SUBNET_ID_ADDRESS6, isc::dhcp::HOSTS_CFG_GET_ONE_SUBNET_ID_ADDRESS6_HOST, isc::dhcp::HOSTS_CFG_GET_ONE_SUBNET_ID_ADDRESS6_NULL, isc::dhcp::HOSTS_CFG_GET_ONE_SUBNET_ID_IDENTIFIER, isc::dhcp::HOSTS_CFG_GET_ONE_SUBNET_ID_IDENTIFIER_HOST, isc::dhcp::HOSTS_CFG_GET_ONE_SUBNET_ID_IDENTIFIER_NULL, isc::dhcp::HOSTS_DBG_RESULTS, isc::dhcp::HOSTS_DBG_TRACE, isc::dhcp::HOSTS_DBG_TRACE_DETAIL_DATA, isc::dhcp::hosts_logger, isc_throw, isc::asiolink::IOAddress::isV6(), LOG_DEBUG, and isc::asiolink::IOAddress::toText().

+ Here is the call graph for this function:

◆ getAllbyHostname() [1/2]

ConstHostCollection isc::dhcp::CfgHosts::getAllbyHostname ( const std::string &  hostname) const
virtual

Return all hosts with a hostname.

This method returns all Host objects which represent reservations using a specified hostname.

Parameters
hostnameThe lower case hostname.
Returns
Collection of const Host objects.

Implements isc::dhcp::BaseHostDataSource.

Definition at line 86 of file cfg_hosts.cc.

Referenced by ~CfgHosts().

◆ getAllbyHostname() [2/2]

HostCollection isc::dhcp::CfgHosts::getAllbyHostname ( const std::string &  hostname)
virtual

Return all hosts with a hostname.

This method returns all Host objects which represent reservations using a specified hostname.

Parameters
hostnameThe lower case hostname.
Returns
Collection of Host objects.

Implements isc::dhcp::WritableHostDataSource.

Definition at line 95 of file cfg_hosts.cc.

◆ getAllbyHostname4() [1/2]

ConstHostCollection isc::dhcp::CfgHosts::getAllbyHostname4 ( const std::string &  hostname,
const SubnetID subnet_id 
) const
virtual

Return all hosts with a hostname in a DHCPv4 subnet.

This method returns all Host objects which represent reservations using a specified hostname in a specified subnet.

Parameters
hostnameThe lower case hostname.
subnet_idSubnet identifier.
Returns
Collection of const Host objects.

Implements isc::dhcp::BaseHostDataSource.

Definition at line 104 of file cfg_hosts.cc.

Referenced by ~CfgHosts().

◆ getAllbyHostname4() [2/2]

HostCollection isc::dhcp::CfgHosts::getAllbyHostname4 ( const std::string &  hostname,
const SubnetID subnet_id 
)
virtual

Return all hosts with a hostname in a DHCPv4 subnet.

This method returns all Host objects which represent reservations using a specified hostname in a specified subnet.

Parameters
hostnameThe lower case hostname.
subnet_idSubnet identifier.
Returns
Collection of Host objects.

Implements isc::dhcp::WritableHostDataSource.

Definition at line 114 of file cfg_hosts.cc.

◆ getAllbyHostname6() [1/2]

ConstHostCollection isc::dhcp::CfgHosts::getAllbyHostname6 ( const std::string &  hostname,
const SubnetID subnet_id 
) const
virtual

Return all hosts with a hostname in a DHCPv6 subnet.

This method returns all Host objects which represent reservations using a specified hostname in a specified subnet.

Parameters
hostnameThe lower case hostname.
subnet_idSubnet identifier.
Returns
Collection of const Host objects.

Implements isc::dhcp::BaseHostDataSource.

Definition at line 124 of file cfg_hosts.cc.

Referenced by ~CfgHosts().

◆ getAllbyHostname6() [2/2]

HostCollection isc::dhcp::CfgHosts::getAllbyHostname6 ( const std::string &  hostname,
const SubnetID subnet_id 
)
virtual

Return all hosts with a hostname in a DHCPv6 subnet.

This method returns all Host objects which represent reservations using a specified hostname in a specified subnet.

Parameters
hostnameThe lower case hostname.
subnet_idSubnet identifier.
Returns
Collection of Host objects.

Implements isc::dhcp::WritableHostDataSource.

Definition at line 134 of file cfg_hosts.cc.

◆ getPage4() [1/4]

ConstHostCollection isc::dhcp::CfgHosts::getPage4 ( const SubnetID subnet_id,
size_t &  source_index,
uint64_t  lower_host_id,
const HostPageSize page_size 
) const
virtual

Returns range of hosts in a DHCPv4 subnet.

This method returns a page of Host objects which represent reservations in a specified subnet.

Parameters
subnet_idSubnet identifier.
source_indexIndex of the source (unused).
lower_host_idHost identifier used as lower bound for the returned range.
page_sizemaximum size of the page returned.
Returns
Collection of const Host objects (may be empty).

Implements isc::dhcp::BaseHostDataSource.

Definition at line 144 of file cfg_hosts.cc.

Referenced by ~CfgHosts().

◆ getPage4() [2/4]

HostCollection isc::dhcp::CfgHosts::getPage4 ( const SubnetID subnet_id,
size_t &  source_index,
uint64_t  lower_host_id,
const HostPageSize page_size 
)
virtual

Returns range of hosts in a DHCPv4 subnet.

This method returns a page of Host objects which represent reservations in a specified subnet.

Parameters
subnet_idSubnet identifier.
source_indexIndex of the source (unused).
lower_host_idHost identifier used as lower bound for the returned range.
page_sizemaximum size of the page returned.
Returns
Collection of non-const Host objects (may be empty).

Implements isc::dhcp::WritableHostDataSource.

Definition at line 159 of file cfg_hosts.cc.

◆ getPage4() [3/4]

ConstHostCollection isc::dhcp::CfgHosts::getPage4 ( size_t &  source_index,
uint64_t  lower_host_id,
const HostPageSize page_size 
) const
virtual

Returns range of hosts.

This method returns a page of Host objects which represent reservations.

Parameters
source_indexIndex of the source (unused).
lower_host_idHost identifier used as lower bound for the returned range.
page_sizemaximum size of the page returned.
Returns
Collection of const Host objects (may be empty).

Implements isc::dhcp::BaseHostDataSource.

Definition at line 204 of file cfg_hosts.cc.

◆ getPage4() [4/4]

HostCollection isc::dhcp::CfgHosts::getPage4 ( size_t &  source_index,
uint64_t  lower_host_id,
const HostPageSize page_size 
)
virtual

Returns range of hosts.

This method returns a page of Host objects which represent reservations.

Parameters
source_indexIndex of the source (unused).
lower_host_idHost identifier used as lower bound for the returned range.
page_sizemaximum size of the page returned.
Returns
Collection of non-const Host objects (may be empty).

Implements isc::dhcp::WritableHostDataSource.

Definition at line 217 of file cfg_hosts.cc.

◆ getPage6() [1/4]

ConstHostCollection isc::dhcp::CfgHosts::getPage6 ( const SubnetID subnet_id,
size_t &  source_index,
uint64_t  lower_host_id,
const HostPageSize page_size 
) const
virtual

Returns range of hosts in a DHCPv6 subnet.

This method returns a page of Host objects which represent reservations in a specified subnet.

Parameters
subnet_idSubnet identifier.
source_indexIndex of the source (unused).
lower_host_idHost identifier used as lower bound for the returned range.
page_sizemaximum size of the page returned.
Returns
Collection of const Host objects (may be empty).

Implements isc::dhcp::BaseHostDataSource.

Definition at line 174 of file cfg_hosts.cc.

Referenced by ~CfgHosts().

◆ getPage6() [2/4]

HostCollection isc::dhcp::CfgHosts::getPage6 ( const SubnetID subnet_id,
size_t &  source_index,
uint64_t  lower_host_id,
const HostPageSize page_size 
)
virtual

Returns range of hosts in a DHCPv6 subnet.

This method returns a page of Host objects which represent reservations in a specified subnet.

Parameters
subnet_idSubnet identifier.
source_indexIndex of the source (unused).
lower_host_idHost identifier used as lower bound for the returned range.
page_sizemaximum size of the page returned.
Returns
Collection of non-const Host objects (may be empty).

Implements isc::dhcp::WritableHostDataSource.

Definition at line 189 of file cfg_hosts.cc.

◆ getPage6() [3/4]

ConstHostCollection isc::dhcp::CfgHosts::getPage6 ( size_t &  source_index,
uint64_t  lower_host_id,
const HostPageSize page_size 
) const
virtual

Returns range of hosts.

This method returns a page of Host objects which represent reservations.

Parameters
source_indexIndex of the source (unused).
lower_host_idHost identifier used as lower bound for the returned range.
page_sizemaximum size of the page returned.
Returns
Collection of const Host objects (may be empty).

Implements isc::dhcp::BaseHostDataSource.

Definition at line 230 of file cfg_hosts.cc.

◆ getPage6() [4/4]

HostCollection isc::dhcp::CfgHosts::getPage6 ( size_t &  source_index,
uint64_t  lower_host_id,
const HostPageSize page_size 
)
virtual

Returns range of hosts.

This method returns a page of Host objects which represent reservations.

Parameters
source_indexIndex of the source (unused).
lower_host_idHost identifier used as lower bound for the returned range.
page_sizemaximum size of the page returned.
Returns
Collection of non-const Host objects (may be empty).

Implements isc::dhcp::WritableHostDataSource.

Definition at line 243 of file cfg_hosts.cc.

◆ getType()

virtual std::string isc::dhcp::CfgHosts::getType ( ) const
inlinevirtual

Return backend type.

Returns the type of the backend (e.g. "mysql", "memfile" etc.)

Returns
Type of the backend.

Implements isc::dhcp::BaseHostDataSource.

Definition at line 597 of file cfg_hosts.h.

References setIPReservationsUnique(), and toElement().

+ Here is the call graph for this function:

◆ setIPReservationsUnique()

bool isc::dhcp::CfgHosts::setIPReservationsUnique ( const bool  unique)
virtual

Controls whether IP reservations are unique or non-unique.

In a typical case, the IP reservations are unique and backends verify prior to adding a host reservation to the database that the reservation for a given IP address/subnet does not exist. In some cases it may be required to allow non-unique IP reservations, e.g. in the case when a host has several interfaces and independently of which interface is used by this host to communicate with the DHCP server the same IP address should be assigned. In this case the unique value should be set to false to disable the checks for uniqueness on the backend side.

Parameters
uniqueboolean flag indicating if the IP reservations must be unique or can be non-unique.
Returns
always true because this data source supports both the case when the addresses must be unique and when they may be non-unique.

Implements isc::dhcp::BaseHostDataSource.

Definition at line 1170 of file cfg_hosts.cc.

Referenced by getType().

◆ toElement()

ElementPtr isc::dhcp::CfgHosts::toElement ( ) const
virtual

Unparse a configuration object.

host reservation lists are not autonomous so they are not returned directly but with the subnet where they are declared as:

[
{ "id": 123, "reservations": [ <resv1>, <resv2> ] },
{ "id": 456, "reservations": [ <resv3 ] },
...
]

isc::dhcp::CfgHostsList can be used to handle this

Returns
a pointer to unparsed configuration

Implements isc::data::CfgToElement.

Definition at line 1177 of file cfg_hosts.cc.

References isc::dhcp::CfgHostsList::add(), isc::dhcp::CfgHostsList::externalize(), isc::dhcp::CfgHostsList::get(), and isc_throw.

Referenced by getType().

+ Here is the call graph for this function:

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