25#include <boost/scoped_ptr.hpp> 
   26#include <boost/date_time/posix_time/posix_time_types.hpp> 
   30#include <netinet/in.h> 
   32#include <sys/socket.h> 
   39using namespace boost::asio;
 
   64    boost::scoped_ptr<IOAsioSocket<IOFetch>> 
socket; 
 
   70    boost::asio::deadline_timer   
timer;             
 
 
  146    initIOFetch(query, protocol, service, question, address, port, buff,
 
 
  154          address, port, buff, 
cb, wait)) {
 
  155    data_->msgbuf = outpkt;
 
  156    data_->packet = 
true;
 
 
  168    initIOFetch(question, protocol, service, **(query_message->beginQuestion()), address,
 
  169                port, buff, 
cb, wait);
 
 
  176    data_ = boost::shared_ptr<IOFetchData>(
new IOFetchData(protocol, service, address, port, buff, 
cb, wait));
 
  177    query->setQid(data_->qid);
 
  181    query->addQuestion(question);
 
  186        query->setEDNS(edns_query);
 
  197    return (data_->protocol);
 
 
  202    if (data_->stopped) {
 
  208    } 
else if (ec && (ec.value() != boost::asio::error::in_progress)) {
 
  213    BOOST_ASIO_CORO_REENTER (
this) {
 
  222                data_->msgbuf->writeUint16At(data_->qid, 0);
 
  229        if (data_->timeout != -1) {
 
  230            data_->timer.expires_from_now(boost::posix_time::milliseconds(
 
  239        if (data_->socket->isOpenSynchronous()) {
 
  240            data_->socket->open(data_->remote_snd.get(), *
this);
 
  242            BOOST_ASIO_CORO_YIELD data_->socket->open(data_->remote_snd.get(), *
this);
 
  249            BOOST_ASIO_CORO_YIELD data_->socket->asyncSend(data_->msgbuf->getData(),
 
  250                data_->msgbuf->getLength(), data_->remote_snd.get(), *
this);
 
  272            data_->cumulative = 0;          
 
  274            data_->received->clear();       
 
  276                BOOST_ASIO_CORO_YIELD data_->socket->asyncReceive(data_->staging,
 
  279                                        data_->remote_rcv.get(), *
this);
 
  280            } 
while (!data_->socket->processReceivedData(data_->staging, length,
 
  281                                        data_->cumulative, data_->offset,
 
  282                                        data_->expected, data_->received));
 
  283        } 
while (!data_->responseOK());
 
  288        data_->socket->close();
 
 
  297    if (!data_->stopped) {
 
  310        data_->stopped = 
true;
 
  314                    arg(data_->remote_snd->getAddress().toText()).
 
  315                    arg(data_->remote_snd->getPort());
 
  320                    arg(data_->remote_rcv->getAddress().toText()).
 
  321                    arg(data_->remote_rcv->getPort());
 
  329                    arg(data_->remote_snd->getAddress().toText()).
 
  330                    arg(data_->remote_snd->getPort());
 
  335                    arg(data_->remote_snd->getAddress().toText()).
 
  336                    arg(data_->remote_snd->getPort());
 
  341        data_->socket->cancel();
 
  342        data_->socket->close();
 
  344        data_->timer.cancel();
 
  347        if (data_->callback) {
 
  348            (*(data_->callback))(result);
 
 
  353void IOFetch::logIOFailure(boost::system::error_code ec) {
 
  363        arg((data_->remote_snd->getProtocol() == IPPROTO_TCP) ?
 
  365        arg(data_->remote_snd->getAddress().toText()).
 
  366        arg(data_->remote_snd->getPort());
 
A generic exception that is thrown when an unexpected error condition occurs.
Upstream Fetch Processing.
IOFetch(Protocol protocol, const isc::asiolink::IOServicePtr &service, const isc::dns::Question &question, const isc::asiolink::IOAddress &address, uint16_t port, isc::util::OutputBufferPtr &buff, Callback *cb, int wait=-1, bool edns=true)
Constructor.
void operator()(boost::system::error_code ec=boost::system::error_code(), size_t length=0)
Coroutine entry point.
Result
Result of Upstream Fetch.
Protocol
Protocol to use on the fetch.
void stop(Result reason=STOPPED)
Terminate query.
Protocol getProtocol() const
Return Current Protocol.
The IOAddress class represents an IP addresses (version agnostic)
I/O Socket with asynchronous operations.
The IOEndpoint class is an abstract base class to represent a communication endpoint.
The TCPEndpoint class is a concrete derived class of IOEndpoint that represents an endpoint of a TCP ...
The TCPSocket class is a concrete derived class of IOAsioSocket that represents a TCP socket.
The UDPEndpoint class is a concrete derived class of IOEndpoint that represents an endpoint of a UDP ...
The UDPSocket class is a concrete derived class of IOAsioSocket that represents a UDP socket.
void setBuffer(isc::util::OutputBuffer *buffer)
Set or reset a temporary output buffer.
The EDNS class represents the EDNS OPT RR defined in RFC2671.
The MessageRenderer is a concrete derived class of AbstractMessageRenderer as a general purpose imple...
The Message class encapsulates a standard DNS message.
static const uint16_t DEFAULT_MAX_EDNS0_UDPSIZE
The default maximum size of UDP DNS messages we can handle.
static const Opcode & QUERY()
A constant object for the QUERY Opcode.
The Question class encapsulates the common search key of DNS lookup, consisting of owner name,...
static const Rcode & NOERROR()
A constant object for the NOERROR Rcode (see Rcode::NOERROR_CODE).
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
isc::log::Logger logger("asiodns")
Use the ASIO logger.
const isc::log::MessageID ASIODNS_READ_TIMEOUT
const isc::log::MessageID ASIODNS_UNKNOWN_ORIGIN
const isc::log::MessageID ASIODNS_FETCH_STOPPED
const isc::log::MessageID ASIODNS_OPEN_SOCKET
const isc::log::MessageID ASIODNS_UNKNOWN_RESULT
const isc::log::MessageID ASIODNS_FETCH_COMPLETED
const isc::log::MessageID ASIODNS_READ_DATA
const isc::log::MessageID ASIODNS_SEND_DATA
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
boost::shared_ptr< const Message > ConstMessagePtr
boost::shared_ptr< Message > MessagePtr
Pointer-like type pointing to a Message.
boost::shared_ptr< EDNS > EDNSPtr
A pointer-like type pointing to an EDNS object.
const int DBGLVL_TRACE_BASIC
Trace basic operations.
const int DBGLVL_TRACE_TECHNICAL
Trace technical operations.
const int DBGLVL_TRACE_DETAIL
Trace detailed operations.
uint16_t readUint16(void const *const buffer, size_t const length)
uint16_t wrapper over readUint.
boost::shared_ptr< OutputBuffer > OutputBufferPtr
Type of pointers to output buffers.
Defines the logger used by the top-level component of kea-lfc.
IOFetch::Callback * callback
boost::scoped_ptr< IOEndpoint > remote_snd
IOFetch::Protocol protocol
uint8_t staging[IOFetch::STAGING_LENGTH]
boost::scoped_ptr< IOAsioSocket< IOFetch > > socket
boost::asio::deadline_timer timer
boost::scoped_ptr< IOEndpoint > remote_rcv
~IOFetchData()
Destructor.
isc::log::MessageID origin
bool responseOK()
Checks if the response we received was ok.
IOFetchData(IOFetch::Protocol proto, const IOServicePtr &service, const IOAddress &address, uint16_t port, OutputBufferPtr &buff, IOFetch::Callback *cb, int wait)
Constructor.