From: Miek Gieben Date: Thu, 8 Sep 2005 12:32:54 +0000 (+0000) Subject: host2str TODO's fixed X-Git-Tag: release-1.0.0~181 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=77cee017a6dcae8b6d1537704af85a3fbcf5e642;p=thirdparty%2Fldns.git host2str TODO's fixed --- diff --git a/host2str.c b/host2str.c index ec0bf7e2..f49ff01e 100644 --- a/host2str.c +++ b/host2str.c @@ -525,15 +525,12 @@ ldns_rdf2buffer_str_apl(ldns_buffer *output, ldns_rdf *rdf) unsigned short i; unsigned int pos = 0; - /* todo: use #defines for address families? */ - - /* ipv4 */ while (pos < (unsigned int) ldns_rdf_size(rdf)) { address_family = ldns_read_uint16(&data[pos]); prefix = data[pos + 2]; - negation = data[pos + 3] & 0x80; - adf_length = data[pos + 3] & 0x7f; - if (address_family == 1) { + negation = data[pos + 3] & LDNS_APL_NEGATION; + adf_length = data[pos + 3] & LDNS_APL_MASK; + if (address_family == LDNS_APL_IP4) { /* check if prefix < 32? */ if (negation) { ldns_buffer_printf(output, "!"); @@ -552,7 +549,7 @@ ldns_rdf2buffer_str_apl(ldns_buffer *output, ldns_rdf *rdf) } } ldns_buffer_printf(output, "/%u ", prefix); - } else if (address_family == 2) { + } else if (address_family == LDNS_APL_IP6) { /* check if prefix < 128? */ if (negation) { ldns_buffer_printf(output, "!"); diff --git a/ldns/host2str.h b/ldns/host2str.h index 4b588f07..6a8589bf 100644 --- a/ldns/host2str.h +++ b/ldns/host2str.h @@ -23,6 +23,11 @@ #include "ldns/util.h" +#define LDNS_APL_IP4 1 +#define LDNS_APL_IP6 2 +#define LDNS_APL_MASK 0x7f +#define LDNS_APL_NEGATION 0x80 + /** * Converts an LDNS_RDF_TYPE_A rdata element to string format and adds it to the output buffer * \param[in] *rdf The rdata to convert diff --git a/libdns.vim b/libdns.vim index be73aa98..e0d35532 100644 --- a/libdns.vim +++ b/libdns.vim @@ -261,6 +261,8 @@ syn keyword ldnsConstant LDNS_MIN_BUFLEN " ldns/host2str.h syn keyword ldnsType ldns_lookup_table +syn keyword ldnsConstant LDNS_APL_IP4 +syn keyword ldnsConstant LDNS_APL_IP6 " ldns/keys.h syn keyword ldnsType ldns_key