unsigned int refcount; /*%< number of users */
dns_dispatchevent_t *failsafe_ev; /*%< failsafe cancel event */
unsigned int shutting_down : 1, shutdown_out : 1, connected : 1,
- tcpmsg_valid : 1, recv_pending : 1; /*%< is a
- * recv()
- * pending?
- * */
+ tcpmsg_valid : 1, recv_pending : 1; /*%< is a recv() pending? *
+ */
isc_result_t shutdown_why;
ISC_LIST(dispsocket_t) activesockets;
ISC_LIST(dispsocket_t) inactivesockets;
if ((attributes & DNS_DISPATCHATTR_EXCLUSIVE) != 0) {
REQUIRE(isc_sockaddr_getport(localaddr) == 0);
- goto createudp;
}
-createudp:
/*
* Nope, create one.
*/
return (ISC_R_NOTIMPLEMENTED);
}
-void
-dns_dispatch_cancel(dns_dispatch_t *disp) {
- REQUIRE(VALID_DISPATCH(disp));
-
- LOCK(&disp->lock);
-
- if (disp->shutting_down == 1) {
- UNLOCK(&disp->lock);
- return;
- }
-
- disp->shutdown_why = ISC_R_CANCELED;
- disp->shutting_down = 1;
- do_cancel(disp);
-
- UNLOCK(&disp->lock);
-
- return;
-}
-
unsigned int
dns_dispatch_getattributes(dns_dispatch_t *disp) {
REQUIRE(VALID_DISPATCH(disp));
UNLOCK(&disp->lock);
}
-void
-dns_dispatch_importrecv(dns_dispatch_t *disp, isc_event_t *event) {
- void *buf;
- isc_socketevent_t *sevent, *newsevent;
-
- REQUIRE(VALID_DISPATCH(disp));
- REQUIRE(event != NULL);
-
- if ((disp->attributes & DNS_DISPATCHATTR_NOLISTEN) == 0) {
- return;
- }
-
- sevent = (isc_socketevent_t *)event;
- INSIST(sevent->n <= disp->mgr->buffersize);
-
- newsevent = (isc_socketevent_t *)isc_event_allocate(
- disp->mgr->mctx, NULL, DNS_EVENT_IMPORTRECVDONE, udp_shrecv,
- disp, sizeof(isc_socketevent_t));
-
- buf = allocate_udp_buffer(disp);
- if (buf == NULL) {
- isc_event_free(ISC_EVENT_PTR(&newsevent));
- return;
- }
- memmove(buf, sevent->region.base, sevent->n);
- newsevent->region.base = buf;
- newsevent->region.length = disp->mgr->buffersize;
- newsevent->n = sevent->n;
- newsevent->result = sevent->result;
- newsevent->address = sevent->address;
- newsevent->timestamp = sevent->timestamp;
- newsevent->pktinfo = sevent->pktinfo;
- newsevent->attributes = sevent->attributes;
-
- isc_task_send(disp->task[0], ISC_EVENT_PTR(&newsevent));
-}
-
dns_dispatch_t *
dns_dispatchset_get(dns_dispatchset_t *dset) {
dns_dispatch_t *disp;
isc_mutex_destroy(&dset->lock);
isc_mem_putanddetach(&dset->mctx, dset, sizeof(dns_dispatchset_t));
}
-
-void
-dns_dispatch_setdscp(dns_dispatch_t *disp, isc_dscp_t dscp) {
- REQUIRE(VALID_DISPATCH(disp));
- disp->dscp = dscp;
-}
-
-isc_dscp_t
-dns_dispatch_getdscp(dns_dispatch_t *disp) {
- REQUIRE(VALID_DISPATCH(disp));
- return (disp->dscp);
-}
-
-#if 0
-void
-dns_dispatchmgr_dump(dns_dispatchmgr_t *mgr) {
- dns_dispatch_t *disp;
- char foo[1024];
-
- disp = ISC_LIST_HEAD(mgr->list);
- while (disp != NULL) {
- isc_sockaddr_format(&disp->local, foo, sizeof(foo));
- printf("\tdispatch %p, addr %s\n", disp, foo);
- disp = ISC_LIST_NEXT(disp, link);
- }
-}
-#endif /* if 0 */
* 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.
*/
*\li ISC_R_NOTIMPLEMENTED
*/
-void
-dns_dispatch_cancel(dns_dispatch_t *disp);
-/*%<
- * cancel outstanding clients
- *
- * Requires:
- *\li disp is valid.
- */
-
unsigned int
dns_dispatch_getattributes(dns_dispatch_t *disp);
/*%<
* attribute on a TCP socket isn't reasonable.
*/
-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.
- *
- * If the attribute DNS_DISPATCHATTR_NOLISTEN is not set, then
- * the dispatch is already handling a recv; return immediately.
- *
- * Requires:
- *\li disp is valid, and the attribute DNS_DISPATCHATTR_NOLISTEN is set.
- * event != NULL
- */
-
dns_dispatch_t *
dns_dispatchset_get(dns_dispatchset_t *dset);
/*%<
*\li dset is valid
*/
-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.
- *
- * Requires:
- *\li disp is valid.
- */
-
isc_result_t
dns_dispatch_getnext(dns_dispentry_t *resp, dns_dispatchevent_t **sockevent);
/*%<