![]() |
Kea
1.5.0
|
Base interface for the classes implementing simple data source for host reservations. More...
#include <base_host_data_source.h>
Inheritance diagram for isc::dhcp::BaseHostDataSource: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. More... | |
| virtual void | add (const HostPtr &host)=0 |
| Adds a new host to the collection. More... | |
| virtual void | commit () |
| Commit Transactions. More... | |
| virtual bool | del (const SubnetID &subnet_id, const asiolink::IOAddress &addr)=0 |
| Attempts to delete a host by (subnet-id, address) More... | |
| 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) More... | |
| 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) More... | |
| 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. More... | |
| 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. More... | |
| virtual ConstHostPtr | get6 (const asiolink::IOAddress &prefix, const uint8_t prefix_len) const =0 |
| Returns a host using the specified IPv6 prefix. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| virtual ConstHostCollection | getAll4 (const asiolink::IOAddress &address) const =0 |
| Returns a collection of hosts using the specified IPv4 address. More... | |
| virtual std::string | getType () const =0 |
| Return backend type. More... | |
| virtual void | rollback () |
| Rollback Transactions. More... | |
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 57 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 69 of file base_host_data_source.h.
|
inlinevirtual |
Default destructor implementation.
Definition at line 75 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::CqlHostDataSource, isc::dhcp::HostMgr, isc::dhcp::CfgHosts, isc::dhcp::PgSqlHostDataSource, and isc::dhcp::MySqlHostDataSource.
|
inlinevirtual |
Commit Transactions.
Commits all pending database operations. On databases that don't support transactions, this is a no-op.
Reimplemented in isc::dhcp::CqlHostDataSource, isc::dhcp::PgSqlHostDataSource, and isc::dhcp::MySqlHostDataSource.
Definition at line 241 of file base_host_data_source.h.
|
pure virtual |
Attempts to delete a host 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::CqlHostDataSource, isc::dhcp::HostMgr, isc::dhcp::CfgHosts, isc::dhcp::PgSqlHostDataSource, and isc::dhcp::MySqlHostDataSource.
|
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::CqlHostDataSource, isc::dhcp::HostMgr, isc::dhcp::CfgHosts, isc::dhcp::PgSqlHostDataSource, and isc::dhcp::MySqlHostDataSource.
|
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::CqlHostDataSource, isc::dhcp::HostMgr, isc::dhcp::CfgHosts, isc::dhcp::PgSqlHostDataSource, and isc::dhcp::MySqlHostDataSource.
|
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::CqlHostDataSource, isc::dhcp::PgSqlHostDataSource, isc::dhcp::HostMgr, isc::dhcp::MySqlHostDataSource, and isc::dhcp::CfgHosts.
|
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::CqlHostDataSource, isc::dhcp::PgSqlHostDataSource, isc::dhcp::HostMgr, isc::dhcp::MySqlHostDataSource, and isc::dhcp::CfgHosts.
|
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::CqlHostDataSource, isc::dhcp::HostMgr, isc::dhcp::PgSqlHostDataSource, isc::dhcp::MySqlHostDataSource, and isc::dhcp::CfgHosts.
|
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::CqlHostDataSource, isc::dhcp::PgSqlHostDataSource, isc::dhcp::CfgHosts, isc::dhcp::MySqlHostDataSource, and isc::dhcp::HostMgr.
|
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::CqlHostDataSource, isc::dhcp::HostMgr, isc::dhcp::PgSqlHostDataSource, isc::dhcp::MySqlHostDataSource, and isc::dhcp::CfgHosts.
|
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::CqlHostDataSource, isc::dhcp::PgSqlHostDataSource, isc::dhcp::MySqlHostDataSource, isc::dhcp::HostMgr, and isc::dhcp::CfgHosts.
|
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::CqlHostDataSource, isc::dhcp::PgSqlHostDataSource, isc::dhcp::MySqlHostDataSource, isc::dhcp::HostMgr, and isc::dhcp::CfgHosts.
|
pure virtual |
Return backend type.
Returns the type of the backend (e.g. "mysql", "memfile" etc.)
Implemented in isc::dhcp::CqlHostDataSource, isc::dhcp::HostMgr, isc::dhcp::CfgHosts, isc::dhcp::PgSqlHostDataSource, and isc::dhcp::MySqlHostDataSource.
|
inlinevirtual |
Rollback Transactions.
Rolls back all pending database operations. On databases that don't support transactions, this is a no-op.
Reimplemented in isc::dhcp::CqlHostDataSource, isc::dhcp::PgSqlHostDataSource, and isc::dhcp::MySqlHostDataSource.
Definition at line 247 of file base_host_data_source.h.