![]() |
Kea 3.1.1
|
Host Cache implementation. More...
#include <host_cache.h>
Public Member Functions | |
HostCache () | |
Constructor. | |
virtual | ~HostCache () |
Destructor. | |
virtual void | add (const dhcp::HostPtr &host) |
Adds a new host to the collection. | |
int | cacheClearHandler (hooks::CalloutHandle &handle) |
cache-clear command handler. | |
int | cacheFlushHandler (hooks::CalloutHandle &handle) |
cache-flush command handler. | |
int | cacheGetByIdHandler (hooks::CalloutHandle &handle) |
cache-get-by-id command handler. | |
int | cacheGetHandler (hooks::CalloutHandle &handle) |
cache-get command handler. | |
int | cacheInsertHandler (hooks::CalloutHandle &handle) |
cache-insert command handler. | |
int | cacheLoadHandler (hooks::CalloutHandle &handle) |
cache-load command handler. | |
int | cacheRemoveHandler (hooks::CalloutHandle &handle) |
cache-remove command handler. | |
int | cacheSizeHandler (hooks::CalloutHandle &handle) |
Command handlers. | |
int | cacheWriteHandler (hooks::CalloutHandle &handle) |
cache-write command handler. | |
virtual size_t | capacity () const |
Return the maximum number of entries. | |
virtual void | configure (const data::ConstElementPtr &config) |
Parses configuration. | |
virtual bool | del (const dhcp::SubnetID &subnet_id, const asiolink::IOAddress &addr) |
Attempts to delete a host by (subnet-id, address) | |
virtual bool | del4 (const dhcp::SubnetID &subnet_id, const dhcp::Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) |
Attempts to delete a host by (subnet-id4, identifier, identifier-type) | |
virtual bool | del6 (const dhcp::SubnetID &subnet_id, const dhcp::Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) |
Attempts to delete a host by (subnet-id6, identifier, identifier-type) | |
virtual void | flush (size_t count) |
Flush entries. | |
virtual dhcp::ConstHostCollection | get (const dhcp::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. | |
virtual dhcp::ConstHostPtr | get4 (const dhcp::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. | |
virtual dhcp::ConstHostPtr | get4 (const dhcp::SubnetID &subnet_id, const dhcp::Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const |
Returns a host connected to the IPv4 subnet. | |
virtual dhcp::ConstHostPtr | get6 (const asiolink::IOAddress &prefix, const uint8_t prefix_len) const |
Returns a host using the specified IPv6 prefix. | |
virtual dhcp::ConstHostPtr | get6 (const dhcp::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 or prefix. | |
virtual dhcp::ConstHostPtr | get6 (const dhcp::SubnetID &subnet_id, const dhcp::Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const |
Returns a host connected to the IPv6 subnet. | |
virtual dhcp::ConstHostCollection | getAll (const dhcp::Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const |
BaseHostDataSource methods. | |
virtual dhcp::ConstHostCollection | getAll4 (const asiolink::IOAddress &address) const |
Returns a collection of hosts using the specified IPv4 address. | |
virtual dhcp::ConstHostCollection | getAll4 (const dhcp::SubnetID &subnet_id) const |
Return all hosts in a DHCPv4 subnet. | |
virtual dhcp::ConstHostCollection | getAll4 (const dhcp::SubnetID &subnet_id, const asiolink::IOAddress &address) const |
Returns all hosts connected to the IPv4 subnet and having a reservation for a specified address. | |
virtual dhcp::ConstHostCollection | getAll6 (const asiolink::IOAddress &address) const |
Returns a collection of hosts using the specified IPv6 address. | |
virtual dhcp::ConstHostCollection | getAll6 (const dhcp::SubnetID &subnet_id) const |
Return all hosts in a DHCPv6 subnet. | |
virtual dhcp::ConstHostCollection | getAll6 (const dhcp::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). | |
virtual dhcp::ConstHostCollection | getAllbyHostname (const std::string &hostname) const |
Return all hosts with a hostname. | |
virtual dhcp::ConstHostCollection | getAllbyHostname4 (const std::string &hostname, const dhcp::SubnetID &subnet_id) const |
Return all hosts with a hostname in a DHCPv4 subnet. | |
virtual dhcp::ConstHostCollection | getAllbyHostname6 (const std::string &hostname, const dhcp::SubnetID &subnet_id) const |
Return all hosts with a hostname in a DHCPv6 subnet. | |
virtual size_t | getMaximum () const |
Get maximum number of cached hosts. | |
virtual dhcp::ConstHostCollection | getPage4 (const dhcp::SubnetID &subnet_id, size_t &source_index, uint64_t lower_host_id, const dhcp::HostPageSize &page_size) const |
Return range of hosts in a DHCPv4 subnet. | |
virtual dhcp::ConstHostCollection | getPage4 (size_t &source_index, uint64_t lower_host_id, const dhcp::HostPageSize &page_size) const |
Return range of hosts. | |
virtual dhcp::ConstHostCollection | getPage6 (const dhcp::SubnetID &subnet_id, size_t &source_index, uint64_t lower_host_id, const dhcp::HostPageSize &page_size) const |
Return range of hosts in a DHCPv6 subnet. | |
virtual dhcp::ConstHostCollection | getPage6 (size_t &source_index, uint64_t lower_host_id, const dhcp::HostPageSize &page_size) const |
Return range of hosts. | |
virtual std::string | getType () const |
Return backend type. | |
virtual size_t | insert (const dhcp::ConstHostPtr &host, bool overwrite) |
Insert a host into the cache. | |
virtual bool | remove (const dhcp::HostPtr &host) |
Remove a host from the cache. | |
virtual bool | setIPReservationsUnique (const bool unique) |
Controls whether IP reservations are unique or non-unique. | |
virtual void | setMaximum (size_t maximum) |
Set maximum number of cached hosts (0 means unbound). | |
virtual size_t | size () const |
Return the number of entries. | |
virtual data::ElementPtr | toElement () const |
Returns the whole content of the cache as Element tree. | |
void | update (isc::dhcp::HostPtr const &host) |
Implements isc::dhcp::BaseHostDataSource::update() for HostCache. | |
![]() | |
virtual | ~CacheHostDataSource () |
Default destructor implementation. | |
![]() | |
virtual | ~BaseHostDataSource () |
Default destructor implementation. | |
virtual void | commit () |
Commit Transactions. | |
virtual isc::db::DatabaseConnection::ParameterMap | getParameters () const |
Return backend parameters. | |
virtual bool | isUnusable () |
Flag which indicates if the host manager has at least one unusable connection. | |
virtual void | rollback () |
Rollback Transactions. | |
Protected Attributes | |
boost::shared_ptr< HostCacheImpl > | impl_ |
Implementation. | |
boost::scoped_ptr< std::mutex > | mutex_ |
mutex | |
Additional Inherited Members | |
![]() | |
enum | IdType { ID_HWADDR = 0 , ID_DUID = 1 } |
Specifies the type of an identifier. More... | |
Host Cache implementation.
This Host cache provides Host backend that is able to cache hosts. Support for both positive (there is an entry for given host) and negative (there is no such entry) can be cached. Host collections (returned by getAll*() methods) are not handled.
Definition at line 34 of file host_cache.h.
isc::host_cache::HostCache::HostCache | ( | ) |
|
virtual |
|
virtual |
Adds a new host to the collection.
The implementations of this method should guard against duplicate reservations for the same host, where possible. For example, when the reservation for the same HW address and subnet id is added twice, the implementation should throw an exception. Note, that usually it is impossible to guard against adding duplicated host, where one instance is identified by HW address, another one by DUID.
host | Pointer to the new Host object being added. |
Implements isc::dhcp::BaseHostDataSource.
Definition at line 280 of file host_cache.cc.
References isc::host_cache::HOST_CACHE_ADD, isc::host_cache::HOST_CACHE_ADD_DUPLICATE, isc::host_cache::HOST_CACHE_DBG_RESULTS, isc::host_cache::host_cache_logger, impl_, isc_throw, LOG_DEBUG, and mutex_.
int isc::host_cache::HostCache::cacheClearHandler | ( | hooks::CalloutHandle & | handle | ) |
cache-clear command handler.
This command cleares the host cache.
No parameter taken.
Example command clearing the whole cache. { "command": "cache-clear" }
handle | Callout context - which is expected to contain the clear command JSON text in the "command" argument |
Definition at line 475 of file host_cache.cc.
References isc::config::CmdsImpl::extractCommand(), isc::host_cache::HOST_CACHE_COMMAND_CLEAR, isc::host_cache::HOST_CACHE_COMMAND_CLEAR_FAILED, isc::host_cache::host_cache_logger, impl_, LOG_ERROR, LOG_INFO, isc::config::CmdsImpl::setErrorResponse(), and isc::config::CmdsImpl::setSuccessResponse().
int isc::host_cache::HostCache::cacheFlushHandler | ( | hooks::CalloutHandle & | handle | ) |
cache-flush command handler.
This command flushes the host cache.
Parameter is the number of entries to flush (must be > 0) or the string 'all'.
Example command flushing at most 5 entries { "command": "cache-flush", "arguments": 5 }
Example command flush the whole cache { "command": "cache-flush", "arguments": "all" }
handle | Callout context - which is expected to contain the flush command JSON text in the "command" argument |
Definition at line 495 of file host_cache.cc.
References isc::config::CmdsImpl::cmd_args_, isc::config::CmdsImpl::extractCommand(), isc::host_cache::HOST_CACHE_COMMAND_FLUSH, isc::host_cache::HOST_CACHE_COMMAND_FLUSH_FAILED, isc::host_cache::host_cache_logger, impl_, isc_throw, LOG_ERROR, LOG_INFO, isc::host_cache::HCConfigParser::MAXIMUM, isc::config::CmdsImpl::setErrorResponse(), and isc::config::CmdsImpl::setSuccessResponse().
int isc::host_cache::HostCache::cacheGetByIdHandler | ( | hooks::CalloutHandle & | handle | ) |
cache-get-by-id command handler.
This command retrieves the host cache entries matching the given identifier.
Parameters are an identifier-type and an identifier.
Example command getting the specified entries. { "command": "cache-get-by-id", "arguments": { "hw-address": "01:02:03:04:05:06" } }
The result is a list of modified host reservations:
handle | Callout context - which is expected to contain the get command JSON text in the "command" argument |
Definition at line 573 of file host_cache.cc.
References isc::config::CmdsImpl::cmd_args_, isc::config::CONTROL_RESULT_EMPTY, isc::config::CONTROL_RESULT_SUCCESS, isc::config::createAnswer(), Element::createList(), isc::util::str::decodeFormattedHexString(), isc::config::CmdsImpl::extractCommand(), isc::host_cache::HOST_CACHE_COMMAND_GET_BY_ID, isc::host_cache::HOST_CACHE_COMMAND_GET_BY_ID_FAILED, isc::host_cache::host_cache_logger, isc::dhcp::Host::IDENT_CIRCUIT_ID, isc::dhcp::Host::IDENT_CLIENT_ID, isc::dhcp::Host::IDENT_DUID, isc::dhcp::Host::IDENT_FLEX, isc::dhcp::Host::IDENT_HWADDR, impl_, isc_throw, LOG_ERROR, LOG_INFO, Element::map, mutex_, isc::util::str::quotedStringToBinary(), isc::config::CmdsImpl::setErrorResponse(), isc::config::CmdsImpl::setResponse(), and isc::host_cache::toElement().
int isc::host_cache::HostCache::cacheGetHandler | ( | hooks::CalloutHandle & | handle | ) |
cache-get command handler.
This command retrieves the host cache content.
No parameter taken.
Example command dumping the whole cache { "command": "cache-get", }
The result is a list of modified host reservations:
handle | Callout context - which is expected to contain the get command JSON text in the "command" argument |
Definition at line 544 of file host_cache.cc.
References isc::config::CONTROL_RESULT_EMPTY, isc::config::CONTROL_RESULT_SUCCESS, isc::config::createAnswer(), isc::config::CmdsImpl::extractCommand(), isc::host_cache::HOST_CACHE_COMMAND_GET, isc::host_cache::HOST_CACHE_COMMAND_GET_FAILED, isc::host_cache::host_cache_logger, impl_, LOG_ERROR, LOG_INFO, isc::config::CmdsImpl::setErrorResponse(), and isc::config::CmdsImpl::setResponse().
int isc::host_cache::HostCache::cacheInsertHandler | ( | hooks::CalloutHandle & | handle | ) |
cache-insert command handler.
This command inserts entries into the host cache.
Parameter is either one entry, or a list of entries in the format described for cache-get.
Example command { "command": "cache-insert", "arguments": { host1, host2 } }
handle | Callout context - which is expected to contain the insert command JSON text in the "command" argument and entry/entries in the "arguments" one. |
Definition at line 672 of file host_cache.cc.
References isc::config::CmdsImpl::cmd_args_, isc::config::CmdsImpl::extractCommand(), isc::host_cache::HOST_CACHE_COMMAND_INSERT, isc::host_cache::HOST_CACHE_COMMAND_INSERT_FAILED, isc::host_cache::host_cache_logger, impl_, isc_throw, LOG_ERROR, LOG_INFO, Element::map, mutex_, isc::host_cache::HCEntryListParser::parse(), isc::host_cache::HCEntryParser::parse(), isc::config::CmdsImpl::setErrorResponse(), and isc::config::CmdsImpl::setSuccessResponse().
int isc::host_cache::HostCache::cacheLoadHandler | ( | hooks::CalloutHandle & | handle | ) |
cache-load command handler.
This command loads the cache content from disk.
Parameter is the path of the file where to read the host cache content, i.e. the cache-write opposite operation. When two entries conflict the most recent one is kept and the previous/older one is removed.
handle | Callout context - which is expected to contain the flush command JSON text in the "command" argument |
Definition at line 793 of file host_cache.cc.
References isc::config::CmdsImpl::cmd_args_, isc::config::CmdsImpl::extractCommand(), Element::fromJSONFile(), isc::host_cache::HOST_CACHE_COMMAND_LOAD, isc::host_cache::HOST_CACHE_COMMAND_LOAD_FAILED, isc::host_cache::host_cache_logger, impl_, isc_throw, LOG_ERROR, LOG_INFO, isc::host_cache::HCEntryListParser::parse(), isc::config::CmdsImpl::setErrorResponse(), isc::config::CmdsImpl::setSuccessResponse(), and Element::string.
int isc::host_cache::HostCache::cacheRemoveHandler | ( | hooks::CalloutHandle & | handle | ) |
cache-remove command handler.
This command removes entries into the host cache.
Parameters are either a subnet-id and an ip-address, or an identifier-type, an identifier and subnet-id4 or subnet-id6.
Example command with an address { "command": "cache-remove", "arguments": { "subnet-id": 123, "ip-address": "192.0.0.2" } }
Example command with an identifier { "command": "cache-remove", "arguments": { "subnet-id6": 10, "hw-address": "01:02:03:04:05:06" } }
handle | Callout context - which is expected to contain the remove command JSON text in the "command" argument and entry/entries in the "arguments" one. |
Definition at line 855 of file host_cache.cc.
References isc::config::CmdsImpl::cmd_args_, isc::config::CONTROL_RESULT_EMPTY, isc::util::str::decodeFormattedHexString(), isc::config::CmdsImpl::extractCommand(), isc::host_cache::HOST_CACHE_COMMAND_REMOVE, isc::host_cache::HOST_CACHE_COMMAND_REMOVE_FAILED, isc::host_cache::host_cache_logger, isc::dhcp::Host::IDENT_CIRCUIT_ID, isc::dhcp::Host::IDENT_CLIENT_ID, isc::dhcp::Host::IDENT_DUID, isc::dhcp::Host::IDENT_FLEX, isc::dhcp::Host::IDENT_HWADDR, impl_, isc_throw, isc::asiolink::IOAddress::isV4(), isc::asiolink::IOAddress::isV4Zero(), isc::asiolink::IOAddress::isV6(), isc::asiolink::IOAddress::isV6Zero(), LOG_ERROR, LOG_INFO, Element::map, mutex_, isc::util::str::quotedStringToBinary(), isc::config::CmdsImpl::setErrorResponse(), and isc::config::CmdsImpl::setSuccessResponse().
int isc::host_cache::HostCache::cacheSizeHandler | ( | hooks::CalloutHandle & | handle | ) |
Command handlers.
cache-size command handler.
This command returns the size of the host cache.
No parameter taken.
Example command returning the cache size. { "command": "cache-size" }
The result is the size of the cache.
handle | Callout context - which is expected to contain the size command JSON text in the "command" argument |
Definition at line 448 of file host_cache.cc.
References isc::config::CONTROL_RESULT_SUCCESS, Element::create(), isc::config::createAnswer(), Element::createMap(), isc::config::CmdsImpl::extractCommand(), isc::host_cache::HOST_CACHE_COMMAND_SIZE, isc::host_cache::HOST_CACHE_COMMAND_SIZE_FAILED, isc::host_cache::host_cache_logger, impl_, LOG_ERROR, LOG_INFO, mutex_, isc::config::CmdsImpl::setErrorResponse(), and isc::config::CmdsImpl::setResponse().
int isc::host_cache::HostCache::cacheWriteHandler | ( | hooks::CalloutHandle & | handle | ) |
cache-write command handler.
This command writes the host cache content to disk.
Parameter is the path of the file where to write the host cache content as a JSON list of entries in the format described for cache-get.
Example command { "command": "cache-write", "arguments": "cache.dump" }
handle | Callout context - which is expected to contain the write command JSON text in the "command" argument |
Definition at line 735 of file host_cache.cc.
References isc::config::CmdsImpl::cmd_args_, isc::config::CmdsImpl::extractCommand(), isc::host_cache::HOST_CACHE_COMMAND_WRITE, isc::host_cache::HOST_CACHE_COMMAND_WRITE_FAILED, isc::host_cache::host_cache_logger, isc::host_cache::HOST_CACHE_PATH_SECURITY_WARNING, impl_, isc::dhcp::CfgMgr::instance(), isc_throw, LOG_ERROR, LOG_INFO, LOG_WARN, isc::data::prettyPrint(), isc::config::CmdsImpl::setErrorResponse(), isc::config::CmdsImpl::setSuccessResponse(), Element::string, isc::dhcp::CfgMgr::validatePath(), and isc::Exception::what().
|
virtual |
Return the maximum number of entries.
Implements isc::dhcp::CacheHostDataSource.
Definition at line 434 of file host_cache.cc.
|
virtual |
Parses configuration.
config | Configuration specified for the hooks library. |
ConfigError | when configuration fails. |
Definition at line 42 of file host_cache.cc.
References isc::host_cache::HCConfigParser::parse().
|
virtual |
Attempts to delete a host by (subnet-id, address)
This method supports both v4 and v6.
subnet_id | subnet identifier. |
addr | specified address. |
Implements isc::dhcp::BaseHostDataSource.
Definition at line 308 of file host_cache.cc.
References isc::host_cache::HOST_CACHE_DBG_RESULTS, isc::host_cache::HOST_CACHE_DEL_SUBNET_ID_ADDRESS4, isc::host_cache::HOST_CACHE_DEL_SUBNET_ID_ADDRESS6, isc::host_cache::host_cache_logger, impl_, isc::asiolink::IOAddress::isV4(), isc::asiolink::IOAddress::isV6(), LOG_DEBUG, mutex_, and isc::asiolink::IOAddress::toText().
|
virtual |
Attempts to delete a host by (subnet-id4, identifier, identifier-type)
This method supports v4 hosts 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. |
Implements isc::dhcp::BaseHostDataSource.
Definition at line 339 of file host_cache.cc.
References isc::dhcp::Host::getIdentifierAsText(), isc::host_cache::HOST_CACHE_DBG_RESULTS, isc::host_cache::HOST_CACHE_DEL_SUBNET_ID_IDENTIFIER4, isc::host_cache::host_cache_logger, impl_, LOG_DEBUG, and mutex_.
|
virtual |
Attempts to delete a host by (subnet-id6, identifier, identifier-type)
This method supports v6 hosts 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. |
Implements isc::dhcp::BaseHostDataSource.
Definition at line 362 of file host_cache.cc.
References isc::dhcp::Host::getIdentifierAsText(), isc::host_cache::HOST_CACHE_DBG_RESULTS, isc::host_cache::HOST_CACHE_DEL_SUBNET_ID_IDENTIFIER6, isc::host_cache::host_cache_logger, impl_, LOG_DEBUG, and mutex_.
|
virtual |
Flush entries.
count | number of entries to remove, 0 means all. |
Implements isc::dhcp::CacheHostDataSource.
Definition at line 418 of file host_cache.cc.
|
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.
identifier_type | Identifier type (ignored). |
identifier_begin | Pointer to a beginning of a buffer containing an identifier (ignored). |
identifier_len | Identifier length. |
Host
objects. Definition at line 440 of file host_cache.cc.
|
virtual |
Returns a host connected to the IPv4 subnet and having a reservation for a specified IPv4 address.
One of the use cases for this method is to detect collisions between dynamically allocated addresses and reserved addresses. When the new address is assigned to a client, the allocation mechanism should check if this address is not reserved for some other host and do not allocate this address if reservation is present.
Implementations of this method should guard against invalid addresses, such as IPv6 address.
subnet_id | Subnet identifier. |
address | reserved IPv4 address. |
Host
object using a specified IPv4 address. Implements isc::dhcp::BaseHostDataSource.
Definition at line 156 of file host_cache.cc.
References isc::host_cache::HOST_CACHE_DBG_RESULTS, isc::host_cache::HOST_CACHE_DBG_TRACE, isc::host_cache::HOST_CACHE_GET_ONE_SUBNET_ID_ADDRESS4, isc::host_cache::HOST_CACHE_GET_ONE_SUBNET_ID_ADDRESS4_HOST, isc::host_cache::host_cache_logger, impl_, isc::asiolink::IOAddress::isV4(), LOG_DEBUG, mutex_, and isc::asiolink::IOAddress::toText().
|
virtual |
Returns a host connected to the IPv4 subnet.
subnet_id | Subnet identifier. |
identifier_type | Identifier type. |
identifier_begin | Pointer to a beginning of a buffer containing an identifier. |
identifier_len | Identifier length. |
Host
object for which reservation has been made using the specified identifier. Implements isc::dhcp::BaseHostDataSource.
Definition at line 127 of file host_cache.cc.
References isc::dhcp::Host::getIdentifierAsText(), isc::host_cache::HOST_CACHE_DBG_RESULTS, isc::host_cache::HOST_CACHE_DBG_TRACE, isc::host_cache::HOST_CACHE_GET_ONE_SUBNET_ID_IDENTIFIER, isc::host_cache::HOST_CACHE_GET_ONE_SUBNET_ID_IDENTIFIER_HOST, isc::host_cache::host_cache_logger, impl_, LOG_DEBUG, and mutex_.
|
virtual |
Returns a host using the specified IPv6 prefix.
prefix | IPv6 prefix for which the Host object is searched. |
prefix_len | IPv6 prefix length. |
Host
object using a specified IPv6 prefix. Implements isc::dhcp::BaseHostDataSource.
Definition at line 218 of file host_cache.cc.
References isc::host_cache::HOST_CACHE_DBG_RESULTS, isc::host_cache::HOST_CACHE_DBG_TRACE, isc::host_cache::HOST_CACHE_GET_ONE_PREFIX, isc::host_cache::HOST_CACHE_GET_ONE_PREFIX_HOST, isc::host_cache::host_cache_logger, impl_, LOG_DEBUG, mutex_, and isc::asiolink::IOAddress::toText().
|
virtual |
Returns a host connected to the IPv6 subnet and having a reservation for a specified IPv6 address or prefix.
subnet_id | Subnet identifier. |
address | reserved IPv6 address/prefix. |
Host
object using a specified IPv6 address/prefix. Implements isc::dhcp::BaseHostDataSource.
Definition at line 241 of file host_cache.cc.
References isc::host_cache::HOST_CACHE_DBG_RESULTS, isc::host_cache::HOST_CACHE_DBG_TRACE, isc::host_cache::HOST_CACHE_GET_ONE_SUBNET_ID_ADDRESS6, isc::host_cache::HOST_CACHE_GET_ONE_SUBNET_ID_ADDRESS6_HOST, isc::host_cache::host_cache_logger, impl_, isc::asiolink::IOAddress::isV6(), LOG_DEBUG, mutex_, and isc::asiolink::IOAddress::toText().
|
virtual |
Returns a host connected to the IPv6 subnet.
subnet_id | Subnet identifier. |
identifier_type | Identifier type. |
identifier_begin | Pointer to a beginning of a buffer containing an identifier. |
identifier_len | Identifier length. |
Host
object for which reservation has been made using the specified identifier. Implements isc::dhcp::BaseHostDataSource.
Definition at line 189 of file host_cache.cc.
References isc::dhcp::Host::getIdentifierAsText(), isc::host_cache::HOST_CACHE_DBG_RESULTS, isc::host_cache::HOST_CACHE_DBG_TRACE, isc::host_cache::HOST_CACHE_GET_ONE_SUBNET_ID_IDENTIFIER, isc::host_cache::HOST_CACHE_GET_ONE_SUBNET_ID_IDENTIFIER_HOST, isc::host_cache::host_cache_logger, impl_, LOG_DEBUG, and mutex_.
|
virtual |
BaseHostDataSource methods.
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.
identifier_type | Identifier type (ignored). |
identifier_begin | Pointer to a beginning of a buffer containing an identifier (ignored). |
identifier_len | Identifier length. |
Host
objects. Implements isc::dhcp::BaseHostDataSource.
Definition at line 58 of file host_cache.cc.
|
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.
address | IPv4 address for which the Host object is searched (ignored). |
Host
objects. Implements isc::dhcp::BaseHostDataSource.
Definition at line 122 of file host_cache.cc.
|
virtual |
Return all hosts in a DHCPv4 subnet.
This method returns all Host
objects which represent reservations in a specified subnet.
subnet_id | Subnet identifier. |
Host
objects. Implements isc::dhcp::BaseHostDataSource.
Definition at line 65 of file host_cache.cc.
|
virtual |
Returns all hosts connected to the IPv4 subnet and having a reservation for a specified address.
subnet_id | Subnet identifier. |
address | reserved IPv4 address. |
Host
objects. Implements isc::dhcp::BaseHostDataSource.
Definition at line 183 of file host_cache.cc.
|
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.
address | IPv6 address for which the Host object is searched. |
Host
objects. Implements isc::dhcp::BaseHostDataSource.
Definition at line 275 of file host_cache.cc.
|
virtual |
Return all hosts in a DHCPv6 subnet.
This method returns all Host
objects which represent reservations in a specified subnet.
subnet_id | Subnet identifier. |
Host
objects. Implements isc::dhcp::BaseHostDataSource.
Definition at line 70 of file host_cache.cc.
|
virtual |
Returns all hosts connected to the IPv6 subnet and having a reservation for a specified address or delegated prefix (lease).
subnet_id | Subnet identifier. |
address | reserved IPv6 address/prefix. |
Host
objects. Implements isc::dhcp::BaseHostDataSource.
Definition at line 269 of file host_cache.cc.
|
virtual |
Return all hosts with a hostname.
This method returns all Host
objects which represent reservations using a specified hostname.
hostname | The lower case hostname. |
Host
objects. Implements isc::dhcp::BaseHostDataSource.
Definition at line 75 of file host_cache.cc.
|
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.
hostname | The lower case hostname. |
subnet_id | Subnet identifier. |
Host
objects. Implements isc::dhcp::BaseHostDataSource.
Definition at line 80 of file host_cache.cc.
|
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.
hostname | The lower case hostname. |
subnet_id | Subnet identifier. |
Host
objects. Implements isc::dhcp::BaseHostDataSource.
Definition at line 86 of file host_cache.cc.
|
virtual |
Get maximum number of cached hosts.
Definition at line 52 of file host_cache.cc.
|
virtual |
Return range of hosts in a DHCPv4 subnet.
This method returns a page of Host
objects which represent reservations in a specified subnet.
subnet_id | Subnet identifier. |
source_index | Index of the source (unused). |
lower_host_id | Host identifier used as lower bound for the returned range. |
page_size | maximum size of the page returned. |
Host
objects. Implements isc::dhcp::BaseHostDataSource.
Definition at line 92 of file host_cache.cc.
|
virtual |
Return range of hosts.
This method returns a page of Host
objects which represent reservations.
source_index | Index of the source (unused). |
lower_host_id | Host identifier used as lower bound for the returned range. |
page_size | maximum size of the page returned. |
Host
objects. Implements isc::dhcp::BaseHostDataSource.
Definition at line 108 of file host_cache.cc.
|
virtual |
Return range of hosts in a DHCPv6 subnet.
This method returns a page of Host
objects which represent reservations in a specified subnet.
subnet_id | Subnet identifier. |
source_index | Index of the source (unused). |
lower_host_id | Host identifier used as lower bound for the returned range. |
page_size | maximum size of the page returned. |
Host
objects. Implements isc::dhcp::BaseHostDataSource.
Definition at line 100 of file host_cache.cc.
|
virtual |
Return range of hosts.
This method returns a page of Host
objects which represent reservations.
source_index | Index of the source (unused). |
lower_host_id | Host identifier used as lower bound for the returned range. |
page_size | maximum size of the page returned. |
Host
objects. Implements isc::dhcp::BaseHostDataSource.
Definition at line 115 of file host_cache.cc.
|
inlinevirtual |
Return backend type.
Returns the type of the backend (e.g. "mysql", "memfile" etc.)
Implements isc::dhcp::BaseHostDataSource.
Definition at line 394 of file host_cache.h.
|
virtual |
Insert a host into the cache.
Similar to add()
but with a different purpose.
host | Pointer to the new Host object being inserted. |
overwrite | false if doing nothing in case of conflicts (and returning 1), true if removing conflicting entries (and returning their number). |
Implements isc::dhcp::CacheHostDataSource.
Definition at line 406 of file host_cache.cc.
|
virtual |
Remove a host from the cache.
Does the same than del
, del4
or del6
but with a more uniform interface and a different purpose.
host | Pointer to the existing Host object being removed. |
Implements isc::dhcp::CacheHostDataSource.
Definition at line 412 of file host_cache.cc.
|
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.
unique | boolean flag indicating if the IP reservations must be unique within the subnet or can be non-unique. |
Implements isc::dhcp::BaseHostDataSource.
Definition at line 391 of file host_cache.cc.
|
virtual |
Set maximum number of cached hosts (0 means unbound).
Definition at line 47 of file host_cache.cc.
Referenced by isc::host_cache::HCConfigParser::parse().
|
virtual |
Return the number of entries.
Implements isc::dhcp::CacheHostDataSource.
Definition at line 428 of file host_cache.cc.
|
virtual |
Returns the whole content of the cache as Element tree.
Definition at line 400 of file host_cache.cc.
|
virtual |
Implements isc::dhcp::BaseHostDataSource::update() for HostCache.
Attempts to update an existing host entry.
host | the host up to date with the requested changes |
Reimplemented from isc::dhcp::BaseHostDataSource.
Definition at line 385 of file host_cache.cc.
|
protected |
Implementation.
Definition at line 674 of file host_cache.h.
Referenced by HostCache(), ~HostCache(), add(), cacheClearHandler(), cacheFlushHandler(), cacheGetByIdHandler(), cacheGetHandler(), cacheInsertHandler(), cacheLoadHandler(), cacheRemoveHandler(), cacheSizeHandler(), cacheWriteHandler(), capacity(), del(), del4(), del6(), flush(), get(), get4(), get4(), get6(), get6(), get6(), getMaximum(), insert(), remove(), setMaximum(), size(), toElement(), and update().
|
protected |
mutex
Definition at line 677 of file host_cache.h.
Referenced by HostCache(), add(), cacheGetByIdHandler(), cacheInsertHandler(), cacheRemoveHandler(), cacheSizeHandler(), capacity(), del(), del4(), del6(), flush(), get(), get4(), get4(), get6(), get6(), get6(), getMaximum(), insert(), remove(), setMaximum(), size(), toElement(), and update().