Kea  1.5.0
isc::dhcp::BaseHostDataSource Class Referenceabstract

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...
 

Detailed Description

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.

Member Enumeration Documentation

◆ IdType

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.

Constructor & Destructor Documentation

◆ ~BaseHostDataSource()

virtual isc::dhcp::BaseHostDataSource::~BaseHostDataSource ( )
inlinevirtual

Default destructor implementation.

Definition at line 75 of file base_host_data_source.h.

Member Function Documentation

◆ add()

virtual void isc::dhcp::BaseHostDataSource::add ( const HostPtr host)
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.

Parameters
hostPointer 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.

◆ commit()

virtual void isc::dhcp::BaseHostDataSource::commit ( )
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.

◆ del()

virtual bool isc::dhcp::BaseHostDataSource::del ( const SubnetID subnet_id,
const asiolink::IOAddress addr 
)
pure virtual

Attempts to delete a host by (subnet-id, address)

This method supports both v4 and v6.

Parameters
subnet_idsubnet identifier.
addrspecified address.
Returns
true if deletion was successful, false if the host was not there.
Exceptions
variousexceptions in case of errors

Implemented in isc::dhcp::CqlHostDataSource, isc::dhcp::HostMgr, isc::dhcp::CfgHosts, isc::dhcp::PgSqlHostDataSource, and isc::dhcp::MySqlHostDataSource.

◆ del4()

virtual bool isc::dhcp::BaseHostDataSource::del4 ( const SubnetID subnet_id,
const Host::IdentifierType identifier_type,
const uint8_t *  identifier_begin,
const size_t  identifier_len 
)
pure virtual

Attempts to delete a host by (subnet-id4, identifier, identifier-type)

This method supports v4 hosts only.

Parameters
subnet_idIPv4 Subnet identifier.
identifier_typeIdentifier type.
identifier_beginPointer to a beginning of a buffer containing an identifier.
identifier_lenIdentifier length.
Returns
true if deletion was successful, false if the host was not there.
Exceptions
variousexceptions in case of errors

Implemented in isc::dhcp::CqlHostDataSource, isc::dhcp::HostMgr, isc::dhcp::CfgHosts, isc::dhcp::PgSqlHostDataSource, and isc::dhcp::MySqlHostDataSource.

◆ del6()

virtual bool isc::dhcp::BaseHostDataSource::del6 ( const SubnetID subnet_id,
const Host::IdentifierType identifier_type,
const uint8_t *  identifier_begin,
const size_t  identifier_len 
)
pure virtual

Attempts to delete a host by (subnet-id6, identifier, identifier-type)

This method supports v6 hosts only.

Parameters
subnet_idIPv6 Subnet identifier.
identifier_typeIdentifier type.
identifier_beginPointer to a beginning of a buffer containing an identifier.
identifier_lenIdentifier length.
Returns
true if deletion was successful, false if the host was not there.
Exceptions
variousexceptions in case of errors

Implemented in isc::dhcp::CqlHostDataSource, isc::dhcp::HostMgr, isc::dhcp::CfgHosts, isc::dhcp::PgSqlHostDataSource, and isc::dhcp::MySqlHostDataSource.

◆ get4() [1/2]

virtual ConstHostPtr isc::dhcp::BaseHostDataSource::get4 ( const SubnetID subnet_id,
const asiolink::IOAddress address 
) const
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.

Parameters
subnet_idSubnet identifier.
addressreserved IPv4 address.
Returns
Const 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.

◆ get4() [2/2]

virtual ConstHostPtr isc::dhcp::BaseHostDataSource::get4 ( const SubnetID subnet_id,
const Host::IdentifierType identifier_type,
const uint8_t *  identifier_begin,
const size_t  identifier_len 
) const
pure virtual

Returns a host connected to the IPv4 subnet.

Parameters
subnet_idSubnet identifier.
identifier_typeIdentifier type.
identifier_beginPointer to a beginning of a buffer containing an identifier.
identifier_lenIdentifier length.
Returns
Const 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.

◆ get6() [1/3]

virtual ConstHostPtr isc::dhcp::BaseHostDataSource::get6 ( const asiolink::IOAddress prefix,
const uint8_t  prefix_len 
) const
pure virtual

Returns a host using the specified IPv6 prefix.

Parameters
prefixIPv6 prefix for which the Host object is searched.
prefix_lenIPv6 prefix length.
Returns
Const 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.

◆ get6() [2/3]

virtual ConstHostPtr isc::dhcp::BaseHostDataSource::get6 ( const SubnetID subnet_id,
const asiolink::IOAddress address 
) const
pure virtual

Returns a host connected to the IPv6 subnet and having a reservation for a specified IPv6 address or prefix.

Parameters
subnet_idSubnet identifier.
addressreserved IPv6 address/prefix.
Returns
Const 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.

◆ get6() [3/3]

virtual ConstHostPtr isc::dhcp::BaseHostDataSource::get6 ( const SubnetID subnet_id,
const Host::IdentifierType identifier_type,
const uint8_t *  identifier_begin,
const size_t  identifier_len 
) const
pure virtual

Returns a host connected to the IPv6 subnet.

Parameters
subnet_idSubnet identifier.
identifier_typeIdentifier type.
identifier_beginPointer to a beginning of a buffer containing an identifier.
identifier_lenIdentifier length.
Returns
Const 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.

◆ getAll()

virtual ConstHostCollection isc::dhcp::BaseHostDataSource::getAll ( const Host::IdentifierType identifier_type,
const uint8_t *  identifier_begin,
const size_t  identifier_len 
) const
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.

Parameters
identifier_typeIdentifier type.
identifier_beginPointer to a beginning of a buffer containing an identifier.
identifier_lenIdentifier length.
Returns
Collection of const Host objects.

Implemented in isc::dhcp::CqlHostDataSource, isc::dhcp::PgSqlHostDataSource, isc::dhcp::MySqlHostDataSource, isc::dhcp::HostMgr, and isc::dhcp::CfgHosts.

◆ getAll4()

virtual ConstHostCollection isc::dhcp::BaseHostDataSource::getAll4 ( const asiolink::IOAddress address) const
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.

Parameters
addressIPv4 address for which the Host object is searched.
Returns
Collection of const Host objects.

Implemented in isc::dhcp::CqlHostDataSource, isc::dhcp::PgSqlHostDataSource, isc::dhcp::MySqlHostDataSource, isc::dhcp::HostMgr, and isc::dhcp::CfgHosts.

◆ getType()

virtual std::string isc::dhcp::BaseHostDataSource::getType ( ) const
pure virtual

Return backend type.

Returns the type of the backend (e.g. "mysql", "memfile" etc.)

Returns
Type of the backend.

Implemented in isc::dhcp::CqlHostDataSource, isc::dhcp::HostMgr, isc::dhcp::CfgHosts, isc::dhcp::PgSqlHostDataSource, and isc::dhcp::MySqlHostDataSource.

◆ rollback()

virtual void isc::dhcp::BaseHostDataSource::rollback ( )
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.


The documentation for this class was generated from the following file: