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
|
6 December 2007: Wouter
|
||||||
- library resolution works in foreground mode, unbound-host app
|
- library resolution works in foreground mode, unbound-host app
|
||||||
receives data.
|
receives data.
|
||||||
|
- unbound-host prints rdata using ldns.
|
||||||
|
|
||||||
5 December 2007: Wouter
|
5 December 2007: Wouter
|
||||||
- locking in context_new() inside the function.
|
- locking in context_new() inside the function.
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@
|
||||||
#include "libunbound/unbound.h"
|
#include "libunbound/unbound.h"
|
||||||
#include "services/outside_network.h"
|
#include "services/outside_network.h"
|
||||||
#include "services/mesh.h"
|
#include "services/mesh.h"
|
||||||
|
#include "services/localzone.h"
|
||||||
#include "services/cache/rrset.h"
|
#include "services/cache/rrset.h"
|
||||||
#include "services/outbound_list.h"
|
#include "services/outbound_list.h"
|
||||||
#include "util/module.h"
|
#include "util/module.h"
|
||||||
|
|
@ -327,13 +328,20 @@ int libworker_fg(struct ub_val_ctx* ctx, struct ctx_query* q)
|
||||||
qflags = BIT_RD;
|
qflags = BIT_RD;
|
||||||
d.q = q;
|
d.q = q;
|
||||||
d.w = w;
|
d.w = w;
|
||||||
if(!mesh_new_callback(w->env->mesh, &qinfo, qflags, &edns,
|
if(local_zones_answer(ctx->local_zones, &qinfo, &edns,
|
||||||
w->back->udp_buff, qid, libworker_fg_done_cb, &d)) {
|
w->back->udp_buff, w->env->scratch)) {
|
||||||
free(qinfo.qname);
|
libworker_fg_done_cb(&d, LDNS_RCODE_NOERROR,
|
||||||
return UB_NOMEM;
|
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);
|
libworker_delete(w);
|
||||||
return UB_NOERROR;
|
return UB_NOERROR;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ isip4(const char* nm, char** res)
|
||||||
if(inet_pton(AF_INET, nm, &addr) <= 0) {
|
if(inet_pton(AF_INET, nm, &addr) <= 0) {
|
||||||
return 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)[3], ((uint8_t*)&addr)[2],
|
||||||
((uint8_t*)&addr)[1], ((uint8_t*)&addr)[0]);
|
((uint8_t*)&addr)[1], ((uint8_t*)&addr)[0]);
|
||||||
*res = strdup(buf);
|
*res = strdup(buf);
|
||||||
|
|
@ -103,7 +103,7 @@ isip6(const char* nm, char** res)
|
||||||
*p++ = hex[ (b&0xf0) >> 4 ];
|
*p++ = hex[ (b&0xf0) >> 4 ];
|
||||||
*p++ = '.';
|
*p++ = '.';
|
||||||
}
|
}
|
||||||
snprintf(buf+16*4, sizeof(buf)-16*4, "ip6.arpa.");
|
snprintf(buf+16*4, sizeof(buf)-16*4, "ip6.arpa");
|
||||||
*res = strdup(buf);
|
*res = strdup(buf);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
@ -167,9 +167,9 @@ massage_class(const char* c)
|
||||||
static const char*
|
static const char*
|
||||||
statstr(int sec, struct ub_val_result* result)
|
statstr(int sec, struct ub_val_result* result)
|
||||||
{
|
{
|
||||||
if(sec) return "[secure]";
|
if(sec) return "(secure)";
|
||||||
if(result->bogus) return "[BOGUS (security failure)]";
|
if(result->bogus) return "(BOGUS (security failure))]";
|
||||||
return "[insecure]";
|
return "(insecure)";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** nice string for type */
|
/** nice string for type */
|
||||||
|
|
@ -212,23 +212,30 @@ pretty_rcode(char* s, size_t len, int r)
|
||||||
static void
|
static void
|
||||||
print_rd(int t, char* data, size_t len)
|
print_rd(int t, char* data, size_t len)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
size_t i, pos = 0;
|
size_t i, pos = 0;
|
||||||
|
uint8_t* rd = malloc(len+2);
|
||||||
|
ldns_rr* rr = ldns_rr_new();
|
||||||
ldns_status status;
|
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);
|
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) {
|
if(status != LDNS_STATUS_OK) {
|
||||||
|
|
||||||
|
free(rd);
|
||||||
printf("error_printing_data");
|
printf("error_printing_data");
|
||||||
}
|
}
|
||||||
printf("len = %d\n", len);
|
|
||||||
for(i=0; i<ldns_rr_rd_count(rr); i++) {
|
for(i=0; i<ldns_rr_rd_count(rr); i++) {
|
||||||
|
printf(" ");
|
||||||
ldns_rdf_print(stdout, ldns_rr_rdf(rr, i));
|
ldns_rdf_print(stdout, ldns_rr_rdf(rr, i));
|
||||||
}
|
}
|
||||||
ldns_rr_free(rr);
|
ldns_rr_free(rr);
|
||||||
*/
|
free(rd);
|
||||||
printf("TODO");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** pretty line of RR data for results */
|
/** 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)
|
if(strcmp(cstr, "IN") != 0)
|
||||||
printf(" in class %s", cstr);
|
printf(" in class %s", cstr);
|
||||||
if(t == LDNS_RR_TYPE_A)
|
if(t == LDNS_RR_TYPE_A)
|
||||||
printf(" has address ");
|
printf(" has address");
|
||||||
else if(t == LDNS_RR_TYPE_AAAA)
|
else if(t == LDNS_RR_TYPE_AAAA)
|
||||||
printf(" has IPv6 address ");
|
printf(" has IPv6 address");
|
||||||
else if(t == LDNS_RR_TYPE_MX)
|
else if(t == LDNS_RR_TYPE_MX)
|
||||||
printf(" mail is handled by ");
|
printf(" mail is handled by");
|
||||||
else printf(" has %s record ", tstr);
|
else if(t == LDNS_RR_TYPE_PTR)
|
||||||
|
printf(" domain name pointer");
|
||||||
|
else printf(" has %s record", tstr);
|
||||||
print_rd(t, data, len);
|
print_rd(t, data, len);
|
||||||
printf(" %s", sec);
|
printf(" %s", sec);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue