]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Constants for netevent callback error value.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 5 Feb 2007 14:25:07 +0000 (14:25 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 5 Feb 2007 14:25:07 +0000 (14:25 +0000)
git-svn-id: file:///svn/unbound/trunk@66 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
services/outside_network.c
util/netevent.c
util/netevent.h

index ec1484515ee7310f24a7de9be72199ebaeb24ca2..d85b6677de164e53bcfdc3e1fe50ba2621ed741d 100644 (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
index d2ef6e9e2936126e46b07be8b3308e5edf0481b8..ea4255278178afe1a76c6ccf8cf304100330db99 100644 (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;
        }
 
index 17db720b6e2fe5b1fada40553e3ca8631b38d64e..1067b73306761649c4d814820dd5329119406547 100644 (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);
index a47a9dd7cbdb2f04414684e1ee264b3d9e609ba3..02ae94b1004c2dfcc2b7abb14da09a27aaf12a83 100644 (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.