From 5890d8f4a46b11e63967059a52f1aa87db720f2d Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Thu, 18 Jul 2013 16:16:43 +0200 Subject: [PATCH] draft-faltstrom-uri-08 defines LONG_STR, yay! --- host2str.c | 31 ------------------------------- ldns/rdata.h | 9 --------- ldns/str2host.h | 12 ------------ rdata.c | 3 --- rr.c | 5 ++--- str2host.c | 47 ----------------------------------------------- wire2host.c | 10 ---------- 7 files changed, 2 insertions(+), 115 deletions(-) diff --git a/host2str.c b/host2str.c index 86b7f1e8..a79df2c2 100644 --- a/host2str.c +++ b/host2str.c @@ -1241,34 +1241,6 @@ ldns_rdf2buffer_str_long_str(ldns_buffer *output, const ldns_rdf *rdf) return ldns_buffer_status(output); } -ldns_status -ldns_rdf2buffer_str_multi_str(ldns_buffer *output, const ldns_rdf *rdf) -{ - size_t pos = 0; - if (ldns_rdf_size(rdf) < pos + 1) { - return LDNS_STATUS_WIRE_RDATA_ERR; - } - ldns_buffer_printf(output, "\""); - while (pos < ldns_rdf_size(rdf)) { - if (ldns_rdf_size(rdf) < pos + 1) { - return LDNS_STATUS_WIRE_RDATA_ERR; - } - if (ldns_rdf_size(rdf) < pos + 1 + ldns_rdf_data(rdf)[pos]) { - return LDNS_STATUS_WIRE_RDATA_ERR; - } - ldns_characters2buffer_str(output, - ldns_rdf_data(rdf)[pos], - &ldns_rdf_data(rdf)[pos + 1]); - /* - * if (ldns_rdf_data(rdf)[pos] < 255) - * break; - */ - pos += 1 + ldns_rdf_data(rdf)[pos]; - } - ldns_buffer_printf(output, "\""); - return ldns_buffer_status(output); -} - ldns_status ldns_rdf2buffer_str_fmt(ldns_buffer *buffer, const ldns_output_format* fmt, const ldns_rdf *rdf) @@ -1383,9 +1355,6 @@ ldns_rdf2buffer_str_fmt(ldns_buffer *buffer, case LDNS_RDF_TYPE_LONG_STR: res = ldns_rdf2buffer_str_long_str(buffer, rdf); break; - case LDNS_RDF_TYPE_MULTI_STR: - res = ldns_rdf2buffer_str_multi_str(buffer, rdf); - break; } } else { /** This will write mangled RRs */ diff --git a/ldns/rdata.h b/ldns/rdata.h index 8f7be8c2..e327eec0 100644 --- a/ldns/rdata.h +++ b/ldns/rdata.h @@ -128,15 +128,6 @@ enum ldns_enum_rdf_type */ LDNS_RDF_TYPE_LONG_STR, - /** A encoding of the value field as specified in - * section 5.1 of [RFC1035], encoded as a sequence of one or more - * (as specified in section 3.3 of [RFC1035]), - * where all but the last are filled up to the - * maximum length of 255 octets. - * For URI. - */ - LDNS_RDF_TYPE_MULTI_STR, - /* Aliases */ LDNS_RDF_TYPE_BITMAP = LDNS_RDF_TYPE_NSEC }; diff --git a/ldns/str2host.h b/ldns/str2host.h index e6cee37a..bd7884a5 100644 --- a/ldns/str2host.h +++ b/ldns/str2host.h @@ -285,18 +285,6 @@ ldns_status ldns_str2rdf_tag(ldns_rdf **rd, const char *str); */ ldns_status ldns_str2rdf_long_str(ldns_rdf **rd, const char *str); -/** - * Convert A encoding of the value field as specified in - * section 5.1 of [RFC1035], encoded as a sequence of one or more - * (as specified in section 3.3 of [RFC1035]), - * where all but the last are filled up to the - * maximum length of 255 octets. - * \param[in] rd the rdf where to put the data - * \param[in] str the string to be converted - * \return ldns_status - */ -ldns_status ldns_str2rdf_multi_str(ldns_rdf **rd, const char *str); - #ifdef __cplusplus } #endif diff --git a/rdata.c b/rdata.c index d6850319..5b53c4a9 100644 --- a/rdata.c +++ b/rdata.c @@ -351,9 +351,6 @@ ldns_rdf_new_frm_str(ldns_rdf_type type, const char *str) case LDNS_RDF_TYPE_LONG_STR: status = ldns_str2rdf_long_str(&rdf, str); break; - case LDNS_RDF_TYPE_MULTI_STR: - status = ldns_str2rdf_multi_str(&rdf, str); - break; case LDNS_RDF_TYPE_NONE: default: /* default default ??? */ diff --git a/rr.c b/rr.c index 0ecc6970..ed227359 100644 --- a/rr.c +++ b/rr.c @@ -92,8 +92,7 @@ INLINE bool ldns_rdf_type_maybe_quoted(ldns_rdf_type rdf_type) { return rdf_type == LDNS_RDF_TYPE_STR || - rdf_type == LDNS_RDF_TYPE_LONG_STR || - rdf_type == LDNS_RDF_TYPE_MULTI_STR; + rdf_type == LDNS_RDF_TYPE_LONG_STR; } /* @@ -1985,7 +1984,7 @@ static const ldns_rdf_type type_eui64_wireformat[] = { static const ldns_rdf_type type_uri_wireformat[] = { LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_INT16, - LDNS_RDF_TYPE_MULTI_STR + LDNS_RDF_TYPE_LONG_STR }; static const ldns_rdf_type type_caa_wireformat[] = { LDNS_RDF_TYPE_INT8, diff --git a/str2host.c b/str2host.c index d5bfd5bc..623f06dd 100644 --- a/str2host.c +++ b/str2host.c @@ -1485,50 +1485,3 @@ ldns_str2rdf_long_str(ldns_rdf **rd, const char *str) return LDNS_STATUS_OK; } -ldns_status -ldns_str2rdf_multi_str(ldns_rdf **rd, const char *str) -{ - uint8_t *data, *dp, ch = 0; - size_t length; - - /* Worst case space requirement. We'll realloc to actual size later. */ - dp = data = LDNS_XMALLOC(uint8_t, strlen(str) + strlen(str) / 255 + 1); - if (! data) { - return LDNS_STATUS_MEM_ERR; - } - - /* Fill data with length byte (255) followed by 255 chars, repeatedly */ - *dp++ = 255; - while (parse_char(&ch, &str)) { - *dp++ = ch; - if ((dp - data) % 256 == 0) { - *dp++ = 255; - } - if (dp - data > LDNS_MAX_RDFLEN) { - LDNS_FREE(data); - return LDNS_STATUS_INVALID_STR; - } - } - if (! str) { - return LDNS_STATUS_SYNTAX_BAD_ESCAPE; - } - length = (size_t)(dp - data); - - /* Fix last length byte */ - data[length / 256 * 256] = (uint8_t)(length % 256 - 1); - - /* Lose the overmeasure */ - data = LDNS_XREALLOC(dp = data, uint8_t, length); - if (! data) { - LDNS_FREE(dp); - return LDNS_STATUS_MEM_ERR; - } - - /* Create rdf */ - *rd = ldns_rdf_new(LDNS_RDF_TYPE_MULTI_STR, length, data); - if (! *rd) { - LDNS_FREE(data); - return LDNS_STATUS_MEM_ERR; - } - return LDNS_STATUS_OK; -} diff --git a/wire2host.c b/wire2host.c index 9ba2c3fb..593fdd66 100644 --- a/wire2host.c +++ b/wire2host.c @@ -311,16 +311,6 @@ ldns_wire2rdf(ldns_rr *rr, const uint8_t *wire, size_t max, size_t *pos) cur_rdf_length = ((size_t) wire[*pos]) + 1; break; - case LDNS_RDF_TYPE_MULTI_STR: - cur_rdf_length = 0; - while (*pos + cur_rdf_length < end) { - str_sz = wire[*pos + cur_rdf_length]; - cur_rdf_length += str_sz + 1; - if (str_sz < 255) { - break; - } - } - break; case LDNS_RDF_TYPE_INT16_DATA: if (*pos + 2 > end) { return LDNS_STATUS_PACKET_OVERFLOW; -- 2.47.3