Kea 2.7.6
|
Upstream Fetch Processing. More...
#include <io_fetch.h>
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. | |
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.
anonymous enum |
Integer Constants.
Enumerator | |
---|---|
STAGING_LENGTH |
Definition at line 77 of file io_fetch.h.
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.
Result of Upstream Fetch.
Enumerator | |
---|---|
SUCCESS | |
TIME_OUT | |
STOPPED | |
NOTSET |
Definition at line 66 of file io_fetch.h.
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.
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 142 of file io_fetch.cc.
References isc::dns::Message::RENDER.
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.
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 159 of file io_fetch.cc.
References isc::dns::Message::HEADERFLAG_CD, isc::dns::Message::HEADERFLAG_RD, and isc::dns::Message::RENDER.
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.
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 150 of file io_fetch.cc.
IOFetch::Protocol isc::asiodns::IOFetch::getProtocol | ( | ) | const |
Return Current Protocol.
Definition at line 196 of file io_fetch.cc.
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.
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 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.
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.
reason | Reason 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()().