Kea
1.9.9-git
|
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, 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... | |
Upstream Fetch Processing.
IOFetch is the class used to send upstream fetches and to handle responses.
E | Endpoint type to use. |
Definition at line 45 of file io_fetch.h.
anonymous enum |
Integer Constants.
Enumerator | |
---|---|
STAGING_LENGTH |
Size of staging buffer. |
Definition at line 81 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 |
No asynchronous call outstanding. |
OPEN | |
SEND | |
RECEIVE | |
CLOSE |
Definition at line 57 of file io_fetch.h.
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.
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.
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 156 of file io_fetch.cc.
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.
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 176 of file io_fetch.cc.
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.
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 165 of file io_fetch.cc.
IOFetch::Protocol isc::asiodns::IOFetch::getProtocol | ( | ) | const |
Return Current Protocol.
Definition at line 223 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 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.
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 231 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.
reason | Reason for terminating the query |
Definition at line 334 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, LOG_DEBUG, LOG_ERROR, isc::asiodns::logger, STOPPED, SUCCESS, and TIME_OUT.
Referenced by operator()().