Kea  1.9.9-git
mysql_host_data_source.h
Go to the documentation of this file.
1 // Copyright (C) 2015-2020 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 
11 #include <database/db_exceptions.h>
13 #include <mysql/mysql_connection.h>
14 
15 #include <stdint.h>
16 
17 #include <utility>
18 #include <string>
19 
20 namespace isc {
21 namespace dhcp {
22 
25 
27 typedef boost::shared_ptr<MySqlHostDataSourceImpl> MySqlHostDataSourceImplPtr;
28 
31 
33 typedef boost::shared_ptr<MySqlHostContext> MySqlHostContextPtr;
34 
41 public:
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 
411  virtual std::string getType() const {
412  return (std::string("mysql"));
413  }
414 
420  virtual std::string getName() const;
421 
427  virtual std::string getDescription() const;
428 
437  virtual std::pair<uint32_t, uint32_t> getVersion() const;
438 
442  virtual void commit();
443 
447  virtual void rollback();
448 
464  virtual bool setIPReservationsUnique(const bool unique);
465 
471  virtual bool isUnusable();
472 
475  public:
476 
484 
489 
491  MySqlHostContextPtr ctx_;
492 
493  private:
496  };
497 
498 private:
500  MySqlHostDataSourceImplPtr impl_;
501 };
502 
503 }
504 }
505 
506 #endif // MYSQL_HOST_DATA_SOURCE_H
boost::shared_ptr< MySqlHostDataSourceImpl > MySqlHostDataSourceImplPtr
Type of pointers to MySqlHostDataSourceImpl.
Wraps value holding size of the page with host reservations.
virtual void rollback()
Rollback Transactions.
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 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:785
virtual ConstHostCollection getAllbyHostname(const std::string &hostname) const
Return all hosts with a hostname.
virtual ConstHostCollection getAll6(const SubnetID &subnet_id) const
Return all hosts in a DHCPv6 subnet.
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 bool isUnusable()
Flag which indicates if the host manager has at least one unusable connection.
std::vector< ConstHostPtr > ConstHostCollection
Collection of the const Host objects.
Definition: host.h:791
virtual void commit()
Commit Transactions.
virtual ~MySqlHostDataSource()
Virtual destructor.
boost::shared_ptr< const Host > ConstHostPtr
Const pointer to the Host object.
Definition: host.h:788
virtual ConstHostCollection getAllbyHostname4(const std::string &hostname, const SubnetID &subnet_id) const
Return all hosts with a hostname in a DHCPv4 subnet.
virtual std::pair< uint32_t, uint32_t > getVersion() const
Returns backend version.
Defines the logger used by the top-level component of kea-dhcp-ddns.
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 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 ConstHostCollection getAllbyHostname6(const std::string &hostname, const SubnetID &subnet_id) const
Return all hosts with a hostname in a DHCPv6 subnet.
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 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...
Implementation of the MySqlHostDataSource.
MySqlHostContextAlloc(MySqlHostDataSourceImpl &mgr)
Constructor.
Base interface for the classes implementing simple data source for host reservations.
boost::shared_ptr< MySqlHostContext > MySqlHostContextPtr
Type of pointers to contexts.
virtual std::string getType() const
Return backend type.
IdentifierType
Type of the host identifier.
Definition: host.h:307
std::map< std::string, std::string > ParameterMap
Database configuration parameter map.
virtual std::string getDescription() const
Returns description of the backend.
virtual std::string getName() const
Returns backend name.
virtual ConstHostCollection getAll4(const SubnetID &subnet_id) const
Return all hosts in a DHCPv4 subnet.
virtual bool del(const SubnetID &subnet_id, const asiolink::IOAddress &addr)
Attempts to delete hosts by (subnet-id, address)
MySqlHostDataSource(const db::DatabaseConnection::ParameterMap &parameters)
Constructor.
virtual isc::db::DatabaseConnection::ParameterMap getParameters() const
Return backend parameters.
virtual void add(const HostPtr &host)
Adds a new host to the collection.
uint32_t SubnetID
Unique identifier for a subnet (both v4 and v6)
Definition: lease.h:24
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.