From 0b2d467420924d1eeb412ce080d917dc6d7b5f27 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Thu, 19 Dec 2013 15:54:13 +0100 Subject: [PATCH 1/3] Implement getdns_convert_dns_name_to_fqdn --- src/convert.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/convert.c b/src/convert.c index 563cc10e..8bfc5028 100644 --- a/src/convert.c +++ b/src/convert.c @@ -36,6 +36,7 @@ #include #include #include +#include /* stuff to make it compile pedantically */ #define UNUSED_PARAM(x) ((void)(x)) @@ -43,8 +44,15 @@ char * getdns_convert_dns_name_to_fqdn(char *name_from_dns_response) { - UNUSED_PARAM(name_from_dns_response); - return NULL; + char *str; + ldns_rdf *rdf = ldns_rdf_new_frm_data( LDNS_RDF_TYPE_DNAME + , strlen(name_from_dns_response)+1 + , name_from_dns_response + ); + if (!rdf) return NULL; + str = ldns_rdf2str(rdf); + ldns_rdf_free(rdf); + return str; } char * From d6118b4caa63ba31240994d131f350cd3b90224c Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Fri, 20 Dec 2013 13:25:55 +0100 Subject: [PATCH 2/3] Allow null characters in wire fmt name -> fqdn --- src/convert.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/convert.c b/src/convert.c index 8bfc5028..2bd1aa06 100644 --- a/src/convert.c +++ b/src/convert.c @@ -41,14 +41,26 @@ /* stuff to make it compile pedantically */ #define UNUSED_PARAM(x) ((void)(x)) +static size_t sizeof_dname(uint8_t *dname) +{ + uint8_t *ptr; + + assert(dname); + ptr = dname; + while (*ptr && (*ptr & 0xC0) == 0) + ptr += *ptr + 1; + if ((*ptr & 0xC0) == 0xC0) + ptr++; + return (ptr - dname) + 1; +} + char * getdns_convert_dns_name_to_fqdn(char *name_from_dns_response) { char *str; - ldns_rdf *rdf = ldns_rdf_new_frm_data( LDNS_RDF_TYPE_DNAME - , strlen(name_from_dns_response)+1 - , name_from_dns_response - ); + ldns_rdf *rdf = ldns_rdf_new_frm_data(LDNS_RDF_TYPE_DNAME, + sizeof_dname((uint8_t *)name_from_dns_response), + name_from_dns_response); if (!rdf) return NULL; str = ldns_rdf2str(rdf); ldns_rdf_free(rdf); From f305ac97daf1d132398ce6359f07118762d987b6 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Fri, 20 Dec 2013 16:15:27 +0100 Subject: [PATCH 3/3] Stubs should be able to lookup AS112 zones --- src/context.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/context.c b/src/context.c index d0313bec..e249dc49 100644 --- a/src/context.c +++ b/src/context.c @@ -987,6 +987,61 @@ ub_setup_stub(struct ub_ctx *ctx, struct getdns_list * upstreams, size_t count) &ip_str); ub_ctx_set_fwd(ctx, ip_str); } + /* Allow lookups of: + */ + /* - localhost */ + (void)ub_ctx_zone_remove(ctx, "localhost."); + + /* - reverse IPv4 loopback */ + (void)ub_ctx_zone_remove(ctx, "127.in-addr.arpa."); + + /* - reverse IPv6 loopback */ + (void)ub_ctx_zone_remove(ctx, "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0." + "0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa."); + + /* - reverse RFC1918 local use zones */ + (void)ub_ctx_zone_remove(ctx, "10.in-addr.arpa."); + (void)ub_ctx_zone_remove(ctx, "16.172.in-addr.arpa."); + (void)ub_ctx_zone_remove(ctx, "17.172.in-addr.arpa."); + (void)ub_ctx_zone_remove(ctx, "18.172.in-addr.arpa."); + (void)ub_ctx_zone_remove(ctx, "19.172.in-addr.arpa."); + (void)ub_ctx_zone_remove(ctx, "20.172.in-addr.arpa."); + (void)ub_ctx_zone_remove(ctx, "21.172.in-addr.arpa."); + (void)ub_ctx_zone_remove(ctx, "22.172.in-addr.arpa."); + (void)ub_ctx_zone_remove(ctx, "23.172.in-addr.arpa."); + (void)ub_ctx_zone_remove(ctx, "24.172.in-addr.arpa."); + (void)ub_ctx_zone_remove(ctx, "25.172.in-addr.arpa."); + (void)ub_ctx_zone_remove(ctx, "26.172.in-addr.arpa."); + (void)ub_ctx_zone_remove(ctx, "27.172.in-addr.arpa."); + (void)ub_ctx_zone_remove(ctx, "28.172.in-addr.arpa."); + (void)ub_ctx_zone_remove(ctx, "29.172.in-addr.arpa."); + (void)ub_ctx_zone_remove(ctx, "30.172.in-addr.arpa."); + (void)ub_ctx_zone_remove(ctx, "31.172.in-addr.arpa."); + (void)ub_ctx_zone_remove(ctx, "168.192.in-addr.arpa."); + + /* - reverse RFC3330 IP4 this, link-local, testnet and broadcast */ + (void)ub_ctx_zone_remove(ctx, "0.in-addr.arpa."); + (void)ub_ctx_zone_remove(ctx, "254.169.in-addr.arpa."); + (void)ub_ctx_zone_remove(ctx, "2.0.192.in-addr.arpa."); + (void)ub_ctx_zone_remove(ctx, "100.51.198.in-addr.arpa."); + (void)ub_ctx_zone_remove(ctx, "113.0.203.in-addr.arpa."); + (void)ub_ctx_zone_remove(ctx, "255.255.255.255.in-addr.arpa."); + + /* - reverse RFC4291 IP6 unspecified */ + (void)ub_ctx_zone_remove(ctx, "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0." + "0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa."); + + /* - reverse RFC4193 IPv6 Locally Assigned Local Addresses */ + (void)ub_ctx_zone_remove(ctx, "D.F.ip6.arpa."); + + /* - reverse RFC4291 IPv6 Link Local Addresses */ + (void)ub_ctx_zone_remove(ctx, "8.E.F.ip6.arpa."); + (void)ub_ctx_zone_remove(ctx, "9.E.F.ip6.arpa."); + (void)ub_ctx_zone_remove(ctx, "A.E.F.ip6.arpa."); + (void)ub_ctx_zone_remove(ctx, "B.E.F.ip6.arpa."); + + /* - reverse IPv6 Example Prefix */ + (void)ub_ctx_zone_remove(ctx, "8.B.D.0.1.0.0.2.ip6.arpa."); } getdns_return_t