Kea 1.5.0
base_host_data_source.h
Go to the documentation of this file.
1// Copyright (C) 2014-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 BASE_HOST_DATA_SOURCE_H
8#define BASE_HOST_DATA_SOURCE_H
9
10#include <asiolink/io_address.h>
11#include <dhcpsrv/host.h>
13#include <boost/shared_ptr.hpp>
14
15#include <vector>
16
17namespace isc {
18namespace dhcp {
19
21class DuplicateHost : public Exception {
22public:
23 DuplicateHost(const char* file, size_t line, const char* what) :
24 isc::Exception(file, line, what) { };
25};
26
29class ReservedAddress : public Exception {
30public:
31 ReservedAddress(const char* file, size_t line, const char* what) :
32 isc::Exception(file, line, what) { };
33};
34
38public:
39 BadHostAddress(const char* file, size_t line, const char* what) :
40 isc::BadValue(file, line, what) { };
41};
42
58public:
59
69 enum IdType {
71 ID_DUID = 1
72 };
73
75 virtual ~BaseHostDataSource() { }
76
91 getAll(const Host::IdentifierType& identifier_type,
92 const uint8_t* identifier_begin,
93 const size_t identifier_len) const = 0;
94
103 virtual ConstHostCollection
104 getAll4(const asiolink::IOAddress& address) const = 0;
105
116 virtual ConstHostPtr
117 get4(const SubnetID& subnet_id,
118 const Host::IdentifierType& identifier_type,
119 const uint8_t* identifier_begin,
120 const size_t identifier_len) const = 0;
121
138 virtual ConstHostPtr
139 get4(const SubnetID& subnet_id,
140 const asiolink::IOAddress& address) const = 0;
141
152 virtual ConstHostPtr
153 get6(const SubnetID& subnet_id,
154 const Host::IdentifierType& identifier_type,
155 const uint8_t* identifier_begin,
156 const size_t identifier_len) const = 0;
157
164 virtual ConstHostPtr
165 get6(const asiolink::IOAddress& prefix, const uint8_t prefix_len) const = 0;
166
174 virtual ConstHostPtr
175 get6(const SubnetID& subnet_id, const asiolink::IOAddress& address) const =
176 0;
177
188 virtual void add(const HostPtr& host) = 0;
189
198 virtual bool del(const SubnetID& subnet_id, const asiolink::IOAddress& addr) = 0;
199
211 virtual bool del4(const SubnetID& subnet_id,
212 const Host::IdentifierType& identifier_type,
213 const uint8_t* identifier_begin, const size_t identifier_len) = 0;
214
226 virtual bool del6(const SubnetID& subnet_id,
227 const Host::IdentifierType& identifier_type,
228 const uint8_t* identifier_begin, const size_t identifier_len) = 0;
229
235 virtual std::string getType() const = 0;
236
241 virtual void commit() {};
242
247 virtual void rollback() {};
248};
249
251typedef boost::shared_ptr<BaseHostDataSource> HostDataSourcePtr;
252
254typedef std::vector<HostDataSourcePtr> HostDataSourceList;
255
256}
257}
258
259#endif // BASE_HOST_DATA_SOURCE_H
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Exception thrown when invalid IP address has been specified for Host.
BadHostAddress(const char *file, size_t line, const char *what)
Base interface for the classes implementing simple data source for host reservations.
virtual std::string getType() const =0
Return backend type.
virtual void add(const HostPtr &host)=0
Adds a new host to the collection.
virtual void commit()
Commit Transactions.
virtual bool del(const SubnetID &subnet_id, const asiolink::IOAddress &addr)=0
Attempts to delete a host by (subnet-id, address)
virtual ConstHostPtr get4(const SubnetID &subnet_id, const asiolink::IOAddress &address) const =0
Returns a host connected to the IPv4 subnet and having a reservation for a specified IPv4 address.
virtual ConstHostPtr get4(const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const =0
Returns a host connected to the IPv4 subnet.
virtual bool del6(const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len)=0
Attempts to delete a host by (subnet-id6, identifier, identifier-type)
virtual ConstHostPtr get6(const SubnetID &subnet_id, const asiolink::IOAddress &address) const =0
Returns a host connected to the IPv6 subnet and having a reservation for a specified IPv6 address or ...
IdType
Specifies the type of an identifier.
virtual ConstHostCollection getAll4(const asiolink::IOAddress &address) const =0
Returns a collection of hosts using the specified IPv4 address.
virtual bool del4(const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len)=0
Attempts to delete a host by (subnet-id4, identifier, identifier-type)
virtual ConstHostPtr get6(const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const =0
Returns a host connected to the IPv6 subnet.
virtual ConstHostPtr get6(const asiolink::IOAddress &prefix, const uint8_t prefix_len) const =0
Returns a host using the specified IPv6 prefix.
virtual ~BaseHostDataSource()
Default destructor implementation.
virtual ConstHostCollection getAll(const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const =0
Return all hosts connected to any subnet for which reservations have been made using a specified iden...
virtual void rollback()
Rollback Transactions.
Exception thrown when the duplicate Host object is detected.
DuplicateHost(const char *file, size_t line, const char *what)
IdentifierType
Type of the host identifier.
Definition: host.h:252
Exception thrown when an address is already reserved by a Host object (DuplicateHost is same identity...
ReservedAddress(const char *file, size_t line, const char *what)
boost::shared_ptr< BaseHostDataSource > HostDataSourcePtr
HostDataSource pointer.
boost::shared_ptr< Host > HostPtr
Pointer to the Host object.
Definition: host.h:725
std::vector< ConstHostPtr > ConstHostCollection
Collection of the const Host objects.
Definition: host.h:731
std::vector< HostDataSourcePtr > HostDataSourceList
HostDataSource list.
uint32_t SubnetID
Unique identifier for a subnet (both v4 and v6)
Definition: lease.h:24
boost::shared_ptr< const Host > ConstHostPtr
Const pointer to the Host object.
Definition: host.h:728
Defines the logger used by the top-level component of kea-dhcp-ddns.