Kea 2.7.5
|
Base interface for the classes implementing simple data source for host reservations. More...
#include <base_host_data_source.h>
Public Types | |
enum | IdType { ID_HWADDR = 0 , ID_DUID = 1 } |
Specifies the type of an identifier. More... | |
Public Member Functions | |
virtual | ~BaseHostDataSource () |
Default destructor implementation. | |
virtual void | add (const HostPtr &host)=0 |
Adds a new host to the collection. | |
virtual void | commit () |
Commit Transactions. | |
virtual bool | del (const SubnetID &subnet_id, const asiolink::IOAddress &addr)=0 |
Attempts to delete hosts by (subnet-id, address) | |
virtual bool | del4 (const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len)=0 |
Attempts to delete a host by (subnet-id4, identifier, identifier-type) | |
virtual bool | del6 (const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len)=0 |
Attempts to delete a host by (subnet-id6, identifier, identifier-type) | |
virtual ConstHostPtr | get4 (const SubnetID &subnet_id, const asiolink::IOAddress &address) const =0 |
Returns a host connected to the IPv4 subnet and having a reservation for a specified IPv4 address. | |
virtual ConstHostPtr | get4 (const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const =0 |
Returns a host connected to the IPv4 subnet. | |
virtual ConstHostPtr | get6 (const asiolink::IOAddress &prefix, const uint8_t prefix_len) const =0 |
Returns a host using the specified IPv6 prefix. | |
virtual ConstHostPtr | get6 (const SubnetID &subnet_id, const asiolink::IOAddress &address) const =0 |
Returns a host connected to the IPv6 subnet and having a reservation for a specified IPv6 address or prefix. | |
virtual ConstHostPtr | get6 (const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const =0 |
Returns a host connected to the IPv6 subnet. | |
virtual ConstHostCollection | getAll (const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const =0 |
Return all hosts connected to any subnet for which reservations have been made using a specified identifier. | |
virtual ConstHostCollection | getAll4 (const asiolink::IOAddress &address) const =0 |
Returns a collection of hosts using the specified IPv4 address. | |
virtual ConstHostCollection | getAll4 (const SubnetID &subnet_id) const =0 |
Return all hosts in a DHCPv4 subnet. | |
virtual ConstHostCollection | getAll4 (const SubnetID &subnet_id, const asiolink::IOAddress &address) const =0 |
Returns all hosts connected to the IPv4 subnet and having a reservation for a specified address. | |
virtual ConstHostCollection | getAll6 (const asiolink::IOAddress &address) const =0 |
Returns all hosts having a reservation for a specified address or delegated prefix (lease) in all subnets. | |
virtual ConstHostCollection | getAll6 (const SubnetID &subnet_id) const =0 |
Return all hosts in a DHCPv6 subnet. | |
virtual ConstHostCollection | getAll6 (const SubnetID &subnet_id, const asiolink::IOAddress &address) const =0 |
Returns all hosts connected to the IPv6 subnet and having a reservation for a specified address or delegated prefix (lease). | |
virtual ConstHostCollection | getAllbyHostname (const std::string &hostname) const =0 |
Return all hosts with a hostname. | |
virtual ConstHostCollection | getAllbyHostname4 (const std::string &hostname, const SubnetID &subnet_id) const =0 |
Return all hosts with a hostname in a DHCPv4 subnet. | |
virtual ConstHostCollection | getAllbyHostname6 (const std::string &hostname, const SubnetID &subnet_id) const =0 |
Return all hosts with a hostname in a DHCPv6 subnet. | |
virtual ConstHostCollection | getPage4 (const SubnetID &subnet_id, size_t &source_index, uint64_t lower_host_id, const HostPageSize &page_size) const =0 |
Returns range of hosts in a DHCPv4 subnet. | |
virtual ConstHostCollection | getPage4 (size_t &source_index, uint64_t lower_host_id, const HostPageSize &page_size) const =0 |
Returns range of hosts. | |
virtual ConstHostCollection | getPage6 (const SubnetID &subnet_id, size_t &source_index, uint64_t lower_host_id, const HostPageSize &page_size) const =0 |
Returns range of hosts in a DHCPv6 subnet. | |
virtual ConstHostCollection | getPage6 (size_t &source_index, uint64_t lower_host_id, const HostPageSize &page_size) const =0 |
Returns range of hosts. | |
virtual isc::db::DatabaseConnection::ParameterMap | getParameters () const |
Return backend parameters. | |
virtual std::string | getType () const =0 |
Return backend type. | |
virtual bool | isUnusable () |
Flag which indicates if the host manager has at least one unusable connection. | |
virtual void | rollback () |
Rollback Transactions. | |
virtual bool | setIPReservationsUnique (const bool unique)=0 |
Controls whether IP reservations are unique or non-unique. | |
virtual void | update (HostPtr const &host) |
Attempts to update an existing host entry. | |
Base interface for the classes implementing simple data source for host reservations.
This abstract class defines an interface for the classes implementing basic data source for host reservations. This interface allows for adding new reservations (represented by Host
objects) and retrieving these reservations using various parameters such as HW address or DUID, subnet identifier (either IPv4 or IPv6) or reserved IP address.
This interface DOES NOT specify the methods to manage existing host reservations such as to remove one IPv6 reservation but leave other reservations. It also lacks the methods used for preparing the data to be added to the SQL database: commit, rollback etc. Such methods are declared in other interfaces.
Definition at line 88 of file base_host_data_source.h.
Specifies the type of an identifier.
This is currently used only by MySQL host data source for now, but it is envisaged that it will be used by other host data sources in the future. Also, this list will grow over time. It is likely that we'll implement other identifiers in the future, e.g. remote-id.
Those value correspond directly to dhcp_identifier_type in hosts table in MySQL schema.
Enumerator | |
---|---|
ID_HWADDR | Hardware address. |
ID_DUID | DUID/client-id. |
Definition at line 100 of file base_host_data_source.h.
|
inlinevirtual |
Default destructor implementation.
Definition at line 106 of file base_host_data_source.h.
|
pure 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. |
Implemented in isc::dhcp::CfgHosts, and isc::dhcp::HostMgr.
Referenced by update().
|
inlinevirtual |
Commit Transactions.
Commits all pending database operations. On databases that don't support transactions, this is a no-op.
Definition at line 533 of file base_host_data_source.h.
|
pure virtual |
Attempts to delete hosts by (subnet-id, address)
This method supports both v4 and v6.
subnet_id | subnet identifier. |
addr | specified address. |
various | exceptions in case of errors |
Implemented in isc::dhcp::CfgHosts, and isc::dhcp::HostMgr.
|
pure 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. |
various | exceptions in case of errors |
Implemented in isc::dhcp::CfgHosts, and isc::dhcp::HostMgr.
Referenced by update().
|
pure 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. |
various | exceptions in case of errors |
Implemented in isc::dhcp::CfgHosts, and isc::dhcp::HostMgr.
Referenced by update().
|
pure 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. Implemented in isc::dhcp::CfgHosts, and isc::dhcp::HostMgr.
|
pure 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. Implemented in isc::dhcp::CfgHosts, and isc::dhcp::HostMgr.
|
pure 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. Implemented in isc::dhcp::CfgHosts, and isc::dhcp::HostMgr.
|
pure 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. Implemented in isc::dhcp::HostMgr, and isc::dhcp::CfgHosts.
|
pure 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. Implemented in isc::dhcp::CfgHosts, and isc::dhcp::HostMgr.
|
pure 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. |
identifier_begin | Pointer to a beginning of a buffer containing an identifier. |
identifier_len | Identifier length. |
Host
objects. Implemented in isc::dhcp::CfgHosts, and isc::dhcp::HostMgr.
|
pure 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. |
Host
objects. Implemented in isc::dhcp::CfgHosts, and isc::dhcp::HostMgr.
|
pure 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. Implemented in isc::dhcp::CfgHosts, and isc::dhcp::HostMgr.
|
pure virtual |
Returns all hosts connected to the IPv4 subnet and having a reservation for a specified address.
In most cases it is desired that there is at most one reservation for a given IPv4 address within a subnet. In a default configuration, the backend does not allow for inserting more than one host with the same IPv4 reservation. In that case, the number of hosts returned by this function is 0 or 1.
If the backend is configured to allow multiple hosts with reservations for the same IPv4 address in the given subnet, this method can return more than one host.
The typical use case when a single IPv4 address is reserved for multiple hosts is when these hosts represent different interfaces of the same machine and each interface comes with a different MAC address. In that case, the same IPv4 address is assigned regardless of which interface is used by the DHCP client to communicate with the server.
subnet_id | Subnet identifier. |
address | reserved IPv4 address |
Host
objects. Implemented in isc::dhcp::CfgHosts, and isc::dhcp::HostMgr.
|
pure virtual |
Returns all hosts having a reservation for a specified address or delegated prefix (lease) in all subnets.
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.
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 per subnet.
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.
address | reserved IPv6 address/prefix. |
Host
objects. Implemented in isc::dhcp::CfgHosts, and isc::dhcp::HostMgr.
|
pure 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. Implemented in isc::dhcp::CfgHosts, and isc::dhcp::HostMgr.
|
pure virtual |
Returns all hosts connected to the IPv6 subnet and having a reservation for a specified address or delegated prefix (lease).
In most cases it is desired that there is at most one reservation for a given IPv6 lease within a subnet. In a default configuration, the backend does not allow for inserting more than one host with the same IPv6 address or prefix. In that case, the number of hosts returned by this function is 0 or 1.
If the backend is configured to allow multiple hosts with reservations for the same IPv6 lease in the given subnet, this method can return more than one host.
The typical use case when a single IPv6 lease is reserved for multiple hosts is when these hosts represent different interfaces of the same machine and each interface comes with a different MAC address. In that case, the same IPv6 lease is assigned regardless of which interface is used by the DHCP client to communicate with the server.
subnet_id | Subnet identifier. |
address | reserved IPv6 address/prefix. |
Host
objects. Implemented in isc::dhcp::CfgHosts, and isc::dhcp::HostMgr.
|
pure 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. Implemented in isc::dhcp::CfgHosts, and isc::dhcp::HostMgr.
|
pure 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. Implemented in isc::dhcp::CfgHosts, and isc::dhcp::HostMgr.
|
pure 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. Implemented in isc::dhcp::CfgHosts, and isc::dhcp::HostMgr.
|
pure virtual |
Returns range of hosts in a DHCPv4 subnet.
This method implements paged browsing of host databases. The parameters specify a page size, an index in sources and the starting host id of the range. If not zero this host id is excluded from the returned range. When a source is exhausted the index is updated. There is no guarantee about the order of returned host reservations, only the sources and reservations from the same source are ordered.
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. |
Implemented in isc::dhcp::CfgHosts, and isc::dhcp::HostMgr.
|
pure virtual |
Returns range of hosts.
This method implements paged browsing of host databases. The parameters specify a page size, an index in sources and the starting host id of the range. If not zero this host id is excluded from the returned range. When a source is exhausted the index is updated. There is no guarantee about the order of returned host reservations, only the sources and reservations from the same source are ordered.
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. |
Implemented in isc::dhcp::CfgHosts, and isc::dhcp::HostMgr.
|
pure virtual |
Returns range of hosts in a DHCPv6 subnet.
This method implements paged browsing of host databases. The parameters specify a page size, an index in sources and the starting host id of the range. If not zero this host id is excluded from the returned range. When a source is exhausted the index is updated. There is no guarantee about the order of returned host reservations, only the sources and reservations from the same source are ordered.
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. |
Implemented in isc::dhcp::CfgHosts, and isc::dhcp::HostMgr.
|
pure virtual |
Returns range of hosts.
This method implements paged browsing of host databases. The parameters specify a page size, an index in sources and the starting host id of the range. If not zero this host id is excluded from the returned range. When a source is exhausted the index is updated. There is no guarantee about the order of returned host reservations, only the sources and reservations from the same source are ordered.
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. |
Implemented in isc::dhcp::CfgHosts, and isc::dhcp::HostMgr.
|
inlinevirtual |
Return backend parameters.
Returns the backend parameters
Definition at line 525 of file base_host_data_source.h.
|
pure virtual |
Return backend type.
Returns the type of the backend (e.g. "mysql", "memfile" etc.)
Implemented in isc::dhcp::CfgHosts, and isc::dhcp::HostMgr.
|
inlinevirtual |
Flag which indicates if the host manager has at least one unusable connection.
Definition at line 566 of file base_host_data_source.h.
|
inlinevirtual |
Rollback Transactions.
Rolls back all pending database operations. On databases that don't support transactions, this is a no-op.
Definition at line 539 of file base_host_data_source.h.
|
pure 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.
All backends are required to support the case when unique setting is true
and they must use this setting by default.
unique | boolean flag indicating if the IP reservations must be unique or can be non-unique. |
Implemented in isc::dhcp::CfgHosts, and isc::dhcp::HostMgr.
|
inlinevirtual |
Attempts to update an existing host entry.
The implementation is common to multiple host data sources, so let's provide it in the base host data source. In some instances, it may require synchronization e.g. with transactions in case of databases.
host | the host up to date with the requested changes |
Reimplemented in isc::dhcp::CfgHosts, and isc::dhcp::HostMgr.
Definition at line 494 of file base_host_data_source.h.
References add(), del4(), del6(), and isc_throw.