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

Detailed Description

Upstream Fetch Processing.

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

Parameters
EEndpoint type to use.

Definition at line 45 of file io_fetch.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Integer Constants.

Enumerator
STAGING_LENGTH 

Size of staging buffer.

Definition at line 81 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 

No asynchronous call outstanding.

OPEN 
SEND 
RECEIVE 
CLOSE 

Definition at line 57 of file io_fetch.h.

◆ Protocol

Protocol to use on the fetch.

Enumerator
UDP 
TCP 

Definition at line 48 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 

Success, fetch completed.

TIME_OUT 

Failure, fetch timed out.

STOPPED 

Control code, fetch has been stopped.

NOTSET 

For testing, indicates value not set.

Definition at line 70 of file io_fetch.h.

Constructor & Destructor Documentation

◆ IOFetch() [1/3]

isc::asiodns::IOFetch::IOFetch ( Protocol  protocol,
isc::asiolink::IOService 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 Constructor - just initialize the private data.

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 154 of file io_fetch.cc.

Referenced by isc::asiodns::IOFetch::Callback::~Callback().

◆ IOFetch() [2/3]

isc::asiodns::IOFetch::IOFetch ( Protocol  protocol,
isc::asiolink::IOService 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 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 171 of file io_fetch.cc.

References isc::dns::AbstractMessageRenderer::setBuffer().

+ Here is the call graph for this function:

◆ IOFetch() [3/3]

isc::asiodns::IOFetch::IOFetch ( Protocol  protocol,
isc::asiolink::IOService 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 162 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 216 of file io_fetch.cc.

Referenced by isc::asiodns::IOFetch::Callback::~Callback().

◆ operator()()

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

Coroutine entry point.

The function operator is implemented with the "stackless coroutine" pattern; see boost/asio/coroutine.hpp for details.

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 224 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)

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