Kea 1.5.0
query_filter.h
Go to the documentation of this file.
1// Copyright (C) 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 QUERY_FILTER_H
8#define QUERY_FILTER_H
9
10#include <ha_config.h>
11#include <dhcp/pkt4.h>
12#include <dhcp/pkt6.h>
13#include <cstdint>
14#include <map>
15#include <vector>
16#include <set>
17#include <string>
18
19namespace isc {
20namespace ha {
21
58public:
59
78 explicit QueryFilter(const HAConfigPtr& config);
79
87 void serveScope(const std::string& scope_name);
88
96 void serveScopeOnly(const std::string& scope_name);
97
103 void serveScopes(const std::vector<std::string>& scopes);
104
109 void serveDefaultScopes();
110
118 void serveFailoverScopes();
119
121 void serveNoScopes();
122
128 bool amServingScope(const std::string& scope_name) const;
129
133 std::set<std::string> getServedScopes() const;
134
149 bool inScope(const dhcp::Pkt4Ptr& query4, std::string& scope_class) const;
150
165 bool inScope(const dhcp::Pkt6Ptr& query6, std::string& scope_class) const;
166
167private:
168
181 template<typename QueryPtrType>
182 bool inScopeInternal(const QueryPtrType& query, std::string& scope_class) const;
183
184protected:
185
198 int loadBalance(const dhcp::Pkt4Ptr& query4) const;
199
212 int loadBalance(const dhcp::Pkt6Ptr& query6) const;
213
224 uint8_t loadBalanceHash(const uint8_t* key, const size_t key_len) const;
225
231 void validateScopeName(const std::string& scope_name) const;
232
247 std::string makeScopeClass(const std::string& scope_name) const;
248
251
253 std::vector<HAConfig::PeerConfigPtr> peers_;
254
257 std::map<std::string, bool> scopes_;
258
261};
262
263} // end of namespace isc::ha
264} // end of namespace isc
265
266#endif // QUERY_FILTER_H
DHCP query filtering class.
Definition: query_filter.h:57
void serveScopes(const std::vector< std::string > &scopes)
Enables selected scopes.
bool inScope(const dhcp::Pkt4Ptr &query4, std::string &scope_class) const
Checks if this server should process the DHCPv4 query.
bool amServingScope(const std::string &scope_name) const
Checks if this server instance is configured to process traffic belonging to a particular scope.
std::string makeScopeClass(const std::string &scope_name) const
Returns scope class name for the specified scope name.
void serveFailoverScopes()
Enable scopes required in failover case.
uint8_t loadBalanceHash(const uint8_t *key, const size_t key_len) const
Compute load balancing hash.
void validateScopeName(const std::string &scope_name) const
Checks if the scope name matches a name of any of the configured servers.
int active_servers_
Number of the active servers in the given HA mode.
Definition: query_filter.h:260
HAConfigPtr config_
Pointer to the HA configuration.
Definition: query_filter.h:250
void serveScopeOnly(const std::string &scope_name)
Enable scope and disable all other scopes.
int loadBalance(const dhcp::Pkt4Ptr &query4) const
Performs load balancing of the DHCPv4 queries.
void serveDefaultScopes()
Serve default scopes for the given HA mode.
void serveNoScopes()
Disables all scopes.
std::set< std::string > getServedScopes() const
Returns served scopes.
void serveScope(const std::string &scope_name)
Enable scope.
std::vector< HAConfig::PeerConfigPtr > peers_
Vector of HA peers configurations.
Definition: query_filter.h:253
std::map< std::string, bool > scopes_
Holds mapping of the scope names to the flag which indicates if the scopes are enabled or disabled.
Definition: query_filter.h:257
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
Definition: pkt4.h:546
boost::shared_ptr< Pkt6 > Pkt6Ptr
A pointer to Pkt6 packet.
Definition: pkt6.h:31
boost::shared_ptr< HAConfig > HAConfigPtr
Pointer to the High Availability configuration structure.
Definition: ha_config.h:509
Defines the logger used by the top-level component of kea-dhcp-ddns.