Kea  1.5.0
mysql_host_data_source.h
Go to the documentation of this file.
1 // Copyright (C) 2015-2018 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 
10 #include <database/db_exceptions.h>
12 #include <mysql/mysql_connection.h>
13 
14 #include <stdint.h>
15 
16 #include <utility>
17 #include <string>
18 
19 namespace isc {
20 namespace dhcp {
21 
23 class MySqlHostDataSourceImpl;
24 
31 public:
32 
57 
61  virtual ~MySqlHostDataSource();
62 
73  virtual void add(const HostPtr& host);
74 
83  virtual bool del(const SubnetID& subnet_id, const asiolink::IOAddress& addr);
84 
97  virtual bool del4(const SubnetID& subnet_id,
98  const Host::IdentifierType& identifier_type,
99  const uint8_t* identifier_begin, const size_t identifier_len);
100 
113  virtual bool del6(const SubnetID& subnet_id,
114  const Host::IdentifierType& identifier_type,
115  const uint8_t* identifier_begin, const size_t identifier_len);
116 
130  virtual ConstHostCollection
131  getAll(const Host::IdentifierType& identifier_type,
132  const uint8_t* identifier_begin, const size_t identifier_len) const;
133 
142  virtual ConstHostCollection
143  getAll4(const asiolink::IOAddress& address) const;
144 
155  virtual ConstHostPtr
156  get4(const SubnetID& subnet_id, const Host::IdentifierType& identifier_type,
157  const uint8_t* identifier_begin, const size_t identifier_len) const;
158 
175  virtual ConstHostPtr
176  get4(const SubnetID& subnet_id, const asiolink::IOAddress& address) const;
177 
188  virtual ConstHostPtr
189  get6(const SubnetID& subnet_id, const Host::IdentifierType& identifier_type,
190  const uint8_t* identifier_begin, const size_t identifier_len) const;
191 
198  virtual ConstHostPtr
199  get6(const asiolink::IOAddress& prefix, const uint8_t prefix_len) const;
200 
208  virtual ConstHostPtr
209  get6(const SubnetID& subnet_id, const asiolink::IOAddress& address) const;
210 
216  virtual std::string getType() const {
217  return (std::string("mysql"));
218  }
219 
225  virtual std::string getName() const;
226 
232  virtual std::string getDescription() const;
233 
242  virtual std::pair<uint32_t, uint32_t> getVersion() const;
243 
247  virtual void commit();
248 
252  virtual void rollback();
253 
254 private:
257 };
258 
259 }
260 }
261 
262 #endif // MYSQL_HOST_DATA_SOURCE_H
virtual std::string getDescription() const
Returns description of the backend.
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)
boost::shared_ptr< Host > HostPtr
Pointer to the Host object.
Definition: host.h:725
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)
std::vector< ConstHostPtr > ConstHostCollection
Collection of the const Host objects.
Definition: host.h:731
virtual void commit()
Commit Transactions.
virtual ~MySqlHostDataSource()
Virtual destructor.
boost::shared_ptr< const Host > ConstHostPtr
Const pointer to the Host object.
Definition: host.h:728
virtual std::string getName() const
Returns backend name.
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.
Defines the logger used by the top-level component of kea-dhcp-ddns.
virtual std::pair< uint32_t, uint32_t > getVersion() const
Returns backend version.
Implementation of the MySqlHostDataSource.
Base interface for the classes implementing simple data source for host reservations.
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...
IdentifierType
Type of the host identifier.
Definition: host.h:252
std::map< std::string, std::string > ParameterMap
Database configuration parameter map.
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 ConstHostCollection getAll4(const asiolink::IOAddress &address) const
Returns a collection of hosts using the specified IPv4 address.
virtual bool del(const SubnetID &subnet_id, const asiolink::IOAddress &addr)
Attempts to delete a host by (subnet-id, address)
MySqlHostDataSource(const db::DatabaseConnection::ParameterMap &parameters)
Constructor.
virtual std::string getType() const
Return backend type.
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