dispatch.h File Reference

DNS Dispatch Management Shared UDP and single-use TCP dispatches for queries and responses. More...

#include <isc/buffer.h>
#include <isc/lang.h>
#include <isc/mutex.h>
#include <isc/socket.h>
#include <isc/types.h>
#include <dns/types.h>

Go to the source code of this file.

Data Structures

struct  dns_dispatchevent
 This event is sent to a task when a response comes in. No part of this structure should ever be modified by the caller, other than parts of the buffer. The holy parts of the buffer are the base and size of the buffer. All other parts of the buffer may be used. On event delivery the used region contains the packet. More...
struct  dns_dispatchset
 This is a set of one or more dispatches which can be retrieved round-robin fashion. More...

Defines

#define DNS_DISPATCH_H   1
#define DNS_DISPATCHOPT_FIXEDID   0x00000001U
#define DNS_DISPATCHATTR_PRIVATE   0x00000001U
 Attributes for added dispatchers.
#define DNS_DISPATCHATTR_TCP   0x00000002U
 Attributes for added dispatchers.
#define DNS_DISPATCHATTR_UDP   0x00000004U
 Attributes for added dispatchers.
#define DNS_DISPATCHATTR_IPV4   0x00000008U
 Attributes for added dispatchers.
#define DNS_DISPATCHATTR_IPV6   0x00000010U
 Attributes for added dispatchers.
#define DNS_DISPATCHATTR_NOLISTEN   0x00000020U
 Attributes for added dispatchers.
#define DNS_DISPATCHATTR_MAKEQUERY   0x00000040U
 Attributes for added dispatchers.
#define DNS_DISPATCHATTR_CONNECTED   0x00000080U
 Attributes for added dispatchers.
#define DNS_DISPATCHATTR_FIXEDID   0x00000100U
 Attributes for added dispatchers.
#define DNS_DISPATCHATTR_EXCLUSIVE   0x00000200U
 Attributes for added dispatchers.

Functions

isc_result_t dns_dispatchmgr_create (isc_mem_t *mctx, isc_entropy_t *entropy, dns_dispatchmgr_t **mgrp)
 Creates a new dispatchmgr object.
void dns_dispatchmgr_destroy (dns_dispatchmgr_t **mgrp)
 Destroys the dispatchmgr when it becomes empty. This could be immediately.
void dns_dispatchmgr_setblackhole (dns_dispatchmgr_t *mgr, dns_acl_t *blackhole)
 Sets the dispatcher's "blackhole list," a list of addresses that will be ignored by all dispatchers created by the dispatchmgr.
dns_acl_tdns_dispatchmgr_getblackhole (dns_dispatchmgr_t *mgr)
 Gets a pointer to the dispatcher's current blackhole list, without incrementing its reference count.
void dns_dispatchmgr_setblackportlist (dns_dispatchmgr_t *mgr, dns_portlist_t *portlist)
 This function is deprecated. Use dns_dispatchmgr_setavailports() instead.
dns_portlist_tdns_dispatchmgr_getblackportlist (dns_dispatchmgr_t *mgr)
 This function is deprecated and always returns NULL.
isc_result_t dns_dispatchmgr_setavailports (dns_dispatchmgr_t *mgr, isc_portset_t *v4portset, isc_portset_t *v6portset)
 Sets a list of UDP ports that can be used for outgoing UDP messages.
void dns_dispatchmgr_setstats (dns_dispatchmgr_t *mgr, isc_stats_t *stats)
 Sets statistics counter for the dispatchmgr. This function is expected to be called only on zone creation (when necessary). Once installed, it cannot be removed or replaced. Also, there is no interface to get the installed stats from the zone; the caller must keep the stats to reference (e.g. dump) it later.
isc_result_t dns_dispatch_getudp (dns_dispatchmgr_t *mgr, isc_socketmgr_t *sockmgr, isc_taskmgr_t *taskmgr, isc_sockaddr_t *localaddr, unsigned int buffersize, unsigned int maxbuffers, unsigned int maxrequests, unsigned int buckets, unsigned int increment, unsigned int attributes, unsigned int mask, dns_dispatch_t **dispp)
isc_result_t dns_dispatch_getudp_dup (dns_dispatchmgr_t *mgr, isc_socketmgr_t *sockmgr, isc_taskmgr_t *taskmgr, isc_sockaddr_t *localaddr, unsigned int buffersize, unsigned int maxbuffers, unsigned int maxrequests, unsigned int buckets, unsigned int increment, unsigned int attributes, unsigned int mask, dns_dispatch_t **dispp, dns_dispatch_t *dup)
 Attach to existing dns_dispatch_t if one is found with dns_dispatchmgr_find, otherwise create a new UDP dispatch.
isc_result_t dns_dispatch_createtcp (dns_dispatchmgr_t *mgr, isc_socket_t *sock, isc_taskmgr_t *taskmgr, unsigned int buffersize, unsigned int maxbuffers, unsigned int maxrequests, unsigned int buckets, unsigned int increment, unsigned int attributes, dns_dispatch_t **dispp)
isc_result_t dns_dispatch_createtcp2 (dns_dispatchmgr_t *mgr, isc_socket_t *sock, isc_taskmgr_t *taskmgr, isc_sockaddr_t *localaddr, isc_sockaddr_t *destaddr, unsigned int buffersize, unsigned int maxbuffers, unsigned int maxrequests, unsigned int buckets, unsigned int increment, unsigned int attributes, dns_dispatch_t **dispp)
 Create a new dns_dispatch and attach it to the provided isc_socket_t.
void dns_dispatch_attach (dns_dispatch_t *disp, dns_dispatch_t **dispp)
 Attach to a dispatch handle.
void dns_dispatch_detach (dns_dispatch_t **dispp)
 Detaches from the dispatch.
void dns_dispatch_starttcp (dns_dispatch_t *disp)
 Start processing of a TCP dispatch once the socket connects.
isc_result_t dns_dispatch_gettcp (dns_dispatchmgr_t *mgr, isc_sockaddr_t *destaddr, isc_sockaddr_t *localaddr, dns_dispatch_t **dispp)
isc_result_t dns_dispatch_gettcp2 (dns_dispatchmgr_t *mgr, isc_sockaddr_t *destaddr, isc_sockaddr_t *localaddr, isc_boolean_t *connected, dns_dispatch_t **dispp)
isc_result_t dns_dispatch_addresponse3 (dns_dispatch_t *disp, unsigned int options, isc_sockaddr_t *dest, isc_task_t *task, isc_taskaction_t action, void *arg, isc_uint16_t *idp, dns_dispentry_t **resp, isc_socketmgr_t *sockmgr)
isc_result_t dns_dispatch_addresponse2 (dns_dispatch_t *disp, isc_sockaddr_t *dest, isc_task_t *task, isc_taskaction_t action, void *arg, isc_uint16_t *idp, dns_dispentry_t **resp, isc_socketmgr_t *sockmgr)
isc_result_t dns_dispatch_addresponse (dns_dispatch_t *disp, isc_sockaddr_t *dest, isc_task_t *task, isc_taskaction_t action, void *arg, isc_uint16_t *idp, dns_dispentry_t **resp)
 Add a response entry for this dispatch.
void dns_dispatch_removeresponse (dns_dispentry_t **resp, dns_dispatchevent_t **sockevent)
 Stops the flow of responses for the provided id and destination. If "sockevent" is non-NULL, the dispatch event and associated buffer is also returned to the system.
isc_socket_tdns_dispatch_getentrysocket (dns_dispentry_t *resp)
isc_socket_tdns_dispatch_getsocket (dns_dispatch_t *disp)
 Return the socket associated with this dispatcher.
isc_result_t dns_dispatch_getlocaladdress (dns_dispatch_t *disp, isc_sockaddr_t *addrp)
 Return the local address for this dispatch. This currently only works for dispatches using UDP sockets.
void dns_dispatch_cancel (dns_dispatch_t *disp)
 cancel outstanding clients
unsigned int dns_dispatch_getattributes (dns_dispatch_t *disp)
 Return the attributes (DNS_DISPATCHATTR_xxx) of this dispatch. Only the non-changeable attributes are expected to be referenced by the caller.
void dns_dispatch_changeattributes (dns_dispatch_t *disp, unsigned int attributes, unsigned int mask)
 Set the bits described by "mask" to the corresponding values in "attributes".
void dns_dispatch_importrecv (dns_dispatch_t *disp, isc_event_t *event)
 Inform the dispatcher of a socket receive. This is used for sockets shared between dispatchers and clients. If the dispatcher fails to copy or send the event, nothing happens.
dns_dispatch_tdns_dispatchset_get (dns_dispatchset_t *dset)
 Retrieve the next dispatch from dispatch set 'dset', and increment the round-robin counter.
isc_result_t dns_dispatchset_create (isc_mem_t *mctx, isc_socketmgr_t *sockmgr, isc_taskmgr_t *taskmgr, dns_dispatch_t *source, dns_dispatchset_t **dsetp, int n)
 Given a valid dispatch 'source', create a dispatch set containing 'n' UDP dispatches, with the remainder filled out by clones of the source.
void dns_dispatchset_cancelall (dns_dispatchset_t *dset, isc_task_t *task)
 Cancel socket operations for the dispatches in 'dset'.
void dns_dispatchset_destroy (dns_dispatchset_t **dsetp)
 Dereference all the dispatches in '*dsetp', free the dispatchset memory, and set *dsetp to NULL.
void dns_dispatch_setdscp (dns_dispatch_t *disp, isc_dscp_t dscp)
isc_dscp_t dns_dispatch_getdscp (dns_dispatch_t *disp)
 Set/get the DSCP value to be used when sending responses to clients, as defined in the "listen-on" or "listen-on-v6" statements.


Detailed Description

DNS Dispatch Management Shared UDP and single-use TCP dispatches for queries and responses.

MP:

Reliability:

Resources:

Security:

Standards:

Definition in file dispatch.h.


Define Documentation

#define DNS_DISPATCH_H   1

Definition at line 19 of file dispatch.h.

#define DNS_DISPATCHATTR_PRIVATE   0x00000001U

Attributes for added dispatchers.

Values with the mask 0xffff0000 are application defined. Values with the mask 0x0000ffff are library defined.

Insane values (like setting both TCP and UDP) are not caught. Don't do that.

_PRIVATE The dispatcher cannot be shared.

_TCP, _UDP The dispatcher is a TCP or UDP socket.

_IPV4, _IPV6 The dispatcher uses an IPv4 or IPv6 socket.

_NOLISTEN The dispatcher should not listen on the socket.

_MAKEQUERY The dispatcher can be used to issue queries to other servers, and accept replies from them.

_RANDOMPORT Previously used to indicate that the port of a dispatch UDP must be chosen randomly. This behavior now always applies and the attribute is obsoleted.

_EXCLUSIVE A separate socket will be used on-demand for each transaction.

Definition at line 136 of file dispatch.h.

Referenced by dispatch_find(), dns_dispatch_createtcp(), dns_dispatch_createtcp2(), dns_dispatch_gettcp(), dns_dispatch_gettcp2(), and resquery_connected().

#define DNS_DISPATCHATTR_TCP   0x00000002U

Attributes for added dispatchers.

Values with the mask 0xffff0000 are application defined. Values with the mask 0x0000ffff are library defined.

Insane values (like setting both TCP and UDP) are not caught. Don't do that.

_PRIVATE The dispatcher cannot be shared.

_TCP, _UDP The dispatcher is a TCP or UDP socket.

_IPV4, _IPV6 The dispatcher uses an IPv4 or IPv6 socket.

_NOLISTEN The dispatcher should not listen on the socket.

_MAKEQUERY The dispatcher can be used to issue queries to other servers, and accept replies from them.

_RANDOMPORT Previously used to indicate that the port of a dispatch UDP must be chosen randomly. This behavior now always applies and the attribute is obsoleted.

_EXCLUSIVE A separate socket will be used on-demand for each transaction.

Definition at line 137 of file dispatch.h.

Referenced by create_tcp_dispatch(), dispatch_createudp(), dns_dispatch_createtcp2(), dns_dispatch_gettcp(), dns_dispatch_gettcp2(), dns_dispatch_getudp_dup(), fctx_query(), find_udp_dispatch(), get_view_querysource_dispatch(), getudpdispatch(), ns_add_reserved_dispatch(), ns_interface_listenudp(), resquery_connected(), and setup_system().

#define DNS_DISPATCHATTR_UDP   0x00000004U

Attributes for added dispatchers.

Values with the mask 0xffff0000 are application defined. Values with the mask 0x0000ffff are library defined.

Insane values (like setting both TCP and UDP) are not caught. Don't do that.

_PRIVATE The dispatcher cannot be shared.

_TCP, _UDP The dispatcher is a TCP or UDP socket.

_IPV4, _IPV6 The dispatcher uses an IPv4 or IPv6 socket.

_NOLISTEN The dispatcher should not listen on the socket.

_MAKEQUERY The dispatcher can be used to issue queries to other servers, and accept replies from them.

_RANDOMPORT Previously used to indicate that the port of a dispatch UDP must be chosen randomly. This behavior now always applies and the attribute is obsoleted.

_EXCLUSIVE A separate socket will be used on-demand for each transaction.

Definition at line 138 of file dispatch.h.

Referenced by dispatch_createudp(), dns_dispatch_addresponse3(), dns_dispatch_createtcp2(), dns_dispatchset_create(), dns_requestmgr_create(), fctx_query(), find_udp_dispatch(), get_view_querysource_dispatch(), getudpdispatch(), make_dispatchset(), ns_add_reserved_dispatch(), ns_interface_listenudp(), and setup_system().

#define DNS_DISPATCHATTR_IPV4   0x00000008U

Attributes for added dispatchers.

Values with the mask 0xffff0000 are application defined. Values with the mask 0x0000ffff are library defined.

Insane values (like setting both TCP and UDP) are not caught. Don't do that.

_PRIVATE The dispatcher cannot be shared.

_TCP, _UDP The dispatcher is a TCP or UDP socket.

_IPV4, _IPV6 The dispatcher uses an IPv4 or IPv6 socket.

_NOLISTEN The dispatcher should not listen on the socket.

_MAKEQUERY The dispatcher can be used to issue queries to other servers, and accept replies from them.

_RANDOMPORT Previously used to indicate that the port of a dispatch UDP must be chosen randomly. This behavior now always applies and the attribute is obsoleted.

_EXCLUSIVE A separate socket will be used on-demand for each transaction.

Definition at line 139 of file dispatch.h.

Referenced by create_tcp_dispatch(), fctx_query(), find_udp_dispatch(), get_view_querysource_dispatch(), getudpdispatch(), make_dispatchset(), ns_add_reserved_dispatch(), ns_interface_listenudp(), resquery_connected(), and setup_system().

#define DNS_DISPATCHATTR_IPV6   0x00000010U

Attributes for added dispatchers.

Values with the mask 0xffff0000 are application defined. Values with the mask 0x0000ffff are library defined.

Insane values (like setting both TCP and UDP) are not caught. Don't do that.

_PRIVATE The dispatcher cannot be shared.

_TCP, _UDP The dispatcher is a TCP or UDP socket.

_IPV4, _IPV6 The dispatcher uses an IPv4 or IPv6 socket.

_NOLISTEN The dispatcher should not listen on the socket.

_MAKEQUERY The dispatcher can be used to issue queries to other servers, and accept replies from them.

_RANDOMPORT Previously used to indicate that the port of a dispatch UDP must be chosen randomly. This behavior now always applies and the attribute is obsoleted.

_EXCLUSIVE A separate socket will be used on-demand for each transaction.

Definition at line 140 of file dispatch.h.

Referenced by create_tcp_dispatch(), fctx_query(), find_udp_dispatch(), get_view_querysource_dispatch(), getudpdispatch(), ns_add_reserved_dispatch(), ns_interface_listenudp(), resquery_connected(), and setup_system().

#define DNS_DISPATCHATTR_NOLISTEN   0x00000020U

Attributes for added dispatchers.

Values with the mask 0xffff0000 are application defined. Values with the mask 0x0000ffff are library defined.

Insane values (like setting both TCP and UDP) are not caught. Don't do that.

_PRIVATE The dispatcher cannot be shared.

_TCP, _UDP The dispatcher is a TCP or UDP socket.

_IPV4, _IPV6 The dispatcher uses an IPv4 or IPv6 socket.

_NOLISTEN The dispatcher should not listen on the socket.

_MAKEQUERY The dispatcher can be used to issue queries to other servers, and accept replies from them.

_RANDOMPORT Previously used to indicate that the port of a dispatch UDP must be chosen randomly. This behavior now always applies and the attribute is obsoleted.

_EXCLUSIVE A separate socket will be used on-demand for each transaction.

Definition at line 141 of file dispatch.h.

Referenced by dns_dispatch_changeattributes(), dns_dispatch_getudp_dup(), dns_dispatch_importrecv(), ns_interface_destroy(), ns_interface_listenudp(), and startrecv().

#define DNS_DISPATCHATTR_MAKEQUERY   0x00000040U

Attributes for added dispatchers.

Values with the mask 0xffff0000 are application defined. Values with the mask 0x0000ffff are library defined.

Insane values (like setting both TCP and UDP) are not caught. Don't do that.

_PRIVATE The dispatcher cannot be shared.

_TCP, _UDP The dispatcher is a TCP or UDP socket.

_IPV4, _IPV6 The dispatcher uses an IPv4 or IPv6 socket.

_NOLISTEN The dispatcher should not listen on the socket.

_MAKEQUERY The dispatcher can be used to issue queries to other servers, and accept replies from them.

_RANDOMPORT Previously used to indicate that the port of a dispatch UDP must be chosen randomly. This behavior now always applies and the attribute is obsoleted.

_EXCLUSIVE A separate socket will be used on-demand for each transaction.

Definition at line 142 of file dispatch.h.

Referenced by create_tcp_dispatch(), resquery_connected(), and setup_system().

#define DNS_DISPATCHATTR_CONNECTED   0x00000080U

Attributes for added dispatchers.

Values with the mask 0xffff0000 are application defined. Values with the mask 0x0000ffff are library defined.

Insane values (like setting both TCP and UDP) are not caught. Don't do that.

_PRIVATE The dispatcher cannot be shared.

_TCP, _UDP The dispatcher is a TCP or UDP socket.

_IPV4, _IPV6 The dispatcher uses an IPv4 or IPv6 socket.

_NOLISTEN The dispatcher should not listen on the socket.

_MAKEQUERY The dispatcher can be used to issue queries to other servers, and accept replies from them.

_RANDOMPORT Previously used to indicate that the port of a dispatch UDP must be chosen randomly. This behavior now always applies and the attribute is obsoleted.

_EXCLUSIVE A separate socket will be used on-demand for each transaction.

Definition at line 143 of file dispatch.h.

Referenced by dns_dispatch_addresponse3(), dns_dispatch_gettcp(), dns_dispatch_gettcp2(), dns_dispatch_starttcp(), and resquery_connected().

#define DNS_DISPATCHATTR_FIXEDID   0x00000100U

Attributes for added dispatchers.

Values with the mask 0xffff0000 are application defined. Values with the mask 0x0000ffff are library defined.

Insane values (like setting both TCP and UDP) are not caught. Don't do that.

_PRIVATE The dispatcher cannot be shared.

_TCP, _UDP The dispatcher is a TCP or UDP socket.

_IPV4, _IPV6 The dispatcher uses an IPv4 or IPv6 socket.

_NOLISTEN The dispatcher should not listen on the socket.

_MAKEQUERY The dispatcher can be used to issue queries to other servers, and accept replies from them.

_RANDOMPORT Previously used to indicate that the port of a dispatch UDP must be chosen randomly. This behavior now always applies and the attribute is obsoleted.

_EXCLUSIVE A separate socket will be used on-demand for each transaction.

Definition at line 144 of file dispatch.h.

Referenced by dns_dispatch_addresponse3().

#define DNS_DISPATCHATTR_EXCLUSIVE   0x00000200U

Attributes for added dispatchers.

Values with the mask 0xffff0000 are application defined. Values with the mask 0x0000ffff are library defined.

Insane values (like setting both TCP and UDP) are not caught. Don't do that.

_PRIVATE The dispatcher cannot be shared.

_TCP, _UDP The dispatcher is a TCP or UDP socket.

_IPV4, _IPV6 The dispatcher uses an IPv4 or IPv6 socket.

_NOLISTEN The dispatcher should not listen on the socket.

_MAKEQUERY The dispatcher can be used to issue queries to other servers, and accept replies from them.

_RANDOMPORT Previously used to indicate that the port of a dispatch UDP must be chosen randomly. This behavior now always applies and the attribute is obsoleted.

_EXCLUSIVE A separate socket will be used on-demand for each transaction.

Definition at line 145 of file dispatch.h.

Referenced by dispatch_createudp(), dispatch_find(), dns_dispatch_addresponse(), dns_dispatch_addresponse3(), dns_dispatch_changeattributes(), dns_dispatch_gettcp(), dns_dispatch_gettcp2(), dns_dispatch_getudp_dup(), dns_resolver_create(), get_view_querysource_dispatch(), req_cancel(), req_getsocket(), startrecv(), and udp_recv().

#define DNS_DISPATCHOPT_FIXEDID   0x00000001U

Definition at line 150 of file dispatch.h.

Referenced by dns_dispatch_addresponse3(), and dns_request_createraw4().


Function Documentation

isc_result_t dns_dispatchmgr_create ( isc_mem_t mctx,
isc_entropy_t entropy,
dns_dispatchmgr_t **  mgrp 
)

Creates a new dispatchmgr object.

Requires:

Returns:

Definition at line 1756 of file dispatch.c.

References dns_dispatchmgr::blackhole, create_default_portset(), DESTROYLOCK, DNS_DISPATCHMGR_MAGIC, dns_dispatchmgr_setavailports(), dns_dispatchmgr::entropy, isc_entropy_attach(), ISC_LIST_INIT, isc_mem_attach(), isc_mem_detach(), isc_mem_get, isc_mem_put, isc_mempool_associatelock(), isc_mempool_create(), isc_mempool_destroy(), isc_mempool_setfillcount(), isc_mempool_setfreemax(), isc_mempool_setmaxalloc(), isc_mempool_setname(), isc_mutex_init, isc_portset_destroy(), ISC_R_NOMEMORY, ISC_R_SUCCESS, isc_rng_create(), dns_dispatchmgr::lock, dns_dispatchmgr::magic, dns_dispatchmgr::mctx, REQUIRE, dns_dispatchmgr::state, and dns_dispatchmgr::stats.

Referenced by dns_client_createx2(), make_dispatchset(), run_server(), and setup_system().

void dns_dispatchmgr_destroy ( dns_dispatchmgr_t **  mgrp  ) 

Destroys the dispatchmgr when it becomes empty. This could be immediately.

Requires:

Definition at line 2116 of file dispatch.c.

References destroy_mgr(), destroy_mgr_ok(), dns_dispatchmgr::lock, LOCK, LVL, mgr_log(), MGR_SHUTTINGDOWN, REQUIRE, dns_dispatchmgr::state, UNLOCK, and VALID_DISPATCHMGR.

Referenced by destroyclient(), dns_client_createx2(), doshutdown(), shutdown_server(), and teardown().

void dns_dispatchmgr_setblackhole ( dns_dispatchmgr_t mgr,
dns_acl_t blackhole 
)

Sets the dispatcher's "blackhole list," a list of addresses that will be ignored by all dispatchers created by the dispatchmgr.

Requires:

Definition at line 1920 of file dispatch.c.

References dns_dispatchmgr::blackhole, dns_acl_attach(), dns_acl_detach(), REQUIRE, and VALID_DISPATCHMGR.

Referenced by load_configuration().

dns_acl_t* dns_dispatchmgr_getblackhole ( dns_dispatchmgr_t mgr  ) 

Gets a pointer to the dispatcher's current blackhole list, without incrementing its reference count.

Requires:

Definition at line 1928 of file dispatch.c.

References dns_dispatchmgr::blackhole, REQUIRE, and VALID_DISPATCHMGR.

Referenced by isblackholed(), and possibly_mark().

void dns_dispatchmgr_setblackportlist ( dns_dispatchmgr_t mgr,
dns_portlist_t portlist 
)

This function is deprecated. Use dns_dispatchmgr_setavailports() instead.

Requires:

Definition at line 1934 of file dispatch.c.

References REQUIRE, UNUSED, and VALID_DISPATCHMGR.

dns_portlist_t* dns_dispatchmgr_getblackportlist ( dns_dispatchmgr_t mgr  ) 

This function is deprecated and always returns NULL.

Requires:

Definition at line 1945 of file dispatch.c.

References REQUIRE, and VALID_DISPATCHMGR.

isc_result_t dns_dispatchmgr_setavailports ( dns_dispatchmgr_t mgr,
isc_portset_t v4portset,
isc_portset_t v6portset 
)

Sets a list of UDP ports that can be used for outgoing UDP messages.

Requires:

Definition at line 1951 of file dispatch.c.

References INSIST, isc_mem_get, isc_mem_put, isc_portset_isset(), isc_portset_nports(), ISC_R_NOMEMORY, ISC_R_SUCCESS, dns_dispatchmgr::mctx, PORTBUFLOCK, PORTBUFUNLOCK, REQUIRE, and VALID_DISPATCHMGR.

Referenced by dns_dispatchmgr_create(), and load_configuration().

void dns_dispatchmgr_setstats ( dns_dispatchmgr_t mgr,
isc_stats_t stats 
)

Sets statistics counter for the dispatchmgr. This function is expected to be called only on zone creation (when necessary). Once installed, it cannot be removed or replaced. Also, there is no interface to get the installed stats from the zone; the caller must keep the stats to reference (e.g. dump) it later.

Requires:

Definition at line 2138 of file dispatch.c.

References ISC_LIST_EMPTY, isc_stats_attach(), REQUIRE, dns_dispatchmgr::stats, and VALID_DISPATCHMGR.

Referenced by run_server().

isc_result_t dns_dispatch_getudp ( dns_dispatchmgr_t mgr,
isc_socketmgr_t sockmgr,
isc_taskmgr_t taskmgr,
isc_sockaddr_t localaddr,
unsigned int  buffersize,
unsigned int  maxbuffers,
unsigned int  maxrequests,
unsigned int  buckets,
unsigned int  increment,
unsigned int  attributes,
unsigned int  mask,
dns_dispatch_t **  dispp 
)

Definition at line 2842 of file dispatch.c.

References dns_dispatch_getudp_dup().

Referenced by fctx_query(), find_udp_dispatch(), get_view_querysource_dispatch(), getudpdispatch(), make_dispatchset(), ns_add_reserved_dispatch(), and setup_system().

isc_result_t dns_dispatch_getudp_dup ( dns_dispatchmgr_t mgr,
isc_socketmgr_t sockmgr,
isc_taskmgr_t taskmgr,
isc_sockaddr_t localaddr,
unsigned int  buffersize,
unsigned int  maxbuffers,
unsigned int  maxrequests,
unsigned int  buckets,
unsigned int  increment,
unsigned int  attributes,
unsigned int  mask,
dns_dispatch_t **  dispp,
dns_dispatch_t dup 
)

Attach to existing dns_dispatch_t if one is found with dns_dispatchmgr_find, otherwise create a new UDP dispatch.

Requires:

Returns:

Definition at line 2756 of file dispatch.c.

References dispatch_createudp(), dispatch_find(), DNS_DISPATCHATTR_EXCLUSIVE, DNS_DISPATCHATTR_NOLISTEN, DNS_DISPATCHATTR_TCP, dns_dispatchmgr_setudp(), ISC_R_SUCCESS, isc_sockaddr_getport(), ISC_SOCKCANCEL_RECV, isc_socket_cancel(), dns_dispatchmgr::lock, LOCK, dns_dispatch::maxrequests, REQUIRE, dns_dispatch::socket, dns_dispatch::task, UNLOCK, and VALID_DISPATCHMGR.

Referenced by dns_dispatch_getudp(), and ns_interface_listenudp().

isc_result_t dns_dispatch_createtcp ( dns_dispatchmgr_t mgr,
isc_socket_t sock,
isc_taskmgr_t taskmgr,
unsigned int  buffersize,
unsigned int  maxbuffers,
unsigned int  maxrequests,
unsigned int  buckets,
unsigned int  increment,
unsigned int  attributes,
dns_dispatch_t **  dispp 
)

Definition at line 2503 of file dispatch.c.

References dns_dispatch_createtcp2(), and DNS_DISPATCHATTR_PRIVATE.

Referenced by resquery_connected().

isc_result_t dns_dispatch_createtcp2 ( dns_dispatchmgr_t mgr,
isc_socket_t sock,
isc_taskmgr_t taskmgr,
isc_sockaddr_t localaddr,
isc_sockaddr_t destaddr,
unsigned int  buffersize,
unsigned int  maxbuffers,
unsigned int  maxrequests,
unsigned int  buckets,
unsigned int  increment,
unsigned int  attributes,
dns_dispatch_t **  dispp 
)

Create a new dns_dispatch and attach it to the provided isc_socket_t.

For all dispatches, "buffersize" is the maximum packet size we will accept.

"maxbuffers" and "maxrequests" control the number of buffers in the overall system and the number of buffers which can be allocated to requests.

"buckets" is the number of buckets to use, and should be prime.

"increment" is used in a collision avoidance function, and needs to be a prime > buckets, and not 2.

Requires:

Returns:

Definition at line 2519 of file dispatch.c.

References AF_INET6, dns_dispatch::ctlevent, destroy_disp(), dispatch_allocate(), dispatch_free(), dispatch_log(), DNS_DISPATCHATTR_PRIVATE, DNS_DISPATCHATTR_TCP, DNS_DISPATCHATTR_UDP, DNS_EVENT_DISPATCHCONTROL, dns_tcpmsg_init(), isc_event_allocate(), ISC_FALSE, ISC_LIST_APPEND, ISC_R_NOMEMORY, ISC_R_SUCCESS, isc_sockaddr_any(), isc_sockaddr_any6(), isc_sockaddr_pf(), isc_socket_attach(), isc_socket_detach(), isc_socket_gettype(), isc_sockettype_tcp, isc_task_create(), isc_task_detach(), isc_task_setname(), dns_dispatch::local, dns_dispatchmgr::lock, LOCK, LVL, dns_dispatchmgr::mctx, mgr_log(), dns_dispatch::ntasks, dns_dispatch::peer, qid_allocate(), REQUIRE, dns_dispatch::sepool, dns_dispatch::socket, dns_dispatch::task, UNLOCK, UNUSED, and VALID_DISPATCHMGR.

Referenced by create_tcp_dispatch(), and dns_dispatch_createtcp().

void dns_dispatch_attach ( dns_dispatch_t disp,
dns_dispatch_t **  dispp 
)

Attach to a dispatch handle.

Requires:

Definition at line 3128 of file dispatch.c.

References LOCK, REQUIRE, UNLOCK, and VALID_DISPATCH.

Referenced by dns_dispatchset_create(), dns_requestmgr_create(), fctx_query(), find_udp_dispatch(), and get_client().

void dns_dispatch_detach ( dns_dispatch_t **  dispp  ) 

Detaches from the dispatch.

Requires:

Definition at line 3147 of file dispatch.c.

References dns_dispatch::ctlevent, destroy_disp_ok(), dispatch_log(), INSIST, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_SOCKCANCEL_RECV, isc_socket_cancel(), isc_task_send(), LOCK, LVL, REQUIRE, dns_dispatch::socket, dns_dispatch::task, UNLOCK, and VALID_DISPATCH.

Referenced by configure_view(), destroyclient(), dns_client_createx2(), dns_dispatchset_create(), dns_dispatchset_destroy(), dns_request_createraw4(), dns_request_createvia4(), doshutdown(), end_reserved_dispatches(), exit_check(), fctx_cancelquery(), fctx_query(), make_dispatchset(), mgr_destroy(), ns_interface_destroy(), ns_interface_listenudp(), req_cancel(), and req_destroy().

void dns_dispatch_starttcp ( dns_dispatch_t disp  ) 

Start processing of a TCP dispatch once the socket connects.

Requires:

Definition at line 3404 of file dispatch.c.

References dispatch_log(), DNS_DISPATCHATTR_CONNECTED, LOCK, LVL, REQUIRE, startrecv(), dns_dispatch::task, UNLOCK, and VALID_DISPATCH.

Referenced by req_connected().

isc_result_t dns_dispatch_gettcp ( dns_dispatchmgr_t mgr,
isc_sockaddr_t destaddr,
isc_sockaddr_t localaddr,
dns_dispatch_t **  dispp 
)

Definition at line 2630 of file dispatch.c.

References ATTRMATCH, DNS_DISPATCHATTR_CONNECTED, DNS_DISPATCHATTR_EXCLUSIVE, DNS_DISPATCHATTR_PRIVATE, DNS_DISPATCHATTR_TCP, ISC_FALSE, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_R_NOTFOUND, ISC_R_SUCCESS, isc_sockaddr_eqaddr(), isc_sockaddr_equal(), isc_socket_getpeername(), isc_socket_getsockname(), ISC_TRUE, dns_dispatch::local, dns_dispatchmgr::lock, LOCK, match(), REQUIRE, dns_dispatch::socket, UNLOCK, and VALID_DISPATCHMGR.

Referenced by create_tcp_dispatch().

isc_result_t dns_dispatch_gettcp2 ( dns_dispatchmgr_t mgr,
isc_sockaddr_t destaddr,
isc_sockaddr_t localaddr,
isc_boolean_t connected,
dns_dispatch_t **  dispp 
)

Definition at line 2679 of file dispatch.c.

References ATTRMATCH, DNS_DISPATCHATTR_CONNECTED, DNS_DISPATCHATTR_EXCLUSIVE, DNS_DISPATCHATTR_PRIVATE, DNS_DISPATCHATTR_TCP, ISC_FALSE, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_R_NOTFOUND, ISC_R_SUCCESS, isc_sockaddr_eqaddr(), isc_sockaddr_equal(), isc_socket_getpeername(), isc_socket_getsockname(), ISC_TRUE, dns_dispatch::local, dns_dispatchmgr::lock, LOCK, match(), dns_dispatch::peer, REQUIRE, dns_dispatch::socket, UNLOCK, and VALID_DISPATCHMGR.

Referenced by create_tcp_dispatch().

isc_result_t dns_dispatch_addresponse3 ( dns_dispatch_t disp,
unsigned int  options,
isc_sockaddr_t dest,
isc_task_t task,
isc_taskaction_t  action,
void *  arg,
isc_uint16_t idp,
dns_dispentry_t **  resp,
isc_socketmgr_t sockmgr 
)

isc_result_t dns_dispatch_addresponse2 ( dns_dispatch_t disp,
isc_sockaddr_t dest,
isc_task_t task,
isc_taskaction_t  action,
void *  arg,
isc_uint16_t idp,
dns_dispentry_t **  resp,
isc_socketmgr_t sockmgr 
)

isc_result_t dns_dispatch_addresponse ( dns_dispatch_t disp,
isc_sockaddr_t dest,
isc_task_t task,
isc_taskaction_t  action,
void *  arg,
isc_uint16_t idp,
dns_dispentry_t **  resp 
)

Add a response entry for this dispatch.

"*idp" is filled in with the assigned message ID, and *resp is filled in to contain the magic token used to request event flow stop.

Arranges for the given task to get a callback for response packets. When the event is delivered, it must be returned using dns_dispatch_freeevent() or through dns_dispatch_removeresponse() for another to be delivered.

Requires:

Ensures:

Returns:

void dns_dispatch_removeresponse ( dns_dispentry_t **  resp,
dns_dispatchevent_t **  sockevent 
)

Stops the flow of responses for the provided id and destination. If "sockevent" is non-NULL, the dispatch event and associated buffer is also returned to the system.

Requires:

Definition at line 3419 of file dispatch.c.

References isc_buffer::base, dns_dispentry::bucket, dns_dispatchevent::buffer, dns_dispatch::ctlevent, dec_stats(), destroy_disp_ok(), dns_dispentry::disp, dns_dispentry::dispsocket, DNS_EVENT_DISPATCH, DNS_QID, dns_qid_t, dns_resstatscounter_dispreqtcp, dns_resstatscounter_disprequdp, do_cancel(), free_buffer(), free_devent(), INSIST, ISC_FALSE, ISC_LIST_HEAD, ISC_LIST_INIT, ISC_LIST_NEXT, ISC_LIST_UNLINK, isc_mempool_put, ISC_SOCKCANCEL_RECV, isc_socket_cancel(), isc_task_detach(), isc_task_send(), isc_task_unsend(), ISC_TRUE, dns_dispentry::item_out, isc_buffer::length, LOCK, LVL, dns_dispentry::magic, dns_dispatch::mgr, request_log(), REQUIRE, dns_dispatch::socket, startrecv(), dns_dispentry::task, dns_dispatch::task, UNLOCK, VALID_DISPATCH, VALID_DISPATCHMGR, and VALID_RESPONSE.

Referenced by dns_request_createvia4(), fctx_cancelquery(), req_cancel(), req_destroy(), req_response(), and resquery_send().

isc_socket_t* dns_dispatch_getentrysocket ( dns_dispentry_t resp  ) 

Definition at line 3592 of file dispatch.c.

References dns_dispentry::dispsocket, REQUIRE, and VALID_RESPONSE.

Referenced by fctx_cancelquery(), req_cancel(), req_getsocket(), and resquery_send().

isc_socket_t* dns_dispatch_getsocket ( dns_dispatch_t disp  ) 

Return the socket associated with this dispatcher.

Requires:

Returns:

Definition at line 3585 of file dispatch.c.

References REQUIRE, dns_dispatch::socket, and VALID_DISPATCH.

Referenced by dns_dispatchset_cancelall(), fctx_cancelquery(), get_client(), req_cancel(), req_getsocket(), and resquery_send().

isc_result_t dns_dispatch_getlocaladdress ( dns_dispatch_t disp,
isc_sockaddr_t addrp 
)

Return the local address for this dispatch. This currently only works for dispatches using UDP sockets.

Requires:

Returns:

Definition at line 3602 of file dispatch.c.

References ISC_R_NOTIMPLEMENTED, ISC_R_SUCCESS, isc_sockettype_udp, dns_dispatch::local, REQUIRE, and VALID_DISPATCH.

Referenced by adjust_interfaces(), and fctx_query().

void dns_dispatch_cancel ( dns_dispatch_t disp  ) 

cancel outstanding clients

Requires:

Definition at line 3615 of file dispatch.c.

References do_cancel(), ISC_R_CANCELED, LOCK, REQUIRE, UNLOCK, and VALID_DISPATCH.

unsigned int dns_dispatch_getattributes ( dns_dispatch_t disp  ) 

Return the attributes (DNS_DISPATCHATTR_xxx) of this dispatch. Only the non-changeable attributes are expected to be referenced by the caller.

Requires:

Definition at line 3635 of file dispatch.c.

References REQUIRE, and VALID_DISPATCH.

Referenced by dns_requestmgr_create(), dns_resolver_create(), req_cancel(), and req_getsocket().

void dns_dispatch_changeattributes ( dns_dispatch_t disp,
unsigned int  attributes,
unsigned int  mask 
)

Set the bits described by "mask" to the corresponding values in "attributes".

That is:

        new = (old & ~mask) | (attributes & mask)

This function has a side effect when DNS_DISPATCHATTR_NOLISTEN changes. When the flag becomes off, the dispatch will start receiving on the corresponding socket. When the flag becomes on, receive events on the corresponding socket will be canceled.

Requires:

Definition at line 3646 of file dispatch.c.

References DNS_DISPATCHATTR_EXCLUSIVE, DNS_DISPATCHATTR_NOLISTEN, ISC_SOCKCANCEL_RECV, isc_socket_cancel(), LOCK, REQUIRE, dns_dispatch::socket, startrecv(), dns_dispatch::task, UNLOCK, and VALID_DISPATCH.

Referenced by ns_interface_destroy(), and ns_interface_listenudp().

void dns_dispatch_importrecv ( dns_dispatch_t disp,
isc_event_t event 
)

Inform the dispatcher of a socket receive. This is used for sockets shared between dispatchers and clients. If the dispatcher fails to copy or send the event, nothing happens.

Requires:

Definition at line 3683 of file dispatch.c.

References isc_socketevent::address, allocate_udp_buffer(), isc_socketevent::attributes, isc_region::base, DNS_DISPATCHATTR_NOLISTEN, DNS_EVENT_IMPORTRECVDONE, INSIST, isc_event_allocate(), isc_event_free(), ISC_EVENT_PTR, isc_task_send(), isc_region::length, dns_dispatchmgr::mctx, dns_dispatch::mgr, isc_socketevent::n, isc_socketevent::pktinfo, isc_socketevent::region, REQUIRE, isc_socketevent::result, dns_dispatch::task, isc_socketevent::timestamp, udp_shrecv(), and VALID_DISPATCH.

Referenced by client_request().

dns_dispatch_t* dns_dispatchset_get ( dns_dispatchset_t dset  ) 

Retrieve the next dispatch from dispatch set 'dset', and increment the round-robin counter.

Requires:

Definition at line 3720 of file dispatch.c.

References dns_dispatchset::cur, dns_dispatchset::dispatches, dns_dispatchset::lock, LOCK, dns_dispatchset::ndisp, and UNLOCK.

Referenced by ATF_TC_BODY(), dns_resolver_dispatchv4(), and dns_resolver_dispatchv6().

isc_result_t dns_dispatchset_create ( isc_mem_t mctx,
isc_socketmgr_t sockmgr,
isc_taskmgr_t taskmgr,
dns_dispatch_t source,
dns_dispatchset_t **  dsetp,
int  n 
)

Given a valid dispatch 'source', create a dispatch set containing 'n' UDP dispatches, with the remainder filled out by clones of the source.

Requires:

Definition at line 3738 of file dispatch.c.

References dns_dispatchset::cur, DESTROYLOCK, dispatch_createudp(), dns_dispatchset::dispatches, dns_dispatch_attach(), dns_dispatch_detach(), DNS_DISPATCHATTR_UDP, dset, isc_mem_attach(), isc_mem_detach(), isc_mem_get, isc_mem_put, isc_mutex_init, ISC_R_NOMEMORY, ISC_R_SUCCESS, dns_dispatch::local, dns_dispatchmgr::lock, LOCK, dns_dispatchset::lock, dns_dispatch::maxrequests, dns_dispatchset::mctx, dns_dispatch::mgr, dns_dispatchset::ndisp, REQUIRE, dns_dispatch::socket, UNLOCK, and VALID_DISPATCH.

Referenced by dns_resolver_create(), and make_dispatchset().

void dns_dispatchset_cancelall ( dns_dispatchset_t dset,
isc_task_t task 
)

Cancel socket operations for the dispatches in 'dset'.

Definition at line 3811 of file dispatch.c.

References dns_dispatchset::dispatches, dns_dispatch_getsocket(), ISC_SOCKCANCEL_ALL, isc_socket_cancel(), dns_dispatchset::ndisp, REQUIRE, and sock.

Referenced by dns_resolver_shutdown().

void dns_dispatchset_destroy ( dns_dispatchset_t **  dsetp  ) 

Dereference all the dispatches in '*dsetp', free the dispatchset memory, and set *dsetp to NULL.

Requires:

Definition at line 3824 of file dispatch.c.

References DESTROYLOCK, dns_dispatchset::dispatches, dns_dispatch_detach(), dset, isc_mem_put, isc_mem_putanddetach, dns_dispatchset::lock, dns_dispatchset::mctx, dns_dispatchset::ndisp, and REQUIRE.

Referenced by destroy(), dns_resolver_create(), and teardown().

void dns_dispatch_setdscp ( dns_dispatch_t disp,
isc_dscp_t  dscp 
)

Definition at line 3842 of file dispatch.c.

References dns_dispatch::dscp, REQUIRE, and VALID_DISPATCH.

isc_dscp_t dns_dispatch_getdscp ( dns_dispatch_t disp  ) 

Set/get the DSCP value to be used when sending responses to clients, as defined in the "listen-on" or "listen-on-v6" statements.

Requires:

Definition at line 3848 of file dispatch.c.

References dns_dispatch::dscp, REQUIRE, and VALID_DISPATCH.

Referenced by client_sendpkg().


Generated on Tue Apr 28 17:41:09 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha