Kea: d2_client_cfg.h Source File

| Kea 3.2.0-git

d2_client_cfg.h
Go to the documentation of this file.
1// Copyright (C) 2013-2022 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>
19#include <dhcpsrv/cfg_globals.h>
20#include <exceptions/exceptions.h>
21#include <util/optional.h>
22
23#include <boost/shared_ptr.hpp>
24
25#include <stdint.h>
26#include <string>
27#include <vector>
28
29namespace isc {
30namespace dhcp {
31
34 class D2ClientError : public isc::Exception {
35public:
36
42 D2ClientError(const char* file, size_t line, const char* what)
43 : isc::Exception(file, line, what) {}
44};
45
48 typedef std::function<ConstCfgGlobalsPtr()> FetchNetworkGlobalsFn;
49
50
57 class D2ClientConfig : public data::UserContext, public isc::data::CfgToElement {
58public:
60 static const char* DFT_SERVER_IP;
61 static const size_t DFT_SERVER_PORT;
62 static const char* DFT_V4_SENDER_IP;
63 static const char* DFT_V6_SENDER_IP;
64 static const size_t DFT_SENDER_PORT;
65 static const size_t DFT_MAX_QUEUE_SIZE;
66 static const char* DFT_NCR_PROTOCOL;
67 static const char* DFT_NCR_FORMAT;
68 static const bool DFT_OVERRIDE_NO_UPDATE;
69 static const bool DFT_OVERRIDE_CLIENT_UPDATE;
70 static const char* DFT_REPLACE_CLIENT_NAME_MODE;
71 static const char* DFT_GENERATED_PREFIX;
72 static const char* DFT_HOSTNAME_CHAR_SET;
73 static const char* DFT_HOSTNAME_CHAR_REPLACEMENT;
74
76 enum ReplaceClientNameMode {
77 RCM_NEVER,
78 RCM_ALWAYS,
79 RCM_WHEN_PRESENT,
80 RCM_WHEN_NOT_PRESENT
81 };
82
98 D2ClientConfig(const bool enable_updates,
99 const isc::asiolink::IOAddress& server_ip,
100 const size_t server_port,
101 const isc::asiolink::IOAddress& sender_ip,
102 const size_t sender_port,
103 const size_t max_queue_size,
104 const dhcp_ddns::NameChangeProtocol& ncr_protocol,
105 const dhcp_ddns::NameChangeFormat& ncr_format);
106
109 D2ClientConfig();
110
112 virtual ~D2ClientConfig();
113
115 bool getEnableUpdates() const {
116 return(enable_updates_);
117 }
118
120 const isc::asiolink::IOAddress& getServerIp() const {
121 return(server_ip_);
122 }
123
125 size_t getServerPort() const {
126 return(server_port_);
127 }
128
130 const isc::asiolink::IOAddress& getSenderIp() const {
131 return(sender_ip_);
132 }
133
135 size_t getSenderPort() const {
136 return(sender_port_);
137 }
138
140 size_t getMaxQueueSize() const {
141 return(max_queue_size_);
142 }
143
145 const dhcp_ddns::NameChangeProtocol& getNcrProtocol() const {
146 return(ncr_protocol_);
147 }
148
150 const dhcp_ddns::NameChangeFormat& getNcrFormat() const {
151 return(ncr_format_);
152 }
153
155 bool operator == (const D2ClientConfig& other) const;
156
158 bool operator != (const D2ClientConfig& other) const;
159
161 std::string toText() const;
162
170 void enableUpdates(bool enable);
171
182 static ReplaceClientNameMode stringToReplaceClientNameMode(const std::string& mode_str);
183
190 static std::string replaceClientNameModeToString(const ReplaceClientNameMode& mode);
191
195 virtual isc::data::ElementPtr toElement() const;
196
202 virtual void validateContents();
203
204private:
206 bool enable_updates_;
207
209 isc::asiolink::IOAddress server_ip_;
210
212 size_t server_port_;
213
215 isc::asiolink::IOAddress sender_ip_;
216
218 size_t sender_port_;
219
221 size_t max_queue_size_;
222
225 dhcp_ddns::NameChangeProtocol ncr_protocol_;
226
229 dhcp_ddns::NameChangeFormat ncr_format_;
230};
231
232std::ostream&
233 operator<<(std::ostream& os, const D2ClientConfig& config);
234
236 typedef boost::shared_ptr<D2ClientConfig> D2ClientConfigPtr;
237
238} // namespace isc
239} // namespace dhcp
240
241#endif
cfg_globals.h
cfg_to_element.h
isc::Exception
This is a base class for exceptions thrown from the DNS library module.
Definition exceptions/exceptions.h:23
isc::Exception::Exception
Exception(const char *file, size_t line, const char *what)
Constructor for a given type for exceptions with file name and file line number.
Definition exceptions/exceptions.cc:17
isc::Exception::what
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Definition exceptions/exceptions.cc:32
isc::asiolink::IOAddress
The IOAddress class represents an IP addresses (version agnostic).
Definition io_address.h:53
isc::dhcp::D2ClientConfig
Acts as a storage vault for D2 client configuration.
Definition d2_client_cfg.h:57
isc::dhcp::D2ClientConfig::toText
std::string toText() const
Generates a string representation of the class contents.
Definition d2_client_cfg.cc:172
isc::dhcp::D2ClientConfig::getEnableUpdates
bool getEnableUpdates() const
Return whether or not DHCP-DDNS updating is enabled.
Definition d2_client_cfg.h:115
isc::dhcp::D2ClientConfig::getServerPort
size_t getServerPort() const
Return the IP port of kea-dhcp-ddns.
Definition d2_client_cfg.h:125
isc::dhcp::D2ClientConfig::DFT_OVERRIDE_CLIENT_UPDATE
static const bool DFT_OVERRIDE_CLIENT_UPDATE
Definition d2_client_cfg.h:69
isc::dhcp::D2ClientConfig::DFT_NCR_FORMAT
static const char * DFT_NCR_FORMAT
Definition d2_client_cfg.h:67
isc::dhcp::D2ClientConfig::stringToReplaceClientNameMode
static ReplaceClientNameMode stringToReplaceClientNameMode(const std::string &mode_str)
Converts labels to ReplaceClientNameMode enum values.
Definition d2_client_cfg.cc:41
isc::dhcp::D2ClientConfig::ReplaceClientNameMode
ReplaceClientNameMode
Defines the client name replacement modes.
Definition d2_client_cfg.h:76
isc::dhcp::D2ClientConfig::RCM_ALWAYS
@ RCM_ALWAYS
Definition d2_client_cfg.h:78
isc::dhcp::D2ClientConfig::RCM_NEVER
@ RCM_NEVER
Definition d2_client_cfg.h:77
isc::dhcp::D2ClientConfig::RCM_WHEN_NOT_PRESENT
@ RCM_WHEN_NOT_PRESENT
Definition d2_client_cfg.h:80
isc::dhcp::D2ClientConfig::RCM_WHEN_PRESENT
@ RCM_WHEN_PRESENT
Definition d2_client_cfg.h:79
isc::dhcp::D2ClientConfig::replaceClientNameModeToString
static std::string replaceClientNameModeToString(const ReplaceClientNameMode &mode)
Converts NameChangeFormat enums to text labels.
Definition d2_client_cfg.cc:63
isc::dhcp::D2ClientConfig::DFT_V4_SENDER_IP
static const char * DFT_V4_SENDER_IP
Definition d2_client_cfg.h:62
isc::dhcp::D2ClientConfig::DFT_SENDER_PORT
static const size_t DFT_SENDER_PORT
Definition d2_client_cfg.h:64
isc::dhcp::D2ClientConfig::getNcrProtocol
const dhcp_ddns::NameChangeProtocol & getNcrProtocol() const
Return the socket protocol to use with kea-dhcp-ddns.
Definition d2_client_cfg.h:145
isc::dhcp::D2ClientConfig::validateContents
virtual void validateContents()
Validates member values.
Definition d2_client_cfg.cc:123
isc::dhcp::D2ClientConfig::getMaxQueueSize
size_t getMaxQueueSize() const
Return Maximum sender queue size.
Definition d2_client_cfg.h:140
isc::dhcp::D2ClientConfig::getNcrFormat
const dhcp_ddns::NameChangeFormat & getNcrFormat() const
Return the kea-dhcp-ddns request format.
Definition d2_client_cfg.h:150
isc::dhcp::D2ClientConfig::operator==
bool operator==(const D2ClientConfig &other) const
Compares two D2ClientConfigs for equality.
Definition d2_client_cfg.cc:155
isc::dhcp::D2ClientConfig::DFT_HOSTNAME_CHAR_REPLACEMENT
static const char * DFT_HOSTNAME_CHAR_REPLACEMENT
Definition d2_client_cfg.h:73
isc::dhcp::D2ClientConfig::D2ClientConfig
D2ClientConfig(const bool enable_updates, const isc::asiolink::IOAddress &server_ip, const size_t server_port, const isc::asiolink::IOAddress &sender_ip, const size_t sender_port, const size_t max_queue_size, const dhcp_ddns::NameChangeProtocol &ncr_protocol, const dhcp_ddns::NameChangeFormat &ncr_format)
Constructor.
Definition d2_client_cfg.cc:82
isc::dhcp::D2ClientConfig::getServerIp
const isc::asiolink::IOAddress & getServerIp() const
Return the IP address of kea-dhcp-ddns (IPv4 or IPv6).
Definition d2_client_cfg.h:120
isc::dhcp::D2ClientConfig::DFT_NCR_PROTOCOL
static const char * DFT_NCR_PROTOCOL
Definition d2_client_cfg.h:66
isc::dhcp::D2ClientConfig::enableUpdates
void enableUpdates(bool enable)
Sets enable-updates flag to the given value.
Definition d2_client_cfg.cc:118
isc::dhcp::D2ClientConfig::DFT_OVERRIDE_NO_UPDATE
static const bool DFT_OVERRIDE_NO_UPDATE
Definition d2_client_cfg.h:68
isc::dhcp::D2ClientConfig::~D2ClientConfig
virtual ~D2ClientConfig()
Destructor.
Definition d2_client_cfg.cc:115
isc::dhcp::D2ClientConfig::DFT_SERVER_IP
static const char * DFT_SERVER_IP
Default configuration constants.
Definition d2_client_cfg.h:60
isc::dhcp::D2ClientConfig::getSenderPort
size_t getSenderPort() const
Return the IP port client should use to send.
Definition d2_client_cfg.h:135
isc::dhcp::D2ClientConfig::DFT_V6_SENDER_IP
static const char * DFT_V6_SENDER_IP
Definition d2_client_cfg.h:63
isc::dhcp::D2ClientConfig::getSenderIp
const isc::asiolink::IOAddress & getSenderIp() const
Return the IP address client should use to send.
Definition d2_client_cfg.h:130
isc::dhcp::D2ClientConfig::operator!=
bool operator!=(const D2ClientConfig &other) const
Compares two D2ClientConfigs for inequality.
Definition d2_client_cfg.cc:167
isc::dhcp::D2ClientConfig::toElement
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
Definition d2_client_cfg.cc:191
isc::dhcp::D2ClientConfig::DFT_SERVER_PORT
static const size_t DFT_SERVER_PORT
Definition d2_client_cfg.h:61
isc::dhcp::D2ClientConfig::DFT_GENERATED_PREFIX
static const char * DFT_GENERATED_PREFIX
Definition d2_client_cfg.h:71
isc::dhcp::D2ClientConfig::DFT_REPLACE_CLIENT_NAME_MODE
static const char * DFT_REPLACE_CLIENT_NAME_MODE
Definition d2_client_cfg.h:70
isc::dhcp::D2ClientConfig::DFT_HOSTNAME_CHAR_SET
static const char * DFT_HOSTNAME_CHAR_SET
Definition d2_client_cfg.h:72
isc::dhcp::D2ClientConfig::DFT_MAX_QUEUE_SIZE
static const size_t DFT_MAX_QUEUE_SIZE
Definition d2_client_cfg.h:65
isc::dhcp::D2ClientConfig::D2ClientConfig
D2ClientConfig()
Default constructor The default constructor creates an instance that has updates disabled.
Definition d2_client_cfg.cc:103
isc::dhcp::D2ClientError::D2ClientError
D2ClientError(const char *file, size_t line, const char *what)
constructor
Definition d2_client_cfg.h:42
exceptions.h
io_address.h
isc::asiolink::operator<<
std::ostream & operator<<(std::ostream &os, const IOAddress &address)
Insert the IOAddress as a string into stream.
Definition io_address.cc:131
isc::config
Definition command_interpreter.cc:23
isc::data::ElementPtr
boost::shared_ptr< Element > ElementPtr
Definition data.h:29
isc::dhcp_ddns::NameChangeFormat
NameChangeFormat
Defines the list of data wire formats supported.
Definition ncr_msg.h:59
isc::dhcp_ddns::NameChangeProtocol
NameChangeProtocol
Defines the list of socket protocols supported.
Definition ncr_io.h:69
isc::dhcp
Definition dhcp4/client_handler.cc:20
isc::dhcp::ConstCfgGlobalsPtr
boost::shared_ptr< const CfgGlobals > ConstCfgGlobalsPtr
Const shared pointer to a CfgGlobals instance.
Definition cfg_globals.h:176
isc::dhcp::D2ClientConfigPtr
boost::shared_ptr< D2ClientConfig > D2ClientConfigPtr
Defines a pointer for D2ClientConfig instances.
Definition d2_client_cfg.h:236
isc::dhcp::FetchNetworkGlobalsFn
std::function< ConstCfgGlobalsPtr()> FetchNetworkGlobalsFn
Callback function for D2ClientConfig that retrieves globally configured parameters.
Definition d2_client_cfg.h:48
isc::util::file
Definition filesystem.cc:29
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18
ncr_io.h
This file defines abstract classes for exchanging NameChangeRequests.
optional.h
isc::data::CfgToElement
Abstract class for configuration Cfg_* classes.
Definition cfg_to_element.h:29
isc::data::UserContext
Base class for user context.
Definition user_context.h:22
user_context.h