Kea 2.7.1
mysql_host_data_source.h
Go to the documentation of this file.
1// Copyright (C) 2015-2023 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef MYSQL_HOST_DATA_SOURCE_H
8#define MYSQL_HOST_DATA_SOURCE_H
9
14
15#include <stdint.h>
16
17#include <utility>
18#include <string>
19
20namespace isc {
21namespace dhcp {
22
24class MySqlHostDataSourceImpl;
25
27typedef boost::shared_ptr<MySqlHostDataSourceImpl> MySqlHostDataSourceImplPtr;
28
31
33typedef boost::shared_ptr<MySqlHostContext> MySqlHostContextPtr;
34
41public:
42
67
71 virtual ~MySqlHostDataSource();
72
79
90 virtual void add(const HostPtr& host);
91
100 virtual bool del(const SubnetID& subnet_id,
101 const asiolink::IOAddress& addr);
102
115 virtual bool del4(const SubnetID& subnet_id,
116 const Host::IdentifierType& identifier_type,
117 const uint8_t* identifier_begin,
118 const size_t identifier_len);
119
132 virtual bool del6(const SubnetID& subnet_id,
133 const Host::IdentifierType& identifier_type,
134 const uint8_t* identifier_begin,
135 const size_t identifier_len);
136
150 virtual ConstHostCollection getAll(const Host::IdentifierType& identifier_type,
151 const uint8_t* identifier_begin,
152 const size_t identifier_len) const;
153
162 virtual ConstHostCollection getAll4(const SubnetID& subnet_id) const;
163
172 virtual ConstHostCollection getAll6(const SubnetID& subnet_id) const;
173
184 virtual ConstHostCollection getAllbyHostname(const std::string& hostname) const;
185
195 virtual ConstHostCollection getAllbyHostname4(const std::string& hostname,
196 const SubnetID& subnet_id) const;
197
207 virtual ConstHostCollection getAllbyHostname6(const std::string& hostname,
208 const SubnetID& subnet_id) const;
209
222 virtual ConstHostCollection getPage4(const SubnetID& subnet_id,
223 size_t& source_index,
224 uint64_t lower_host_id,
225 const HostPageSize& page_size) const;
226
239 virtual ConstHostCollection getPage6(const SubnetID& subnet_id,
240 size_t& source_index,
241 uint64_t lower_host_id,
242 const HostPageSize& page_size) const;
243
255 virtual ConstHostCollection getPage4(size_t& source_index,
256 uint64_t lower_host_id,
257 const HostPageSize& page_size) const;
258
270 virtual ConstHostCollection getPage6(size_t& source_index,
271 uint64_t lower_host_id,
272 const HostPageSize& page_size) const;
273
282 virtual ConstHostCollection getAll4(const asiolink::IOAddress& address) const;
283
294 virtual ConstHostPtr get4(const SubnetID& subnet_id,
295 const Host::IdentifierType& identifier_type,
296 const uint8_t* identifier_begin,
297 const size_t identifier_len) const;
298
315 virtual ConstHostPtr get4(const SubnetID& subnet_id,
316 const asiolink::IOAddress& address) const;
317
341 virtual ConstHostCollection
342 getAll4(const SubnetID& subnet_id,
343 const asiolink::IOAddress& address) const;
344
355 virtual ConstHostPtr get6(const SubnetID& subnet_id,
356 const Host::IdentifierType& identifier_type,
357 const uint8_t* identifier_begin,
358 const size_t identifier_len) const;
359
366 virtual ConstHostPtr get6(const asiolink::IOAddress& prefix,
367 const uint8_t prefix_len) const;
368
376 virtual ConstHostPtr get6(const SubnetID& subnet_id,
377 const asiolink::IOAddress& address) const;
378
402 virtual ConstHostCollection
403 getAll6(const SubnetID& subnet_id,
404 const asiolink::IOAddress& address) const;
405
427 virtual ConstHostCollection getAll6(const asiolink::IOAddress& address) const;
428
434 void update(HostPtr const& host);
435
441 virtual std::string getType() const {
442 return (std::string("mysql"));
443 }
444
450 virtual std::string getName() const;
451
457 virtual std::string getDescription() const;
458
468 virtual std::pair<uint32_t, uint32_t> getVersion(const std::string& timer_name = std::string()) const;
469
473 virtual void commit();
474
478 virtual void rollback();
479
495 virtual bool setIPReservationsUnique(const bool unique);
496
502 virtual bool isUnusable();
503
506 public:
507
515
520
523
524 private:
527 };
528
529private:
532};
533
534}
535}
536
537#endif // MYSQL_HOST_DATA_SOURCE_H
std::map< std::string, std::string > ParameterMap
Database configuration parameter map.
Base interface for the classes implementing simple data source for host reservations.
Wraps value holding size of the page with host reservations.
IdentifierType
Type of the host identifier.
Definition host.h:307
Implementation of the MySqlHostDataSource.
MySqlHostContextAlloc(MySqlHostDataSourceImpl &mgr)
Constructor.
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 iden...
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.
virtual std::pair< uint32_t, uint32_t > getVersion(const std::string &timer_name=std::string()) const
Returns backend version.
virtual void commit()
Commit Transactions.
virtual bool del(const SubnetID &subnet_id, const asiolink::IOAddress &addr)
Attempts to delete hosts by (subnet-id, address)
virtual ConstHostCollection getAll4(const SubnetID &subnet_id) const
Return all hosts in a DHCPv4 subnet.
virtual ConstHostCollection getAll6(const SubnetID &subnet_id) const
Return all hosts in a DHCPv6 subnet.
virtual std::string getDescription() const
Returns description of the backend.
MySqlHostDataSource(const db::DatabaseConnection::ParameterMap &parameters)
Constructor.
virtual ~MySqlHostDataSource()
Virtual destructor.
virtual ConstHostCollection getAllbyHostname(const std::string &hostname) const
Return all hosts with a hostname.
virtual isc::db::DatabaseConnection::ParameterMap getParameters() const
Return backend parameters.
void update(HostPtr const &host)
Implements BaseHostDataSource::update() for MySQL.
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)
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.
virtual ConstHostCollection getAllbyHostname6(const std::string &hostname, const SubnetID &subnet_id) const
Return all hosts with a hostname in a DHCPv6 subnet.
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)
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.
virtual bool isUnusable()
Flag which indicates if the host manager has at least one unusable connection.
virtual ConstHostCollection getAllbyHostname4(const std::string &hostname, const SubnetID &subnet_id) const
Return all hosts with a hostname in a DHCPv4 subnet.
virtual void rollback()
Rollback Transactions.
virtual std::string getType() const
Return backend type.
virtual std::string getName() const
Returns backend name.
virtual void add(const HostPtr &host)
Adds a new host to the collection.
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.
virtual bool setIPReservationsUnique(const bool unique)
Controls whether IP reservations are unique or non-unique.
boost::shared_ptr< Host > HostPtr
Pointer to the Host object.
Definition host.h:807
std::vector< ConstHostPtr > ConstHostCollection
Collection of the const Host objects.
Definition host.h:813
boost::shared_ptr< MySqlHostDataSourceImpl > MySqlHostDataSourceImplPtr
Type of pointers to MySqlHostDataSourceImpl.
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
Definition subnet_id.h:25
boost::shared_ptr< const Host > ConstHostPtr
Const pointer to the Host object.
Definition host.h:810
boost::shared_ptr< MySqlHostContext > MySqlHostContextPtr
Type of pointers to contexts.
Defines the logger used by the top-level component of kea-lfc.