mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 14:35:26 +00:00
apply the modified style
This commit is contained in:
@@ -32,10 +32,10 @@
|
||||
#include <dns/result.h>
|
||||
#include <dns/tsig.h>
|
||||
|
||||
#define REQUESTMGR_MAGIC ISC_MAGIC('R', 'q', 'u', 'M')
|
||||
#define REQUESTMGR_MAGIC ISC_MAGIC('R', 'q', 'u', 'M')
|
||||
#define VALID_REQUESTMGR(mgr) ISC_MAGIC_VALID(mgr, REQUESTMGR_MAGIC)
|
||||
|
||||
#define REQUEST_MAGIC ISC_MAGIC('R', 'q', 'u', '!')
|
||||
#define REQUEST_MAGIC ISC_MAGIC('R', 'q', 'u', '!')
|
||||
#define VALID_REQUEST(request) ISC_MAGIC_VALID(request, REQUEST_MAGIC)
|
||||
|
||||
typedef ISC_LIST(dns_request_t) dns_requestlist_t;
|
||||
@@ -44,95 +44,80 @@ typedef ISC_LIST(dns_request_t) dns_requestlist_t;
|
||||
|
||||
struct dns_requestmgr {
|
||||
unsigned int magic;
|
||||
isc_mutex_t lock;
|
||||
isc_mem_t * mctx;
|
||||
isc_mutex_t lock;
|
||||
isc_mem_t *mctx;
|
||||
|
||||
/* locked */
|
||||
int32_t eref;
|
||||
int32_t iref;
|
||||
isc_timermgr_t * timermgr;
|
||||
isc_socketmgr_t * socketmgr;
|
||||
isc_taskmgr_t * taskmgr;
|
||||
int32_t eref;
|
||||
int32_t iref;
|
||||
isc_timermgr_t *timermgr;
|
||||
isc_socketmgr_t *socketmgr;
|
||||
isc_taskmgr_t *taskmgr;
|
||||
dns_dispatchmgr_t *dispatchmgr;
|
||||
dns_dispatch_t * dispatchv4;
|
||||
dns_dispatch_t * dispatchv6;
|
||||
bool exiting;
|
||||
isc_eventlist_t whenshutdown;
|
||||
unsigned int hash;
|
||||
isc_mutex_t locks[DNS_REQUEST_NLOCKS];
|
||||
dns_requestlist_t requests;
|
||||
dns_dispatch_t *dispatchv4;
|
||||
dns_dispatch_t *dispatchv6;
|
||||
bool exiting;
|
||||
isc_eventlist_t whenshutdown;
|
||||
unsigned int hash;
|
||||
isc_mutex_t locks[DNS_REQUEST_NLOCKS];
|
||||
dns_requestlist_t requests;
|
||||
};
|
||||
|
||||
struct dns_request {
|
||||
unsigned int magic;
|
||||
unsigned int hash;
|
||||
isc_mem_t * mctx;
|
||||
int32_t flags;
|
||||
isc_mem_t *mctx;
|
||||
int32_t flags;
|
||||
ISC_LINK(dns_request_t) link;
|
||||
isc_buffer_t * query;
|
||||
isc_buffer_t * answer;
|
||||
isc_buffer_t *query;
|
||||
isc_buffer_t *answer;
|
||||
dns_requestevent_t *event;
|
||||
dns_dispatch_t * dispatch;
|
||||
dns_dispentry_t * dispentry;
|
||||
isc_timer_t * timer;
|
||||
dns_requestmgr_t * requestmgr;
|
||||
isc_buffer_t * tsig;
|
||||
dns_tsigkey_t * tsigkey;
|
||||
isc_event_t ctlevent;
|
||||
bool canceling; /* ctlevent outstanding */
|
||||
isc_sockaddr_t destaddr;
|
||||
unsigned int udpcount;
|
||||
isc_dscp_t dscp;
|
||||
dns_dispatch_t *dispatch;
|
||||
dns_dispentry_t *dispentry;
|
||||
isc_timer_t *timer;
|
||||
dns_requestmgr_t *requestmgr;
|
||||
isc_buffer_t *tsig;
|
||||
dns_tsigkey_t *tsigkey;
|
||||
isc_event_t ctlevent;
|
||||
bool canceling; /* ctlevent outstanding */
|
||||
isc_sockaddr_t destaddr;
|
||||
unsigned int udpcount;
|
||||
isc_dscp_t dscp;
|
||||
};
|
||||
|
||||
#define DNS_REQUEST_F_CONNECTING 0x0001
|
||||
#define DNS_REQUEST_F_SENDING 0x0002
|
||||
#define DNS_REQUEST_F_CANCELED \
|
||||
0x0004 /*%< ctlevent received, or otherwise \
|
||||
* synchronously canceled */
|
||||
#define DNS_REQUEST_F_TIMEDOUT 0x0008 /*%< canceled due to a timeout */
|
||||
#define DNS_REQUEST_F_TCP 0x0010 /*%< This request used TCP */
|
||||
#define DNS_REQUEST_CANCELED(r) (((r)->flags & DNS_REQUEST_F_CANCELED) != 0)
|
||||
#define DNS_REQUEST_F_SENDING 0x0002
|
||||
#define DNS_REQUEST_F_CANCELED \
|
||||
0x0004 /*%< ctlevent received, or otherwise \
|
||||
* synchronously canceled */
|
||||
#define DNS_REQUEST_F_TIMEDOUT 0x0008 /*%< canceled due to a timeout */
|
||||
#define DNS_REQUEST_F_TCP 0x0010 /*%< This request used TCP */
|
||||
#define DNS_REQUEST_CANCELED(r) (((r)->flags & DNS_REQUEST_F_CANCELED) != 0)
|
||||
#define DNS_REQUEST_CONNECTING(r) (((r)->flags & DNS_REQUEST_F_CONNECTING) != 0)
|
||||
#define DNS_REQUEST_SENDING(r) (((r)->flags & DNS_REQUEST_F_SENDING) != 0)
|
||||
#define DNS_REQUEST_TIMEDOUT(r) (((r)->flags & DNS_REQUEST_F_TIMEDOUT) != 0)
|
||||
#define DNS_REQUEST_SENDING(r) (((r)->flags & DNS_REQUEST_F_SENDING) != 0)
|
||||
#define DNS_REQUEST_TIMEDOUT(r) (((r)->flags & DNS_REQUEST_F_TIMEDOUT) != 0)
|
||||
|
||||
/***
|
||||
*** Forward
|
||||
***/
|
||||
|
||||
static void
|
||||
mgr_destroy(dns_requestmgr_t *requestmgr);
|
||||
static void
|
||||
mgr_shutdown(dns_requestmgr_t *requestmgr);
|
||||
static unsigned int
|
||||
mgr_gethash(dns_requestmgr_t *requestmgr);
|
||||
static void
|
||||
send_shutdown_events(dns_requestmgr_t *requestmgr);
|
||||
static void mgr_destroy(dns_requestmgr_t *requestmgr);
|
||||
static void mgr_shutdown(dns_requestmgr_t *requestmgr);
|
||||
static unsigned int mgr_gethash(dns_requestmgr_t *requestmgr);
|
||||
static void send_shutdown_events(dns_requestmgr_t *requestmgr);
|
||||
|
||||
static isc_result_t
|
||||
req_render(dns_message_t *message, isc_buffer_t **buffer, unsigned int options,
|
||||
isc_mem_t *mctx);
|
||||
static void
|
||||
req_senddone(isc_task_t *task, isc_event_t *event);
|
||||
static void
|
||||
req_response(isc_task_t *task, isc_event_t *event);
|
||||
static void
|
||||
req_timeout(isc_task_t *task, isc_event_t *event);
|
||||
static isc_socket_t *
|
||||
req_getsocket(dns_request_t *request);
|
||||
static void
|
||||
req_connected(isc_task_t *task, isc_event_t *event);
|
||||
static void
|
||||
req_sendevent(dns_request_t *request, isc_result_t result);
|
||||
static void
|
||||
req_cancel(dns_request_t *request);
|
||||
static void
|
||||
req_destroy(dns_request_t *request);
|
||||
static void
|
||||
req_log(int level, const char *fmt, ...) ISC_FORMAT_PRINTF(2, 3);
|
||||
static void
|
||||
do_cancel(isc_task_t *task, isc_event_t *event);
|
||||
static isc_result_t req_render(dns_message_t *message, isc_buffer_t **buffer,
|
||||
unsigned int options, isc_mem_t *mctx);
|
||||
static void req_senddone(isc_task_t *task, isc_event_t *event);
|
||||
static void req_response(isc_task_t *task, isc_event_t *event);
|
||||
static void req_timeout(isc_task_t *task, isc_event_t *event);
|
||||
static isc_socket_t *req_getsocket(dns_request_t *request);
|
||||
static void req_connected(isc_task_t *task, isc_event_t *event);
|
||||
static void req_sendevent(dns_request_t *request, isc_result_t result);
|
||||
static void req_cancel(dns_request_t *request);
|
||||
static void req_destroy(dns_request_t *request);
|
||||
static void req_log(int level, const char *fmt, ...) ISC_FORMAT_PRINTF(2, 3);
|
||||
static void do_cancel(isc_task_t *task, isc_event_t *event);
|
||||
|
||||
/***
|
||||
*** Public
|
||||
@@ -143,12 +128,11 @@ dns_requestmgr_create(isc_mem_t *mctx, isc_timermgr_t *timermgr,
|
||||
isc_socketmgr_t *socketmgr, isc_taskmgr_t *taskmgr,
|
||||
dns_dispatchmgr_t *dispatchmgr,
|
||||
dns_dispatch_t *dispatchv4, dns_dispatch_t *dispatchv6,
|
||||
dns_requestmgr_t **requestmgrp)
|
||||
{
|
||||
dns_requestmgr_t **requestmgrp) {
|
||||
dns_requestmgr_t *requestmgr;
|
||||
isc_socket_t * sock;
|
||||
int i;
|
||||
unsigned int dispattr;
|
||||
isc_socket_t *sock;
|
||||
int i;
|
||||
unsigned int dispattr;
|
||||
|
||||
req_log(ISC_LOG_DEBUG(3), "dns_requestmgr_create");
|
||||
|
||||
@@ -204,9 +188,8 @@ dns_requestmgr_create(isc_mem_t *mctx, isc_timermgr_t *timermgr,
|
||||
|
||||
void
|
||||
dns_requestmgr_whenshutdown(dns_requestmgr_t *requestmgr, isc_task_t *task,
|
||||
isc_event_t **eventp)
|
||||
{
|
||||
isc_task_t * tclone;
|
||||
isc_event_t **eventp) {
|
||||
isc_task_t *tclone;
|
||||
isc_event_t *event;
|
||||
|
||||
req_log(ISC_LOG_DEBUG(3), "dns_requestmgr_whenshutdown");
|
||||
@@ -235,8 +218,7 @@ dns_requestmgr_whenshutdown(dns_requestmgr_t *requestmgr, isc_task_t *task,
|
||||
}
|
||||
|
||||
void
|
||||
dns_requestmgr_shutdown(dns_requestmgr_t *requestmgr)
|
||||
{
|
||||
dns_requestmgr_shutdown(dns_requestmgr_t *requestmgr) {
|
||||
REQUIRE(VALID_REQUESTMGR(requestmgr));
|
||||
|
||||
req_log(ISC_LOG_DEBUG(3), "dns_requestmgr_shutdown: %p", requestmgr);
|
||||
@@ -247,8 +229,7 @@ dns_requestmgr_shutdown(dns_requestmgr_t *requestmgr)
|
||||
}
|
||||
|
||||
static void
|
||||
mgr_shutdown(dns_requestmgr_t *requestmgr)
|
||||
{
|
||||
mgr_shutdown(dns_requestmgr_t *requestmgr) {
|
||||
dns_request_t *request;
|
||||
|
||||
/*
|
||||
@@ -257,7 +238,8 @@ mgr_shutdown(dns_requestmgr_t *requestmgr)
|
||||
if (!requestmgr->exiting) {
|
||||
requestmgr->exiting = true;
|
||||
for (request = ISC_LIST_HEAD(requestmgr->requests);
|
||||
request != NULL; request = ISC_LIST_NEXT(request, link)) {
|
||||
request != NULL; request = ISC_LIST_NEXT(request, link))
|
||||
{
|
||||
dns_request_cancel(request);
|
||||
}
|
||||
if (requestmgr->iref == 0) {
|
||||
@@ -268,8 +250,7 @@ mgr_shutdown(dns_requestmgr_t *requestmgr)
|
||||
}
|
||||
|
||||
static void
|
||||
requestmgr_attach(dns_requestmgr_t *source, dns_requestmgr_t **targetp)
|
||||
{
|
||||
requestmgr_attach(dns_requestmgr_t *source, dns_requestmgr_t **targetp) {
|
||||
/*
|
||||
* Locked by caller.
|
||||
*/
|
||||
@@ -287,10 +268,9 @@ requestmgr_attach(dns_requestmgr_t *source, dns_requestmgr_t **targetp)
|
||||
}
|
||||
|
||||
static void
|
||||
requestmgr_detach(dns_requestmgr_t **requestmgrp)
|
||||
{
|
||||
requestmgr_detach(dns_requestmgr_t **requestmgrp) {
|
||||
dns_requestmgr_t *requestmgr;
|
||||
bool need_destroy = false;
|
||||
bool need_destroy = false;
|
||||
|
||||
REQUIRE(requestmgrp != NULL);
|
||||
requestmgr = *requestmgrp;
|
||||
@@ -319,8 +299,7 @@ requestmgr_detach(dns_requestmgr_t **requestmgrp)
|
||||
}
|
||||
|
||||
void
|
||||
dns_requestmgr_attach(dns_requestmgr_t *source, dns_requestmgr_t **targetp)
|
||||
{
|
||||
dns_requestmgr_attach(dns_requestmgr_t *source, dns_requestmgr_t **targetp) {
|
||||
REQUIRE(VALID_REQUESTMGR(source));
|
||||
REQUIRE(targetp != NULL && *targetp == NULL);
|
||||
REQUIRE(!source->exiting);
|
||||
@@ -335,10 +314,9 @@ dns_requestmgr_attach(dns_requestmgr_t *source, dns_requestmgr_t **targetp)
|
||||
}
|
||||
|
||||
void
|
||||
dns_requestmgr_detach(dns_requestmgr_t **requestmgrp)
|
||||
{
|
||||
dns_requestmgr_detach(dns_requestmgr_t **requestmgrp) {
|
||||
dns_requestmgr_t *requestmgr;
|
||||
bool need_destroy = false;
|
||||
bool need_destroy = false;
|
||||
|
||||
REQUIRE(requestmgrp != NULL);
|
||||
requestmgr = *requestmgrp;
|
||||
@@ -365,10 +343,9 @@ dns_requestmgr_detach(dns_requestmgr_t **requestmgrp)
|
||||
}
|
||||
|
||||
static void
|
||||
send_shutdown_events(dns_requestmgr_t *requestmgr)
|
||||
{
|
||||
send_shutdown_events(dns_requestmgr_t *requestmgr) {
|
||||
isc_event_t *event, *next_event;
|
||||
isc_task_t * etask;
|
||||
isc_task_t *etask;
|
||||
|
||||
req_log(ISC_LOG_DEBUG(3), "send_shutdown_events: %p", requestmgr);
|
||||
|
||||
@@ -376,7 +353,8 @@ send_shutdown_events(dns_requestmgr_t *requestmgr)
|
||||
* Caller must be holding the manager lock.
|
||||
*/
|
||||
for (event = ISC_LIST_HEAD(requestmgr->whenshutdown); event != NULL;
|
||||
event = next_event) {
|
||||
event = next_event)
|
||||
{
|
||||
next_event = ISC_LIST_NEXT(event, ev_link);
|
||||
ISC_LIST_UNLINK(requestmgr->whenshutdown, event, ev_link);
|
||||
etask = event->ev_sender;
|
||||
@@ -386,8 +364,7 @@ send_shutdown_events(dns_requestmgr_t *requestmgr)
|
||||
}
|
||||
|
||||
static void
|
||||
mgr_destroy(dns_requestmgr_t *requestmgr)
|
||||
{
|
||||
mgr_destroy(dns_requestmgr_t *requestmgr) {
|
||||
int i;
|
||||
|
||||
req_log(ISC_LOG_DEBUG(3), "mgr_destroy");
|
||||
@@ -411,8 +388,7 @@ mgr_destroy(dns_requestmgr_t *requestmgr)
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
mgr_gethash(dns_requestmgr_t *requestmgr)
|
||||
{
|
||||
mgr_gethash(dns_requestmgr_t *requestmgr) {
|
||||
req_log(ISC_LOG_DEBUG(3), "mgr_gethash");
|
||||
/*
|
||||
* Locked by caller.
|
||||
@@ -423,12 +399,11 @@ mgr_gethash(dns_requestmgr_t *requestmgr)
|
||||
|
||||
static inline isc_result_t
|
||||
req_send(dns_request_t *request, isc_task_t *task,
|
||||
const isc_sockaddr_t *address)
|
||||
{
|
||||
isc_region_t r;
|
||||
isc_socket_t * sock;
|
||||
const isc_sockaddr_t *address) {
|
||||
isc_region_t r;
|
||||
isc_socket_t *sock;
|
||||
isc_socketevent_t *sendevent;
|
||||
isc_result_t result;
|
||||
isc_result_t result;
|
||||
|
||||
req_log(ISC_LOG_DEBUG(3), "req_send: request %p", request);
|
||||
|
||||
@@ -455,15 +430,14 @@ req_send(dns_request_t *request, isc_task_t *task,
|
||||
}
|
||||
|
||||
request->flags |= DNS_REQUEST_F_SENDING;
|
||||
result =
|
||||
isc_socket_sendto2(sock, &r, task, address, NULL, sendevent, 0);
|
||||
result = isc_socket_sendto2(sock, &r, task, address, NULL, sendevent,
|
||||
0);
|
||||
INSIST(result == ISC_R_SUCCESS);
|
||||
return (result);
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
new_request(isc_mem_t *mctx, dns_request_t **requestp)
|
||||
{
|
||||
new_request(isc_mem_t *mctx, dns_request_t **requestp) {
|
||||
dns_request_t *request;
|
||||
|
||||
request = isc_mem_get(mctx, sizeof(*request));
|
||||
@@ -499,20 +473,20 @@ new_request(isc_mem_t *mctx, dns_request_t **requestp)
|
||||
}
|
||||
|
||||
static bool
|
||||
isblackholed(dns_dispatchmgr_t *dispatchmgr, const isc_sockaddr_t *destaddr)
|
||||
{
|
||||
dns_acl_t * blackhole;
|
||||
isblackholed(dns_dispatchmgr_t *dispatchmgr, const isc_sockaddr_t *destaddr) {
|
||||
dns_acl_t *blackhole;
|
||||
isc_netaddr_t netaddr;
|
||||
int match;
|
||||
bool drop = false;
|
||||
char netaddrstr[ISC_NETADDR_FORMATSIZE];
|
||||
int match;
|
||||
bool drop = false;
|
||||
char netaddrstr[ISC_NETADDR_FORMATSIZE];
|
||||
|
||||
blackhole = dns_dispatchmgr_getblackhole(dispatchmgr);
|
||||
if (blackhole != NULL) {
|
||||
isc_netaddr_fromsockaddr(&netaddr, destaddr);
|
||||
if (dns_acl_match(&netaddr, NULL, blackhole, NULL, &match,
|
||||
NULL) == ISC_R_SUCCESS &&
|
||||
match > 0) {
|
||||
match > 0)
|
||||
{
|
||||
drop = true;
|
||||
}
|
||||
}
|
||||
@@ -527,12 +501,11 @@ static isc_result_t
|
||||
create_tcp_dispatch(bool newtcp, bool share, dns_requestmgr_t *requestmgr,
|
||||
const isc_sockaddr_t *srcaddr,
|
||||
const isc_sockaddr_t *destaddr, isc_dscp_t dscp,
|
||||
bool *connected, dns_dispatch_t **dispatchp)
|
||||
{
|
||||
isc_result_t result;
|
||||
isc_socket_t * sock = NULL;
|
||||
bool *connected, dns_dispatch_t **dispatchp) {
|
||||
isc_result_t result;
|
||||
isc_socket_t *sock = NULL;
|
||||
isc_sockaddr_t src;
|
||||
unsigned int attrs;
|
||||
unsigned int attrs;
|
||||
isc_sockaddr_t bind_any;
|
||||
|
||||
if (!newtcp && share) {
|
||||
@@ -604,10 +577,9 @@ cleanup:
|
||||
|
||||
static isc_result_t
|
||||
find_udp_dispatch(dns_requestmgr_t *requestmgr, const isc_sockaddr_t *srcaddr,
|
||||
const isc_sockaddr_t *destaddr, dns_dispatch_t **dispatchp)
|
||||
{
|
||||
const isc_sockaddr_t *destaddr, dns_dispatch_t **dispatchp) {
|
||||
dns_dispatch_t *disp = NULL;
|
||||
unsigned int attrs, attrmask;
|
||||
unsigned int attrs, attrmask;
|
||||
|
||||
if (srcaddr == NULL) {
|
||||
switch (isc_sockaddr_pf(destaddr)) {
|
||||
@@ -656,8 +628,7 @@ find_udp_dispatch(dns_requestmgr_t *requestmgr, const isc_sockaddr_t *srcaddr,
|
||||
static isc_result_t
|
||||
get_dispatch(bool tcp, bool newtcp, bool share, dns_requestmgr_t *requestmgr,
|
||||
const isc_sockaddr_t *srcaddr, const isc_sockaddr_t *destaddr,
|
||||
isc_dscp_t dscp, bool *connected, dns_dispatch_t **dispatchp)
|
||||
{
|
||||
isc_dscp_t dscp, bool *connected, dns_dispatch_t **dispatchp) {
|
||||
isc_result_t result;
|
||||
|
||||
if (tcp) {
|
||||
@@ -672,11 +643,10 @@ get_dispatch(bool tcp, bool newtcp, bool share, dns_requestmgr_t *requestmgr,
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
set_timer(isc_timer_t *timer, unsigned int timeout, unsigned int udpresend)
|
||||
{
|
||||
isc_time_t expires;
|
||||
isc_interval_t interval;
|
||||
isc_result_t result;
|
||||
set_timer(isc_timer_t *timer, unsigned int timeout, unsigned int udpresend) {
|
||||
isc_time_t expires;
|
||||
isc_interval_t interval;
|
||||
isc_result_t result;
|
||||
isc_timertype_t timertype;
|
||||
|
||||
isc_interval_set(&interval, timeout, 0);
|
||||
@@ -698,20 +668,19 @@ dns_request_createraw(dns_requestmgr_t *requestmgr, isc_buffer_t *msgbuf,
|
||||
unsigned int options, unsigned int timeout,
|
||||
unsigned int udptimeout, unsigned int udpretries,
|
||||
isc_task_t *task, isc_taskaction_t action, void *arg,
|
||||
dns_request_t **requestp)
|
||||
{
|
||||
dns_request_t * request = NULL;
|
||||
isc_task_t * tclone = NULL;
|
||||
isc_socket_t * sock = NULL;
|
||||
isc_result_t result;
|
||||
isc_mem_t * mctx;
|
||||
dns_request_t **requestp) {
|
||||
dns_request_t *request = NULL;
|
||||
isc_task_t *tclone = NULL;
|
||||
isc_socket_t *sock = NULL;
|
||||
isc_result_t result;
|
||||
isc_mem_t *mctx;
|
||||
dns_messageid_t id;
|
||||
bool tcp = false;
|
||||
bool newtcp = false;
|
||||
bool share = false;
|
||||
isc_region_t r;
|
||||
bool connected = false;
|
||||
unsigned int dispopt = 0;
|
||||
bool tcp = false;
|
||||
bool newtcp = false;
|
||||
bool share = false;
|
||||
isc_region_t r;
|
||||
bool connected = false;
|
||||
unsigned int dispopt = 0;
|
||||
|
||||
REQUIRE(VALID_REQUESTMGR(requestmgr));
|
||||
REQUIRE(msgbuf != NULL);
|
||||
@@ -875,8 +844,8 @@ isc_result_t
|
||||
dns_request_create(dns_requestmgr_t *requestmgr, dns_message_t *message,
|
||||
const isc_sockaddr_t *address, unsigned int options,
|
||||
dns_tsigkey_t *key, unsigned int timeout, isc_task_t *task,
|
||||
isc_taskaction_t action, void *arg, dns_request_t **requestp)
|
||||
{
|
||||
isc_taskaction_t action, void *arg,
|
||||
dns_request_t **requestp) {
|
||||
return (dns_request_createvia(requestmgr, message, NULL, address, -1,
|
||||
options, key, timeout, 0, 0, task, action,
|
||||
arg, requestp));
|
||||
@@ -890,18 +859,17 @@ dns_request_createvia(dns_requestmgr_t *requestmgr, dns_message_t *message,
|
||||
unsigned int timeout, unsigned int udptimeout,
|
||||
unsigned int udpretries, isc_task_t *task,
|
||||
isc_taskaction_t action, void *arg,
|
||||
dns_request_t **requestp)
|
||||
{
|
||||
dns_request_t * request = NULL;
|
||||
isc_task_t * tclone = NULL;
|
||||
isc_socket_t * sock = NULL;
|
||||
isc_result_t result;
|
||||
isc_mem_t * mctx;
|
||||
dns_request_t **requestp) {
|
||||
dns_request_t *request = NULL;
|
||||
isc_task_t *tclone = NULL;
|
||||
isc_socket_t *sock = NULL;
|
||||
isc_result_t result;
|
||||
isc_mem_t *mctx;
|
||||
dns_messageid_t id;
|
||||
bool tcp;
|
||||
bool share;
|
||||
bool settsigkey = true;
|
||||
bool connected = false;
|
||||
bool tcp;
|
||||
bool share;
|
||||
bool settsigkey = true;
|
||||
bool connected = false;
|
||||
|
||||
REQUIRE(VALID_REQUESTMGR(requestmgr));
|
||||
REQUIRE(message != NULL);
|
||||
@@ -1059,15 +1027,14 @@ cleanup:
|
||||
|
||||
static isc_result_t
|
||||
req_render(dns_message_t *message, isc_buffer_t **bufferp, unsigned int options,
|
||||
isc_mem_t *mctx)
|
||||
{
|
||||
isc_buffer_t * buf1 = NULL;
|
||||
isc_buffer_t * buf2 = NULL;
|
||||
isc_result_t result;
|
||||
isc_region_t r;
|
||||
bool tcp = false;
|
||||
isc_mem_t *mctx) {
|
||||
isc_buffer_t *buf1 = NULL;
|
||||
isc_buffer_t *buf2 = NULL;
|
||||
isc_result_t result;
|
||||
isc_region_t r;
|
||||
bool tcp = false;
|
||||
dns_compress_t cctx;
|
||||
bool cleanup_cctx = false;
|
||||
bool cleanup_cctx = false;
|
||||
|
||||
REQUIRE(bufferp != NULL && *bufferp == NULL);
|
||||
|
||||
@@ -1168,8 +1135,7 @@ cleanup:
|
||||
* 'request' is locked by the caller.
|
||||
*/
|
||||
static void
|
||||
send_if_done(dns_request_t *request, isc_result_t result)
|
||||
{
|
||||
send_if_done(dns_request_t *request, isc_result_t result) {
|
||||
if (request->event != NULL && !request->canceling) {
|
||||
req_sendevent(request, result);
|
||||
}
|
||||
@@ -1179,8 +1145,7 @@ send_if_done(dns_request_t *request, isc_result_t result)
|
||||
* Handle the control event.
|
||||
*/
|
||||
static void
|
||||
do_cancel(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
do_cancel(isc_task_t *task, isc_event_t *event) {
|
||||
dns_request_t *request = event->ev_arg;
|
||||
UNUSED(task);
|
||||
INSIST(event->ev_type == DNS_EVENT_REQUESTCONTROL);
|
||||
@@ -1194,8 +1159,7 @@ do_cancel(isc_task_t *task, isc_event_t *event)
|
||||
}
|
||||
|
||||
void
|
||||
dns_request_cancel(dns_request_t *request)
|
||||
{
|
||||
dns_request_cancel(dns_request_t *request) {
|
||||
REQUIRE(VALID_REQUEST(request));
|
||||
|
||||
req_log(ISC_LOG_DEBUG(3), "dns_request_cancel: request %p", request);
|
||||
@@ -1213,8 +1177,7 @@ dns_request_cancel(dns_request_t *request)
|
||||
|
||||
isc_result_t
|
||||
dns_request_getresponse(dns_request_t *request, dns_message_t *message,
|
||||
unsigned int options)
|
||||
{
|
||||
unsigned int options) {
|
||||
isc_result_t result;
|
||||
|
||||
REQUIRE(VALID_REQUEST(request));
|
||||
@@ -1242,24 +1205,21 @@ dns_request_getresponse(dns_request_t *request, dns_message_t *message,
|
||||
}
|
||||
|
||||
isc_buffer_t *
|
||||
dns_request_getanswer(dns_request_t *request)
|
||||
{
|
||||
dns_request_getanswer(dns_request_t *request) {
|
||||
REQUIRE(VALID_REQUEST(request));
|
||||
|
||||
return (request->answer);
|
||||
}
|
||||
|
||||
bool
|
||||
dns_request_usedtcp(dns_request_t *request)
|
||||
{
|
||||
dns_request_usedtcp(dns_request_t *request) {
|
||||
REQUIRE(VALID_REQUEST(request));
|
||||
|
||||
return ((request->flags & DNS_REQUEST_F_TCP) != 0);
|
||||
}
|
||||
|
||||
void
|
||||
dns_request_destroy(dns_request_t **requestp)
|
||||
{
|
||||
dns_request_destroy(dns_request_t **requestp) {
|
||||
dns_request_t *request;
|
||||
|
||||
REQUIRE(requestp != NULL && VALID_REQUEST(*requestp));
|
||||
@@ -1294,9 +1254,8 @@ dns_request_destroy(dns_request_t **requestp)
|
||||
***/
|
||||
|
||||
static isc_socket_t *
|
||||
req_getsocket(dns_request_t *request)
|
||||
{
|
||||
unsigned int dispattr;
|
||||
req_getsocket(dns_request_t *request) {
|
||||
unsigned int dispattr;
|
||||
isc_socket_t *sock;
|
||||
|
||||
dispattr = dns_dispatch_getattributes(request->dispatch);
|
||||
@@ -1311,11 +1270,10 @@ req_getsocket(dns_request_t *request)
|
||||
}
|
||||
|
||||
static void
|
||||
req_connected(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
req_connected(isc_task_t *task, isc_event_t *event) {
|
||||
isc_socketevent_t *sevent = (isc_socketevent_t *)event;
|
||||
isc_result_t result;
|
||||
dns_request_t * request = event->ev_arg;
|
||||
isc_result_t result;
|
||||
dns_request_t *request = event->ev_arg;
|
||||
|
||||
REQUIRE(event->ev_type == ISC_SOCKEVENT_CONNECT);
|
||||
REQUIRE(VALID_REQUEST(request));
|
||||
@@ -1352,10 +1310,9 @@ req_connected(isc_task_t *task, isc_event_t *event)
|
||||
}
|
||||
|
||||
static void
|
||||
req_senddone(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
req_senddone(isc_task_t *task, isc_event_t *event) {
|
||||
isc_socketevent_t *sevent = (isc_socketevent_t *)event;
|
||||
dns_request_t * request = event->ev_arg;
|
||||
dns_request_t *request = event->ev_arg;
|
||||
|
||||
REQUIRE(event->ev_type == ISC_SOCKEVENT_SENDDONE);
|
||||
REQUIRE(VALID_REQUEST(request));
|
||||
@@ -1387,12 +1344,11 @@ req_senddone(isc_task_t *task, isc_event_t *event)
|
||||
}
|
||||
|
||||
static void
|
||||
req_response(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
isc_result_t result;
|
||||
dns_request_t * request = event->ev_arg;
|
||||
req_response(isc_task_t *task, isc_event_t *event) {
|
||||
isc_result_t result;
|
||||
dns_request_t *request = event->ev_arg;
|
||||
dns_dispatchevent_t *devent = (dns_dispatchevent_t *)event;
|
||||
isc_region_t r;
|
||||
isc_region_t r;
|
||||
|
||||
REQUIRE(VALID_REQUEST(request));
|
||||
REQUIRE(event->ev_type == DNS_EVENT_DISPATCH);
|
||||
@@ -1431,10 +1387,9 @@ done:
|
||||
}
|
||||
|
||||
static void
|
||||
req_timeout(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
req_timeout(isc_task_t *task, isc_event_t *event) {
|
||||
dns_request_t *request = event->ev_arg;
|
||||
isc_result_t result;
|
||||
isc_result_t result;
|
||||
|
||||
REQUIRE(VALID_REQUEST(request));
|
||||
|
||||
@@ -1460,8 +1415,7 @@ req_timeout(isc_task_t *task, isc_event_t *event)
|
||||
}
|
||||
|
||||
static void
|
||||
req_sendevent(dns_request_t *request, isc_result_t result)
|
||||
{
|
||||
req_sendevent(dns_request_t *request, isc_result_t result) {
|
||||
isc_task_t *task;
|
||||
|
||||
REQUIRE(VALID_REQUEST(request));
|
||||
@@ -1478,8 +1432,7 @@ req_sendevent(dns_request_t *request, isc_result_t result)
|
||||
}
|
||||
|
||||
static void
|
||||
req_destroy(dns_request_t *request)
|
||||
{
|
||||
req_destroy(dns_request_t *request) {
|
||||
REQUIRE(VALID_REQUEST(request));
|
||||
|
||||
req_log(ISC_LOG_DEBUG(3), "req_destroy: request %p", request);
|
||||
@@ -1519,10 +1472,9 @@ req_destroy(dns_request_t *request)
|
||||
* Stop the current request. Must be called from the request's task.
|
||||
*/
|
||||
static void
|
||||
req_cancel(dns_request_t *request)
|
||||
{
|
||||
req_cancel(dns_request_t *request) {
|
||||
isc_socket_t *sock;
|
||||
unsigned int dispattr;
|
||||
unsigned int dispattr;
|
||||
|
||||
REQUIRE(VALID_REQUEST(request));
|
||||
|
||||
@@ -1561,8 +1513,7 @@ req_cancel(dns_request_t *request)
|
||||
}
|
||||
|
||||
static void
|
||||
req_log(int level, const char *fmt, ...)
|
||||
{
|
||||
req_log(int level, const char *fmt, ...) {
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
|
Reference in New Issue
Block a user