From: Miek Gieben Date: Thu, 20 Jan 2005 15:03:56 +0000 (+0000) Subject: added dns.h for dns specific defines X-Git-Tag: release-0.50~546 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c4648b352d5144bbc394644ace2b51bb04210593;p=thirdparty%2Fldns.git added dns.h for dns specific defines added str2rdf for A and AAAA assorted updates and stuff and.... it compiles :) With a lot of warnings though --- diff --git a/ldns/dns.h b/ldns/dns.h new file mode 100644 index 00000000..74a0af8a --- /dev/null +++ b/ldns/dns.h @@ -0,0 +1,17 @@ +/* + * dns.h -- defines for the Domain Name System + * + * Copyright (c) 2001-2005, NLnet Labs. All rights reserved. + * + * See LICENSE for the license. + * + * A bunch of defines that are used in the DNS + */ + +#ifndef _DNS_H_ +#define _DNS_H_ + +#define IP4ADDRLEN (32/8) +#define IP6ADDRLEN (128/8) + +#endif /* _DNS_H_ */ diff --git a/ldns/error.h b/ldns/error.h index 38fe69c6..2baa8996 100644 --- a/ldns/error.h +++ b/ldns/error.h @@ -26,7 +26,8 @@ enum ldns_enum_status LDNS_STATUS_INTERNAL_ERR, LDNS_STATUS_ERR, LDNS_STATUS_INT_EXP, - LDNS_STATUS_INVALID_IP4 + LDNS_STATUS_INVALID_IP4, + LDNS_STATUS_INVALID_IP6 }; typedef enum ldns_enum_status ldns_status; diff --git a/ldns/ldns.h b/ldns/ldns.h index 62079528..10dfc0d9 100644 --- a/ldns/ldns.h +++ b/ldns/ldns.h @@ -20,5 +20,6 @@ #include #include #include +#include #endif /* _LDNS_H */ diff --git a/libdns.vim b/libdns.vim index fa1383d1..94c6825f 100644 --- a/libdns.vim +++ b/libdns.vim @@ -60,6 +60,7 @@ syn keyword ldnsMacro LDNS_STATUS_INTERNAL_ERR syn keyword ldnsMacro LDNS_STATUS_INT_EXP syn keyword ldnsMacro LDNS_STATUS_ERR syn keyword ldnsMacro LDNS_STATUS_INVALID_IP4 +syn keyword ldnsMacro LDNS_STATUS_INVALID_IP6 " ldns/resolver.h syn keyword ldnsType ldns_resolver diff --git a/str2host.c b/str2host.c index 7b01d3c4..a3fc6414 100644 --- a/str2host.c +++ b/str2host.c @@ -13,6 +13,7 @@ #include #include +#include #include "util.h" @@ -173,6 +174,13 @@ ldns_str2rdf_a(ldns_rdf **rd, const uint8_t* str) ldns_status ldns_str2rdf_aaaa(ldns_rdf **rd, const uint8_t* str) { + uint8_t address[IP6ADDRLEN]; + + if (inet_pton(AF_INET6, (char*)str, address) != 1) { + return LDNS_STATUS_INVALID_IP6; + } else { + *rd = ldns_rdf_new(sizeof(address), LDNS_RDF_TYPE_AAAA, &address); + } return LDNS_STATUS_OK; }