Kea: isc::dhcp::D2ClientConfig Class Reference

| Kea 3.2.0-git

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:
[legend]

## 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.
| 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.
virtual | ~D2ClientConfig ()
| Destructor.
void | enableUpdates (bool enable)
| Sets enable-updates flag to the given value.
bool | getEnableUpdates () const
| Return whether or not DHCP-DDNS updating is enabled.
size_t | getMaxQueueSize () const
| Return Maximum sender queue size.
const dhcp_ddns::NameChangeFormat & | getNcrFormat () const
| Return the kea-dhcp-ddns request format.
const dhcp_ddns::NameChangeProtocol & | getNcrProtocol () const
| Return the socket protocol to use with kea-dhcp-ddns.
const isc::asiolink::IOAddress & | getSenderIp () const
| Return the IP address client should use to send.
size_t | getSenderPort () const
| Return the IP port client should use to send.
const isc::asiolink::IOAddress & | getServerIp () const
| Return the IP address of kea-dhcp-ddns (IPv4 or IPv6).
size_t | getServerPort () const
| Return the IP port of kea-dhcp-ddns.
bool | operator!= (const D2ClientConfig &other) const
| Compares two D2ClientConfigs for inequality.
bool | operator== (const D2ClientConfig &other) const
| Compares two D2ClientConfigs for equality.
virtual isc::data::ElementPtr | toElement () const
| Unparse a configuration object.
std::string | toText () const
| Generates a string representation of the class contents.
virtual void | validateContents ()
| Validates member values.
Public Member Functions inherited from isc::data::UserContext
void | contextToElement (data::ElementPtr map) const
| Merge unparse a user_context object.
data::ConstElementPtr | getContext () const
| Returns const pointer to the user context.
void | setContext (const data::ConstElementPtr &ctx)
| Sets user context.
Public Member Functions inherited from isc::data::CfgToElement
virtual | ~CfgToElement ()
| Destructor.

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

## 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.
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 = "::"

## Additional Inherited Members
Protected Attributes inherited from isc::data::UserContext
data::ConstElementPtr | user_context_
| Pointer to the user context (may be NULL).

## 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 57 of file d2_client_cfg.h.

## Member Enumeration Documentation

## ◆ ReplaceClientNameMode

enum isc::dhcp::D2ClientConfig::ReplaceClientNameMode

Defines the client name replacement modes.

Enumerator
RCM_NEVER |
RCM_ALWAYS |
RCM_WHEN_PRESENT |
RCM_WHEN_NOT_PRESENT |

Definition at line 76 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 )

Constructor.

Parameters

  enable_updates | Enables DHCP-DDNS updates
  server_ip | IP address of the kea-dhcp-ddns server (IPv4 or IPv6)
  server_port | IP port of the kea-dhcp-ddns server
  sender_ip | IP address of the kea-dhcp-ddns server (IPv4 or IPv6)
  sender_port | IP port of the kea-dhcp-ddns server
  max_queue_size | maximum NCRs allowed in sender's queue
  ncr_protocol | Socket protocol to use with kea-dhcp-ddns Currently only UDP is supported.
  ncr_format | Format of the kea-dhcp-ddns requests. Currently only JSON format is supported. `enable_updates` is mandatory, other parameters are optional.

Exceptions

  D2ClientError | if given an invalid protocol or format.

Definition at line 82 of file d2_client_cfg.cc.

References validateContents().

Referenced by operator!=(), and operator==().

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 103 of file d2_client_cfg.cc.

References DFT_MAX_QUEUE_SIZE, DFT_NCR_FORMAT, DFT_NCR_PROTOCOL, DFT_SENDER_PORT, DFT_SERVER_IP, DFT_SERVER_PORT, DFT_V4_SENDER_IP, and validateContents().

Here is the call graph for this function:

## ◆ ~D2ClientConfig()

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

Destructor.

Definition at line 115 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

  enable | boolean value to assign to the enable-updates flag

Definition at line 118 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 115 of file d2_client_cfg.h.

## ◆ getMaxQueueSize()

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

Return Maximum sender queue size.

Definition at line 140 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 150 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 145 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 130 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 135 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 120 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 125 of file d2_client_cfg.h.

## ◆ operator!=()

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

Compares two D2ClientConfigs for inequality.

Definition at line 167 of file d2_client_cfg.cc.

References D2ClientConfig().

Here is the call graph for this function:

## ◆ operator==()

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

Compares two D2ClientConfigs for equality.

Definition at line 155 of file d2_client_cfg.cc.

References D2ClientConfig().

Here is the call graph for this function:

## ◆ replaceClientNameModeToString()

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

Converts NameChangeFormat enums to text labels.

Parameters

  mode | enum 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.

References RCM_ALWAYS, RCM_NEVER, RCM_WHEN_NOT_PRESENT, and RCM_WHEN_PRESENT.

## ◆ stringToReplaceClientNameMode()

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

Converts labels to ReplaceClientNameMode enum values.

Parameters

  mode_str | text 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::BadValue | if 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, RCM_ALWAYS, RCM_NEVER, RCM_WHEN_NOT_PRESENT, and RCM_WHEN_PRESENT.

Referenced by isc::dhcp::Network::getDdnsReplaceClientNameMode(), and isc::dhcp::BaseNetworkParser::parseDdnsParameters().

## ◆ 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 191 of file d2_client_cfg.cc.

References isc::data::UserContext::contextToElement(), isc::data::Element::create(), isc::data::Element::createMap(), isc::dhcp_ddns::ncrFormatToString(), and isc::dhcp_ddns::ncrProtocolToString().

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 172 of file d2_client_cfg.cc.

## ◆ validateContents()

void isc::dhcp::D2ClientConfig::validateContents | ( |  | ) |
| virtual

Validates member values.

Method is used by the constructor to validate member contents.

Exceptions

  D2ClientError | if 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 123 of file d2_client_cfg.cc.

References isc::dhcp_ddns::FMT_JSON, isc_throw, isc::dhcp_ddns::NCR_UDP, isc::dhcp_ddns::ncrFormatToString(), and isc::dhcp_ddns::ncrProtocolToString().

Referenced by D2ClientConfig(), and 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 71 of file d2_client_cfg.h.

## ◆ DFT_HOSTNAME_CHAR_REPLACEMENT

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

Definition at line 73 of file d2_client_cfg.h.

## ◆ DFT_HOSTNAME_CHAR_SET

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

Definition at line 72 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 65 of file d2_client_cfg.h.

Referenced by D2ClientConfig().

## ◆ DFT_NCR_FORMAT

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

Definition at line 67 of file d2_client_cfg.h.

Referenced by D2ClientConfig().

## ◆ DFT_NCR_PROTOCOL

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

Definition at line 66 of file d2_client_cfg.h.

Referenced by D2ClientConfig().

## ◆ DFT_OVERRIDE_CLIENT_UPDATE

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

Definition at line 69 of file d2_client_cfg.h.

## ◆ DFT_OVERRIDE_NO_UPDATE

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

Definition at line 68 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 70 of file d2_client_cfg.h.

## ◆ DFT_SENDER_PORT

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

Definition at line 64 of file d2_client_cfg.h.

Referenced by D2ClientConfig().

## ◆ 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 60 of file d2_client_cfg.h.

Referenced by D2ClientConfig().

## ◆ DFT_SERVER_PORT

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

Definition at line 61 of file d2_client_cfg.h.

Referenced by D2ClientConfig().

## ◆ DFT_V4_SENDER_IP

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

Definition at line 62 of file d2_client_cfg.h.

Referenced by D2ClientConfig().

## ◆ DFT_V6_SENDER_IP

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

Definition at line 63 of file d2_client_cfg.h.

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

- d2_client_cfg.h
- d2_client_cfg.cc