Kea  2.3.5-git
isc::d2::DNSClientImpl Class Reference
+ Inheritance diagram for isc::d2::DNSClientImpl:

Public Member Functions

 DNSClientImpl (D2UpdateMessagePtr &response_placeholder, DNSClient::Callback *callback, const DNSClient::Protocol proto)
 Constructor. More...
 
virtual ~DNSClientImpl ()
 Destructor. More...
 
void doUpdate (asiolink::IOService &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. More...
 
DNSClient::Status getStatus (const asiodns::IOFetch::Result result)
 This function maps the IO error to the DNSClient error. More...
 
void incrStats (const std::string &stat, bool update_key=true)
 This function updates statistics. More...
 
virtual void operator() (asiodns::IOFetch::Result result)
 This internal callback is called when the DNS update message exchange is complete. More...
 
- Public Member Functions inherited from isc::asiodns::IOFetch::Callback
 Callback ()
 Default Constructor. More...
 
virtual ~Callback ()
 Virtual Destructor. More...
 

Public Attributes

DNSClient::Callbackcallback_
 A caller-supplied external callback which is invoked when DNS message exchange is complete or interrupted. More...
 
util::OutputBufferPtr in_buf_
 A buffer holding response from a DNS. More...
 
DNSClient::Protocol proto_
 A Transport Layer protocol used to communicate with a DNS. More...
 
D2UpdateMessagePtrresponse_
 A caller-supplied object which will hold the parsed response from DNS. More...
 
dns::TSIGContextPtr tsig_context_
 TSIG context used to sign outbound and verify inbound messages. More...
 
std::string tsig_key_name_
 TSIG key name for stats. More...
 

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_placeholderMessage object pointer which will be updated with dynamically allocated object holding the DNS server's response.
callbackPointer 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.
protocaller's preference regarding Transport layer protocol to be used by DNS Client to communicate with a server.

Definition at line 124 of file dns_client.cc.

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

◆ ~DNSClientImpl()

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

Destructor.

Definition at line 161 of file dns_client.cc.

Member Function Documentation

◆ doUpdate()

void isc::d2::DNSClientImpl::doUpdate ( asiolink::IOService 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_serviceIO service to be used to run the message exchange.
ns_addrDNS server address.
ns_portDNS server port.
updateA DNS Update message to be sent to the server.
waitA 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_keyA 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 225 of file dns_client.cc.

References isc::d2::DNSClient::getMaxTimeout(), in_buf_, incrStats(), isc_throw, isc::asiolink::IOService::post(), isc::dns::AbstractMessageRenderer::setBuffer(), 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
resultThe IOFetch result to be converted to DNSClient status.
Returns
The DNSClient status corresponding to the IOFetch result.

Definition at line 207 of file dns_client.cc.

References isc::d2::DNSClient::IO_STOPPED, isc::d2::DNSClient::OTHER, isc::asiodns::IOFetch::STOPPED, isc::d2::DNSClient::SUCCESS, isc::asiodns::IOFetch::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
statThe statistic name to be incremented.
update_keyThe flag indicating if the key statistics should also be updated.

Definition at line 290 of file dns_client.cc.

References isc::stats::StatsMgr::addValue(), 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 165 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_, isc::d2::DNSClient::SUCCESS, isc::d2::DNSClient::TIMEOUT, tsig_context_, and isc::Exception::what().

+ Here is the call graph for this function:

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 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 doUpdate(), and operator()().

◆ 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()().

◆ 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: