mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-20 23:00:56 -05:00
unbound-host works.
git-svn-id: file:///svn/unbound/trunk@810 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
75073cefea
commit
1f9ad9e66e
3 changed files with 39 additions and 21 deletions
|
|
@ -1,6 +1,7 @@
|
|||
6 December 2007: Wouter
|
||||
- library resolution works in foreground mode, unbound-host app
|
||||
receives data.
|
||||
- unbound-host prints rdata using ldns.
|
||||
|
||||
5 December 2007: Wouter
|
||||
- locking in context_new() inside the function.
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@
|
|||
#include "libunbound/unbound.h"
|
||||
#include "services/outside_network.h"
|
||||
#include "services/mesh.h"
|
||||
#include "services/localzone.h"
|
||||
#include "services/cache/rrset.h"
|
||||
#include "services/outbound_list.h"
|
||||
#include "util/module.h"
|
||||
|
|
@ -327,13 +328,20 @@ int libworker_fg(struct ub_val_ctx* ctx, struct ctx_query* q)
|
|||
qflags = BIT_RD;
|
||||
d.q = q;
|
||||
d.w = w;
|
||||
if(!mesh_new_callback(w->env->mesh, &qinfo, qflags, &edns,
|
||||
w->back->udp_buff, qid, libworker_fg_done_cb, &d)) {
|
||||
free(qinfo.qname);
|
||||
return UB_NOMEM;
|
||||
if(local_zones_answer(ctx->local_zones, &qinfo, &edns,
|
||||
w->back->udp_buff, w->env->scratch)) {
|
||||
libworker_fg_done_cb(&d, LDNS_RCODE_NOERROR,
|
||||
w->back->udp_buff, sec_status_insecure);
|
||||
}
|
||||
else {
|
||||
if(!mesh_new_callback(w->env->mesh, &qinfo, qflags, &edns,
|
||||
w->back->udp_buff, qid, libworker_fg_done_cb, &d)) {
|
||||
free(qinfo.qname);
|
||||
return UB_NOMEM;
|
||||
}
|
||||
free(qinfo.qname);
|
||||
comm_base_dispatch(w->base);
|
||||
}
|
||||
free(qinfo.qname);
|
||||
comm_base_dispatch(w->base);
|
||||
libworker_delete(w);
|
||||
return UB_NOERROR;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ isip4(const char* nm, char** res)
|
|||
if(inet_pton(AF_INET, nm, &addr) <= 0) {
|
||||
return 0;
|
||||
}
|
||||
snprintf(buf, sizeof(buf), "%u.%u.%u.%u.in-addr.arpa.",
|
||||
snprintf(buf, sizeof(buf), "%u.%u.%u.%u.in-addr.arpa",
|
||||
((uint8_t*)&addr)[3], ((uint8_t*)&addr)[2],
|
||||
((uint8_t*)&addr)[1], ((uint8_t*)&addr)[0]);
|
||||
*res = strdup(buf);
|
||||
|
|
@ -103,7 +103,7 @@ isip6(const char* nm, char** res)
|
|||
*p++ = hex[ (b&0xf0) >> 4 ];
|
||||
*p++ = '.';
|
||||
}
|
||||
snprintf(buf+16*4, sizeof(buf)-16*4, "ip6.arpa.");
|
||||
snprintf(buf+16*4, sizeof(buf)-16*4, "ip6.arpa");
|
||||
*res = strdup(buf);
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -167,9 +167,9 @@ massage_class(const char* c)
|
|||
static const char*
|
||||
statstr(int sec, struct ub_val_result* result)
|
||||
{
|
||||
if(sec) return "[secure]";
|
||||
if(result->bogus) return "[BOGUS (security failure)]";
|
||||
return "[insecure]";
|
||||
if(sec) return "(secure)";
|
||||
if(result->bogus) return "(BOGUS (security failure))]";
|
||||
return "(insecure)";
|
||||
}
|
||||
|
||||
/** nice string for type */
|
||||
|
|
@ -212,23 +212,30 @@ pretty_rcode(char* s, size_t len, int r)
|
|||
static void
|
||||
print_rd(int t, char* data, size_t len)
|
||||
{
|
||||
/*
|
||||
size_t i, pos = 0;
|
||||
uint8_t* rd = malloc(len+2);
|
||||
ldns_rr* rr = ldns_rr_new();
|
||||
ldns_status status;
|
||||
ldns_rr* rr = ldns_rr_new_frm_type(t);
|
||||
if(!rd || !rr) {
|
||||
fprintf(stderr, "out of memory");
|
||||
exit(1);
|
||||
}
|
||||
ldns_rr_set_type(rr, t);
|
||||
ldns_write_uint16(rd, len);
|
||||
memmove(rd+2, data, len);
|
||||
ldns_rr_set_owner(rr, NULL);
|
||||
status = ldns_wire2rdf(rr, (uint8_t*)data, len, &pos);
|
||||
status = ldns_wire2rdf(rr, rd, len+2, &pos);
|
||||
if(status != LDNS_STATUS_OK) {
|
||||
|
||||
free(rd);
|
||||
printf("error_printing_data");
|
||||
}
|
||||
printf("len = %d\n", len);
|
||||
for(i=0; i<ldns_rr_rd_count(rr); i++) {
|
||||
printf(" ");
|
||||
ldns_rdf_print(stdout, ldns_rr_rdf(rr, i));
|
||||
}
|
||||
ldns_rr_free(rr);
|
||||
*/
|
||||
printf("TODO");
|
||||
free(rd);
|
||||
}
|
||||
|
||||
/** pretty line of RR data for results */
|
||||
|
|
@ -240,12 +247,14 @@ pretty_rdata(char* q, char* cstr, char* tstr, int t, const char* sec,
|
|||
if(strcmp(cstr, "IN") != 0)
|
||||
printf(" in class %s", cstr);
|
||||
if(t == LDNS_RR_TYPE_A)
|
||||
printf(" has address ");
|
||||
printf(" has address");
|
||||
else if(t == LDNS_RR_TYPE_AAAA)
|
||||
printf(" has IPv6 address ");
|
||||
printf(" has IPv6 address");
|
||||
else if(t == LDNS_RR_TYPE_MX)
|
||||
printf(" mail is handled by ");
|
||||
else printf(" has %s record ", tstr);
|
||||
printf(" mail is handled by");
|
||||
else if(t == LDNS_RR_TYPE_PTR)
|
||||
printf(" domain name pointer");
|
||||
else printf(" has %s record", tstr);
|
||||
print_rd(t, data, len);
|
||||
printf(" %s", sec);
|
||||
printf("\n");
|
||||
|
|
|
|||
Loading…
Reference in a new issue