Kea  1.5.0
pgsql_host_data_source.h
Go to the documentation of this file.
1 // Copyright (C) 2016-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 PGSQL_HOST_DATA_SOURCE_H
8 #define PGSQL_HOST_DATA_SOURCE_H
9 
11 #include <pgsql/pgsql_connection.h>
12 #include <pgsql/pgsql_exchange.h>
13 
14 namespace isc {
15 namespace dhcp {
16 
18 class PgSqlHostDataSourceImpl;
19 
36 public:
37 
61 
65  virtual ~PgSqlHostDataSource();
66 
100  virtual void add(const HostPtr& host);
101 
110  virtual bool del(const SubnetID& subnet_id, const asiolink::IOAddress& addr);
111 
124  virtual bool del4(const SubnetID& subnet_id,
125  const Host::IdentifierType& identifier_type,
126  const uint8_t* identifier_begin, const size_t identifier_len);
127 
140  virtual bool del6(const SubnetID& subnet_id,
141  const Host::IdentifierType& identifier_type,
142  const uint8_t* identifier_begin, const size_t identifier_len);
143 
157  virtual ConstHostCollection
158  getAll(const Host::IdentifierType& identifier_type,
159  const uint8_t* identifier_begin, const size_t identifier_len) const;
160 
169  virtual ConstHostCollection
170  getAll4(const asiolink::IOAddress& address) const;
171 
182  virtual ConstHostPtr
183  get4(const SubnetID& subnet_id, const Host::IdentifierType& identifier_type,
184  const uint8_t* identifier_begin, const size_t identifier_len) const;
185 
200  virtual ConstHostPtr
201  get4(const SubnetID& subnet_id, const asiolink::IOAddress& address) const;
202 
213  virtual ConstHostPtr
214  get6(const SubnetID& subnet_id, const Host::IdentifierType& identifier_type,
215  const uint8_t* identifier_begin, const size_t identifier_len) const;
216 
223  virtual ConstHostPtr
224  get6(const asiolink::IOAddress& prefix, const uint8_t prefix_len) const;
225 
233  virtual ConstHostPtr
234  get6(const SubnetID& subnet_id, const asiolink::IOAddress& address) const;
235 
242  virtual std::string getType() const {
243  return (std::string("postgresql"));
244  }
245 
249  virtual std::string getName() const;
250 
256  virtual std::string getDescription() const;
257 
271  virtual std::pair<uint32_t, uint32_t> getVersion() const;
272 
276  virtual void commit();
277 
281  virtual void rollback();
282 
283 private:
286 };
287 
288 }
289 }
290 
291 #endif // PGSQL_HOST_DATA_SOURCE_H
virtual void add(const HostPtr &host)
Adds a new host to the collection.
boost::shared_ptr< Host > HostPtr
Pointer to the Host object.
Definition: host.h:725
virtual std::string getName() const
Returns the name of the open database.
PgSqlHostDataSource(const db::DatabaseConnection::ParameterMap &parameters)
Constructor.
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 getAll4(const asiolink::IOAddress &address) const
Returns a collection of hosts using the specified IPv4 address.
std::vector< ConstHostPtr > ConstHostCollection
Collection of the const Host objects.
Definition: host.h:731
boost::shared_ptr< const Host > ConstHostPtr
Const pointer to the Host object.
Definition: host.h:728
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 ~PgSqlHostDataSource()
Virtual destructor.
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 del(const SubnetID &subnet_id, const asiolink::IOAddress &addr)
Attempts to delete a host by (subnet-id, address)
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 std::string getDescription() const
Returns description of the backend.
Defines the logger used by the top-level component of kea-dhcp-ddns.
Implementation of the PgSqlHostDataSource.
Base interface for the classes implementing simple data source for host reservations.
virtual void rollback()
Rollback Transactions.
PostgreSQL Host Data Source.
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 void commit()
Commit Transactions.
IdentifierType
Type of the host identifier.
Definition: host.h:252
virtual std::pair< uint32_t, uint32_t > getVersion() const
Returns backend version.
std::map< std::string, std::string > ParameterMap
Database configuration parameter map.
virtual std::string getType() const
Return backend type.
uint32_t SubnetID
Unique identifier for a subnet (both v4 and v6)
Definition: lease.h:24