![]() |
Kea
1.5.0
|
MySQL Host Data Source. More...
#include <mysql_host_data_source.h>
Inheritance diagram for isc::dhcp::MySqlHostDataSource:Public Member Functions | |
| MySqlHostDataSource (const db::DatabaseConnection::ParameterMap ¶meters) | |
| 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 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) |
| 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 asiolink::IOAddress &address) const |
| 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 |
| Returns a host connected to the IPv4 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 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 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 asiolink::IOAddress &address) const |
| Returns a collection of hosts using the specified IPv4 address. More... | |
| virtual std::string | getDescription () const |
| Returns description of the backend. More... | |
| virtual std::string | getName () const |
| Returns backend name. More... | |
| virtual std::string | getType () const |
| Return backend type. More... | |
| virtual std::pair< uint32_t, uint32_t > | getVersion () const |
| Returns backend version. More... | |
| virtual void | rollback () |
| Rollback Transactions. 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... | |
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 30 of file mysql_host_data_source.h.
| 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:
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 | A data structure relating keywords and values concerned with the database. |
| isc::dhcp::NoDatabaseName | Mandatory database name not given |
| isc::db::DbOpenError | Error opening the database or the schema version is invalid. |
| isc::db::DbOperationError | An operation on the open database has failed. |
Definition at line 2680 of file mysql_host_data_source.cc.
|
virtual |
Virtual destructor.
Releases prepared MySQL statements used by the backend.
Definition at line 2685 of file mysql_host_data_source.cc.
|
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.
| host | Pointer to the new Host object being added. |
Implements isc::dhcp::BaseHostDataSource.
Definition at line 2690 of file mysql_host_data_source.cc.
References isc::dhcp::MySqlHostDataSourceImpl::addOptions(), isc::dhcp::MySqlHostDataSourceImpl::addResv(), isc::dhcp::MySqlHostDataSourceImpl::addStatement(), isc::dhcp::MySqlHostDataSourceImpl::checkReadOnly(), isc::db::MySqlTransaction::commit(), isc::dhcp::MySqlHostDataSourceImpl::conn_, isc::dhcp::MySqlHostDataSourceImpl::host_exchange_, isc::dhcp::MySqlHostDataSourceImpl::INSERT_HOST, isc::dhcp::MySqlHostDataSourceImpl::INSERT_V4_OPTION, isc::dhcp::MySqlHostDataSourceImpl::INSERT_V6_OPTION, and isc::db::MySqlConnection::mysql_.
Here is the call graph for this function:
|
virtual |
Commit Transactions.
Commits all pending database operations.
Reimplemented from isc::dhcp::BaseHostDataSource.
Definition at line 3042 of file mysql_host_data_source.cc.
References isc::dhcp::MySqlHostDataSourceImpl::checkReadOnly(), isc::db::MySqlConnection::commit(), and isc::dhcp::MySqlHostDataSourceImpl::conn_.
Here is the call graph for this function:
|
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 |
Implements isc::dhcp::BaseHostDataSource.
Definition at line 2737 of file mysql_host_data_source.cc.
References isc::dhcp::MySqlHostDataSourceImpl::checkReadOnly(), del6(), isc::dhcp::MySqlHostDataSourceImpl::DEL_HOST_ADDR4, isc::dhcp::MySqlHostDataSourceImpl::delStatement(), get6(), isc::asiolink::IOAddress::isV4(), isc::db::MLM_TRUE, and isc::asiolink::IOAddress::toUint32().
Here is the call graph for this function:
|
virtual |
Attempts to delete a host by (subnet4-id, identifier type, identifier)
This method supports v4 hosts only.
| subnet_id | 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 |
Implements isc::dhcp::BaseHostDataSource.
Definition at line 2772 of file mysql_host_data_source.cc.
References isc::dhcp::MySqlHostDataSourceImpl::checkReadOnly(), isc::dhcp::MySqlHostDataSourceImpl::DEL_HOST_SUBID4_ID, isc::dhcp::MySqlHostDataSourceImpl::delStatement(), and isc::db::MLM_TRUE.
Here is the call graph for this function:
|
virtual |
Attempts to delete a host by (subnet6-id, identifier type, identifier)
This method supports v6 hosts only.
| subnet_id | 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 |
Implements isc::dhcp::BaseHostDataSource.
Definition at line 2808 of file mysql_host_data_source.cc.
References isc::dhcp::MySqlHostDataSourceImpl::checkReadOnly(), isc::dhcp::MySqlHostDataSourceImpl::DEL_HOST_SUBID6_ID, isc::dhcp::MySqlHostDataSourceImpl::delStatement(), and isc::db::MLM_TRUE.
Referenced by del().
Here is the call graph for this function:
|
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. Implements isc::dhcp::BaseHostDataSource.
Definition at line 2904 of file mysql_host_data_source.cc.
References isc::dhcp::MySqlHostDataSourceImpl::GET_HOST_SUBID_ADDR, isc::dhcp::MySqlHostDataSourceImpl::getHostCollection(), isc::dhcp::MySqlHostDataSourceImpl::host_exchange_, isc_throw, isc::asiolink::IOAddress::isV4(), isc::db::MLM_TRUE, and isc::asiolink::IOAddress::toUint32().
Here is the call graph for this function:
|
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. Implements isc::dhcp::BaseHostDataSource.
Definition at line 2893 of file mysql_host_data_source.cc.
References isc::dhcp::MySqlHostDataSourceImpl::GET_HOST_SUBID4_DHCPID, isc::dhcp::MySqlHostDataSourceImpl::getHost(), and isc::dhcp::MySqlHostDataSourceImpl::host_exchange_.
Here is the call graph for this function:
|
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. Implements isc::dhcp::BaseHostDataSource.
Definition at line 2949 of file mysql_host_data_source.cc.
References isc::dhcp::MySqlHostDataSourceImpl::GET_HOST_PREFIX, isc::dhcp::MySqlHostDataSourceImpl::getHostCollection(), isc::dhcp::MySqlHostDataSourceImpl::host_ipv6_exchange_, isc::db::MLM_TRUE, and isc::asiolink::IOAddress::toText().
Here is the call graph for this function:
|
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. Implements isc::dhcp::BaseHostDataSource.
Definition at line 2986 of file mysql_host_data_source.cc.
References isc::dhcp::MySqlHostDataSourceImpl::GET_HOST_SUBID6_ADDR, isc::dhcp::MySqlHostDataSourceImpl::getHostCollection(), isc::dhcp::MySqlHostDataSourceImpl::host_ipv6_exchange_, isc::db::MLM_TRUE, and isc::asiolink::IOAddress::toText().
Here is the call graph for this function:
|
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. Implements isc::dhcp::BaseHostDataSource.
Definition at line 2938 of file mysql_host_data_source.cc.
References isc::dhcp::MySqlHostDataSourceImpl::GET_HOST_SUBID6_DHCPID, isc::dhcp::MySqlHostDataSourceImpl::getHost(), and isc::dhcp::MySqlHostDataSourceImpl::host_ipv6_exchange_.
Referenced by del().
Here is the call graph for this function:
|
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. Implements isc::dhcp::BaseHostDataSource.
Definition at line 2844 of file mysql_host_data_source.cc.
References isc::dhcp::MySqlHostDataSourceImpl::GET_HOST_DHCPID, isc::dhcp::MySqlHostDataSourceImpl::getHostCollection(), isc::dhcp::MySqlHostDataSourceImpl::host_ipv46_exchange_, and isc::db::MLM_TRUE.
Here is the call graph for this function:
|
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. Implements isc::dhcp::BaseHostDataSource.
Definition at line 2874 of file mysql_host_data_source.cc.
References isc::dhcp::MySqlHostDataSourceImpl::GET_HOST_ADDR, isc::dhcp::MySqlHostDataSourceImpl::getHostCollection(), isc::dhcp::MySqlHostDataSourceImpl::host_exchange_, isc::db::MLM_TRUE, and isc::asiolink::IOAddress::toUint32().
Here is the call graph for this function:
|
virtual |
Returns description of the backend.
This description may be multiline text that describes the backend.
Definition at line 3032 of file mysql_host_data_source.cc.
|
virtual |
Returns backend name.
Each backend have specific name.
Definition at line 3022 of file mysql_host_data_source.cc.
References isc::dhcp::MySqlHostDataSourceImpl::conn_, and isc::db::DatabaseConnection::getParameter().
Here is the call graph for this function:
|
inlinevirtual |
Return backend type.
Returns the type of the backend (e.g. "mysql", "memfile" etc.)
Implements isc::dhcp::BaseHostDataSource.
Definition at line 216 of file mysql_host_data_source.h.
|
virtual |
Returns backend version.
| isc::db::DbOperationError | An operation on the open database has failed. |
Definition at line 3037 of file mysql_host_data_source.cc.
References isc::dhcp::MySqlHostDataSourceImpl::getVersion().
Here is the call graph for this function:
|
virtual |
Rollback Transactions.
Rolls back all pending database operations.
Reimplemented from isc::dhcp::BaseHostDataSource.
Definition at line 3049 of file mysql_host_data_source.cc.
References isc::dhcp::MySqlHostDataSourceImpl::checkReadOnly(), isc::dhcp::MySqlHostDataSourceImpl::conn_, and isc::db::MySqlConnection::rollback().
Here is the call graph for this function: