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)
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 */
*/
LDNS_RDF_TYPE_LONG_STR,
- /** A <character-string> encoding of the value field as specified in
- * section 5.1 of [RFC1035], encoded as a sequence of one or more
- * <character-string> (as specified in section 3.3 of [RFC1035]),
- * where all but the last <character-string> 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
};
*/
ldns_status ldns_str2rdf_long_str(ldns_rdf **rd, const char *str);
-/**
- * Convert A <character-string> encoding of the value field as specified in
- * section 5.1 of [RFC1035], encoded as a sequence of one or more
- * <character-string> (as specified in section 3.3 of [RFC1035]),
- * where all but the last <character-string> 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
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 ??? */
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;
}
/*
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,
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;
-}
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;