return result;
}
-static long double pow10 (int exp)
+static long double compat_pow10 (int exp)
{
long double result = 1;
return result;
}
-static long round (long double value)
+static long compat_round (long double value)
{
long intpart;
/* We "cheat" by converting the fractional part to integer by
* multiplying by a factor of 10
*/
- fracpart = round ((pow10 (max)) * (ufvalue - intpart));
+ fracpart = compat_round ((compat_pow10 (max)) * (ufvalue - intpart));
- if (fracpart >= pow10 (max))
+ if (fracpart >= compat_pow10 (max))
{
intpart++;
- fracpart -= pow10 (max);
+ fracpart -= compat_pow10 (max);
}
#ifdef DEBUG_SNPRINTF
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.61 for unbound 1.0.
+# Generated by GNU Autoconf 2.61 for unbound 0.10.
#
# Report bugs to <unbound-bugs@nlnetlabs.nl>.
#
# Identity of this package.
PACKAGE_NAME='unbound'
PACKAGE_TARNAME='unbound'
-PACKAGE_VERSION='1.0'
-PACKAGE_STRING='unbound 1.0'
+PACKAGE_VERSION='0.10'
+PACKAGE_STRING='unbound 0.10'
PACKAGE_BUGREPORT='unbound-bugs@nlnetlabs.nl'
# Factoring default headers for most tests.
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures unbound 1.0 to adapt to many kinds of systems.
+\`configure' configures unbound 0.10 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of unbound 1.0:";;
+ short | recursive ) echo "Configuration of unbound 0.10:";;
esac
cat <<\_ACEOF
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-unbound configure 1.0
+unbound configure 0.10
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by unbound $as_me 1.0, which was
+It was created by unbound $as_me 0.10, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by unbound $as_me 1.0, which was
+This file was extended by unbound $as_me 0.10, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-unbound config.status 1.0
+unbound config.status 0.10
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.57)
-AC_INIT(unbound, 1.0, unbound-bugs@nlnetlabs.nl, unbound)
+AC_INIT(unbound, 0.10, unbound-bugs@nlnetlabs.nl, unbound)
CFLAGS=
AC_AIX
+28 February 2008: Wouter
+ - fixed memory leaks in libunbound (during cancellation and wait).
+ - libunbound returns the answer packet in full.
+ - snprintf compat update.
+ - harvest performs lookup.
+ - ldns-tarball update with fix for ldns_dname_label.
+
27 February 2008: Wouter
- option to use caps for id randomness.
- config file option use-caps-for-id: yes
int* len; /* array with lengths of rdata items */
char* canonname; /* canonical name of result */
int rcode; /* additional error code in case of no data */
+ void* answer_packet; /* full network format answer packet */
+ int answer_len; /* length of packet in octets */
int havedata; /* true if there is data */
int nxdomain; /* true if nodata because name does not exist */
int secure; /* true if result is secure */
libworker_enter_result(*res, buf, region,
q->msg_security);
}
+ (*res)->answer_packet = q->msg;
+ (*res)->answer_len = q->msg_len;
+ q->msg = NULL;
ldns_buffer_free(buf);
regional_destroy(region);
}
lock_basic_unlock(&ctx->cfglock);
if(*cb) return 2;
+ ub_resolve_free(*res);
return 1;
}
r = process_answer_detail(ctx, msg, len,
&cb, &cbarg, &err, &res);
lock_basic_unlock(&ctx->rrpipe_lock);
+ free(msg);
if(r == 0)
return UB_PIPE;
if(r == 2)
lock_basic_unlock(&ctx->cfglock);
return r;
}
+ q->res->answer_packet = q->msg;
+ q->res->answer_len = q->msg_len;
+ q->msg = NULL;
*result = q->res;
q->res = NULL;
if(!ctx->dothread) { /* if forked */
(void)rbtree_delete(&ctx->queries, q->node.key);
ctx->num_async--;
- context_query_delete(q);
msg = context_serialize_cancel(q, &len);
+ context_query_delete(q);
lock_basic_unlock(&ctx->cfglock);
if(!msg) {
return UB_NOMEM;
free(*p);
free(result->data);
free(result->len);
+ free(result->answer_packet);
free(result);
}
if((r=read(fd, *buf, *len)) == -1) {
log_err("msg read failed: %s", strerror(errno));
(void)fd_set_nonblock(fd);
+ free(*buf);
return 0;
}
if(r == 0) { /* EOF */
(void)fd_set_nonblock(fd);
+ free(*buf);
return 0;
}
- if(!fd_set_nonblock(fd))
+ if(!fd_set_nonblock(fd)) {
+ free(*buf);
return 0;
+ }
return 1;
}
*/
int rcode;
+ /**
+ * The DNS answer packet. Network formatted. Can contain DNSSEC types.
+ */
+ void* answer_packet;
+ /** length of the answer packet in octets. */
+ int answer_len;
+
/**
* If there is any data, this is true.
* If false, there was no data (nxdomain may be true, rcode can be set).
"wrong.\n", desc);
exit(1);
}
+ if(result->answer_packet == NULL) {
+ printf("%s: error result->answer_packet is NULL.\n",
+ desc);
+ exit(1);
+ }
+ if(result->answer_len != 54) {
+ printf("%s: error result->answer_len is wrong.\n",
+ desc);
+ exit(1);
+ }
}
}
r = ub_resolve(inf->ctx, inf->argv[i%inf->argc],
LDNS_RR_TYPE_A, LDNS_RR_CLASS_IN, &result);
ext_check_result("ub_resolve", r, result);
+ ub_resolve_free(result);
}
}
if(inf->thread_num > NUMTHR/2) {
if(!lab) error_exit("out of memory");
lab->label = ldns_dname_new_frm_str(name);
if(!lab->label) error_exit("out of memory");
+ printf("labcount %d\n", ldns_dname_label_count(lab->label));
lab->name = ldns_dname_new_frm_str(name);
if(!lab->name) error_exit("out of memory");
lab->node.key = lab->label;
/* create it */
nextlab = (struct labdata*)calloc(1, sizeof(*lab));
if(!nextlab) error_exit("out of memory");
+ printf("nextcount %d len %d\n",
+ ldns_dname_label_count(next),
+ ldns_rdf_size(next));
nextlab->label = ldns_rdf_clone(next);
if(!nextlab->label) error_exit("out of memory");
+ printf("labcount %d\n", ldns_dname_label_count(nextlab->label));
nextlab->node.key = nextlab->label;
nextlab->node.data = nextlab;
nextlab->sublabels = ldns_rbtree_create(lab_cmp);
LDNS_RR_CLASS_IN, it->depth);
new_todo_item(data, lab->name, LDNS_RR_TYPE_DS,
LDNS_RR_CLASS_IN, it->depth);
+ new_todo_item(data, lab->name, LDNS_RR_TYPE_A,
+ LDNS_RR_CLASS_IN, it->depth);
+ new_todo_item(data, lab->name, LDNS_RR_TYPE_AAAA,
+ LDNS_RR_CLASS_IN, it->depth);
lab->done = 1;
}
}
}
}
-/** get result and store it */
+/** store RR and make new work items for it if needed */
+static void
+process_rr(struct harvest_data* data, ldns_rr* rr, int depth)
+{
+ /* must free or store rr */
+ struct labdata* lab = find_create_lab(data, ldns_rr_owner(rr));
+ if(!lab) error_exit("cannot find/create label");
+ /* generate extra queries */
+ if(ldns_rr_get_type(rr) == LDNS_RR_TYPE_NS) {
+ new_todo_item(data, ldns_rr_ns_nsdname(rr), LDNS_RR_TYPE_A,
+ LDNS_RR_CLASS_IN, depth+1);
+ new_todo_item(data, ldns_rr_ns_nsdname(rr), LDNS_RR_TYPE_AAAA,
+ LDNS_RR_CLASS_IN, depth+1);
+ } else if(ldns_rr_get_type(rr) == LDNS_RR_TYPE_MX) {
+ new_todo_item(data, ldns_rr_mx_exchange(rr), LDNS_RR_TYPE_A,
+ LDNS_RR_CLASS_IN, depth+1);
+ new_todo_item(data, ldns_rr_mx_exchange(rr), LDNS_RR_TYPE_AAAA,
+ LDNS_RR_CLASS_IN, depth+1);
+ } else if(ldns_rr_get_type(rr) == LDNS_RR_TYPE_SOA) {
+ new_todo_item(data, ldns_rr_rdf(rr, 0), LDNS_RR_TYPE_A,
+ LDNS_RR_CLASS_IN, depth+1);
+ new_todo_item(data, ldns_rr_rdf(rr, 0), LDNS_RR_TYPE_AAAA,
+ LDNS_RR_CLASS_IN, depth+1);
+ }
+ /* store it */
+ if(!ldns_rr_list_contains_rr(lab->rrlist, rr)) {
+ if(hverb) printf("store RR\n");
+ if(!ldns_rr_list_push_rr(lab->rrlist, rr))
+ error_exit("outofmem ldns_rr_list_push_rr");
+ } else {
+ if(hverb) printf("duplicate RR\n");
+ ldns_rr_free(rr);
+ }
+}
+
+/** store RRs and make new work items if needed */
+static void
+process_pkt(struct harvest_data* data, ldns_pkt* pkt, int depth)
+{
+ size_t i;
+ ldns_rr_list* list;
+ list = ldns_pkt_get_section_clone(pkt, LDNS_SECTION_ANY_NOQUESTION);
+ if(!list) error_exit("outofmemory");
+ for(i=0; i<ldns_rr_list_rr_count(list); i++) {
+ process_rr(data, ldns_rr_list_rr(list, i), depth);
+ }
+ ldns_rr_list_free(list);
+}
+
static void
process(struct harvest_data* data, struct todo_item* it)
{
+ int r;
+ char* nm;
+ struct ub_result* result = NULL;
+ ldns_pkt* pkt = NULL;
+ ldns_status s;
if(hverb) {
printf("process: ");
ldns_rdf_print(stdout, it->qname);
printf("\n");
}
/* do lookup */
-
+ nm = ldns_rdf2str(it->qname);
+ if(!nm) error_exit("ldns_rdf2str");
+ r = ub_resolve(data->ctx, nm, it->qtype, it->qclass, &result);
+ if(r != 0) {
+ printf("ub_resolve(%s, %d, %d): %s\n", nm, it->qtype,
+ it->qclass, ub_strerror(r));
+ free(nm);
+ return;
+ }
+ /* even if result is a negative, try to store resulting SOA/NSEC */
/* create ldns pkt */
- /* create recursive todo items */
- /* store results */
+ s = ldns_wire2pkt(&pkt, result->answer_packet, result->answer_len);
+ if(s != LDNS_STATUS_OK) {
+ printf("ldns_wire2pkt failed! %s %d %d %s", nm,
+ it->qtype, it->qclass, ldns_get_errorstr_by_id(s));
+ free(nm);
+ return;
+ }
+ if(hverb >= 2) {
+ printf("answer: ");
+ ldns_pkt_print(stdout, pkt);
+ printf("\n");
+ }
+ /* process results */
+ process_pkt(data, pkt, it->depth);
+
+ ldns_pkt_free(pkt);
+ free(nm);
+ ub_resolve_free(result);
}
/** perform main harvesting */
}
data->numtodo--;
process(data, it);
+ exit(1);
}
}
{
struct harvest_data data;
char* nm = argv[0];
- struct ub_ctx* ctx = ub_ctx_create();
int c;
/* defaults */
memset(&data, 0, sizeof(data));
+ data.ctx = ub_ctx_create();
data.resultdir = strdup("harvested_zones");
if(!data.resultdir) error_exit("out of memory");
data.maxdepth = 10;
harvest_main(&data);
/* no cleanup except the context (to close open sockets) */
- ub_ctx_delete(ctx);
+ ub_ctx_delete(data.ctx);
return 0;
}