Kea: isc::asiodns::IOFetch Class Reference

| Kea 3.0.2-git

isc::asiodns::IOFetch Class Reference

Upstream Fetch Processing. More...

`#include <io_fetch.h>`

Inheritance diagram for isc::asiodns::IOFetch:
[legend]

## 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 33 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 69 of file io_fetch.h.

## ◆ Origin

enum isc::asiodns::IOFetch::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 45 of file io_fetch.h.

## ◆ Protocol

enum isc::asiodns::IOFetch::Protocol

Protocol to use on the fetch.

Enumerator
UDP |
TCP |

Definition at line 36 of file io_fetch.h.

## ◆ Result

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

  protocol | Fetch protocol, either IOFetch::TCP or IOFetch::UDP.
  service | I/O Service object to handle the asynchronous operations.
  question | DNS question to send to the upstream server.
  address | IP address of upstream server.
  port | Port to which to connect on the upstream server.
  buff | Output buffer into which the response (in wire format) is written (if a response is received).
  cb | Callback object containing the callback to be called when we terminate. The caller is responsible for managing this object and deleting it if necessary.
  wait | Timeout for the fetch (in ms). The default value of -1 indicates no timeout.
  edns | true if the request should be EDNS. The default value is true.

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

  protocol | Fetch protocol, either IOFetch::TCP or IOFetch::UDP.
  service | I/O Service object to handle the asynchronous operations.
  query_message | the shared_ptr to a full query message got from a query client.
  address | IP address of upstream server.
  port | Port to which to connect on the upstream server.
  buff | Output buffer into which the response (in wire format) is written (if a response is received).
  cb | Callback object containing the callback to be called when we terminate. The caller is responsible for managing this object and deleting it if necessary.
  wait | Timeout for the fetch (in ms). The default value of -1 indicates no timeout.

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

  protocol | Fetch protocol, either IOFetch::TCP or IOFetch::UDP
  service | I/O Service object to handle the asynchronous operations.
  outpkt | Packet to send to upstream server. Note that the QID (first two bytes of the packet) may be altered in the sending.
  buff | Output buffer into which the response (in wire format) is written (if a response is received).
  cb | Callback object containing the callback to be called when we terminate. The caller is responsible for managing this object and deleting it if necessary.
  address | IP address of upstream server.
  port | Port to which to connect on the upstream server (default = 53).
  wait | Timeout for the fetch (in ms). The default value of -1 indicates no timeout.

Definition at line 151 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 197 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

  ec | Error code, the result of the last asynchronous I/O operation.
  length | Amount 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 202 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

  reason | Reason for terminating the query.

Definition at line 297 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:

- io_fetch.h
- io_fetch.cc