![]() |
Kea
2.5.2
|
#include <host_mgr.h>
Public Member Functions | |
virtual void | add (const HostPtr &host) |
The HostMgr::add compatible with BaseHostDataSource interfaces. More... | |
void | add (const HostPtr &host, const HostMgrOperationTarget target) |
Adds a new host to the alternate data source. More... | |
virtual bool | del (const SubnetID &subnet_id, const asiolink::IOAddress &addr) |
The HostMgr::del compatible with BaseHostDataSource interfaces. More... | |
bool | del (const SubnetID &subnet_id, const asiolink::IOAddress &addr, const HostMgrOperationTarget target) |
Attempts to delete 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) |
The HostMgr::del4 compatible with BaseHostDataSource interfaces. More... | |
bool | del4 (const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len, const HostMgrOperationTarget target) |
Attempts to delete a host by (subnet4-id, identifier, identifier-type, operation-target) More... | |
virtual bool | del6 (const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) |
The HostMgr::del6 compatible with BaseHostDataSource interfaces. More... | |
bool | del6 (const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len, const HostMgrOperationTarget target) |
Attempts to delete a host by (subnet6-id, identifier, identifier-type, operation-target) More... | |
virtual ConstHostPtr | get4 (const SubnetID &subnet_id, const asiolink::IOAddress &address) const |
The HostMgr::get4 compatible with BaseHostDataSource interfaces. More... | |
ConstHostPtr | get4 (const SubnetID &subnet_id, const asiolink::IOAddress &address, const HostMgrOperationTarget target) const |
Returns a host connected to the IPv4 subnet and having a reservation for a specified IPv4 address. More... | |
virtual ConstHostPtr | get4 (const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const |
The HostMgr::get4 compatible with BaseHostDataSource interfaces. More... | |
ConstHostPtr | get4 (const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len, const HostMgrOperationTarget target) const |
Returns a host connected to the IPv4 subnet. More... | |
virtual ConstHostPtr | get4Any (const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const |
The HostMgr::get4Any compatible with BaseHostDataSource interfaces. More... | |
ConstHostPtr | get4Any (const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len, const HostMgrOperationTarget target) const |
Returns any host connected to the IPv4 subnet. More... | |
virtual ConstHostPtr | get6 (const asiolink::IOAddress &prefix, const uint8_t prefix_len) const |
The HostMgr::get6 compatible with BaseHostDataSource interfaces. More... | |
ConstHostPtr | get6 (const asiolink::IOAddress &prefix, const uint8_t prefix_len, const HostMgrOperationTarget target) const |
Returns a host using the specified IPv6 prefix. More... | |
virtual ConstHostPtr | get6 (const SubnetID &subnet_id, const asiolink::IOAddress &addr) const |
The HostMgr::get6 compatible with BaseHostDataSource interfaces. More... | |
ConstHostPtr | get6 (const SubnetID &subnet_id, const asiolink::IOAddress &addr, const HostMgrOperationTarget target) const |
Returns a host from specific subnet and reserved 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 |
The HostMgr::get6 compatible with BaseHostDataSource interfaces. More... | |
ConstHostPtr | get6 (const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len, const HostMgrOperationTarget target) const |
Returns a host connected to the IPv6 subnet. More... | |
virtual ConstHostPtr | get6Any (const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const |
The HostMgr::get6Any compatible with BaseHostDataSource interfaces. More... | |
ConstHostPtr | get6Any (const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len, const HostMgrOperationTarget target) const |
Returns any host connected to the IPv6 subnet. More... | |
virtual ConstHostCollection | getAll (const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const |
The HostMgr::getAll compatible with BaseHostDataSource interfaces. More... | |
ConstHostCollection | getAll (const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len, const HostMgrOperationTarget target) const |
Return all hosts connected to any subnet for which reservations have been made using a specified identifier. More... | |
virtual ConstHostCollection | getAll4 (const asiolink::IOAddress &address) const |
The HostMgr::getAll4 compatible with BaseHostDataSource interfaces. More... | |
ConstHostCollection | getAll4 (const asiolink::IOAddress &address, const HostMgrOperationTarget target) const |
Returns a collection of hosts using the specified IPv4 address. More... | |
virtual ConstHostCollection | getAll4 (const SubnetID &subnet_id) const |
The HostMgr::getAll4 compatible with BaseHostDataSource interfaces. More... | |
virtual ConstHostCollection | getAll4 (const SubnetID &subnet_id, const asiolink::IOAddress &address) const |
The HostMgr::getAll4 compatible with BaseHostDataSource interfaces. More... | |
ConstHostCollection | getAll4 (const SubnetID &subnet_id, const asiolink::IOAddress &address, const HostMgrOperationTarget target) const |
Returns all hosts connected to the IPv4 subnet and having a reservation for a specified address. More... | |
ConstHostCollection | getAll4 (const SubnetID &subnet_id, const HostMgrOperationTarget target) const |
Return all hosts in a DHCPv4 subnet. More... | |
virtual ConstHostCollection | getAll6 (const asiolink::IOAddress &address) const |
The HostMgr::getAll6 compatible with BaseHostDataSource interfaces. More... | |
ConstHostCollection | getAll6 (const asiolink::IOAddress &address, const HostMgrOperationTarget target) const |
Returns a collection of hosts using the specified IPv6 address/prefix. More... | |
virtual ConstHostCollection | getAll6 (const SubnetID &subnet_id) const |
The HostMgr::getAll6 compatible with BaseHostDataSource interfaces. More... | |
virtual ConstHostCollection | getAll6 (const SubnetID &subnet_id, const asiolink::IOAddress &address) const |
The HostMgr::getAll6 compatible with BaseHostDataSource interfaces. More... | |
ConstHostCollection | getAll6 (const SubnetID &subnet_id, const asiolink::IOAddress &address, const HostMgrOperationTarget target) const |
Returns all hosts connected to the IPv6 subnet and having a reservation for a specified address or delegated prefix (lease). More... | |
ConstHostCollection | getAll6 (const SubnetID &subnet_id, const HostMgrOperationTarget target) const |
Return all hosts in a DHCPv6 subnet. More... | |
virtual ConstHostCollection | getAllbyHostname (const std::string &hostname) const |
The HostMgr::getAllbyHostname compatible with BaseHostDataSource interfaces. More... | |
ConstHostCollection | getAllbyHostname (const std::string &hostname, const HostMgrOperationTarget target) const |
Return all hosts with a hostname. More... | |
virtual ConstHostCollection | getAllbyHostname4 (const std::string &hostname, const SubnetID &subnet_id) const |
The HostMgr::getAllbyHostname4 compatible with BaseHostDataSource interfaces. More... | |
ConstHostCollection | getAllbyHostname4 (const std::string &hostname, const SubnetID &subnet_id, const HostMgrOperationTarget target) const |
Return all hosts with a hostname in a DHCPv4 subnet. More... | |
virtual ConstHostCollection | getAllbyHostname6 (const std::string &hostname, const SubnetID &subnet_id) const |
The HostMgr::getAllbyHostname6 compatible with BaseHostDataSource interfaces. More... | |
ConstHostCollection | getAllbyHostname6 (const std::string &hostname, const SubnetID &subnet_id, const HostMgrOperationTarget target) const |
Return all hosts with a hostname in a DHCPv6 subnet. More... | |
bool | getDisableSingleQuery () const |
Returns the disable single query flag. More... | |
HostDataSourcePtr | getHostDataSource () const |
Returns the first host data source. More... | |
HostDataSourceList & | getHostDataSourceList () |
Returns the host data source list. More... | |
bool | getIPReservationsUnique () const |
Returns the boolean flag indicating if the IP reservations must be unique or can be non-unique. More... | |
bool | getNegativeCaching () const |
Returns the negative caching flag. 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 ConstHostCollection | getPage4 (size_t &source_index, uint64_t lower_host_id, const HostPageSize &page_size) const |
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 ConstHostCollection | getPage6 (size_t &source_index, uint64_t lower_host_id, const HostPageSize &page_size) const |
Returns range of hosts. More... | |
virtual std::string | getType () const |
Return backend type. More... | |
void | setDisableSingleQuery (bool disable_single_query) |
Sets the disable single query flag. More... | |
virtual bool | setIPReservationsUnique (const bool unique) |
Controls whether IP reservations are unique or non-unique. More... | |
void | setNegativeCaching (bool negative_caching) |
Sets the negative caching flag. More... | |
void | update (HostPtr const &host) |
The HostMgr::update with default operation target. More... | |
void | update (HostPtr const &host, const HostMgrOperationTarget target) |
Implements BaseHostDataSource::update() for alternate sources. More... | |
![]() | |
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... | |
Static Public Member Functions | |
static void | addBackend (const std::string &access) |
Add an alternate host backend (aka host data source). More... | |
static bool | checkCacheBackend (bool logging=false) |
Check for the cache host backend. More... | |
static void | create () |
Creates new instance of the HostMgr . More... | |
static void | delAllBackends () |
Delete all alternate backends. More... | |
static bool | delBackend (const std::string &db_type) |
Delete an alternate host backend (aka host data source). More... | |
static bool | delBackend (const std::string &db_type, const std::string &access, bool if_unusable=false) |
Delete an alternate host backend (aka host data source). More... | |
static isc::asiolink::IOServicePtr & | getIOService () |
Returns pointer to the IO service. More... | |
static HostMgr & | instance () |
Returns a sole instance of the HostMgr . More... | |
static void | setIOService (const isc::asiolink::IOServicePtr &io_service) |
Sets IO service to be used by the Host Manager. More... | |
Protected Member Functions | |
virtual void | cache (ConstHostPtr host) const |
Cache an answer. More... | |
virtual void | cacheNegative (const SubnetID &ipv4_subnet_id, const SubnetID &ipv6_subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const |
Cache a negative answer. More... | |
Protected Attributes | |
bool | disable_single_query_ |
The disable single query flag. More... | |
bool | negative_caching_ |
The negative caching flag. More... | |
Additional Inherited Members | |
![]() | |
enum | IdType { ID_HWADDR = 0 , ID_DUID = 1 } |
Specifies the type of an identifier. More... | |
Host Manager.
This is a singleton class which provides access to multiple sources of information about static host reservations. These sources are also referred to as host data sources. Each source derives (directly or indirectly) from the BaseHostDataSource
.
The HostMgr
is a central point for providing information about the host reservations. Internally, it relays the queries (calls to the appropriate methods declared in the BaseHostDataSource
) to the data sources it is connected to. The HostMgr
is always connected to the server's configuration, accessible through the CfgHosts
object in the CfgMgr
. The CfgHosts
object holds all reservations specified in the DHCP server configuration file. If a particular reservation is not found in the CfgHosts
object, the HostMgr
will try to find it using alternate host data storages. An alternate host data storage is usually a database (e.g. SQL database), accessible through a dedicated host data source object (a.k.a. database backend). This datasource is responsible for managing the connection with the database and forming appropriate queries to retrieve (or update) the information about the reservations.
The use of alternate host data sources is optional and usually requires additional configuration to be specified by the server administrator. For example, for the SQL database the user's credentials, database address, and database name are required. The HostMgr
passes these parameters to an appropriate datasource which is responsible for opening a connection and maintaining it.
It is possible to switch to different alternate data sources or disable the use of alternate datasources, e.g. as a result of server's reconfiguration. However, the use of the primary host data source (i.e. reservations specified in the configuration file) can't be disabled.
Definition at line 68 of file host_mgr.h.
|
virtual |
The HostMgr::add
compatible with BaseHostDataSource
interfaces.
Operates on alternate host sources only.
Implements isc::dhcp::BaseHostDataSource.
Definition at line 791 of file host_mgr.cc.
References isc::dhcp::ALTERNATE_SOURCES.
void isc::dhcp::HostMgr::add | ( | const HostPtr & | host, |
const HostMgrOperationTarget | target | ||
) |
Adds a new host to the alternate data source.
This method will throw an exception if no alternate data source is in use.
host | Pointer to the new Host object being added. |
target | The host data source being a target of the operation. |
Definition at line 766 of file host_mgr.cc.
References isc::dhcp::ALTERNATE_SOURCES, isc_throw, and isc::dhcp::PRIMARY_SOURCE.
|
static |
Add an alternate host backend (aka host data source).
access | Host backend access parameters for the alternate host backend. It holds "keyword=value" pairs, separated by spaces. |
The supported values are specific to the alternate backend in use. However, the "type" parameter will be common and it will specify which backend is to be used. Currently, no parameters are supported and the parameter is ignored.
Definition at line 59 of file host_mgr.cc.
References isc::dhcp::HostDataSourceFactory::add().
Referenced by isc::dhcp::CfgDbAccess::createManagers(), isc::dhcp::MySqlHostDataSourceImpl::dbReconnect(), and isc::dhcp::PgSqlHostDataSourceImpl::dbReconnect().
|
protectedvirtual |
Cache an answer.
host | Pointer to the missed host. |
Definition at line 929 of file host_mgr.cc.
|
protectedvirtual |
Cache a negative answer.
ipv4_subnet_id | Identifier of the IPv4 subnet. |
ipv6_subnet_id | Identifier of the IPv6 subnet. |
identifier_type | Identifier type. |
identifier_begin | Pointer to a beginning of the Identifier. |
identifier_len | Identifier length. |
Definition at line 942 of file host_mgr.cc.
References isc::asiolink::IOAddress::IPV4_ZERO_ADDRESS().
|
static |
Check for the cache host backend.
Checks if the first host backend implements the cache abstract class and sets cache_ptr_.
logging | When true (not the default) emit an informational log. |
Definition at line 94 of file host_mgr.cc.
References isc::dhcp::HOSTS_CFG_CACHE_HOST_DATA_SOURCE, isc::dhcp::hosts_logger, and LOG_INFO.
Referenced by isc::dhcp::CfgDbAccess::createManagers().
|
static |
Creates new instance of the HostMgr
.
If an instance of the HostMgr
already exists, it will be replaced by the new instance. Thus, any instances of alternate host data sources will be dropped.
Definition at line 54 of file host_mgr.cc.
Referenced by isc::dhcp::ControlledDhcpv4Srv::~ControlledDhcpv4Srv(), isc::dhcp::ControlledDhcpv6Srv::~ControlledDhcpv6Srv(), and isc::dhcp::CfgDbAccess::createManagers().
|
virtual |
The HostMgr::del
compatible with BaseHostDataSource
interfaces.
Operates on alternate host sources only.
Implements isc::dhcp::BaseHostDataSource.
Definition at line 821 of file host_mgr.cc.
References isc::dhcp::ALTERNATE_SOURCES.
bool isc::dhcp::HostMgr::del | ( | const SubnetID & | subnet_id, |
const asiolink::IOAddress & | addr, | ||
const HostMgrOperationTarget | target | ||
) |
Attempts to delete hosts by address.
It deletes hosts from the first alternate source in which at least one matching host is found. In unlikely case that the hosts having the same IP address exist in other alternate sources, the hosts from these other sources are not deleted.
This method supports both v4 and v6.
subnet_id | subnet identifier. |
addr | specified address. |
target | The host data source being a target of the operation. |
Definition at line 796 of file host_mgr.cc.
References isc::dhcp::ALTERNATE_SOURCES, isc_throw, and isc::dhcp::PRIMARY_SOURCE.
|
virtual |
The HostMgr::del4
compatible with BaseHostDataSource
interfaces.
Operates on alternate host sources only.
Implements isc::dhcp::BaseHostDataSource.
Definition at line 856 of file host_mgr.cc.
References isc::dhcp::ALTERNATE_SOURCES.
bool isc::dhcp::HostMgr::del4 | ( | const SubnetID & | subnet_id, |
const Host::IdentifierType & | identifier_type, | ||
const uint8_t * | identifier_begin, | ||
const size_t | identifier_len, | ||
const HostMgrOperationTarget | target | ||
) |
Attempts to delete a host by (subnet4-id, identifier, identifier-type, operation-target)
This method supports v4 only.
subnet_id | IPv4 Subnet identifier. |
identifier_type | Identifier type. |
identifier_begin | Pointer to a beginning of a buffer containing an identifier. |
identifier_len | Identifier length. |
target | The host data source being a target of the operation. |
Definition at line 826 of file host_mgr.cc.
References isc::dhcp::ALTERNATE_SOURCES, isc_throw, and isc::dhcp::PRIMARY_SOURCE.
|
virtual |
The HostMgr::del6
compatible with BaseHostDataSource
interfaces.
Operates on alternate host sources only.
Implements isc::dhcp::BaseHostDataSource.
Definition at line 893 of file host_mgr.cc.
References isc::dhcp::ALTERNATE_SOURCES.
bool isc::dhcp::HostMgr::del6 | ( | const SubnetID & | subnet_id, |
const Host::IdentifierType & | identifier_type, | ||
const uint8_t * | identifier_begin, | ||
const size_t | identifier_len, | ||
const HostMgrOperationTarget | target | ||
) |
Attempts to delete a host by (subnet6-id, identifier, identifier-type, operation-target)
This method supports v6 only.
subnet_id | IPv6 Subnet identifier. |
identifier_type | Identifier type. |
identifier_begin | Pointer to a beginning of a buffer containing an identifier. |
identifier_len | Identifier length. |
target | The host data source being a target of the operation. |
Definition at line 863 of file host_mgr.cc.
References isc::dhcp::ALTERNATE_SOURCES, isc_throw, and isc::dhcp::PRIMARY_SOURCE.
|
static |
Delete all alternate backends.
Definition at line 81 of file host_mgr.cc.
|
static |
Delete an alternate host backend (aka host data source).
db_type | database backend type. |
Definition at line 64 of file host_mgr.cc.
References isc::dhcp::HostDataSourceFactory::del().
Referenced by isc::dhcp::MySqlHostDataSourceImpl::dbReconnect(), and isc::dhcp::PgSqlHostDataSourceImpl::dbReconnect().
|
static |
Delete an alternate host backend (aka host data source).
db_type | database backend type. |
access | Host backend access parameters for the alternate host backend. It holds "keyword=value" pairs, separated by spaces. |
if_unusable | flag which indicates if the host data source should be deleted only if it is unusable. |
Definition at line 74 of file host_mgr.cc.
References isc::dhcp::HostDataSourceFactory::del().
|
virtual |
The HostMgr::get4
compatible with BaseHostDataSource
interfaces.
Operates on all host sources.
Implements isc::dhcp::BaseHostDataSource.
Definition at line 524 of file host_mgr.cc.
References isc::dhcp::ALL_SOURCES.
ConstHostPtr isc::dhcp::HostMgr::get4 | ( | const SubnetID & | subnet_id, |
const asiolink::IOAddress & | address, | ||
const HostMgrOperationTarget | target | ||
) | const |
Returns a host connected to the IPv4 subnet and having a reservation for a specified IPv4 address.
This method returns a single reservation for the particular host (identified by the HW address or DUID) as documented in the BaseHostDataSource::get4
.
subnet_id | Subnet identifier. |
address | reserved IPv4 address. |
target | The host data source being a target of the operation. |
Host
object using a specified IPv4 address. Definition at line 493 of file host_mgr.cc.
References isc::dhcp::ALTERNATE_SOURCES, isc::dhcp::HOSTS_DBG_TRACE, isc::dhcp::hosts_logger, isc::dhcp::HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_ADDRESS4, LOG_DEBUG, isc::dhcp::PRIMARY_SOURCE, and isc::asiolink::IOAddress::toText().
|
virtual |
The HostMgr::get4
compatible with BaseHostDataSource
interfaces.
Operates on all host sources.
Implements isc::dhcp::BaseHostDataSource.
Definition at line 484 of file host_mgr.cc.
References isc::dhcp::ALL_SOURCES.
ConstHostPtr isc::dhcp::HostMgr::get4 | ( | const SubnetID & | subnet_id, |
const Host::IdentifierType & | identifier_type, | ||
const uint8_t * | identifier_begin, | ||
const size_t | identifier_len, | ||
const HostMgrOperationTarget | target | ||
) | const |
Returns a host connected to the IPv4 subnet.
This method returns a single reservation for a particular host as documented in the BaseHostDataSource::get4
.
subnet_id | Subnet identifier. |
identifier_type | Identifier type. |
identifier_begin | Pointer to a beginning of a buffer containing an identifier. |
identifier_len | Identifier length. |
target | The host data source being a target of the operation. |
Host
object for which reservation has been made using the specified identifier. Definition at line 467 of file host_mgr.cc.
Referenced by isc::dhcp::AllocEngine::findGlobalReservation(), and isc::dhcp::AllocEngine::findReservation().
|
virtual |
The HostMgr::get4Any
compatible with BaseHostDataSource
interfaces.
Operates on all host sources.
Definition at line 458 of file host_mgr.cc.
References isc::dhcp::ALL_SOURCES.
ConstHostPtr isc::dhcp::HostMgr::get4Any | ( | const SubnetID & | subnet_id, |
const Host::IdentifierType & | identifier_type, | ||
const uint8_t * | identifier_begin, | ||
const size_t | identifier_len, | ||
const HostMgrOperationTarget | target | ||
) | const |
Returns any host connected to the IPv4 subnet.
This method returns a single reservation for a particular host as documented in the BaseHostDataSource::get4
even when the reservation is marked as from negative caching. This allows to monitor negative caching.
subnet_id | Subnet identifier. |
identifier_type | Identifier type. |
identifier_begin | Pointer to a beginning of a buffer containing an identifier. |
identifier_len | Identifier length. |
target | The host data source being a target of the operation. |
Host
object for which reservation has been made using the specified identifier. Definition at line 403 of file host_mgr.cc.
References isc::dhcp::ALTERNATE_SOURCES, isc::dhcp::Host::getIdentifierAsText(), isc::dhcp::HOSTS_DBG_RESULTS, isc::dhcp::HOSTS_DBG_TRACE, isc::dhcp::hosts_logger, isc::dhcp::HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_IDENTIFIER, isc::dhcp::HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_IDENTIFIER_HOST, isc::dhcp::HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_IDENTIFIER_NULL, LOG_DEBUG, and isc::dhcp::PRIMARY_SOURCE.
|
virtual |
The HostMgr::get6
compatible with BaseHostDataSource
interfaces.
Operates on all host sources.
Implements isc::dhcp::BaseHostDataSource.
Definition at line 587 of file host_mgr.cc.
References isc::dhcp::ALL_SOURCES.
ConstHostPtr isc::dhcp::HostMgr::get6 | ( | const asiolink::IOAddress & | prefix, |
const uint8_t | prefix_len, | ||
const HostMgrOperationTarget | target | ||
) | const |
Returns a host using the specified IPv6 prefix.
This method returns a host using specified IPv6 prefix, as described in the BaseHostDataSource::get6
.
prefix | IPv6 prefix for which the Host object is searched. |
prefix_len | IPv6 prefix length. |
target | The host data source being a target of the operation. |
Host
object using a specified IPv6 prefix. Definition at line 559 of file host_mgr.cc.
References isc::dhcp::ALTERNATE_SOURCES, isc::dhcp::HOSTS_DBG_TRACE, isc::dhcp::hosts_logger, isc::dhcp::HOSTS_MGR_ALTERNATE_GET6_PREFIX, LOG_DEBUG, isc::dhcp::PRIMARY_SOURCE, and isc::asiolink::IOAddress::toText().
|
virtual |
The HostMgr::get6
compatible with BaseHostDataSource
interfaces.
Operates on all host sources.
Implements isc::dhcp::BaseHostDataSource.
Definition at line 708 of file host_mgr.cc.
References isc::dhcp::ALL_SOURCES.
ConstHostPtr isc::dhcp::HostMgr::get6 | ( | const SubnetID & | subnet_id, |
const asiolink::IOAddress & | addr, | ||
const HostMgrOperationTarget | target | ||
) | const |
Returns a host from specific subnet and reserved address.
subnet_id | subnet identifier. |
addr | specified address. |
target | The host data source being a target of the operation. |
host
object that has a reservation for specified address. Definition at line 678 of file host_mgr.cc.
References isc::dhcp::ALTERNATE_SOURCES, isc::dhcp::HOSTS_DBG_TRACE, isc::dhcp::hosts_logger, isc::dhcp::HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_ADDRESS6, LOG_DEBUG, isc::dhcp::PRIMARY_SOURCE, and isc::asiolink::IOAddress::toText().
|
virtual |
The HostMgr::get6
compatible with BaseHostDataSource
interfaces.
Operates on all host sources.
Implements isc::dhcp::BaseHostDataSource.
Definition at line 669 of file host_mgr.cc.
References isc::dhcp::ALL_SOURCES.
ConstHostPtr isc::dhcp::HostMgr::get6 | ( | const SubnetID & | subnet_id, |
const Host::IdentifierType & | identifier_type, | ||
const uint8_t * | identifier_begin, | ||
const size_t | identifier_len, | ||
const HostMgrOperationTarget | target | ||
) | const |
Returns a host connected to the IPv6 subnet.
This method returns a host connected to the IPv6 subnet as described in the BaseHostDataSource::get6
.
subnet_id | Subnet identifier. |
identifier_type | Identifier type. |
identifier_begin | Pointer to a beginning of a buffer containing an identifier. |
identifier_len | Identifier length. |
target | The host data source being a target of the operation. |
Host
object for which reservation has been made using the specified identifier. Definition at line 652 of file host_mgr.cc.
Referenced by isc::dhcp::AllocEngine::findGlobalReservation(), and isc::dhcp::AllocEngine::findReservation().
|
virtual |
The HostMgr::get6Any
compatible with BaseHostDataSource
interfaces.
Operates on all host sources.
Definition at line 643 of file host_mgr.cc.
References isc::dhcp::ALL_SOURCES.
ConstHostPtr isc::dhcp::HostMgr::get6Any | ( | const SubnetID & | subnet_id, |
const Host::IdentifierType & | identifier_type, | ||
const uint8_t * | identifier_begin, | ||
const size_t | identifier_len, | ||
const HostMgrOperationTarget | target | ||
) | const |
Returns any host connected to the IPv6 subnet.
This method returns a host connected to the IPv6 subnet as described in the BaseHostDataSource::get6
even when the reservation is marked as from negative caching. This allows to monitor negative caching.
subnet_id | Subnet identifier. |
identifier_type | Identifier type. |
identifier_begin | Pointer to a beginning of a buffer containing an identifier. |
identifier_len | Identifier length. |
target | The host data source being a target of the operation. |
Host
object for which reservation has been made using the specified identifier. Definition at line 592 of file host_mgr.cc.
References isc::dhcp::ALTERNATE_SOURCES, isc::dhcp::Host::getIdentifierAsText(), isc::dhcp::HOSTS_DBG_RESULTS, isc::dhcp::HOSTS_DBG_TRACE, isc::dhcp::hosts_logger, isc::dhcp::HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_IDENTIFIER, isc::dhcp::HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_IDENTIFIER_HOST, isc::dhcp::HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_IDENTIFIER_NULL, LOG_DEBUG, and isc::dhcp::PRIMARY_SOURCE.
|
virtual |
The HostMgr::getAll
compatible with BaseHostDataSource
interfaces.
Operates on all host sources.
Implements isc::dhcp::BaseHostDataSource.
Definition at line 145 of file host_mgr.cc.
References isc::dhcp::ALL_SOURCES.
ConstHostCollection isc::dhcp::HostMgr::getAll | ( | const Host::IdentifierType & | identifier_type, |
const uint8_t * | identifier_begin, | ||
const size_t | identifier_len, | ||
const HostMgrOperationTarget | target | ||
) | const |
Return all hosts connected to any subnet for which reservations have been made using a specified identifier.
This method returns all Host
objects representing reservations for a specified identifier as documented in the BaseHostDataSource::getAll
.
It retrieves reservations from both primary and alternate host data source as a single collection of Host
objects, i.e. if matching reservations are in both sources, all of them are returned. The reservations from the primary data source are placed before the reservations from the alternate source.
identifier_type | Identifier type. |
identifier_begin | Pointer to a beginning of a buffer containing an identifier. |
identifier_len | Identifier length. |
target | The host data source being a target of the operation. |
Host
objects. Definition at line 125 of file host_mgr.cc.
References isc::dhcp::ALTERNATE_SOURCES, and isc::dhcp::PRIMARY_SOURCE.
Referenced by isc::dhcp::AllocEngine::findReservation().
|
virtual |
The HostMgr::getAll4
compatible with BaseHostDataSource
interfaces.
Operates on all host sources.
Implements isc::dhcp::BaseHostDataSource.
Definition at line 398 of file host_mgr.cc.
References isc::dhcp::ALL_SOURCES.
ConstHostCollection isc::dhcp::HostMgr::getAll4 | ( | const asiolink::IOAddress & | address, |
const HostMgrOperationTarget | target | ||
) | const |
Returns a collection of hosts using the specified IPv4 address.
This method may return multiple Host
objects if they are connected to different subnets.
If matching reservations are both in the primary and the alternate data source, all of them are returned. The reservations from the primary data source are placed before the reservations from the alternate source.
address | IPv4 address for which the Host object is searched. |
target | The host data source being a target of the operation. |
Host
objects. Definition at line 383 of file host_mgr.cc.
References isc::dhcp::ALTERNATE_SOURCES, and isc::dhcp::PRIMARY_SOURCE.
|
virtual |
The HostMgr::getAll4
compatible with BaseHostDataSource
interfaces.
Operates on all host sources.
Implements isc::dhcp::BaseHostDataSource.
Definition at line 168 of file host_mgr.cc.
References isc::dhcp::ALL_SOURCES.
|
virtual |
The HostMgr::getAll4
compatible with BaseHostDataSource
interfaces.
Operates on all host sources.
Implements isc::dhcp::BaseHostDataSource.
Definition at line 553 of file host_mgr.cc.
References isc::dhcp::ALL_SOURCES.
ConstHostCollection isc::dhcp::HostMgr::getAll4 | ( | const SubnetID & | subnet_id, |
const asiolink::IOAddress & | address, | ||
const HostMgrOperationTarget | target | ||
) | const |
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.
subnet_id | Subnet identifier. |
address | reserved IPv4 address. |
target | The host data source being a target of the operation. |
Host
objects. Definition at line 530 of file host_mgr.cc.
References isc::dhcp::ALTERNATE_SOURCES, isc::dhcp::HOSTS_DBG_TRACE, isc::dhcp::hosts_logger, isc::dhcp::HOSTS_MGR_ALTERNATE_GET_ALL_SUBNET_ID_ADDRESS4, LOG_DEBUG, isc::dhcp::PRIMARY_SOURCE, and isc::asiolink::IOAddress::toText().
ConstHostCollection isc::dhcp::HostMgr::getAll4 | ( | const SubnetID & | subnet_id, |
const HostMgrOperationTarget | target | ||
) | const |
Return all hosts in a DHCPv4 subnet.
This method returns all Host
objects representing reservations in a specified subnet as documented in the BaseHostDataSource::getAll4
It retrieves reservations from both primary and alternate host data source as a single collection of Host
objects, i.e. if matching reservations are in both sources, all of them are returned. The reservations from the primary data source are placed before the reservations from the alternate source.
subnet_id | Subnet identifier. |
target | The host data source being a target of the operation. |
Host
objects. Definition at line 153 of file host_mgr.cc.
References isc::dhcp::ALTERNATE_SOURCES, and isc::dhcp::PRIMARY_SOURCE.
|
virtual |
The HostMgr::getAll6
compatible with BaseHostDataSource
interfaces.
Operates on all host sources.
Implements isc::dhcp::BaseHostDataSource.
Definition at line 744 of file host_mgr.cc.
References isc::dhcp::ALL_SOURCES.
ConstHostCollection isc::dhcp::HostMgr::getAll6 | ( | const asiolink::IOAddress & | address, |
const HostMgrOperationTarget | target | ||
) | const |
Returns a collection of hosts using the specified IPv6 address/prefix.
This method may return multiple Host
objects if they are connected to different subnets or if there are multiple hosts with the same IPv6 address/prefix.
If matching reservations are both in the primary and the alternate data source, all of them are returned. The reservations from the primary data source are placed before the reservations from the alternate source.
address | IPv6 address for which the Host object is searched. |
target | The host data source being a target of the operation. |
Host
objects. Definition at line 749 of file host_mgr.cc.
References isc::dhcp::ALTERNATE_SOURCES, and isc::dhcp::PRIMARY_SOURCE.
|
virtual |
The HostMgr::getAll6
compatible with BaseHostDataSource
interfaces.
Operates on all host sources.
Implements isc::dhcp::BaseHostDataSource.
Definition at line 188 of file host_mgr.cc.
References isc::dhcp::ALL_SOURCES.
|
virtual |
The HostMgr::getAll6
compatible with BaseHostDataSource
interfaces.
Operates on all host sources.
Implements isc::dhcp::BaseHostDataSource.
Definition at line 738 of file host_mgr.cc.
References isc::dhcp::ALL_SOURCES.
ConstHostCollection isc::dhcp::HostMgr::getAll6 | ( | const SubnetID & | subnet_id, |
const asiolink::IOAddress & | address, | ||
const HostMgrOperationTarget | target | ||
) | const |
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.
subnet_id | Subnet identifier. |
address | reserved IPv6 address/prefix. |
target | The host data source being a target of the operation. |
Host
objects. Definition at line 714 of file host_mgr.cc.
References isc::dhcp::ALTERNATE_SOURCES, isc::dhcp::HOSTS_DBG_TRACE, isc::dhcp::hosts_logger, isc::dhcp::HOSTS_MGR_ALTERNATE_GET_ALL_SUBNET_ID_ADDRESS6, LOG_DEBUG, isc::dhcp::PRIMARY_SOURCE, and isc::asiolink::IOAddress::toText().
ConstHostCollection isc::dhcp::HostMgr::getAll6 | ( | const SubnetID & | subnet_id, |
const HostMgrOperationTarget | target | ||
) | const |
Return all hosts in a DHCPv6 subnet.
This method returns all Host
objects representing reservations in a specified subnet as documented in the BaseHostDataSource::getAll6
It retrieves reservations from both primary and alternate host data source as a single collection of Host
objects, i.e. if matching reservations are in both sources, all of them are returned. The reservations from the primary data source are placed before the reservations from the alternate source.
subnet_id | Subnet identifier. |
target | The host data source being a target of the operation. |
Host
objects. Definition at line 173 of file host_mgr.cc.
References isc::dhcp::ALTERNATE_SOURCES, and isc::dhcp::PRIMARY_SOURCE.
|
virtual |
The HostMgr::getAllbyHostname
compatible with BaseHostDataSource
interfaces.
Operates on all host sources.
Implements isc::dhcp::BaseHostDataSource.
Definition at line 208 of file host_mgr.cc.
References isc::dhcp::ALL_SOURCES.
ConstHostCollection isc::dhcp::HostMgr::getAllbyHostname | ( | const std::string & | hostname, |
const HostMgrOperationTarget | target | ||
) | const |
Return all hosts with a hostname.
This method returns all Host
objects which represent reservations using a specified hostname.
hostname | The lower case hostname. |
target | The host data source being a target of the operation. |
Host
objects. Definition at line 193 of file host_mgr.cc.
References isc::dhcp::ALTERNATE_SOURCES, and isc::dhcp::PRIMARY_SOURCE.
|
virtual |
The HostMgr::getAllbyHostname4
compatible with BaseHostDataSource
interfaces.
Operates on all host sources.
Implements isc::dhcp::BaseHostDataSource.
Definition at line 231 of file host_mgr.cc.
References isc::dhcp::ALL_SOURCES.
ConstHostCollection isc::dhcp::HostMgr::getAllbyHostname4 | ( | const std::string & | hostname, |
const SubnetID & | subnet_id, | ||
const HostMgrOperationTarget | target | ||
) | const |
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.
hostname | The lower case hostname. |
subnet_id | Subnet identifier. |
target | The host data source being a target of the operation. |
Host
objects. Definition at line 213 of file host_mgr.cc.
References isc::dhcp::ALTERNATE_SOURCES, and isc::dhcp::PRIMARY_SOURCE.
|
virtual |
The HostMgr::getAllbyHostname6
compatible with BaseHostDataSource
interfaces.
Operates on all host sources.
Implements isc::dhcp::BaseHostDataSource.
Definition at line 255 of file host_mgr.cc.
References isc::dhcp::ALL_SOURCES.
ConstHostCollection isc::dhcp::HostMgr::getAllbyHostname6 | ( | const std::string & | hostname, |
const SubnetID & | subnet_id, | ||
const HostMgrOperationTarget | target | ||
) | const |
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.
hostname | The lower case hostname. |
subnet_id | Subnet identifier. |
target | The host data source being a target of the operation. |
Host
objects. Definition at line 237 of file host_mgr.cc.
References isc::dhcp::ALTERNATE_SOURCES, and isc::dhcp::PRIMARY_SOURCE.
|
inline |
Returns the disable single query flag.
Definition at line 796 of file host_mgr.h.
References disable_single_query_.
Referenced by isc::dhcp::AllocEngine::findReservation().
HostDataSourcePtr isc::dhcp::HostMgr::getHostDataSource | ( | ) | const |
Returns the first host data source.
May return NULL if the host data source list is empty.
Definition at line 86 of file host_mgr.cc.
|
inline |
Returns the host data source list.
Definition at line 770 of file host_mgr.h.
|
inlinestatic |
Returns pointer to the IO service.
Definition at line 843 of file host_mgr.h.
Referenced by isc::dhcp::MySqlHostDataSourceImpl::createContext(), and isc::dhcp::PgSqlHostDataSourceImpl::createContext().
|
inline |
Returns the boolean flag indicating if the IP reservations must be unique or can be non-unique.
Definition at line 831 of file host_mgr.h.
|
inline |
Returns the negative caching flag.
Definition at line 783 of file host_mgr.h.
References negative_caching_.
|
virtual |
Returns range of hosts in a DHCPv4 subnet.
This method returns a page of Host
objects representing reservations in a specified subnet as documented in the BaseHostDataSource::getPage4
The typical usage of this method is as follows:
subnet_id | Subnet identifier. |
source_index | Index of the source. |
lower_host_id | Host identifier used as lower bound for the returned range. |
page_size | maximum size of the page returned. |
Implements isc::dhcp::BaseHostDataSource.
Definition at line 261 of file host_mgr.cc.
|
virtual |
Returns range of hosts.
This method returns a page of Host
objects representing reservations as documented in the BaseHostDataSource::getPage4
The typical usage of this method is as follows:
source_index | Index of the source. |
lower_host_id | Host identifier used as lower bound for the returned range. |
page_size | maximum size of the page returned. |
Implements isc::dhcp::BaseHostDataSource.
Definition at line 323 of file host_mgr.cc.
|
virtual |
Returns range of hosts in a DHCPv6 subnet.
This method returns a page of Host
objects representing reservations in a specified subnet as documented in the BaseHostDataSource::getPage6
The typical usage of this method is as follows:
subnet_id | Subnet identifier. |
source_index | Index of the source. |
lower_host_id | Host identifier used as lower bound for the returned range. |
page_size | maximum size of the page returned. |
Implements isc::dhcp::BaseHostDataSource.
Definition at line 292 of file host_mgr.cc.
|
virtual |
Returns range of hosts.
This method returns a page of Host
objects representing reservations as documented in the BaseHostDataSource::getPage6
The typical usage of this method is as follows:
source_index | Index of the source. |
lower_host_id | Host identifier used as lower bound for the returned range. |
page_size | maximum size of the page returned. |
Implements isc::dhcp::BaseHostDataSource.
Definition at line 353 of file host_mgr.cc.
References getPage6().
Referenced by getPage6().
|
inlinevirtual |
Return backend type.
Returns the type of the backend (e.g. "mysql", "memfile" etc.)
Implements isc::dhcp::BaseHostDataSource.
Definition at line 763 of file host_mgr.h.
|
static |
Returns a sole instance of the HostMgr
.
This method should be used to retrieve an instance of the HostMgr
to be used to gather/manage host reservations. It returns an instance of the HostMgr
created by the create
method. If such instance doesn't exist yet, it is created using the create
method with the default value of the data access string, which configures the host manager to not use the alternate host data source.
Definition at line 116 of file host_mgr.cc.
Referenced by isc::dhcp::CfgDbAccess::createManagers(), isc::dhcp::AllocEngine::findGlobalReservation(), and isc::dhcp::AllocEngine::findReservation().
|
inline |
Sets the disable single query flag.
Definition at line 802 of file host_mgr.h.
References disable_single_query_.
|
inlinestatic |
Sets IO service to be used by the Host Manager.
io_service | IOService object, used for all ASIO operations. |
Definition at line 838 of file host_mgr.h.
Referenced by isc::dhcp::ControlledDhcpv4Srv::ControlledDhcpv4Srv(), isc::dhcp::ControlledDhcpv6Srv::ControlledDhcpv6Srv(), isc::dhcp::ControlledDhcpv4Srv::~ControlledDhcpv4Srv(), and isc::dhcp::ControlledDhcpv6Srv::~ControlledDhcpv6Srv().
|
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.
Calling this function on HostMgr
causes the manager to attempt to set this flag on all backends in use.
unique | boolean flag indicating if the IP reservations must be unique or can be non-unique. |
Implements isc::dhcp::BaseHostDataSource.
Definition at line 960 of file host_mgr.cc.
References isc::dhcp::hosts_logger, isc::dhcp::HOSTS_MGR_NON_UNIQUE_IP_UNSUPPORTED, and LOG_WARN.
|
inline |
Sets the negative caching flag.
Definition at line 789 of file host_mgr.h.
References negative_caching_.
|
virtual |
The HostMgr::update
with default operation target.
Operates on alternate host sources only.
Reimplemented from isc::dhcp::BaseHostDataSource.
Definition at line 924 of file host_mgr.cc.
References isc::dhcp::ALTERNATE_SOURCES.
void isc::dhcp::HostMgr::update | ( | HostPtr const & | host, |
const HostMgrOperationTarget | target | ||
) |
Implements BaseHostDataSource::update() for alternate sources.
Attempts to update an existing host entry.
host | the host up to date with the requested changes |
target | The host data source being a target of the operation. |
Definition at line 900 of file host_mgr.cc.
References isc::dhcp::ALTERNATE_SOURCES, isc_throw, and isc::dhcp::PRIMARY_SOURCE.
|
protected |
The disable single query flag.
When true prevent the use of lookup methods returning a collection aka single queries when methods returning a host object are usable instead.
Definition at line 861 of file host_mgr.h.
Referenced by getDisableSingleQuery(), and setDisableSingleQuery().
|
protected |
The negative caching flag.
When true and the first backend is a cache negative answers are inserted in the cache. This works for get[46] for a subnet and an identifier.
Definition at line 854 of file host_mgr.h.
Referenced by getNegativeCaching(), and setNegativeCaching().