]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
unbound-host works.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 6 Dec 2007 16:35:36 +0000 (16:35 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 6 Dec 2007 16:35:36 +0000 (16:35 +0000)
git-svn-id: file:///svn/unbound/trunk@810 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
libunbound/worker.c
smallapp/unbound-host.c

index 0e6a986d890e75dd2aadb2a841811679a10aef87..792a57a8eb87a9239df303f261c23ef6518b8996 100644 (file)
@@ -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.
index 087d39d209463b699b1614d208d03d2da74b87b3..c0294aafda52b0e57728e4bdfd94a8760ac4e520 100644 (file)
@@ -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)) {
+       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);
-               return UB_NOMEM;
+               comm_base_dispatch(w->base);
        }
-       free(qinfo.qname);
-       comm_base_dispatch(w->base);
        libworker_delete(w);
        return UB_NOERROR;
 }
index 0babe60d3e921755c9683e0185880bec1786dd1e..00e9e37a8106118d5fc6ff3f0cdc6bccc354eafe 100644 (file)
@@ -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");