Constants for netevent callback error value.

git-svn-id: file:///svn/unbound/trunk@66 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards 2007-02-05 14:25:07 +00:00
parent f62a1e549a
commit 193ff884bb
4 changed files with 17 additions and 8 deletions

View file

@ -1,6 +1,7 @@
5 February 2007: Wouter
- Picked up stdc99 and other define tests from ldns. Improved
POSIX define test to include getaddrinfo.
- defined constants for netevent callback error code.
2 February 2007: Wouter
- Created udp4 and udp6 port arrays to provide service for both

View file

@ -107,7 +107,7 @@ static int outnet_udp_cb(struct comm_point* c, void* arg, int error,
}
comm_timer_disable(p->timer);
log_info("outnet handle udp reply");
(void)(*p->cb)(p->c, p->cb_arg, 0, NULL);
(void)(*p->cb)(p->c, p->cb_arg, NETEVENT_NOERROR, NULL);
return 0;
}
@ -227,7 +227,7 @@ static void pending_udp_timer_cb(void *arg)
struct pending* p = (struct pending*)arg;
/* it timed out */
log_info("timeout udp");
(void)(*p->cb)(p->c, p->cb_arg, -2, NULL);
(void)(*p->cb)(p->c, p->cb_arg, NETEVENT_TIMEOUT, NULL);
}
struct outside_network*
@ -448,7 +448,7 @@ void pending_udp_query(struct outside_network* outnet, ldns_buffer* packet,
/* create pending struct (and possibly change ID to be unique) */
if(!(pend=new_pending(outnet, packet, addr, addrlen, cb, cb_arg))) {
/* callback user for the error */
(void)(*cb)(NULL, cb_arg, -1, NULL);
(void)(*cb)(NULL, cb_arg, NETEVENT_CLOSED, NULL);
return;
}
select_port(outnet, pend);
@ -459,7 +459,7 @@ void pending_udp_query(struct outside_network* outnet, ldns_buffer* packet,
/* error, call error callback function */
pending_delete(outnet, pend);
/* callback user for the error */
(void)(*pend->cb)(pend->c, pend->cb_arg, -1, NULL);
(void)(*pend->cb)(pend->c, pend->cb_arg, NETEVENT_CLOSED, NULL);
return;
}

View file

@ -209,7 +209,7 @@ comm_point_udp_callback(int fd, short event, void* arg)
}
ldns_buffer_skip(rep.c->buffer, recv);
ldns_buffer_flip(rep.c->buffer);
if((*rep.c->callback)(rep.c, rep.c->cb_arg, 0, &rep)) {
if((*rep.c->callback)(rep.c, rep.c->cb_arg, NETEVENT_NOERROR, &rep)) {
/* send back immediate reply */
(void)comm_point_send_udp_msg(rep.c, rep.c->buffer,
(struct sockaddr*)&rep.addr, rep.addrlen);

View file

@ -66,6 +66,13 @@ struct internal_timer;
typedef int comm_point_callback_t(struct comm_point*, void*, int,
struct comm_reply*);
/** to pass no_error to callback function */
#define NETEVENT_NOERROR 0
/** to pass closed connection to callback function */
#define NETEVENT_CLOSED -1
/** to pass timeout happened to callback function */
#define NETEVENT_TIMEOUT -2
/**
* A communication point dispatcher. Thread specific.
*/
@ -142,10 +149,11 @@ struct comm_point {
tcp_accept does not get called back, is NULL then.
If a timeout happens, callback with timeout=1 is called.
If an error happens, callback is called with error set
nonzero. If nonzero, it is an errno value.
nonzero. If not NETEVENT_NOERROR, it is an errno value.
If the connection is closed (by remote end) then the
callback is called with error set to -1.
If a timeout happens on the connection, the error is set to -2.
callback is called with error set to NETEVENT_CLOSED=-1.
If a timeout happens on the connection, the error is set to
NETEVENT_TIMEOUT=-2.
The reply_info can be copied if the reply needs to happen at a
later time. It consists of a struct with commpoint and address.
It can be passed to a msg send routine some time later.