Kea 3.3.3
d2_client_cfg.h
Go to the documentation of this file.
1// Copyright (C) 2013-2026 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>
21#include <util/optional.h>
22
23#include <cstdint>
24#include <string>
25
26#include <boost/shared_ptr.hpp>
27
28namespace isc {
29namespace dhcp {
30
34public:
35
41 D2ClientError(const char* file, size_t line, const char* what)
42 : isc::Exception(file, line, what) {}
43};
44
48
49
57public:
59 static const char* DFT_SERVER_IP;
60 static const size_t DFT_SERVER_PORT;
61 static const char* DFT_V4_SENDER_IP;
62 static const char* DFT_V6_SENDER_IP;
63 static const size_t DFT_SENDER_PORT;
64 static const size_t DFT_MAX_QUEUE_SIZE;
65 static const char* DFT_NCR_PROTOCOL;
66 static const char* DFT_NCR_FORMAT;
67 static const bool DFT_OVERRIDE_NO_UPDATE;
68 static const bool DFT_OVERRIDE_CLIENT_UPDATE;
69 static const char* DFT_REPLACE_CLIENT_NAME_MODE;
70 static const char* DFT_GENERATED_PREFIX;
71 static const char* DFT_HOSTNAME_CHAR_SET;
73
81
97 D2ClientConfig(const bool enable_updates,
98 const isc::asiolink::IOAddress& server_ip,
99 const size_t server_port,
100 const isc::asiolink::IOAddress& sender_ip,
101 const size_t sender_port,
102 const size_t max_queue_size,
103 const dhcp_ddns::NameChangeProtocol& ncr_protocol,
104 const dhcp_ddns::NameChangeFormat& ncr_format);
105
109
111 virtual ~D2ClientConfig();
112
114 bool getEnableUpdates() const {
115 return(enable_updates_);
116 }
117
120 return(server_ip_);
121 }
122
124 size_t getServerPort() const {
125 return(server_port_);
126 }
127
130 return(sender_ip_);
131 }
132
134 size_t getSenderPort() const {
135 return(sender_port_);
136 }
137
139 size_t getMaxQueueSize() const {
140 return(max_queue_size_);
141 }
142
145 return(ncr_protocol_);
146 }
147
150 return(ncr_format_);
151 }
152
154 bool operator == (const D2ClientConfig& other) const;
155
157 bool operator != (const D2ClientConfig& other) const;
158
160 std::string toText() const;
161
169 void enableUpdates(bool enable);
170
181 static ReplaceClientNameMode stringToReplaceClientNameMode(const std::string& mode_str);
182
189 static std::string replaceClientNameModeToString(const ReplaceClientNameMode& mode);
190
194 virtual isc::data::ElementPtr toElement() const;
195
201 virtual void validateContents();
202
203private:
205 bool enable_updates_;
206
208 isc::asiolink::IOAddress server_ip_;
209
211 size_t server_port_;
212
214 isc::asiolink::IOAddress sender_ip_;
215
217 size_t sender_port_;
218
220 size_t max_queue_size_;
221
224 dhcp_ddns::NameChangeProtocol ncr_protocol_;
225
228 dhcp_ddns::NameChangeFormat ncr_format_;
229};
230
231std::ostream&
232operator<<(std::ostream& os, const D2ClientConfig& config);
233
235typedef boost::shared_ptr<D2ClientConfig> D2ClientConfigPtr;
236
237} // namespace isc
238} // namespace dhcp
239
240#endif
This is a base class for exceptions thrown from the DNS library module.
Exception(const char *file, size_t line, const char *what)
Constructor for a given type for exceptions with file name and file line number.
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.
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
static const char * DFT_NCR_FORMAT
static ReplaceClientNameMode stringToReplaceClientNameMode(const std::string &mode_str)
Converts labels to ReplaceClientNameMode enum values.
static std::string replaceClientNameModeToString(const ReplaceClientNameMode &mode)
Converts NameChangeFormat enums to text labels.
static const char * DFT_V4_SENDER_IP
static const size_t DFT_SENDER_PORT
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.
bool operator==(const D2ClientConfig &other) const
Compares two D2ClientConfigs for equality.
static const char * DFT_HOSTNAME_CHAR_REPLACEMENT
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.
const isc::asiolink::IOAddress & getServerIp() const
Return the IP address of kea-dhcp-ddns (IPv4 or IPv6).
static const char * DFT_NCR_PROTOCOL
void enableUpdates(bool enable)
Sets enable-updates flag to the given value.
ReplaceClientNameMode
Defines the client name replacement modes.
static const bool DFT_OVERRIDE_NO_UPDATE
virtual ~D2ClientConfig()
Destructor.
static const char * DFT_SERVER_IP
Default configuration constants.
size_t getSenderPort() const
Return the IP port client should use to send.
static const char * DFT_V6_SENDER_IP
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
static const char * DFT_GENERATED_PREFIX
static const char * DFT_REPLACE_CLIENT_NAME_MODE
static const char * DFT_HOSTNAME_CHAR_SET
static const size_t DFT_MAX_QUEUE_SIZE
D2ClientConfig()
Default constructor The default constructor creates an instance that has updates disabled.
D2ClientError(const char *file, size_t line, const char *what)
constructor
boost::shared_ptr< Element > ElementPtr
Definition data.h:29
NameChangeProtocol
Defines the list of socket protocols supported.
Definition ncr_io.h:70
NameChangeFormat
Defines the list of data wire formats supported.
Definition ncr_msg.h:63
boost::shared_ptr< const CfgGlobals > ConstCfgGlobalsPtr
Const shared pointer to a CfgGlobals instance.
boost::shared_ptr< D2ClientConfig > D2ClientConfigPtr
Defines a pointer for D2ClientConfig instances.
std::function< ConstCfgGlobalsPtr()> FetchNetworkGlobalsFn
Callback function for D2ClientConfig that retrieves globally configured parameters.
Defines the logger used by the top-level component of kea-lfc.
This file defines abstract classes for exchanging NameChangeRequests.
Abstract class for configuration Cfg_* classes.
Base class for user context.