#include <config.h>
#include <isc/mem.h>
#include <isc/task.h>
#include <isc/util.h>
#include <dns/events.h>
#include <dns/result.h>
#include <dns/tcpmsg.h>
Go to the source code of this file.
Defines | |
#define | XDEBUG(x) |
#define | TCPMSG_MAGIC ISC_MAGIC('T', 'C', 'P', 'm') |
#define | VALID_TCPMSG(foo) ISC_MAGIC_VALID(foo, TCPMSG_MAGIC) |
Functions | |
static void | recv_length (isc_task_t *, isc_event_t *) |
static void | recv_message (isc_task_t *, isc_event_t *) |
void | dns_tcpmsg_init (isc_mem_t *mctx, isc_socket_t *sock, dns_tcpmsg_t *tcpmsg) |
Associate a tcp message state with a given memory context and TCP socket. | |
void | dns_tcpmsg_setmaxsize (dns_tcpmsg_t *tcpmsg, unsigned int maxsize) |
Set the maximum packet size to "maxsize". | |
isc_result_t | dns_tcpmsg_readmessage (dns_tcpmsg_t *tcpmsg, isc_task_t *task, isc_taskaction_t action, void *arg) |
Schedule an event to be delivered when a DNS message is readable, or when an error occurs on the socket. | |
void | dns_tcpmsg_cancelread (dns_tcpmsg_t *tcpmsg) |
Cancel a readmessage() call. The event will still be posted with a CANCELED result code. | |
void | dns_tcpmsg_keepbuffer (dns_tcpmsg_t *tcpmsg, isc_buffer_t *buffer) |
If a dns buffer is to be kept between calls, this function marks the internal state-machine buffer as invalid, and copies all the contents of the state into "buffer". | |
void | dns_tcpmsg_invalidate (dns_tcpmsg_t *tcpmsg) |
Clean up all allocated state, and invalidate the structure. |
Definition in file tcpmsg.c.
#define XDEBUG | ( | x | ) |
#define TCPMSG_MAGIC ISC_MAGIC('T', 'C', 'P', 'm') |
#define VALID_TCPMSG | ( | foo | ) | ISC_MAGIC_VALID(foo, TCPMSG_MAGIC) |
Definition at line 40 of file tcpmsg.c.
Referenced by dns_tcpmsg_cancelread(), dns_tcpmsg_invalidate(), dns_tcpmsg_keepbuffer(), dns_tcpmsg_readmessage(), dns_tcpmsg_setmaxsize(), recv_length(), and recv_message().
static void recv_length | ( | isc_task_t * | task, | |
isc_event_t * | ev_in | |||
) | [static] |
Definition at line 47 of file tcpmsg.c.
References isc_socketevent::address, dns_tcpmsg::address, isc_region::base, dns_tcpmsg::buffer, dns_tcpmsg::event, INSIST, isc_buffer_init, isc_event_free(), isc_mem_get, ISC_R_NOMEMORY, ISC_R_RANGE, ISC_R_SUCCESS, ISC_R_UNEXPECTEDEND, isc_socket_recv(), isc_task_send(), isc_region::length, dns_tcpmsg::maxsize, dns_tcpmsg::mctx, recv_message(), dns_tcpmsg::result, isc_socketevent::result, dns_tcpmsg::size, dns_tcpmsg::sock, dns_tcpmsg::task, VALID_TCPMSG, and XDEBUG.
Referenced by dns_tcpmsg_readmessage(), and isccc_ccmsg_readmessage().
static void recv_message | ( | isc_task_t * | task, | |
isc_event_t * | ev_in | |||
) | [static] |
Definition at line 104 of file tcpmsg.c.
References isc_socketevent::address, dns_tcpmsg::address, dns_tcpmsg::buffer, dns_tcpmsg::event, INSIST, isc_buffer_add, isc_event_free(), ISC_R_SUCCESS, isc_task_send(), isc_socketevent::n, dns_tcpmsg::result, isc_socketevent::result, dns_tcpmsg::size, dns_tcpmsg::task, VALID_TCPMSG, and XDEBUG.
Referenced by recv_length().
void dns_tcpmsg_init | ( | isc_mem_t * | mctx, | |
isc_socket_t * | sock, | |||
dns_tcpmsg_t * | tcpmsg | |||
) |
Associate a tcp message state with a given memory context and TCP socket.
Requires:
Definition at line 133 of file tcpmsg.c.
References isc_buffer::base, dns_tcpmsg::buffer, ISC_R_UNEXPECTED, isc_buffer::length, dns_tcpmsg::magic, dns_tcpmsg::maxsize, dns_tcpmsg::mctx, REQUIRE, dns_tcpmsg::result, dns_tcpmsg::size, dns_tcpmsg::sock, dns_tcpmsg::task, and TCPMSG_MAGIC.
Referenced by client_newconn(), dns_dispatch_createtcp2(), get_worker(), and xfrin_connect_done().
void dns_tcpmsg_setmaxsize | ( | dns_tcpmsg_t * | tcpmsg, | |
unsigned int | maxsize | |||
) |
Set the maximum packet size to "maxsize".
Requires:
Definition at line 154 of file tcpmsg.c.
References dns_tcpmsg::maxsize, REQUIRE, and VALID_TCPMSG.
isc_result_t dns_tcpmsg_readmessage | ( | dns_tcpmsg_t * | tcpmsg, | |
isc_task_t * | task, | |||
isc_taskaction_t | action, | |||
void * | arg | |||
) |
Schedule an event to be delivered when a DNS message is readable, or when an error occurs on the socket.
Requires:
Definition at line 163 of file tcpmsg.c.
References dns_tcpmsg::action, dns_tcpmsg::arg, isc_region::base, isc_buffer::base, dns_tcpmsg::buffer, DNS_EVENT_TCPMSG, dns_tcpmsg::event, ISC_EVENT_INIT, isc_mem_put, ISC_R_SUCCESS, ISC_R_UNEXPECTED, isc_socket_recv(), isc_region::length, isc_buffer::length, dns_tcpmsg::mctx, recv_length(), REQUIRE, dns_tcpmsg::result, dns_tcpmsg::size, dns_tcpmsg::sock, dns_tcpmsg::task, and VALID_TCPMSG.
Referenced by client_read(), startrecv(), xfrin_recv_done(), and xfrin_send_done().
void dns_tcpmsg_cancelread | ( | dns_tcpmsg_t * | tcpmsg | ) |
Cancel a readmessage() call. The event will still be posted with a CANCELED result code.
Requires:
Definition at line 201 of file tcpmsg.c.
References ISC_SOCKCANCEL_RECV, isc_socket_cancel(), REQUIRE, dns_tcpmsg::sock, and VALID_TCPMSG.
Referenced by exit_check(), and xfrin_cancelio().
void dns_tcpmsg_keepbuffer | ( | dns_tcpmsg_t * | tcpmsg, | |
isc_buffer_t * | buffer | |||
) |
If a dns buffer is to be kept between calls, this function marks the internal state-machine buffer as invalid, and copies all the contents of the state into "buffer".
Requires:
Definition at line 208 of file tcpmsg.c.
References isc_buffer::base, dns_tcpmsg::buffer, isc_buffer::length, REQUIRE, and VALID_TCPMSG.
Referenced by tcp_recv().
void dns_tcpmsg_invalidate | ( | dns_tcpmsg_t * | tcpmsg | ) |
Clean up all allocated state, and invalidate the structure.
Requires:
Definition at line 232 of file tcpmsg.c.
References isc_buffer::base, dns_tcpmsg::buffer, isc_mem_put, isc_buffer::length, dns_tcpmsg::magic, dns_tcpmsg::mctx, REQUIRE, and VALID_TCPMSG.
Referenced by dispatch_free(), exit_check(), maybe_free(), and xfrin_reset().