Kea 2.7.6
isc::asiodns::IOFetch Class Reference

Upstream Fetch Processing. More...

#include <io_fetch.h>

+ Inheritance diagram for isc::asiodns::IOFetch:

Classes

class  Callback
 I/O Fetch Callback. More...
 

Public Types

enum  { STAGING_LENGTH = 8192 }
 Integer Constants. More...
 
enum  Origin {
  NONE = 0 , OPEN = 1 , SEND = 2 , RECEIVE = 3 ,
  CLOSE = 4
}
 Origin of Asynchronous I/O Call. More...
 
enum  Protocol { UDP = 0 , TCP = 1 }
 Protocol to use on the fetch. More...
 
enum  Result { SUCCESS = 0 , TIME_OUT = 1 , STOPPED = 2 , NOTSET = 3 }
 Result of Upstream Fetch. More...
 

Public Member Functions

 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.
 
 IOFetch (Protocol protocol, const isc::asiolink::IOServicePtr &service, isc::dns::ConstMessagePtr query_message, const isc::asiolink::IOAddress &address, uint16_t port, isc::util::OutputBufferPtr &buff, Callback *cb, int wait=-1)
 Constructor.
 
 IOFetch (Protocol protocol, const isc::asiolink::IOServicePtr &service, isc::util::OutputBufferPtr &outpkt, const isc::asiolink::IOAddress &address, uint16_t port, isc::util::OutputBufferPtr &buff, Callback *cb, int wait=-1)
 Constructor.
 
Protocol getProtocol () const
 Return Current Protocol.
 
void operator() (boost::system::error_code ec=boost::system::error_code(), size_t length=0)
 Coroutine entry point.
 
void stop (Result reason=STOPPED)
 Terminate query.
 

Detailed Description

Upstream Fetch Processing.

IOFetch is the class used to send upstream fetches and to handle responses.

Definition at line 41 of file io_fetch.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Integer Constants.

Note
The next enum is a "trick" to allow constants to be defined in a class declaration.
Enumerator
STAGING_LENGTH 

Definition at line 77 of file io_fetch.h.

◆ Origin

Origin of Asynchronous I/O Call.

Indicates what initiated an asynchronous I/O call and used in deciding what error message to output if the I/O fails.

Enumerator
NONE 
OPEN 
SEND 
RECEIVE 
CLOSE 

Definition at line 53 of file io_fetch.h.

◆ Protocol

Protocol to use on the fetch.

Enumerator
UDP 
TCP 

Definition at line 44 of file io_fetch.h.

◆ Result

Result of Upstream Fetch.

Note
that this applies to the status of I/Os in the fetch - a fetch that resulted in a packet being received from the server is a SUCCESS, even if the contents of the packet indicate that some error occurred.
Enumerator
SUCCESS 
TIME_OUT 
STOPPED 
NOTSET 

Definition at line 66 of file io_fetch.h.

Constructor & Destructor Documentation

◆ IOFetch() [1/3]

isc::asiodns::IOFetch::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.

Creates the object that will handle the upstream fetch.

Parameters
protocolFetch protocol, either IOFetch::TCP or IOFetch::UDP.
serviceI/O Service object to handle the asynchronous operations.
questionDNS question to send to the upstream server.
addressIP address of upstream server.
portPort to which to connect on the upstream server.
buffOutput buffer into which the response (in wire format) is written (if a response is received).
cbCallback object containing the callback to be called when we terminate. The caller is responsible for managing this object and deleting it if necessary.
waitTimeout for the fetch (in ms). The default value of -1 indicates no timeout.
ednstrue if the request should be EDNS. The default value is true.

Definition at line 142 of file io_fetch.cc.

References isc::dns::Message::RENDER.

◆ IOFetch() [2/3]

isc::asiodns::IOFetch::IOFetch ( Protocol protocol,
const isc::asiolink::IOServicePtr & service,
isc::dns::ConstMessagePtr query_message,
const isc::asiolink::IOAddress & address,
uint16_t port,
isc::util::OutputBufferPtr & buff,
Callback * cb,
int wait = -1 )

Constructor.

This constructor has one parameter "query_message", which is the shared_ptr to a full query message. It's different with above constructor which has only question section. All other parameters are the same.

Parameters
protocolFetch protocol, either IOFetch::TCP or IOFetch::UDP.
serviceI/O Service object to handle the asynchronous operations.
query_messagethe shared_ptr to a full query message got from a query client.
addressIP address of upstream server.
portPort to which to connect on the upstream server.
buffOutput buffer into which the response (in wire format) is written (if a response is received).
cbCallback object containing the callback to be called when we terminate. The caller is responsible for managing this object and deleting it if necessary.
waitTimeout for the fetch (in ms). The default value of -1 indicates no timeout.

Definition at line 159 of file io_fetch.cc.

References isc::dns::Message::HEADERFLAG_CD, isc::dns::Message::HEADERFLAG_RD, and isc::dns::Message::RENDER.

◆ IOFetch() [3/3]

isc::asiodns::IOFetch::IOFetch ( Protocol protocol,
const isc::asiolink::IOServicePtr & service,
isc::util::OutputBufferPtr & outpkt,
const isc::asiolink::IOAddress & address,
uint16_t port,
isc::util::OutputBufferPtr & buff,
Callback * cb,
int wait = -1 )

Constructor.

Creates the object that will handle the upstream fetch.

Parameters
protocolFetch protocol, either IOFetch::TCP or IOFetch::UDP
serviceI/O Service object to handle the asynchronous operations.
outpktPacket to send to upstream server. Note that the QID (first two bytes of the packet) may be altered in the sending.
buffOutput buffer into which the response (in wire format) is written (if a response is received).
cbCallback object containing the callback to be called when we terminate. The caller is responsible for managing this object and deleting it if necessary.
addressIP address of upstream server.
portPort to which to connect on the upstream server (default = 53).
waitTimeout for the fetch (in ms). The default value of -1 indicates no timeout.

Definition at line 150 of file io_fetch.cc.

Member Function Documentation

◆ getProtocol()

IOFetch::Protocol isc::asiodns::IOFetch::getProtocol ( ) const

Return Current Protocol.

Returns
Protocol associated with this IOFetch object.

Definition at line 196 of file io_fetch.cc.

◆ operator()()

void isc::asiodns::IOFetch::operator() ( boost::system::error_code ec = boost::system::error_code(),
size_t length = 0 )

Coroutine entry point.

The operator() method is the method in which the coroutine code enters this object when an operation has been completed.

Parameters
ecError code, the result of the last asynchronous I/O operation.
lengthAmount of data received on the last asynchronous read.

Generate the upstream query and render it to wire format This is done in a different scope to allow inline variable declarations.

We are done

Definition at line 201 of file io_fetch.cc.

References isc::asiodns::ASIODNS_OPEN_SOCKET, isc::asiodns::ASIODNS_READ_DATA, isc::asiodns::ASIODNS_SEND_DATA, isc::asiodns::ASIODNS_UNKNOWN_ORIGIN, STAGING_LENGTH, stop(), SUCCESS, and TIME_OUT.

+ Here is the call graph for this function:

◆ stop()

void isc::asiodns::IOFetch::stop ( Result reason = STOPPED)

Terminate query.

This method can be called at any point. It terminates the current query with the specified reason. This function stops the coroutine sequence. It is called either when the query finishes or when the timer times out. Either way, it sets the "stopped_" flag and cancels anything that is in progress.

As the function may be entered multiple times as things wind down, it checks if the stopped_ flag is already set. If it is, the call is a no-op.

Parameters
reasonReason for terminating the query.

Definition at line 296 of file io_fetch.cc.

References isc::asiodns::ASIODNS_FETCH_COMPLETED, isc::asiodns::ASIODNS_FETCH_STOPPED, isc::asiodns::ASIODNS_READ_TIMEOUT, isc::asiodns::ASIODNS_UNKNOWN_RESULT, isc::asiodns::DBG_COMMON, isc::asiodns::DBG_IMPORTANT, isc::asiodns::DBG_VERBOSE, LOG_DEBUG, LOG_ERROR, isc::asiodns::logger, STOPPED, SUCCESS, and TIME_OUT.

Referenced by operator()().


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