Kea 2.7.6
|
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. | |
Definition at line 39 of file dns_client.cc.
isc::d2::DNSClientImpl::DNSClientImpl | ( | D2UpdateMessagePtr & | response_placeholder, |
DNSClient::Callback * | callback, | ||
const DNSClient::Protocol | proto ) |
Constructor.
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 isc_throw, proto_, response_, isc::d2::DNSClient::TCP, and isc::d2::DNSClient::UDP.
|
virtual |
Destructor.
Definition at line 178 of file dns_client.cc.
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.
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.
DNSClient::Status isc::d2::DNSClientImpl::getStatus | ( | const asiodns::IOFetch::Result | result | ) |
This function maps the IO error to the DNSClient error.
result | The IOFetch result to be converted to DNSClient status. |
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()().
void isc::d2::DNSClientImpl::incrStats | ( | const std::string & | stat, |
bool | update_key = true ) |
This function updates statistics.
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()().
|
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().
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_.
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()().
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()().
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().
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().
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. (
Definition at line 54 of file dns_client.cc.
Referenced by DNSClientImpl(), and operator()().
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 doUpdate(), operator()(), and stop().
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()().
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().