Kea  2.3.7
pgsql_host_data_source.h
Go to the documentation of this file.
1 // Copyright (C) 2016-2021 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 
19 class PgSqlHostDataSourceImpl;
20 
22 typedef boost::shared_ptr<PgSqlHostDataSourceImpl> PgSqlHostDataSourceImplPtr;
23 
25 class PgSqlHostContext;
26 
28 typedef boost::shared_ptr<PgSqlHostContext> PgSqlHostContextPtr;
29 
46 public:
47 
71 
76  virtual ~PgSqlHostDataSource();
77 
84 
118  virtual void add(const HostPtr& host);
119 
128  virtual bool del(const SubnetID& subnet_id,
129  const asiolink::IOAddress& addr);
130 
143  virtual bool del4(const SubnetID& subnet_id,
144  const Host::IdentifierType& identifier_type,
145  const uint8_t* identifier_begin,
146  const size_t identifier_len);
147 
160  virtual bool del6(const SubnetID& subnet_id,
161  const Host::IdentifierType& identifier_type,
162  const uint8_t* identifier_begin,
163  const size_t identifier_len);
164 
178  virtual ConstHostCollection getAll(const Host::IdentifierType& identifier_type,
179  const uint8_t* identifier_begin,
180  const size_t identifier_len) const;
181 
191  virtual ConstHostCollection getAll4(const SubnetID& subnet_id) const;
192 
202  virtual ConstHostCollection getAll6(const SubnetID& subnet_id) const;
203 
214  virtual ConstHostCollection getAllbyHostname(const std::string& hostname) const;
215 
225  virtual ConstHostCollection getAllbyHostname4(const std::string& hostname,
226  const SubnetID& subnet_id) const;
227 
237  virtual ConstHostCollection getAllbyHostname6(const std::string& hostname,
238  const SubnetID& subnet_id) const;
239 
257  virtual ConstHostCollection getPage4(const SubnetID& subnet_id,
258  size_t& source_index,
259  uint64_t lower_host_id,
260  const HostPageSize& page_size) const;
261 
279  virtual ConstHostCollection getPage6(const SubnetID& subnet_id,
280  size_t& source_index,
281  uint64_t lower_host_id,
282  const HostPageSize& page_size) const;
283 
300  virtual ConstHostCollection getPage4(size_t& source_index,
301  uint64_t lower_host_id,
302  const HostPageSize& page_size) const;
303 
320  virtual ConstHostCollection getPage6(size_t& source_index,
321  uint64_t lower_host_id,
322  const HostPageSize& page_size) const;
323 
332  virtual ConstHostCollection getAll4(const asiolink::IOAddress& address) const;
333 
344  virtual ConstHostPtr get4(const SubnetID& subnet_id,
345  const Host::IdentifierType& identifier_type,
346  const uint8_t* identifier_begin,
347  const size_t identifier_len) const;
348 
363  virtual ConstHostPtr get4(const SubnetID& subnet_id,
364  const asiolink::IOAddress& address) const;
365 
389  virtual ConstHostCollection
390  getAll4(const SubnetID& subnet_id,
391  const asiolink::IOAddress& address) const;
392 
403  virtual ConstHostPtr get6(const SubnetID& subnet_id,
404  const Host::IdentifierType& identifier_type,
405  const uint8_t* identifier_begin,
406  const size_t identifier_len) const;
407 
414  virtual ConstHostPtr get6(const asiolink::IOAddress& prefix,
415  const uint8_t prefix_len) const;
416 
424  virtual ConstHostPtr get6(const SubnetID& subnet_id,
425  const asiolink::IOAddress& address) const;
426 
450  virtual ConstHostCollection
451  getAll6(const SubnetID& subnet_id,
452  const asiolink::IOAddress& address) const;
453 
460  virtual std::string getType() const {
461  return (std::string("postgresql"));
462  }
463 
467  virtual std::string getName() const;
468 
474  virtual std::string getDescription() const;
475 
489  virtual std::pair<uint32_t, uint32_t> getVersion() const;
490 
494  virtual void commit();
495 
499  virtual void rollback();
500 
516  virtual bool setIPReservationsUnique(const bool unique);
517 
523  virtual bool isUnusable();
524 
527  public:
528 
536 
541 
544 
545  private:
548  };
549 
550 private:
553 };
554 
555 }
556 }
557 
558 #endif // PGSQL_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 PgSqlHostDataSource.
PgSqlHostContextAlloc(PgSqlHostDataSourceImpl &mgr)
Constructor.
PostgreSQL Host Data Source.
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 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 isUnusable()
Flag which indicates if the host manager has at least one unusable connection.
virtual std::string getName() const
Returns the name of the open database.
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.
virtual ConstHostCollection getAllbyHostname4(const std::string &hostname, const SubnetID &subnet_id) const
Return all hosts with a hostname in a DHCPv4 subnet.
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 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.
virtual void rollback()
Rollback Transactions.
virtual std::pair< uint32_t, uint32_t > getVersion() const
Returns backend version.
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 getAll6(const SubnetID &subnet_id) const
Return all 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 void commit()
Commit Transactions.
virtual bool setIPReservationsUnique(const bool unique)
Controls whether IP reservations are unique or non-unique.
virtual ConstHostCollection getAll4(const SubnetID &subnet_id) const
Return all hosts in a DHCPv4 subnet.
virtual isc::db::DatabaseConnection::ParameterMap getParameters() const
Return backend parameters.
PgSqlHostDataSource(const db::DatabaseConnection::ParameterMap &parameters)
Constructor.
virtual void add(const HostPtr &host)
Adds a new host to the collection.
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 ConstHostCollection getAllbyHostname(const std::string &hostname) const
Return all hosts with a hostname.
virtual std::string getType() const
Return backend type.
boost::shared_ptr< PgSqlHostContext > PgSqlHostContextPtr
Type of pointers to contexts.
boost::shared_ptr< Host > HostPtr
Pointer to the Host object.
Definition: host.h:801
std::vector< ConstHostPtr > ConstHostCollection
Collection of the const Host objects.
Definition: host.h:807
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:804
boost::shared_ptr< PgSqlHostDataSourceImpl > PgSqlHostDataSourceImplPtr
Type of pointers to PgSqlHostDataSourceImpl.
Defines the logger used by the top-level component of kea-lfc.