Kea 2.5.8
pgsql_host_data_source.h
Go to the documentation of this file.
1// Copyright (C) 2016-2023 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
14
15namespace isc {
16namespace dhcp {
17
19class PgSqlHostDataSourceImpl;
20
22typedef boost::shared_ptr<PgSqlHostDataSourceImpl> PgSqlHostDataSourceImplPtr;
23
26
28typedef boost::shared_ptr<PgSqlHostContext> PgSqlHostContextPtr;
29
46public:
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
475 virtual ConstHostCollection getAll6(const asiolink::IOAddress& address) const;
476
482 void update(HostPtr const& host);
483
490 virtual std::string getType() const {
491 return (std::string("postgresql"));
492 }
493
497 virtual std::string getName() const;
498
504 virtual std::string getDescription() const;
505
520 virtual std::pair<uint32_t, uint32_t> getVersion(const std::string& timer_name = std::string()) const;
521
525 virtual void commit();
526
530 virtual void rollback();
531
547 virtual bool setIPReservationsUnique(const bool unique);
548
554 virtual bool isUnusable();
555
558 public:
559
567
572
575
576 private:
579 };
580
581private:
584};
585
586} // namespace dhcp
587} // namespace isc
588
589#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.
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 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.
void update(HostPtr const &host)
Implements BaseHostDataSource::update() for PostgreSQL.
virtual isc::db::DatabaseConnection::ParameterMap getParameters() const
Return backend parameters.
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::pair< uint32_t, uint32_t > getVersion(const std::string &timer_name=std::string()) const
Returns backend version.
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:807
std::vector< ConstHostPtr > ConstHostCollection
Collection of the const Host objects.
Definition: host.h:813
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:810
boost::shared_ptr< PgSqlHostDataSourceImpl > PgSqlHostDataSourceImplPtr
Type of pointers to PgSqlHostDataSourceImpl.
Defines the logger used by the top-level component of kea-lfc.