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
}
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;
}
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*
/* 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);
/* 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;
}
}
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);
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.
*/
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.