and unit test for addr_in_common().
- 0.8: access-control config file element.
and unit test rpl replay file.
+ - 0.8: fixup address reporting from netevent.
16 November 2007: Wouter
- privilege separation is not needed in unbound at this time.
w->outnet->tcp_free = pend->next_free;
pend->next_free = NULL;
pend->query = w;
+ pend->c->repinfo.addrlen = w->addrlen;
+ memcpy(&pend->c->repinfo.addr, &w->addr, w->addrlen);
ldns_buffer_clear(pend->c->buffer);
ldns_buffer_write(pend->c->buffer, pkt, pkt_len);
ldns_buffer_flip(pend->c->buffer);
} else if(parse_keyword(&remain, "QUERY")) {
mom->evt_type = repevt_front_query;
readentry = 1;
+ if(!extstrtoaddr("127.0.0.1", &mom->addr, &mom->addrlen))
+ fatal_exit("internal error");
} else if(parse_keyword(&remain, "CHECK_ANSWER")) {
mom->evt_type = repevt_front_reply;
readentry = 1;
free(mom);
return NULL;
}
- }
+ }
if(readentry) {
mom->match = read_entry(in, name, lineno, ttl, or, prev);
comm_point_tcp_accept_callback(int fd, short event, void* arg)
{
struct comm_point* c = (struct comm_point*)arg, *c_hdl;
- struct comm_reply rep;
int new_fd;
log_assert(c->type == comm_tcp_accept);
if(!(event & EV_READ)) {
log_info("ignoring tcp accept event %d", (int)event);
return;
}
+ /* find free tcp handler. */
+ if(!c->tcp_free) {
+ log_warn("accepted too many tcp, connections full");
+ return;
+ }
/* accept incoming connection. */
- rep.c = NULL;
- rep.addrlen = (socklen_t)sizeof(rep.addr);
+ c_hdl = c->tcp_free;
+ c_hdl->repinfo.addrlen = (socklen_t)sizeof(c_hdl->repinfo.addr);
log_assert(fd != -1);
- new_fd = accept(fd, (struct sockaddr*)&rep.addr, &rep.addrlen);
+ new_fd = accept(fd, (struct sockaddr*)&c_hdl->repinfo.addr,
+ &c_hdl->repinfo.addrlen);
if(new_fd == -1) {
/* EINTR is signal interrupt. others are closed connection. */
if( errno != EINTR
log_err("accept failed: %s", strerror(errno));
return;
}
- /* find free tcp handler. */
- if(!c->tcp_free) {
- log_err("accepted too many tcp, connections full");
- close(new_fd);
- return;
- }
- /* grab it */
- c_hdl = c->tcp_free;
+ /* grab the tcp handler buffers */
c->tcp_free = c_hdl->tcp_free;
if(!c->tcp_free) {
/* stop accepting incoming queries for now. */
static void
tcp_callback_reader(struct comm_point* c)
{
- struct comm_reply rep;
log_assert(c->type == comm_tcp || c->type == comm_local);
ldns_buffer_flip(c->buffer);
if(c->tcp_do_toggle_rw)
c->tcp_byte_count = 0;
if(c->type == comm_tcp)
comm_point_stop_listening(c);
- rep.c = c;
- rep.addrlen = 0;
log_assert(fptr_whitelist_comm_point(c->callback));
- if( (*c->callback)(c, c->cb_arg, NETEVENT_NOERROR, &rep) ) {
+ if( (*c->callback)(c, c->cb_arg, NETEVENT_NOERROR, &c->repinfo) ) {
comm_point_start_listening(c, -1, TCP_QUERY_TIMEOUT);
}
}
c->do_not_close = 0;
c->tcp_do_toggle_rw = 1;
c->tcp_check_nb_connect = 0;
+ c->repinfo.c = c;
c->callback = callback;
c->cb_arg = callback_arg;
/* add to parent free list */
c->do_not_close = 0;
c->tcp_do_toggle_rw = 1;
c->tcp_check_nb_connect = 1;
+ c->repinfo.c = c;
c->callback = callback;
c->cb_arg = callback_arg;
evbits = EV_PERSIST | EV_WRITE;
struct internal_base* eb;
};
+/**
+ * Reply information for a communication point.
+ */
+struct comm_reply {
+ /** the comm_point with fd to send reply on to. */
+ struct comm_point* c;
+ /** the address (for UDP based communication) */
+ struct sockaddr_storage addr;
+ /** length of address */
+ socklen_t addrlen;
+};
+
/**
* Communication point to the network
* These behaviours can be accomplished by setting the flags
size_t tcp_byte_count;
/** parent communication point (for TCP sockets) */
struct comm_point* tcp_parent;
+ /** sockaddr from peer, for TCP handlers */
+ struct comm_reply repinfo;
/* -------- TCP Accept -------- */
/** the number of TCP handlers for this tcp-accept socket */
void *cb_arg;
};
-/**
- * Reply information for a communication point.
- */
-struct comm_reply {
- /** the comm_point with fd to send reply on to. */
- struct comm_point* c;
- /** the address (for UDP based communication) */
- struct sockaddr_storage addr;
- /** length of address */
- socklen_t addrlen;
-};
-
/**
* Structure only for making timeout events.
*/