Kea 1.5.0
d2_client_cfg.h
Go to the documentation of this file.
1// Copyright (C) 2013-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 D2_CLIENT_CFG_H
8#define D2_CLIENT_CFG_H
9
14
15#include <asiolink/io_address.h>
16#include <cc/cfg_to_element.h>
17#include <cc/user_context.h>
18#include <dhcp_ddns/ncr_io.h>
20#include <util/strutil.h>
21
22#include <boost/shared_ptr.hpp>
23
24#include <stdint.h>
25#include <string>
26#include <vector>
27
28namespace isc {
29namespace dhcp {
30
31
35public:
36
42 D2ClientError(const char* file, size_t line, const char* what)
43 : isc::Exception(file, line, what) {}
44};
45
46
54public:
56 static const char* DFT_SERVER_IP;
57 static const size_t DFT_SERVER_PORT;
58 static const char* DFT_V4_SENDER_IP;
59 static const char* DFT_V6_SENDER_IP;
60 static const size_t DFT_SENDER_PORT;
61 static const size_t DFT_MAX_QUEUE_SIZE;
62 static const char* DFT_NCR_PROTOCOL;
63 static const char* DFT_NCR_FORMAT;
64 static const bool DFT_OVERRIDE_NO_UPDATE;
65 static const bool DFT_OVERRIDE_CLIENT_UPDATE;
66 static const char* DFT_REPLACE_CLIENT_NAME_MODE;
67 static const char* DFT_GENERATED_PREFIX;
68 static const char* DFT_HOSTNAME_CHAR_SET;
70
77 };
78
108 D2ClientConfig(const bool enable_updates,
109 const isc::asiolink::IOAddress& server_ip,
110 const size_t server_port,
111 const isc::asiolink::IOAddress& sender_ip,
112 const size_t sender_port,
113 const size_t max_queue_size,
114 const dhcp_ddns::NameChangeProtocol& ncr_protocol,
115 const dhcp_ddns::NameChangeFormat& ncr_format,
116 const bool override_no_update,
117 const bool override_client_update,
118 const ReplaceClientNameMode replace_client_name_mode,
119 const std::string& generated_prefix,
120 const std::string& qualifying_suffix,
121 const std::string& hostname_char_set,
122 const std::string& hostname_char_replacement);
123
124
128
130 virtual ~D2ClientConfig();
131
133 bool getEnableUpdates() const {
134 return(enable_updates_);
135 }
136
139 return(server_ip_);
140 }
141
143 size_t getServerPort() const {
144 return(server_port_);
145 }
146
149 return(sender_ip_);
150 }
151
153 size_t getSenderPort() const {
154 return(sender_port_);
155 }
156
158 size_t getMaxQueueSize() const {
159 return(max_queue_size_);
160 }
161
164 return(ncr_protocol_);
165 }
166
169 return(ncr_format_);
170 }
171
173 bool getOverrideNoUpdate() const {
174 return(override_no_update_);
175 }
176
179 return(override_client_update_);
180 }
181
184 return(replace_client_name_mode_);
185 }
186
188 const std::string& getGeneratedPrefix() const {
189 return(generated_prefix_);
190 }
191
193 const std::string& getQualifyingSuffix() const {
194 return(qualifying_suffix_);
195 }
196
198 const std::string& getHostnameCharSet() const {
199 return(hostname_char_set_);
200 }
201
203 const std::string& getHostnameCharReplacement() const {
204 return(hostname_char_replacement_);
205 }
206
210 return(hostname_sanitizer_);
211 }
212
214 bool operator == (const D2ClientConfig& other) const;
215
217 bool operator != (const D2ClientConfig& other) const;
218
220 std::string toText() const;
221
229 void enableUpdates(bool enable);
230
241 static ReplaceClientNameMode stringToReplaceClientNameMode(const std::string& mode_str);
242
249 static std::string replaceClientNameModeToString(const ReplaceClientNameMode& mode);
250
254 virtual isc::data::ElementPtr toElement() const;
255
256protected:
262 virtual void validateContents();
263
264private:
266 bool enable_updates_;
267
269 isc::asiolink::IOAddress server_ip_;
270
272 size_t server_port_;
273
275 isc::asiolink::IOAddress sender_ip_;
276
278 size_t sender_port_;
279
281 size_t max_queue_size_;
282
285 dhcp_ddns::NameChangeProtocol ncr_protocol_;
286
289 dhcp_ddns::NameChangeFormat ncr_format_;
290
293 bool override_no_update_;
294
296 bool override_client_update_;
297
299 ReplaceClientNameMode replace_client_name_mode_;
300
302 std::string generated_prefix_;
303
305 std::string qualifying_suffix_;
306
309 std::string hostname_char_set_;
310
313 std::string hostname_char_replacement_;
314
316 util::str::StringSanitizerPtr hostname_sanitizer_;
317};
318
319std::ostream&
320operator<<(std::ostream& os, const D2ClientConfig& config);
321
323typedef boost::shared_ptr<D2ClientConfig> D2ClientConfigPtr;
324
325} // namespace isc
326} // namespace dhcp
327
328#endif
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.
Acts as a storage vault for D2 client configuration.
Definition: d2_client_cfg.h:53
std::string toText() const
Generates a string representation of the class contents.
bool getEnableUpdates() const
Return whether or not DHCP-DDNS updating is enabled.
size_t getServerPort() const
Return the IP port of kea-dhcp-ddns.
static const bool DFT_OVERRIDE_CLIENT_UPDATE
Definition: d2_client_cfg.h:65
static const char * DFT_NCR_FORMAT
Definition: d2_client_cfg.h:63
static ReplaceClientNameMode stringToReplaceClientNameMode(const std::string &mode_str)
Converts labels to ReplaceClientNameMode enum values.
const std::string & getHostnameCharSet() const
Return the char set regexp used to sanitize client hostnames.
ReplaceClientNameMode
Defines the client name replacement modes.
Definition: d2_client_cfg.h:72
static std::string replaceClientNameModeToString(const ReplaceClientNameMode &mode)
Converts NameChangeFormat enums to text labels.
static const char * DFT_V4_SENDER_IP
Definition: d2_client_cfg.h:58
ReplaceClientNameMode getReplaceClientNameMode() const
Return mode of replacement to use regarding client's client's domain-name.
static const size_t DFT_SENDER_PORT
Definition: d2_client_cfg.h:60
const std::string & getHostnameCharReplacement() const
Return the invalid char replacement used to sanitize client hostnames.
const dhcp_ddns::NameChangeProtocol & getNcrProtocol() const
Return the socket protocol to use with kea-dhcp-ddns.
virtual void validateContents()
Validates member values.
size_t getMaxQueueSize() const
Return Maximum sender queue size.
const dhcp_ddns::NameChangeFormat & getNcrFormat() const
Return the kea-dhcp-ddns request format.
const std::string & getGeneratedPrefix() const
Return the prefix to use when generating domain-names.
bool operator==(const D2ClientConfig &other) const
Compares two D2ClientConfigs for equality.
static const char * DFT_HOSTNAME_CHAR_REPLACEMENT
Definition: d2_client_cfg.h:69
const isc::asiolink::IOAddress & getServerIp() const
Return the IP address of kea-dhcp-ddns (IPv4 or IPv6).
static const char * DFT_NCR_PROTOCOL
Definition: d2_client_cfg.h:62
void enableUpdates(bool enable)
Sets enable-updates flag to the given value.
util::str::StringSanitizerPtr getHostnameSanitizer() const
Return pointer to compiled regular expression string sanitizer Will be empty if hostname-char-set is ...
const std::string & getQualifyingSuffix() const
Return the suffix to use to qualify partial domain-names.
static const bool DFT_OVERRIDE_NO_UPDATE
Definition: d2_client_cfg.h:64
virtual ~D2ClientConfig()
Destructor.
bool getOverrideClientUpdate() const
Return if updates are done even when clients request delegation.
static const char * DFT_SERVER_IP
Default configuration constants.
Definition: d2_client_cfg.h:56
size_t getSenderPort() const
Return the IP port client should use to send.
bool getOverrideNoUpdate() const
Return if updates are done even if clients request no updates.
static const char * DFT_V6_SENDER_IP
Definition: d2_client_cfg.h:59
const isc::asiolink::IOAddress & getSenderIp() const
Return the IP address client should use to send.
bool operator!=(const D2ClientConfig &other) const
Compares two D2ClientConfigs for inequality.
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
static const size_t DFT_SERVER_PORT
Definition: d2_client_cfg.h:57
static const char * DFT_GENERATED_PREFIX
Definition: d2_client_cfg.h:67
static const char * DFT_REPLACE_CLIENT_NAME_MODE
Definition: d2_client_cfg.h:66
static const char * DFT_HOSTNAME_CHAR_SET
Definition: d2_client_cfg.h:68
static const size_t DFT_MAX_QUEUE_SIZE
Definition: d2_client_cfg.h:61
D2ClientConfig()
Default constructor The default constructor creates an instance that has updates disabled.
An exception that is thrown if an error occurs while configuring the D2 DHCP DDNS client.
Definition: d2_client_cfg.h:34
D2ClientError(const char *file, size_t line, const char *what)
constructor
Definition: d2_client_cfg.h:42
boost::shared_ptr< Element > ElementPtr
Definition: data.h:22
NameChangeFormat
Defines the list of data wire formats supported.
Definition: ncr_msg.h:60
NameChangeProtocol
Defines the list of socket protocols supported.
Definition: ncr_io.h:66
boost::shared_ptr< D2ClientConfig > D2ClientConfigPtr
Defines a pointer for D2ClientConfig instances.
boost::shared_ptr< StringSanitizer > StringSanitizerPtr
Definition: strutil.h:305
Defines the logger used by the top-level component of kea-dhcp-ddns.
This file defines abstract classes for exchanging NameChangeRequests.
Abstract class for configuration Cfg_* classes.
Base class for user context.
Definition: user_context.h:22