Kea  2.1.7-git
isc::dhcp::MySqlHostDataSource Class Reference

MySQL Host Data Source. More...

#include <mysql_host_data_source.h>

+ Inheritance diagram for isc::dhcp::MySqlHostDataSource:

Classes

class  MySqlHostContextAlloc
 Context RAII Allocator. More...
 

Public Member Functions

 MySqlHostDataSource (const db::DatabaseConnection::ParameterMap &parameters)
 Constructor. More...
 
virtual ~MySqlHostDataSource ()
 Virtual destructor. More...
 
virtual void add (const HostPtr &host)
 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)
 Attempts to delete hosts 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)
 Attempts to delete a host by (subnet4-id, identifier type, identifier) More...
 
virtual bool del6 (const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len)
 Attempts to delete a host by (subnet6-id, identifier type, identifier) More...
 
virtual ConstHostPtr get4 (const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const
 Returns a host connected to the IPv4 subnet. More...
 
virtual ConstHostPtr get4 (const 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. More...
 
virtual ConstHostPtr get6 (const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const
 Returns a host connected to the IPv6 subnet. More...
 
virtual ConstHostPtr get6 (const asiolink::IOAddress &prefix, const uint8_t prefix_len) const
 Returns a host using the specified IPv6 prefix. More...
 
virtual ConstHostPtr get6 (const 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. More...
 
virtual ConstHostCollection getAll (const 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. More...
 
virtual ConstHostCollection getAll4 (const SubnetID &subnet_id) const
 Return all hosts in a DHCPv4 subnet. More...
 
virtual ConstHostCollection getAll4 (const asiolink::IOAddress &address) const
 Returns a collection of hosts using the specified IPv4 address. More...
 
virtual ConstHostCollection getAll4 (const SubnetID &subnet_id, const asiolink::IOAddress &address) const
 Returns all hosts connected to the IPv4 subnet and having a reservation for a specified address. More...
 
virtual ConstHostCollection getAll6 (const SubnetID &subnet_id) const
 Return all hosts in a DHCPv6 subnet. More...
 
virtual ConstHostCollection getAll6 (const 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). More...
 
virtual ConstHostCollection getAllbyHostname (const std::string &hostname) const
 Return all hosts with a hostname. More...
 
virtual ConstHostCollection getAllbyHostname4 (const std::string &hostname, const SubnetID &subnet_id) const
 Return all hosts with a hostname in a DHCPv4 subnet. More...
 
virtual ConstHostCollection getAllbyHostname6 (const std::string &hostname, const SubnetID &subnet_id) const
 Return all hosts with a hostname in a DHCPv6 subnet. More...
 
virtual std::string getDescription () const
 Returns description of the backend. More...
 
virtual std::string getName () const
 Returns backend name. More...
 
virtual ConstHostCollection getPage4 (const SubnetID &subnet_id, size_t &source_index, uint64_t lower_host_id, const HostPageSize &page_size) const
 Returns range of hosts in a DHCPv4 subnet. More...
 
virtual ConstHostCollection getPage4 (size_t &source_index, uint64_t lower_host_id, const HostPageSize &page_size) const
 Returns range of hosts. More...
 
virtual ConstHostCollection getPage6 (const SubnetID &subnet_id, size_t &source_index, uint64_t lower_host_id, const HostPageSize &page_size) const
 Returns range of hosts in a DHCPv6 subnet. More...
 
virtual ConstHostCollection getPage6 (size_t &source_index, uint64_t lower_host_id, const HostPageSize &page_size) const
 Returns range of hosts. More...
 
virtual isc::db::DatabaseConnection::ParameterMap getParameters () const
 Return backend parameters. More...
 
virtual std::string getType () const
 Return backend type. More...
 
virtual std::pair< uint32_t, uint32_t > getVersion () const
 Returns backend version. More...
 
virtual bool isUnusable ()
 Flag which indicates if the host manager has at least one unusable connection. More...
 
virtual void rollback ()
 Rollback Transactions. More...
 
virtual bool setIPReservationsUnique (const bool unique)
 Controls whether IP reservations are unique or non-unique. More...
 
- Public Member Functions inherited from isc::dhcp::BaseHostDataSource
virtual ~BaseHostDataSource ()
 Default destructor implementation. More...
 

Additional Inherited Members

- Public Types inherited from isc::dhcp::BaseHostDataSource
enum  IdType { ID_HWADDR = 0, ID_DUID = 1 }
 Specifies the type of an identifier. More...
 

Detailed Description

MySQL Host Data Source.

This class implements the isc::dhcp::BaseHostDataSource interface to the MySQL database. Use of this backend presupposes that a MySQL database is available and that the Kea schema has been created within it.

Definition at line 40 of file mysql_host_data_source.h.

Constructor & Destructor Documentation

◆ MySqlHostDataSource()

isc::dhcp::MySqlHostDataSource::MySqlHostDataSource ( const db::DatabaseConnection::ParameterMap parameters)

Constructor.

Uses the following keywords in the parameters passed to it to connect to the database:

  • name - Name of the database to which to connect (mandatory)
  • host - Host to which to connect (optional, defaults to "localhost")
  • user - Username under which to connect (optional)
  • password - Password for "user" on the database (optional)

If the database is successfully opened, the version number in the schema_version table will be checked against hard-coded value in the implementation file.

Finally, all the SQL commands are pre-compiled.

Parameters
parametersA data structure relating keywords and values concerned with the database.
Exceptions
isc::dhcp::NoDatabaseNameMandatory database name not given
isc::db::DbOpenErrorError opening the database or the schema version is invalid.
isc::db::DbOperationErrorAn operation on the open database has failed.

Definition at line 3157 of file mysql_host_data_source.cc.

◆ ~MySqlHostDataSource()

isc::dhcp::MySqlHostDataSource::~MySqlHostDataSource ( )
virtual

Virtual destructor.

Releases prepared MySQL statements used by the backend.

Definition at line 3161 of file mysql_host_data_source.cc.

Member Function Documentation

◆ add()

void isc::dhcp::MySqlHostDataSource::add ( const HostPtr host)
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 addHost method should throw an DuplicateEntry 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.

Implements isc::dhcp::BaseHostDataSource.

Definition at line 3170 of file mysql_host_data_source.cc.

References isc::db::MySqlTransaction::commit(), isc::dhcp::MySqlHostDataSource::MySqlHostContextAlloc::ctx_, isc::dhcp::MySqlHostDataSourceImpl::INSERT_HOST_NON_UNIQUE_IP, isc::dhcp::MySqlHostDataSourceImpl::INSERT_HOST_UNIQUE_IP, isc::dhcp::MySqlHostDataSourceImpl::INSERT_V4_HOST_OPTION, and isc::dhcp::MySqlHostDataSourceImpl::INSERT_V6_HOST_OPTION.

+ Here is the call graph for this function:

◆ commit()

void isc::dhcp::MySqlHostDataSource::commit ( )
virtual

Commit Transactions.

Commits all pending database operations.

Reimplemented from isc::dhcp::BaseHostDataSource.

Definition at line 3927 of file mysql_host_data_source.cc.

References isc::dhcp::MySqlHostDataSource::MySqlHostContextAlloc::ctx_.

Referenced by getType().

◆ del()

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

Attempts to delete hosts 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

Implements isc::dhcp::BaseHostDataSource.

Definition at line 3229 of file mysql_host_data_source.cc.

References isc::dhcp::MySqlHostDataSource::MySqlHostContextAlloc::ctx_, isc::dhcp::MySqlHostDataSourceImpl::DEL_HOST_ADDR4, isc::dhcp::MySqlHostDataSourceImpl::DEL_HOST_ADDR6, isc::asiolink::IOAddress::isV4(), isc::db::MLM_TRUE, isc::asiolink::IOAddress::toText(), and isc::asiolink::IOAddress::toUint32().

+ Here is the call graph for this function:

◆ del4()

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

Attempts to delete a host by (subnet4-id, identifier type, identifier)

This method supports v4 hosts only.

Parameters
subnet_idsubnet 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

Implements isc::dhcp::BaseHostDataSource.

Definition at line 3270 of file mysql_host_data_source.cc.

References isc::dhcp::MySqlHostDataSource::MySqlHostContextAlloc::ctx_, isc::dhcp::MySqlHostDataSourceImpl::DEL_HOST_SUBID4_ID, and isc::db::MLM_TRUE.

◆ del6()

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

Attempts to delete a host by (subnet6-id, identifier type, identifier)

This method supports v6 hosts only.

Parameters
subnet_idsubnet 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

Implements isc::dhcp::BaseHostDataSource.

Definition at line 3311 of file mysql_host_data_source.cc.

References isc::dhcp::MySqlHostDataSource::MySqlHostContextAlloc::ctx_, isc::dhcp::MySqlHostDataSourceImpl::DEL_HOST_SUBID6_ID, and isc::db::MLM_TRUE.

◆ get4() [1/2]

ConstHostPtr isc::dhcp::MySqlHostDataSource::get4 ( const SubnetID subnet_id,
const Host::IdentifierType identifier_type,
const uint8_t *  identifier_begin,
const size_t  identifier_len 
) const
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.

Implements isc::dhcp::BaseHostDataSource.

Definition at line 3680 of file mysql_host_data_source.cc.

References isc::dhcp::MySqlHostDataSource::MySqlHostContextAlloc::ctx_, and isc::dhcp::MySqlHostDataSourceImpl::GET_HOST_SUBID4_DHCPID.

◆ get4() [2/2]

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

Implements isc::dhcp::BaseHostDataSource.

Definition at line 3694 of file mysql_host_data_source.cc.

References isc::dhcp::MySqlHostDataSource::MySqlHostContextAlloc::ctx_, isc::dhcp::MySqlHostDataSourceImpl::GET_HOST_SUBID_ADDR, isc_throw, isc::asiolink::IOAddress::isV4(), isc::db::MLM_TRUE, and isc::asiolink::IOAddress::toUint32().

+ Here is the call graph for this function:

◆ get6() [1/3]

ConstHostPtr isc::dhcp::MySqlHostDataSource::get6 ( const SubnetID subnet_id,
const Host::IdentifierType identifier_type,
const uint8_t *  identifier_begin,
const size_t  identifier_len 
) const
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.

Implements isc::dhcp::BaseHostDataSource.

Definition at line 3763 of file mysql_host_data_source.cc.

References isc::dhcp::MySqlHostDataSource::MySqlHostContextAlloc::ctx_, and isc::dhcp::MySqlHostDataSourceImpl::GET_HOST_SUBID6_DHCPID.

◆ get6() [2/3]

ConstHostPtr isc::dhcp::MySqlHostDataSource::get6 ( const asiolink::IOAddress prefix,
const uint8_t  prefix_len 
) const
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.

Implements isc::dhcp::BaseHostDataSource.

Definition at line 3777 of file mysql_host_data_source.cc.

References isc::dhcp::MySqlHostDataSource::MySqlHostContextAlloc::ctx_, isc::dhcp::MySqlHostDataSourceImpl::GET_HOST_PREFIX, isc_throw, isc::asiolink::IOAddress::isV6(), isc::db::MLM_TRUE, and isc::asiolink::IOAddress::toText().

+ Here is the call graph for this function:

◆ get6() [3/3]

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

Implements isc::dhcp::BaseHostDataSource.

Definition at line 3820 of file mysql_host_data_source.cc.

References isc::dhcp::MySqlHostDataSource::MySqlHostContextAlloc::ctx_, isc::dhcp::MySqlHostDataSourceImpl::GET_HOST_SUBID6_ADDR, isc_throw, isc::asiolink::IOAddress::isV6(), isc::db::MLM_TRUE, and isc::asiolink::IOAddress::toText().

+ Here is the call graph for this function:

◆ getAll()

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

Implements isc::dhcp::BaseHostDataSource.

Definition at line 3352 of file mysql_host_data_source.cc.

References isc::dhcp::MySqlHostDataSource::MySqlHostContextAlloc::ctx_, isc::dhcp::MySqlHostDataSourceImpl::GET_HOST_DHCPID, and isc::db::MLM_TRUE.

◆ getAll4() [1/3]

ConstHostCollection isc::dhcp::MySqlHostDataSource::getAll4 ( const SubnetID subnet_id) const
virtual

Return all hosts in a DHCPv4 subnet.

This method returns all Host objects which represent reservations in a specified subnet.

Parameters
subnet_idsubnet identifier to filter by
Returns
Collection of const Host objects.

Implements isc::dhcp::BaseHostDataSource.

Definition at line 3386 of file mysql_host_data_source.cc.

References isc::dhcp::MySqlHostDataSource::MySqlHostContextAlloc::ctx_, isc::dhcp::MySqlHostDataSourceImpl::GET_HOST_SUBID4, and isc::db::MLM_TRUE.

◆ getAll4() [2/3]

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

Implements isc::dhcp::BaseHostDataSource.

Definition at line 3658 of file mysql_host_data_source.cc.

References isc::dhcp::MySqlHostDataSource::MySqlHostContextAlloc::ctx_, isc::dhcp::MySqlHostDataSourceImpl::GET_HOST_ADDR, isc::db::MLM_TRUE, and isc::asiolink::IOAddress::toUint32().

+ Here is the call graph for this function:

◆ getAll4() [3/3]

ConstHostCollection isc::dhcp::MySqlHostDataSource::getAll4 ( const SubnetID subnet_id,
const asiolink::IOAddress address 
) const
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.

Parameters
subnet_idSubnet identifier.
addressreserved IPv4 address.
Returns
Collection of const Host objects.

Implements isc::dhcp::BaseHostDataSource.

Definition at line 3732 of file mysql_host_data_source.cc.

References isc::dhcp::MySqlHostDataSource::MySqlHostContextAlloc::ctx_, isc::dhcp::MySqlHostDataSourceImpl::GET_HOST_SUBID_ADDR, isc_throw, isc::asiolink::IOAddress::isV4(), isc::db::MLM_TRUE, and isc::asiolink::IOAddress::toUint32().

+ Here is the call graph for this function:

◆ getAll6() [1/2]

ConstHostCollection isc::dhcp::MySqlHostDataSource::getAll6 ( const SubnetID subnet_id) const
virtual

Return all hosts in a DHCPv6 subnet.

This method returns all Host objects which represent reservations in a specified subnet.

Parameters
subnet_idsubnet identifier to filter by
Returns
Collection of const Host objects.

Implements isc::dhcp::BaseHostDataSource.

Definition at line 3407 of file mysql_host_data_source.cc.

References isc::dhcp::MySqlHostDataSource::MySqlHostContextAlloc::ctx_, isc::dhcp::MySqlHostDataSourceImpl::GET_HOST_SUBID6, and isc::db::MLM_TRUE.

◆ getAll6() [2/2]

ConstHostCollection isc::dhcp::MySqlHostDataSource::getAll6 ( const SubnetID subnet_id,
const asiolink::IOAddress address 
) const
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.

Parameters
subnet_idSubnet identifier.
addressreserved IPv6 address/prefix.
Returns
Collection of const Host objects.

Implements isc::dhcp::BaseHostDataSource.

Definition at line 3863 of file mysql_host_data_source.cc.

References isc::dhcp::MySqlHostDataSource::MySqlHostContextAlloc::ctx_, isc::dhcp::MySqlHostDataSourceImpl::GET_HOST_SUBID6_ADDR, isc_throw, isc::asiolink::IOAddress::isV6(), isc::db::MLM_TRUE, and isc::asiolink::IOAddress::toText().

+ Here is the call graph for this function:

◆ getAllbyHostname()

ConstHostCollection isc::dhcp::MySqlHostDataSource::getAllbyHostname ( const std::string &  hostname) const
virtual

Return all hosts with a hostname.

This method returns all Host objects which represent reservations using a specified hostname.

MySQL uses the case-insensitive hosts_by_hostname index on hostname.

Parameters
hostnameThe lower case hostname.
Returns
Collection of const Host objects.

Implements isc::dhcp::BaseHostDataSource.

Definition at line 3428 of file mysql_host_data_source.cc.

References isc::dhcp::MySqlHostDataSource::MySqlHostContextAlloc::ctx_, isc::dhcp::MySqlHostDataSourceImpl::GET_HOST_HOSTNAME, and isc::dhcp::HOSTNAME_MAX_LEN.

◆ getAllbyHostname4()

ConstHostCollection isc::dhcp::MySqlHostDataSource::getAllbyHostname4 ( const std::string &  hostname,
const SubnetID subnet_id 
) const
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.

Parameters
hostnameThe lower case hostname.
subnet_idSubnet identifier.
Returns
Collection of const Host objects.

Implements isc::dhcp::BaseHostDataSource.

Definition at line 3454 of file mysql_host_data_source.cc.

References isc::dhcp::MySqlHostDataSource::MySqlHostContextAlloc::ctx_, isc::dhcp::MySqlHostDataSourceImpl::GET_HOST_HOSTNAME_SUBID4, isc::dhcp::HOSTNAME_MAX_LEN, and isc::db::MLM_TRUE.

◆ getAllbyHostname6()

ConstHostCollection isc::dhcp::MySqlHostDataSource::getAllbyHostname6 ( const std::string &  hostname,
const SubnetID subnet_id 
) const
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.

Parameters
hostnameThe lower case hostname.
subnet_idSubnet identifier.
Returns
Collection of const Host objects.

Implements isc::dhcp::BaseHostDataSource.

Definition at line 3487 of file mysql_host_data_source.cc.

References isc::dhcp::MySqlHostDataSource::MySqlHostContextAlloc::ctx_, isc::dhcp::MySqlHostDataSourceImpl::GET_HOST_HOSTNAME_SUBID6, isc::dhcp::HOSTNAME_MAX_LEN, and isc::db::MLM_TRUE.

◆ getDescription()

std::string isc::dhcp::MySqlHostDataSource::getDescription ( ) const
virtual

Returns description of the backend.

This description may be multiline text that describes the backend.

Returns
Description of the backend.

Definition at line 3916 of file mysql_host_data_source.cc.

Referenced by getType().

◆ getName()

std::string isc::dhcp::MySqlHostDataSource::getName ( ) const
virtual

Returns backend name.

Each backend have specific name.

Returns
"mysql".

Definition at line 3901 of file mysql_host_data_source.cc.

References isc::dhcp::MySqlHostDataSource::MySqlHostContextAlloc::ctx_.

Referenced by getType().

◆ getPage4() [1/2]

ConstHostCollection isc::dhcp::MySqlHostDataSource::getPage4 ( const SubnetID subnet_id,
size_t &  source_index,
uint64_t  lower_host_id,
const HostPageSize page_size 
) const
virtual

Returns range of hosts in a DHCPv4 subnet.

This method returns a page of Host objects which represent reservations in a specified subnet.

Parameters
subnet_idSubnet identifier.
source_indexIndex of the source (unused).
lower_host_idHost identifier used as lower bound for the returned range.
page_sizemaximum size of the page returned.
Returns
Collection of const Host objects (may be empty).

Implements isc::dhcp::BaseHostDataSource.

Definition at line 3520 of file mysql_host_data_source.cc.

References isc::dhcp::MySqlHostDataSource::MySqlHostContextAlloc::ctx_, isc::dhcp::MySqlHostDataSourceImpl::GET_HOST_SUBID4_PAGE, isc::db::MLM_TRUE, and isc::dhcp::HostPageSize::page_size_.

◆ getPage4() [2/2]

ConstHostCollection isc::dhcp::MySqlHostDataSource::getPage4 ( size_t &  source_index,
uint64_t  lower_host_id,
const HostPageSize page_size 
) const
virtual

Returns range of hosts.

This method returns a page of Host objects which represent reservations.

Parameters
source_indexIndex of the source (unused).
lower_host_idHost identifier used as lower bound for the returned range.
page_sizemaximum size of the page returned.
Returns
Collection of const Host objects (may be empty).

Implements isc::dhcp::BaseHostDataSource.

Definition at line 3596 of file mysql_host_data_source.cc.

References isc::dhcp::MySqlHostDataSource::MySqlHostContextAlloc::ctx_, isc::dhcp::MySqlHostDataSourceImpl::GET_HOST_PAGE4, isc::db::MLM_TRUE, and isc::dhcp::HostPageSize::page_size_.

◆ getPage6() [1/2]

ConstHostCollection isc::dhcp::MySqlHostDataSource::getPage6 ( const SubnetID subnet_id,
size_t &  source_index,
uint64_t  lower_host_id,
const HostPageSize page_size 
) const
virtual

Returns range of hosts in a DHCPv6 subnet.

This method returns a page of Host objects which represent reservations in a specified subnet.

Parameters
subnet_idSubnet identifier.
source_indexIndex of the source (unused).
lower_host_idHost identifier used as lower bound for the returned range.
page_sizemaximum size of the page returned.
Returns
Collection of const Host objects (may be empty).

Implements isc::dhcp::BaseHostDataSource.

Definition at line 3558 of file mysql_host_data_source.cc.

References isc::dhcp::MySqlHostDataSource::MySqlHostContextAlloc::ctx_, isc::dhcp::MySqlHostDataSourceImpl::GET_HOST_SUBID6_PAGE, isc::db::MLM_TRUE, and isc::dhcp::HostPageSize::page_size_.

◆ getPage6() [2/2]

ConstHostCollection isc::dhcp::MySqlHostDataSource::getPage6 ( size_t &  source_index,
uint64_t  lower_host_id,
const HostPageSize page_size 
) const
virtual

Returns range of hosts.

This method returns a page of Host objects which represent reservations.

Parameters
source_indexIndex of the source (unused).
lower_host_idHost identifier used as lower bound for the returned range.
page_sizemaximum size of the page returned.
Returns
Collection of const Host objects (may be empty).

Implements isc::dhcp::BaseHostDataSource.

Definition at line 3627 of file mysql_host_data_source.cc.

References isc::dhcp::MySqlHostDataSource::MySqlHostContextAlloc::ctx_, isc::dhcp::MySqlHostDataSourceImpl::GET_HOST_PAGE6, isc::db::MLM_TRUE, and isc::dhcp::HostPageSize::page_size_.

◆ getParameters()

DatabaseConnection::ParameterMap isc::dhcp::MySqlHostDataSource::getParameters ( ) const
virtual

Return backend parameters.

Returns the backend parameters

Returns
Parameters of the backend.

Reimplemented from isc::dhcp::BaseHostDataSource.

Definition at line 3165 of file mysql_host_data_source.cc.

◆ getType()

virtual std::string isc::dhcp::MySqlHostDataSource::getType ( ) const
inlinevirtual

Return backend type.

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

Returns
Type of the backend.

Implements isc::dhcp::BaseHostDataSource.

Definition at line 411 of file mysql_host_data_source.h.

References commit(), getDescription(), getName(), getVersion(), isUnusable(), rollback(), and setIPReservationsUnique().

+ Here is the call graph for this function:

◆ getVersion()

std::pair< uint32_t, uint32_t > isc::dhcp::MySqlHostDataSource::getVersion ( ) const
virtual

Returns backend version.

Returns
Version number stored in the database, as a pair of unsigned integers. "first" is the major version number, "second" the minor number.
Exceptions
isc::db::DbOperationErrorAn operation on the open database has failed.

Definition at line 3922 of file mysql_host_data_source.cc.

Referenced by getType().

◆ isUnusable()

bool isc::dhcp::MySqlHostDataSource::isUnusable ( )
virtual

Flag which indicates if the host manager has at least one unusable connection.

Returns
true if there is at least one unusable connection, false otherwise

Reimplemented from isc::dhcp::BaseHostDataSource.

Definition at line 3959 of file mysql_host_data_source.cc.

Referenced by getType().

◆ rollback()

void isc::dhcp::MySqlHostDataSource::rollback ( )
virtual

Rollback Transactions.

Rolls back all pending database operations.

Reimplemented from isc::dhcp::BaseHostDataSource.

Definition at line 3940 of file mysql_host_data_source.cc.

References isc::dhcp::MySqlHostDataSource::MySqlHostContextAlloc::ctx_.

Referenced by getType().

◆ setIPReservationsUnique()

bool isc::dhcp::MySqlHostDataSource::setIPReservationsUnique ( const bool  unique)
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.

Parameters
uniqueboolean flag indicating if the IP reservations must be unique within the subnet or can be non-unique.
Returns
always true because this backend supports both the case when the addresses must be unique and when they may be non-unique.

Implements isc::dhcp::BaseHostDataSource.

Definition at line 3953 of file mysql_host_data_source.cc.

Referenced by getType().


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