Kea  1.5.0
isc::dhcp::D2ClientConfig Class Reference

Acts as a storage vault for D2 client configuration. More...

#include <d2_client_cfg.h>

+ Inheritance diagram for isc::dhcp::D2ClientConfig:

Public Types

enum  ReplaceClientNameMode { RCM_NEVER, RCM_ALWAYS, RCM_WHEN_PRESENT, RCM_WHEN_NOT_PRESENT }
 Defines the client name replacement modes. More...
 

Public Member Functions

 D2ClientConfig ()
 Default constructor The default constructor creates an instance that has updates disabled. More...
 
 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, const bool override_no_update, const bool override_client_update, const ReplaceClientNameMode replace_client_name_mode, const std::string &generated_prefix, const std::string &qualifying_suffix, const std::string &hostname_char_set, const std::string &hostname_char_replacement)
 Constructor. More...
 
virtual ~D2ClientConfig ()
 Destructor. More...
 
void enableUpdates (bool enable)
 Sets enable-updates flag to the given value. More...
 
bool getEnableUpdates () const
 Return whether or not DHCP-DDNS updating is enabled. More...
 
const std::string & getGeneratedPrefix () const
 Return the prefix to use when generating domain-names. More...
 
const std::string & getHostnameCharReplacement () const
 Return the invalid char replacement used to sanitize client hostnames. More...
 
const std::string & getHostnameCharSet () const
 Return the char set regexp used to sanitize client hostnames. More...
 
util::str::StringSanitizerPtr getHostnameSanitizer () const
 Return pointer to compiled regular expression string sanitizer Will be empty if hostname-char-set is empty. More...
 
size_t getMaxQueueSize () const
 Return Maximum sender queue size. More...
 
const dhcp_ddns::NameChangeFormatgetNcrFormat () const
 Return the kea-dhcp-ddns request format. More...
 
const dhcp_ddns::NameChangeProtocolgetNcrProtocol () const
 Return the socket protocol to use with kea-dhcp-ddns. More...
 
bool getOverrideClientUpdate () const
 Return if updates are done even when clients request delegation. More...
 
bool getOverrideNoUpdate () const
 Return if updates are done even if clients request no updates. More...
 
const std::string & getQualifyingSuffix () const
 Return the suffix to use to qualify partial domain-names. More...
 
ReplaceClientNameMode getReplaceClientNameMode () const
 Return mode of replacement to use regarding client's client's domain-name. More...
 
const isc::asiolink::IOAddressgetSenderIp () const
 Return the IP address client should use to send. More...
 
size_t getSenderPort () const
 Return the IP port client should use to send. More...
 
const isc::asiolink::IOAddressgetServerIp () const
 Return the IP address of kea-dhcp-ddns (IPv4 or IPv6). More...
 
size_t getServerPort () const
 Return the IP port of kea-dhcp-ddns. More...
 
bool operator!= (const D2ClientConfig &other) const
 Compares two D2ClientConfigs for inequality. More...
 
bool operator== (const D2ClientConfig &other) const
 Compares two D2ClientConfigs for equality. More...
 
virtual isc::data::ElementPtr toElement () const
 Unparse a configuration object. More...
 
std::string toText () const
 Generates a string representation of the class contents. More...
 
- Public Member Functions inherited from isc::data::UserContext
void contextToElement (data::ElementPtr map) const
 Merge unparse a user_context object. More...
 
data::ConstElementPtr getContext () const
 Returns const pointer to the user context. More...
 
void setContext (const data::ConstElementPtr &ctx)
 Sets user context. More...
 
- Public Member Functions inherited from isc::data::CfgToElement
virtual ~CfgToElement ()
 Destructor. More...
 

Static Public Member Functions

static std::string replaceClientNameModeToString (const ReplaceClientNameMode &mode)
 Converts NameChangeFormat enums to text labels. More...
 
static ReplaceClientNameMode stringToReplaceClientNameMode (const std::string &mode_str)
 Converts labels to ReplaceClientNameMode enum values. More...
 
- Static Public Member Functions inherited from isc::data::UserContext
static data::ElementPtr toElement (data::ConstElementPtr map)
 Copy extracting comments an Element map. More...
 

Static Public Attributes

static const char * DFT_GENERATED_PREFIX = "myhost"
 
static const char * DFT_HOSTNAME_CHAR_REPLACEMENT = ""
 
static const char * DFT_HOSTNAME_CHAR_SET = ""
 
static const size_t DFT_MAX_QUEUE_SIZE = 1024
 
static const char * DFT_NCR_FORMAT = "JSON"
 
static const char * DFT_NCR_PROTOCOL = "UDP"
 
static const bool DFT_OVERRIDE_CLIENT_UPDATE = false
 
static const bool DFT_OVERRIDE_NO_UPDATE = false
 
static const char * DFT_REPLACE_CLIENT_NAME_MODE = "NEVER"
 
static const size_t DFT_SENDER_PORT = 0
 
static const char * DFT_SERVER_IP = "127.0.0.1"
 Default configuration constants. More...
 
static const size_t DFT_SERVER_PORT = 53001
 
static const char * DFT_V4_SENDER_IP = "0.0.0.0"
 
static const char * DFT_V6_SENDER_IP = "::"
 

Protected Member Functions

virtual void validateContents ()
 Validates member values. More...
 

Additional Inherited Members

- Protected Attributes inherited from isc::data::UserContext
data::ConstElementPtr user_context_
 Pointer to the user context (may be NULL) More...
 

Detailed Description

Acts as a storage vault for D2 client configuration.

A simple container class for storing and retrieving the configuration parameters associated with DHCP-DDNS and acting as a client of D2. Instances of this class may be constructed through configuration parsing.

Definition at line 53 of file d2_client_cfg.h.

Member Enumeration Documentation

◆ ReplaceClientNameMode

Defines the client name replacement modes.

Enumerator
RCM_NEVER 
RCM_ALWAYS 
RCM_WHEN_PRESENT 
RCM_WHEN_NOT_PRESENT 

Definition at line 72 of file d2_client_cfg.h.

Constructor & Destructor Documentation

◆ D2ClientConfig() [1/2]

isc::dhcp::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,
const bool  override_no_update,
const bool  override_client_update,
const ReplaceClientNameMode  replace_client_name_mode,
const std::string &  generated_prefix,
const std::string &  qualifying_suffix,
const std::string &  hostname_char_set,
const std::string &  hostname_char_replacement 
)

Constructor.

Parameters
enable_updatesEnables DHCP-DDNS updates
server_ipIP address of the kea-dhcp-ddns server (IPv4 or IPv6)
server_portIP port of the kea-dhcp-ddns server
sender_ipIP address of the kea-dhcp-ddns server (IPv4 or IPv6)
sender_portIP port of the kea-dhcp-ddns server
max_queue_sizemaximum NCRs allowed in sender's queue
ncr_protocolSocket protocol to use with kea-dhcp-ddns Currently only UDP is supported.
ncr_formatFormat of the kea-dhcp-ddns requests. Currently only JSON format is supported.
override_no_updateEnables updates, even if clients request no updates.
override_client_updatePerform updates, even if client requested delegation.
replace_client_name_modeenables replacement of the domain-name supplied by the client with a generated name.
generated_prefixPrefix to use when generating domain-names.
qualifying_suffixSuffix to use to qualify partial domain-names.
hostname_char_setregular expression string which describes invalid characters to be scrubbed from client host names
hostname_char_replacementstring of zero or more characters to replace invalid chars when sanitizing client host names

enable_updates is mandatory, qualifying_suffix is mandatory when updates are enabled, other parameters are optional.

Exceptions
D2ClientErrorif given an invalid protocol or format.

Definition at line 82 of file d2_client_cfg.cc.

References validateContents().

+ Here is the call graph for this function:

◆ D2ClientConfig() [2/2]

isc::dhcp::D2ClientConfig::D2ClientConfig ( )

Default constructor The default constructor creates an instance that has updates disabled.

Definition at line 118 of file d2_client_cfg.cc.

References validateContents().

+ Here is the call graph for this function:

◆ ~D2ClientConfig()

isc::dhcp::D2ClientConfig::~D2ClientConfig ( )
virtual

Destructor.

Definition at line 138 of file d2_client_cfg.cc.

Member Function Documentation

◆ enableUpdates()

void isc::dhcp::D2ClientConfig::enableUpdates ( bool  enable)

Sets enable-updates flag to the given value.

This is the only value that may be altered outside the constructor as it may be desirable to toggle it off and on when dealing with D2 IO errors.

Parameters
enableboolean value to assign to the enable-updates flag

Definition at line 141 of file d2_client_cfg.cc.

◆ getEnableUpdates()

bool isc::dhcp::D2ClientConfig::getEnableUpdates ( ) const
inline

Return whether or not DHCP-DDNS updating is enabled.

Definition at line 133 of file d2_client_cfg.h.

◆ getGeneratedPrefix()

const std::string& isc::dhcp::D2ClientConfig::getGeneratedPrefix ( ) const
inline

Return the prefix to use when generating domain-names.

Definition at line 188 of file d2_client_cfg.h.

◆ getHostnameCharReplacement()

const std::string& isc::dhcp::D2ClientConfig::getHostnameCharReplacement ( ) const
inline

Return the invalid char replacement used to sanitize client hostnames.

Definition at line 203 of file d2_client_cfg.h.

◆ getHostnameCharSet()

const std::string& isc::dhcp::D2ClientConfig::getHostnameCharSet ( ) const
inline

Return the char set regexp used to sanitize client hostnames.

Definition at line 198 of file d2_client_cfg.h.

◆ getHostnameSanitizer()

util::str::StringSanitizerPtr isc::dhcp::D2ClientConfig::getHostnameSanitizer ( ) const
inline

Return pointer to compiled regular expression string sanitizer Will be empty if hostname-char-set is empty.

Definition at line 209 of file d2_client_cfg.h.

◆ getMaxQueueSize()

size_t isc::dhcp::D2ClientConfig::getMaxQueueSize ( ) const
inline

Return Maximum sender queue size.

Definition at line 158 of file d2_client_cfg.h.

◆ getNcrFormat()

const dhcp_ddns::NameChangeFormat& isc::dhcp::D2ClientConfig::getNcrFormat ( ) const
inline

Return the kea-dhcp-ddns request format.

Definition at line 168 of file d2_client_cfg.h.

◆ getNcrProtocol()

const dhcp_ddns::NameChangeProtocol& isc::dhcp::D2ClientConfig::getNcrProtocol ( ) const
inline

Return the socket protocol to use with kea-dhcp-ddns.

Definition at line 163 of file d2_client_cfg.h.

◆ getOverrideClientUpdate()

bool isc::dhcp::D2ClientConfig::getOverrideClientUpdate ( ) const
inline

Return if updates are done even when clients request delegation.

Definition at line 178 of file d2_client_cfg.h.

◆ getOverrideNoUpdate()

bool isc::dhcp::D2ClientConfig::getOverrideNoUpdate ( ) const
inline

Return if updates are done even if clients request no updates.

Definition at line 173 of file d2_client_cfg.h.

◆ getQualifyingSuffix()

const std::string& isc::dhcp::D2ClientConfig::getQualifyingSuffix ( ) const
inline

Return the suffix to use to qualify partial domain-names.

Definition at line 193 of file d2_client_cfg.h.

◆ getReplaceClientNameMode()

ReplaceClientNameMode isc::dhcp::D2ClientConfig::getReplaceClientNameMode ( ) const
inline

Return mode of replacement to use regarding client's client's domain-name.

Definition at line 183 of file d2_client_cfg.h.

◆ getSenderIp()

const isc::asiolink::IOAddress& isc::dhcp::D2ClientConfig::getSenderIp ( ) const
inline

Return the IP address client should use to send.

Definition at line 148 of file d2_client_cfg.h.

◆ getSenderPort()

size_t isc::dhcp::D2ClientConfig::getSenderPort ( ) const
inline

Return the IP port client should use to send.

Definition at line 153 of file d2_client_cfg.h.

◆ getServerIp()

const isc::asiolink::IOAddress& isc::dhcp::D2ClientConfig::getServerIp ( ) const
inline

Return the IP address of kea-dhcp-ddns (IPv4 or IPv6).

Definition at line 138 of file d2_client_cfg.h.

◆ getServerPort()

size_t isc::dhcp::D2ClientConfig::getServerPort ( ) const
inline

Return the IP port of kea-dhcp-ddns.

Definition at line 143 of file d2_client_cfg.h.

◆ operator!=()

bool isc::dhcp::D2ClientConfig::operator!= ( const D2ClientConfig other) const

Compares two D2ClientConfigs for inequality.

Definition at line 207 of file d2_client_cfg.cc.

◆ operator==()

bool isc::dhcp::D2ClientConfig::operator== ( const D2ClientConfig other) const

Compares two D2ClientConfigs for equality.

Definition at line 188 of file d2_client_cfg.cc.

◆ replaceClientNameModeToString()

std::string isc::dhcp::D2ClientConfig::replaceClientNameModeToString ( const ReplaceClientNameMode mode)
static

Converts NameChangeFormat enums to text labels.

Parameters
modeenum value to convert to label
Returns
std:string containing the text label if the value is valid, or "unknown" if not.

Definition at line 63 of file d2_client_cfg.cc.

Referenced by toElement(), and toText().

◆ stringToReplaceClientNameMode()

D2ClientConfig::ReplaceClientNameMode isc::dhcp::D2ClientConfig::stringToReplaceClientNameMode ( const std::string &  mode_str)
static

Converts labels to ReplaceClientNameMode enum values.

Parameters
mode_strtext to convert to an enum. Valid string values: "never", "always", "when-present", "when-not-present" (case-insensitive)
Returns
NameChangeFormat value which maps to the given string.
Exceptions
isc::BadValueif given a string value which does not map to an enum value.

Definition at line 41 of file d2_client_cfg.cc.

References isc_throw.

◆ toElement()

ElementPtr isc::dhcp::D2ClientConfig::toElement ( ) const
virtual

Unparse a configuration object.

Returns
a pointer to unparsed configuration

Implements isc::data::CfgToElement.

Definition at line 240 of file d2_client_cfg.cc.

References isc::data::UserContext::contextToElement(), isc::dhcp_ddns::ncrFormatToString(), isc::dhcp_ddns::ncrProtocolToString(), replaceClientNameModeToString(), and isc::asiolink::IOAddress::toText().

+ Here is the call graph for this function:

◆ toText()

std::string isc::dhcp::D2ClientConfig::toText ( ) const

Generates a string representation of the class contents.

Definition at line 212 of file d2_client_cfg.cc.

References isc::dhcp_ddns::ncrFormatToString(), isc::dhcp_ddns::ncrProtocolToString(), replaceClientNameModeToString(), and isc::asiolink::IOAddress::toText().

Referenced by isc::dhcp::operator<<().

+ Here is the call graph for this function:

◆ validateContents()

void isc::dhcp::D2ClientConfig::validateContents ( )
protectedvirtual

Validates member values.

Method is used by the constructor to validate member contents.

Exceptions
D2ClientErrorif given an invalid protocol or format.
Todo:
perhaps more validation we should do yet? Are there any invalid combinations of options we need to test against?

Definition at line 146 of file d2_client_cfg.cc.

References isc::dhcp_ddns::FMT_JSON, isc::asiolink::IOAddress::getFamily(), isc_throw, isc::asiolink::IOAddress::isV4(), isc::dhcp_ddns::NCR_UDP, isc::dhcp_ddns::ncrFormatToString(), isc::dhcp_ddns::ncrProtocolToString(), and isc::asiolink::IOAddress::toText().

Referenced by D2ClientConfig().

+ Here is the call graph for this function:

Member Data Documentation

◆ DFT_GENERATED_PREFIX

const char * isc::dhcp::D2ClientConfig::DFT_GENERATED_PREFIX = "myhost"
static

Definition at line 67 of file d2_client_cfg.h.

◆ DFT_HOSTNAME_CHAR_REPLACEMENT

const char * isc::dhcp::D2ClientConfig::DFT_HOSTNAME_CHAR_REPLACEMENT = ""
static

Definition at line 69 of file d2_client_cfg.h.

◆ DFT_HOSTNAME_CHAR_SET

const char * isc::dhcp::D2ClientConfig::DFT_HOSTNAME_CHAR_SET = ""
static

Definition at line 68 of file d2_client_cfg.h.

◆ DFT_MAX_QUEUE_SIZE

const size_t isc::dhcp::D2ClientConfig::DFT_MAX_QUEUE_SIZE = 1024
static

Definition at line 61 of file d2_client_cfg.h.

◆ DFT_NCR_FORMAT

const char * isc::dhcp::D2ClientConfig::DFT_NCR_FORMAT = "JSON"
static

Definition at line 63 of file d2_client_cfg.h.

◆ DFT_NCR_PROTOCOL

const char * isc::dhcp::D2ClientConfig::DFT_NCR_PROTOCOL = "UDP"
static

Definition at line 62 of file d2_client_cfg.h.

◆ DFT_OVERRIDE_CLIENT_UPDATE

const bool isc::dhcp::D2ClientConfig::DFT_OVERRIDE_CLIENT_UPDATE = false
static

Definition at line 65 of file d2_client_cfg.h.

◆ DFT_OVERRIDE_NO_UPDATE

const bool isc::dhcp::D2ClientConfig::DFT_OVERRIDE_NO_UPDATE = false
static

Definition at line 64 of file d2_client_cfg.h.

◆ DFT_REPLACE_CLIENT_NAME_MODE

const char * isc::dhcp::D2ClientConfig::DFT_REPLACE_CLIENT_NAME_MODE = "NEVER"
static

Definition at line 66 of file d2_client_cfg.h.

◆ DFT_SENDER_PORT

const size_t isc::dhcp::D2ClientConfig::DFT_SENDER_PORT = 0
static

Definition at line 60 of file d2_client_cfg.h.

◆ DFT_SERVER_IP

const char * isc::dhcp::D2ClientConfig::DFT_SERVER_IP = "127.0.0.1"
static

Default configuration constants.

These values need to match those used in D2ClientConfigParser::SimpleDefaults.

Definition at line 56 of file d2_client_cfg.h.

◆ DFT_SERVER_PORT

const size_t isc::dhcp::D2ClientConfig::DFT_SERVER_PORT = 53001
static

Definition at line 57 of file d2_client_cfg.h.

◆ DFT_V4_SENDER_IP

const char * isc::dhcp::D2ClientConfig::DFT_V4_SENDER_IP = "0.0.0.0"
static

Definition at line 58 of file d2_client_cfg.h.

◆ DFT_V6_SENDER_IP

const char * isc::dhcp::D2ClientConfig::DFT_V6_SENDER_IP = "::"
static

Definition at line 59 of file d2_client_cfg.h.


The documentation for this class was generated from the following files: