Kea: isc::d2::DNSClientImpl Class Reference

| Kea 3.0.2-git

isc::d2::DNSClientImpl Class Reference
Inheritance diagram for isc::d2::DNSClientImpl:
[legend]

## Public Member Functions
| DNSClientImpl (D2UpdateMessagePtr &response_placeholder, DNSClient::Callback *callback, const DNSClient::Protocol proto)
| Constructor.
virtual | ~DNSClientImpl ()
| Destructor.
void | doUpdate (const asiolink::IOServicePtr &io_service, const asiolink::IOAddress &ns_addr, const uint16_t ns_port, D2UpdateMessage &update, const unsigned int wait, const D2TsigKeyPtr &tsig_key)
| Starts asynchronous DNS Update using TSIG.
DNSClient::Status | getStatus (const asiodns::IOFetch::Result result)
| This function maps the IO error to the DNSClient error.
void | incrStats (const std::string &stat, bool update_key=true)
| This function updates statistics.
virtual void | operator() (asiodns::IOFetch::Result result)
| This internal callback is called when the DNS update message exchange is complete.
void | stop ()
| This function stops the IOFetch objects.
Public Member Functions inherited from isc::asiodns::IOFetch::Callback
| Callback ()=default
| Constructor.
virtual | ~Callback ()=default
| Destructor.

## Public Attributes
DNSClient::Callback * | callback_
| A caller-supplied external callback which is invoked when DNS message exchange is complete or interrupted.
util::OutputBufferPtr | in_buf_
| A buffer holding response from a DNS.
std::list< IOFetchPtr > | io_fetch_list_
| The list of IOFetch objects.
DNSClient::Protocol | proto_
| A Transport Layer protocol used to communicate with a DNS.
D2UpdateMessagePtr & | response_
| A caller-supplied object which will hold the parsed response from DNS.
bool | stopped_
| Flag which indicates that the client has been stopped.
dns::TSIGContextPtr | tsig_context_
| TSIG context used to sign outbound and verify inbound messages.
std::string | tsig_key_name_
| TSIG key name for stats.

## Detailed Description

Definition at line 39 of file dns_client.cc.

## Constructor & Destructor Documentation

## ◆ DNSClientImpl()

isc::d2::DNSClientImpl::DNSClientImpl | ( | D2UpdateMessagePtr & | response_placeholder,
|  | DNSClient::Callback * | callback,
|  | const DNSClient::Protocol | proto )

Constructor.

Parameters

  response_placeholder | Message object pointer which will be updated with dynamically allocated object holding the DNS server's response.
  callback | Pointer to an object implementing `DNSClient::Callback` class. This object will be called when DNS message exchange completes or if an error occurs. NULL value disables callback invocation.
  proto | caller's preference regarding Transport layer protocol to be used by DNS Client to communicate with a server.

Definition at line 133 of file dns_client.cc.

References callback_, in_buf_, isc_throw, proto_, response_, stopped_, isc::d2::DNSClient::TCP, and isc::d2::DNSClient::UDP.

## ◆ ~DNSClientImpl()

isc::d2::DNSClientImpl::~DNSClientImpl | ( |  | ) |
| virtual

Destructor.

Definition at line 178 of file dns_client.cc.

## Member Function Documentation

## ◆ doUpdate()

void isc::d2::DNSClientImpl::doUpdate | ( | const asiolink::IOServicePtr & | io_service,
|  | const asiolink::IOAddress & | ns_addr,
|  | const uint16_t | ns_port,
|  | D2UpdateMessage & | update,
|  | const unsigned int | wait,
|  | const D2TsigKeyPtr & | tsig_key )

Starts asynchronous DNS Update using TSIG.

Parameters

  io_service | IO service to be used to run the message exchange.
  ns_addr | DNS server address.
  ns_port | DNS server port.
  update | A DNS Update message to be sent to the server.
  wait | A timeout (in milliseconds) for the response. If a response is not received within the timeout, exchange is interrupted. This value must not exceed maximal value for 'int' data type.
  tsig_key | A pointer to an `D2TsigKeyPtr` object that will (if not null) be used to sign the DNS Update message and verify the response.

Definition at line 245 of file dns_client.cc.

References isc::d2::DNSClient::getMaxTimeout(), in_buf_, incrStats(), io_fetch_list_, isc_throw, isc::dns::AbstractMessageRenderer::setBuffer(), stopped_, isc::d2::D2UpdateMessage::toWire(), tsig_context_, tsig_key_name_, and isc::asiodns::IOFetch::UDP.

Here is the call graph for this function:

## ◆ getStatus()

DNSClient::Status isc::d2::DNSClientImpl::getStatus | ( | const asiodns::IOFetch::Result | result | ) |

This function maps the IO error to the DNSClient error.

Parameters

  result | The IOFetch result to be converted to DNSClient status.

Returns
  The DNSClient status corresponding to the IOFetch result.

Definition at line 227 of file dns_client.cc.

References isc::d2::DNSClient::IO_STOPPED, isc::d2::DNSClient::OTHER, isc::asiodns::IOFetch::STOPPED, isc::asiodns::IOFetch::SUCCESS, isc::d2::DNSClient::SUCCESS, isc::asiodns::IOFetch::TIME_OUT, and isc::d2::DNSClient::TIMEOUT.

Referenced by operator()().

## ◆ incrStats()

void isc::d2::DNSClientImpl::incrStats | ( | const std::string & | stat,
|  | bool | update_key = true )

This function updates statistics.

Parameters

  stat | The statistic name to be incremented.
  update_key | The flag indicating if the key statistics should also be updated.

Definition at line 314 of file dns_client.cc.

References isc::stats::StatsMgr::generateName(), isc::stats::StatsMgr::instance(), and tsig_key_name_.

Referenced by doUpdate(), and operator()().

Here is the call graph for this function:

## ◆ operator()()

void isc::d2::DNSClientImpl::operator() | ( | asiodns::IOFetch::Result | result | ) |
| virtual

This internal callback is called when the DNS update message exchange is complete.

It further invokes the external callback provided by a caller. Before external callback is invoked, an object of the D2UpdateMessage type, representing a response from the server is set.

Implements isc::asiodns::IOFetch::Callback.

Definition at line 182 of file dns_client.cc.

References callback_, isc::d2::d2_to_dns_logger, isc::log::DBGLVL_TRACE_DETAIL, isc::d2::DHCP_DDNS_INVALID_RESPONSE, getStatus(), in_buf_, isc::d2::D2UpdateMessage::INBOUND, incrStats(), isc::d2::DNSClient::INVALID_RESPONSE, LOG_DEBUG, response_, stopped_, isc::d2::DNSClient::SUCCESS, isc::d2::DNSClient::TIMEOUT, tsig_context_, and isc::Exception::what().

Here is the call graph for this function:

## ◆ stop()

void isc::d2::DNSClientImpl::stop | ( |  | ) |

This function stops the IOFetch objects.

Definition at line 171 of file dns_client.cc.

References io_fetch_list_, and stopped_.

## Member Data Documentation

## ◆ callback_

DNSClient::Callback* isc::d2::DNSClientImpl::callback_

A caller-supplied external callback which is invoked when DNS message exchange is complete or interrupted.

Definition at line 58 of file dns_client.cc.

Referenced by DNSClientImpl(), and operator()().

## ◆ in_buf_

util::OutputBufferPtr isc::d2::DNSClientImpl::in_buf_

A buffer holding response from a DNS.

Definition at line 42 of file dns_client.cc.

Referenced by DNSClientImpl(), doUpdate(), and operator()().

## ◆ io_fetch_list_

std::list<IOFetchPtr> isc::d2::DNSClientImpl::io_fetch_list_

The list of IOFetch objects.

Definition at line 73 of file dns_client.cc.

Referenced by doUpdate(), and stop().

## ◆ proto_

DNSClient::Protocol isc::d2::DNSClientImpl::proto_

A Transport Layer protocol used to communicate with a DNS.

Definition at line 61 of file dns_client.cc.

Referenced by DNSClientImpl().

## ◆ response_

D2UpdateMessagePtr& isc::d2::DNSClientImpl::response_

A caller-supplied object which will hold the parsed response from DNS.

The response object is (or descends from) isc::dns::Message and is populated using Message::fromWire(). This method may only be called once in the lifetime of a Message instance. Therefore, response_ is a pointer reference thus allowing this class to replace the object pointed to with a new Message instance each time a message is received. This allows a single DNSClientImpl instance to be used for multiple, sequential IOFetch calls. (

Todo
  Trac# 3286 has been opened against dns::Message::fromWire. Should the behavior of fromWire change the behavior here with could be reexamined).

Definition at line 54 of file dns_client.cc.

Referenced by DNSClientImpl(), and operator()().

## ◆ stopped_

bool isc::d2::DNSClientImpl::stopped_

Flag which indicates that the client has been stopped.

Definition at line 70 of file dns_client.cc.

Referenced by DNSClientImpl(), doUpdate(), operator()(), and stop().

## ◆ tsig_context_

dns::TSIGContextPtr isc::d2::DNSClientImpl::tsig_context_

TSIG context used to sign outbound and verify inbound messages.

Definition at line 64 of file dns_client.cc.

Referenced by doUpdate(), and operator()().

## ◆ tsig_key_name_

std::string isc::d2::DNSClientImpl::tsig_key_name_

TSIG key name for stats.

Definition at line 67 of file dns_client.cc.

Referenced by doUpdate(), and incrStats().

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

- dns_client.cc