![]() |
Kea 3.1.1
|
Host Cache hooks library implementation. More...
#include <host_cache_impl.h>
Public Member Functions | |
HostCacheImpl () | |
Constructor. | |
virtual | ~HostCacheImpl () |
Destructor. | |
bool | add (const dhcp::HostPtr &host) |
Adds a new host to the collection. | |
size_t | capacity () const |
Return the maximum number of entries. | |
void | clear () |
Flush all entries. | |
std::string | del4 (const dhcp::SubnetID &subnet_id, const asiolink::IOAddress &addr) |
Attempts to delete a host by (subnet-id4, address) | |
std::string | 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) | |
std::string | del6 (const dhcp::SubnetID &subnet_id, const asiolink::IOAddress &addr) |
Attempts to delete a host by (subnet-id6, address) | |
std::string | 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) | |
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. | |
dhcp::ConstHostPtr | get4 (const dhcp::SubnetID &subnet_id, const asiolink::IOAddress &address) |
Returns a host connected to the IPv4 subnet and having a reservation for a specified IPv4 address. | |
dhcp::ConstHostPtr | get4 (const dhcp::SubnetID &subnet_id, const dhcp::Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) |
Returns a host connected to the IPv4 subnet. | |
dhcp::ConstHostPtr | get6 (const asiolink::IOAddress &prefix, const uint8_t prefix_len) |
Returns a host using the specified IPv6 prefix. | |
dhcp::ConstHostPtr | get6 (const dhcp::SubnetID &subnet_id, const asiolink::IOAddress &address) |
Returns a host connected to the IPv6 subnet and having a reservation for a specified IPv6 address or prefix. | |
dhcp::ConstHostPtr | get6 (const dhcp::SubnetID &subnet_id, const dhcp::Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) |
Returns a host connected to the IPv6 subnet. | |
HostContainerSequencedIndex::iterator | getHostInternal (const dhcp::SubnetID &subnet_id, const bool subnet6, const dhcp::Host::IdentifierType &identifier_type, const uint8_t *identifier, const size_t identifier_len) |
Returns Host object connected to a subnet. | |
HostContainerSequencedIndex::iterator | getHostInternal4 (const dhcp::SubnetID &subnet_id, const asiolink::IOAddress &address) |
Returns a host connected to the IPv4 subnet and having a reservation for a specified IPv4 address. | |
dhcp::HostPtr | getHostInternal6 (const asiolink::IOAddress &prefix, const uint8_t prefix_len) |
Returns a host using the specified IPv6 prefix. | |
dhcp::HostPtr | getHostInternal6 (const dhcp::SubnetID &subnet_id, const asiolink::IOAddress &address) |
Returns a host connected to the IPv6 subnet and having a reservation for a specified IPv6 address or prefix. | |
size_t | getMaximum () const |
Get maximum number of elements. | |
size_t | insert (const dhcp::ConstHostPtr &host, bool overwrite) |
Insert a host into the cache. | |
bool | insertResv6 (const dhcp::HostPtr &host) |
Insert IPv6 reservations. | |
dhcp::HostPtr | relocate (dhcp::HostPtr host) |
Relocate an entry to the end of sequenced index. | |
bool | remove (const dhcp::HostPtr &host) |
Remove a host from the cache. | |
void | removeResv6 (const dhcp::HostPtr &host) |
Remove IPv6 reservations. | |
void | setMaximum (size_t maximum) |
Set maximum number of elements. | |
size_t | size () const |
Return the number of entries. | |
data::ElementPtr | toElement () const |
Unparse cache content. | |
void | update (isc::dhcp::ConstHostPtr const &host) |
Implements isc::dhcp::BaseHostDataSource::update() for HostCacheImpl. | |
Public Attributes | |
size_t | maximum_ |
Maximum number of elements (0 means unbound). | |
Host Cache hooks library implementation.
Definition at line 24 of file host_cache_impl.h.
isc::host_cache::HostCacheImpl::HostCacheImpl | ( | ) |
Constructor.
Unexpected | if allocation fails. |
Definition at line 24 of file host_cache_impl.cc.
References maximum_.
|
virtual |
Destructor.
Definition at line 27 of file host_cache_impl.cc.
bool isc::host_cache::HostCacheImpl::add | ( | const dhcp::HostPtr & | host | ) |
Adds a new host to the collection.
host | Pointer to the new Host object being added. |
Definition at line 390 of file host_cache_impl.cc.
References insert().
|
inline |
Return the maximum number of entries.
Definition at line 280 of file host_cache_impl.h.
References maximum_.
|
inline |
Flush all entries.
Definition at line 260 of file host_cache_impl.h.
string isc::host_cache::HostCacheImpl::del4 | ( | const dhcp::SubnetID & | subnet_id, |
const asiolink::IOAddress & | addr ) |
Attempts to delete a host by (subnet-id4, address)
subnet_id | subnet identifier. |
addr | specified address. |
Definition at line 395 of file host_cache_impl.cc.
References removeResv6().
string isc::host_cache::HostCacheImpl::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)
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. |
Definition at line 432 of file host_cache_impl.cc.
References removeResv6().
string isc::host_cache::HostCacheImpl::del6 | ( | const dhcp::SubnetID & | subnet_id, |
const asiolink::IOAddress & | addr ) |
Attempts to delete a host by (subnet-id6, address)
subnet_id | subnet identifier. |
addr | specified address. |
Definition at line 415 of file host_cache_impl.cc.
References remove().
string isc::host_cache::HostCacheImpl::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)
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. |
Definition at line 457 of file host_cache_impl.cc.
References removeResv6().
void isc::host_cache::HostCacheImpl::flush | ( | size_t | count | ) |
Flush entries.
count | number of entries to remove. |
Definition at line 497 of file host_cache_impl.cc.
References removeResv6().
Referenced by insert().
|
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 528 of file host_cache_impl.cc.
ConstHostPtr isc::host_cache::HostCacheImpl::get4 | ( | const dhcp::SubnetID & | subnet_id, |
const asiolink::IOAddress & | address ) |
Returns a host connected to the IPv4 subnet and having a reservation for a specified IPv4 address.
subnet_id | Subnet identifier. |
address | reserved IPv4 address. |
Host
object using a specified IPv4 address. Definition at line 131 of file host_cache_impl.cc.
References getHostInternal4().
ConstHostPtr isc::host_cache::HostCacheImpl::get4 | ( | const dhcp::SubnetID & | subnet_id, |
const dhcp::Host::IdentifierType & | identifier_type, | ||
const uint8_t * | identifier_begin, | ||
const size_t | identifier_len ) |
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 using the specified identifier. Definition at line 116 of file host_cache_impl.cc.
References getHostInternal().
ConstHostPtr isc::host_cache::HostCacheImpl::get6 | ( | const asiolink::IOAddress & | prefix, |
const uint8_t | prefix_len ) |
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 prefix. Definition at line 158 of file host_cache_impl.cc.
References getHostInternal6(), and relocate().
ConstHostPtr isc::host_cache::HostCacheImpl::get6 | ( | const dhcp::SubnetID & | subnet_id, |
const asiolink::IOAddress & | address ) |
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. Definition at line 165 of file host_cache_impl.cc.
References getHostInternal6(), and relocate().
ConstHostPtr isc::host_cache::HostCacheImpl::get6 | ( | const dhcp::SubnetID & | subnet_id, |
const dhcp::Host::IdentifierType & | identifier_type, | ||
const uint8_t * | identifier_begin, | ||
const size_t | identifier_len ) |
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 using the specified identifier. Definition at line 143 of file host_cache_impl.cc.
References getHostInternal().
HostContainerSequencedIndex::iterator isc::host_cache::HostCacheImpl::getHostInternal | ( | const dhcp::SubnetID & | subnet_id, |
const bool | subnet6, | ||
const dhcp::Host::IdentifierType & | identifier_type, | ||
const uint8_t * | identifier, | ||
const size_t | identifier_len ) |
Returns Host
object connected to a subnet.
subnet_id | IPv4 or IPv6 subnet identifier. |
subnet6 | A boolean flag which indicates if the subnet identifier points to a IPv4 (if false) or IPv6 subnet (if true). |
identifier_type | Identifier type. |
identifier | Pointer to a first byte of the buffer holding an identifier. |
identifier_len | Identifier length. |
Definition at line 172 of file host_cache_impl.cc.
HostContainerSequencedIndex::iterator isc::host_cache::HostCacheImpl::getHostInternal4 | ( | const dhcp::SubnetID & | subnet_id, |
const asiolink::IOAddress & | address ) |
Returns a host connected to the IPv4 subnet and having a reservation for a specified IPv4 address.
subnet_id | Subnet identifier. |
address | reserved IPv4 address. |
Definition at line 198 of file host_cache_impl.cc.
HostPtr isc::host_cache::HostCacheImpl::getHostInternal6 | ( | const asiolink::IOAddress & | prefix, |
const uint8_t | prefix_len ) |
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 prefix, or NULL if no Definition at line 215 of file host_cache_impl.cc.
HostPtr isc::host_cache::HostCacheImpl::getHostInternal6 | ( | const dhcp::SubnetID & | subnet_id, |
const asiolink::IOAddress & | address ) |
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, or NULL if no host is found. Definition at line 231 of file host_cache_impl.cc.
|
inline |
Get maximum number of elements.
Definition at line 43 of file host_cache_impl.h.
References maximum_.
size_t isc::host_cache::HostCacheImpl::insert | ( | const dhcp::ConstHostPtr & | host, |
bool | overwrite ) |
Insert a host into the cache.
Does the same than 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). |
Definition at line 248 of file host_cache_impl.cc.
References flush(), getHostInternal(), getHostInternal4(), getHostInternal6(), insertResv6(), isc::asiolink::IOAddress::isV4Zero(), maximum_, remove(), removeResv6(), isc::dhcp::IPv6Resrv::TYPE_NA, and isc::dhcp::IPv6Resrv::TYPE_PD.
Referenced by add(), and update().
bool isc::host_cache::HostCacheImpl::insertResv6 | ( | const dhcp::HostPtr & | host | ) |
Insert IPv6 reservations.
host | host with the IPv6 reservations to insert. |
Definition at line 31 of file host_cache_impl.cc.
Referenced by insert().
HostPtr isc::host_cache::HostCacheImpl::relocate | ( | dhcp::HostPtr | host | ) |
Relocate an entry to the end of sequenced index.
Used to implement least-recently-used, called to return get*() results.
host | host to relocate. |
Definition at line 100 of file host_cache_impl.cc.
References removeResv6().
Referenced by get6(), and get6().
bool isc::host_cache::HostCacheImpl::remove | ( | const dhcp::HostPtr & | host | ) |
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. |
Definition at line 483 of file host_cache_impl.cc.
References removeResv6().
Referenced by del6(), and insert().
void isc::host_cache::HostCacheImpl::removeResv6 | ( | const dhcp::HostPtr & | host | ) |
Remove IPv6 reservations.
host | host with the IPv6 reservations to remove. |
Definition at line 51 of file host_cache_impl.cc.
References isc::dhcp::IPv6Resrv::TYPE_NA, and isc::dhcp::IPv6Resrv::TYPE_PD.
Referenced by del4(), del4(), del6(), flush(), insert(), relocate(), and remove().
|
inline |
Set maximum number of elements.
Definition at line 38 of file host_cache_impl.h.
References maximum_.
|
inline |
Return the number of entries.
Definition at line 273 of file host_cache_impl.h.
ElementPtr isc::host_cache::HostCacheImpl::toElement | ( | ) | const |
Unparse cache content.
Definition at line 513 of file host_cache_impl.cc.
References Element::createList(), and isc::host_cache::toElement().
void isc::host_cache::HostCacheImpl::update | ( | isc::dhcp::ConstHostPtr const & | host | ) |
Implements isc::dhcp::BaseHostDataSource::update() for HostCacheImpl.
Attempts to update an existing host entry.
host | the host up to date with the requested changes |
This is not an upsert, so if the host doesn't exist yet, throw an error.
Definition at line 359 of file host_cache_impl.cc.
References insert(), and isc_throw.
size_t isc::host_cache::HostCacheImpl::maximum_ |
Maximum number of elements (0 means unbound).
Definition at line 35 of file host_cache_impl.h.
Referenced by HostCacheImpl(), capacity(), getMaximum(), insert(), and setMaximum().