Kea  1.9.9-git
pgsql_host_data_source.h
Go to the documentation of this file.
1 // Copyright (C) 2016-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 PGSQL_HOST_DATA_SOURCE_H
8 #define PGSQL_HOST_DATA_SOURCE_H
9 
12 #include <pgsql/pgsql_connection.h>
13 #include <pgsql/pgsql_exchange.h>
14 
15 namespace isc {
16 namespace dhcp {
17 
20 
22 typedef boost::shared_ptr<PgSqlHostDataSourceImpl> PgSqlHostDataSourceImplPtr;
23 
26 
28 typedef boost::shared_ptr<PgSqlHostContext> PgSqlHostContextPtr;
29 
46 public:
47 
71 
75  virtual ~PgSqlHostDataSource();
76 
83 
117  virtual void add(const HostPtr& host);
118 
127  virtual bool del(const SubnetID& subnet_id,
128  const asiolink::IOAddress& addr);
129 
142  virtual bool del4(const SubnetID& subnet_id,
143  const Host::IdentifierType& identifier_type,
144  const uint8_t* identifier_begin,
145  const size_t identifier_len);
146 
159  virtual bool del6(const SubnetID& subnet_id,
160  const Host::IdentifierType& identifier_type,
161  const uint8_t* identifier_begin,
162  const size_t identifier_len);
163 
177  virtual ConstHostCollection getAll(const Host::IdentifierType& identifier_type,
178  const uint8_t* identifier_begin,
179  const size_t identifier_len) const;
180 
190  virtual ConstHostCollection getAll4(const SubnetID& subnet_id) const;
191 
201  virtual ConstHostCollection getAll6(const SubnetID& subnet_id) const;
202 
213  virtual ConstHostCollection getAllbyHostname(const std::string& hostname) const;
214 
224  virtual ConstHostCollection getAllbyHostname4(const std::string& hostname,
225  const SubnetID& subnet_id) const;
226 
236  virtual ConstHostCollection getAllbyHostname6(const std::string& hostname,
237  const SubnetID& subnet_id) const;
238 
256  virtual ConstHostCollection getPage4(const SubnetID& subnet_id,
257  size_t& source_index,
258  uint64_t lower_host_id,
259  const HostPageSize& page_size) const;
260 
278  virtual ConstHostCollection getPage6(const SubnetID& subnet_id,
279  size_t& source_index,
280  uint64_t lower_host_id,
281  const HostPageSize& page_size) const;
282 
299  virtual ConstHostCollection getPage4(size_t& source_index,
300  uint64_t lower_host_id,
301  const HostPageSize& page_size) const;
302 
319  virtual ConstHostCollection getPage6(size_t& source_index,
320  uint64_t lower_host_id,
321  const HostPageSize& page_size) const;
322 
331  virtual ConstHostCollection getAll4(const asiolink::IOAddress& address) const;
332 
343  virtual ConstHostPtr get4(const SubnetID& subnet_id,
344  const Host::IdentifierType& identifier_type,
345  const uint8_t* identifier_begin,
346  const size_t identifier_len) const;
347 
362  virtual ConstHostPtr get4(const SubnetID& subnet_id,
363  const asiolink::IOAddress& address) const;
364 
388  virtual ConstHostCollection
389  getAll4(const SubnetID& subnet_id,
390  const asiolink::IOAddress& address) const;
391 
402  virtual ConstHostPtr get6(const SubnetID& subnet_id,
403  const Host::IdentifierType& identifier_type,
404  const uint8_t* identifier_begin,
405  const size_t identifier_len) const;
406 
413  virtual ConstHostPtr get6(const asiolink::IOAddress& prefix,
414  const uint8_t prefix_len) const;
415 
423  virtual ConstHostPtr get6(const SubnetID& subnet_id,
424  const asiolink::IOAddress& address) const;
425 
449  virtual ConstHostCollection
450  getAll6(const SubnetID& subnet_id,
451  const asiolink::IOAddress& address) const;
452 
459  virtual std::string getType() const {
460  return (std::string("postgresql"));
461  }
462 
466  virtual std::string getName() const;
467 
473  virtual std::string getDescription() const;
474 
488  virtual std::pair<uint32_t, uint32_t> getVersion() const;
489 
493  virtual void commit();
494 
498  virtual void rollback();
499 
515  virtual bool setIPReservationsUnique(const bool unique);
516 
522  virtual bool isUnusable();
523 
526  public:
527 
535 
540 
542  PgSqlHostContextPtr ctx_;
543 
544  private:
547  };
548 
549 private:
551  PgSqlHostDataSourceImplPtr impl_;
552 };
553 
554 }
555 }
556 
557 #endif // PGSQL_HOST_DATA_SOURCE_H
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 getAllbyHostname4(const std::string &hostname, const SubnetID &subnet_id) const
Return all hosts with a hostname in a DHCPv4 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...
Wraps value holding size of the page with host reservations.
virtual void add(const HostPtr &host)
Adds a new host to the collection.
virtual std::string getType() const
Return backend type.
virtual ConstHostCollection getAll4(const SubnetID &subnet_id) const
Return all hosts in a DHCPv4 subnet.
boost::shared_ptr< Host > HostPtr
Pointer to the Host object.
Definition: host.h:785
virtual bool setIPReservationsUnique(const bool unique)
Controls whether IP reservations are unique or non-unique.
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 getAll6(const SubnetID &subnet_id) const
Return all hosts in a DHCPv6 subnet.
std::vector< ConstHostPtr > ConstHostCollection
Collection of the const Host objects.
Definition: host.h:791
virtual std::string getName() const
Returns the name of the open database.
virtual ConstHostCollection getAllbyHostname(const std::string &hostname) const
Return all hosts with a hostname.
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 std::pair< uint32_t, uint32_t > getVersion() const
Returns backend version.
boost::shared_ptr< const Host > ConstHostPtr
Const pointer to the Host object.
Definition: host.h:788
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 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 ~PgSqlHostDataSource()
Virtual destructor.
virtual bool del(const SubnetID &subnet_id, const asiolink::IOAddress &addr)
Attempts to delete hosts by (subnet-id, address)
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.
boost::shared_ptr< PgSqlHostContext > PgSqlHostContextPtr
Type of pointers to contexts.
Defines the logger used by the top-level component of kea-dhcp-ddns.
virtual std::string getDescription() const
Returns description of the backend.
Implementation of the PgSqlHostDataSource.
PgSqlHostContextAlloc(PgSqlHostDataSourceImpl &mgr)
Constructor.
virtual bool isUnusable()
Flag which indicates if the host manager has at least one unusable connection.
Base interface for the classes implementing simple data source for host reservations.
virtual void rollback()
Rollback Transactions.
PostgreSQL Host Data Source.
virtual isc::db::DatabaseConnection::ParameterMap getParameters() const
Return backend parameters.
virtual void commit()
Commit Transactions.
IdentifierType
Type of the host identifier.
Definition: host.h:307
std::map< std::string, std::string > ParameterMap
Database configuration parameter map.
virtual ConstHostCollection getAllbyHostname6(const std::string &hostname, const SubnetID &subnet_id) const
Return all hosts with a hostname in a DHCPv6 subnet.
boost::shared_ptr< PgSqlHostDataSourceImpl > PgSqlHostDataSourceImplPtr
Type of pointers to PgSqlHostDataSourceImpl.
uint32_t SubnetID
Unique identifier for a subnet (both v4 and v6)
Definition: lease.h:24