summaryrefslogtreecommitdiff
path: root/sldns
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2018-05-12 11:56:38 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2018-05-12 11:56:38 +0000
commit197f1a0fe3e81cde0cd25a3a1f37ebedf9a99488 (patch)
tree9a121ad4cef31a32608c065400c31246d549c0dc /sldns
parentb5c63b395d5df7ff6ee4d41a7dfecd938d894037 (diff)
downloadsrc-test2-197f1a0fe3e81cde0cd25a3a1f37ebedf9a99488.tar.gz
src-test2-197f1a0fe3e81cde0cd25a3a1f37ebedf9a99488.zip
Notes
Diffstat (limited to 'sldns')
-rw-r--r--sldns/str2wire.c11
-rw-r--r--sldns/str2wire.h6
-rw-r--r--sldns/wire2str.c6
-rw-r--r--sldns/wire2str.h16
4 files changed, 37 insertions, 2 deletions
diff --git a/sldns/str2wire.c b/sldns/str2wire.c
index 6759944e4a7f..fdb355754028 100644
--- a/sldns/str2wire.c
+++ b/sldns/str2wire.c
@@ -836,7 +836,7 @@ const char* sldns_get_errorstr_parse(int e)
}
/* Strip whitespace from the start and the end of <line>. */
-static char *
+char *
sldns_strip_ws(char *line)
{
char *s = line, *e;
@@ -906,7 +906,7 @@ int sldns_fp2wire_rr_buf(FILE* in, uint8_t* rr, size_t* len, size_t* dname_len,
*dname_len = 0;
return LDNS_WIREPARSE_ERR_INCLUDE;
} else {
- return sldns_str2wire_rr_buf(line, rr, len, dname_len,
+ int r = sldns_str2wire_rr_buf(line, rr, len, dname_len,
parse_state?parse_state->default_ttl:0,
(parse_state&&parse_state->origin_len)?
parse_state->origin:NULL,
@@ -914,6 +914,13 @@ int sldns_fp2wire_rr_buf(FILE* in, uint8_t* rr, size_t* len, size_t* dname_len,
(parse_state&&parse_state->prev_rr_len)?
parse_state->prev_rr:NULL,
parse_state?parse_state->prev_rr_len:0);
+ if(r == LDNS_WIREPARSE_ERR_OK && (*dname_len) != 0 &&
+ parse_state &&
+ (*dname_len) <= sizeof(parse_state->prev_rr)) {
+ memmove(parse_state->prev_rr, rr, *dname_len);
+ parse_state->prev_rr_len = (*dname_len);
+ }
+ return r;
}
return LDNS_WIREPARSE_ERR_OK;
}
diff --git a/sldns/str2wire.h b/sldns/str2wire.h
index a0d6f55b03e8..70070e4f5752 100644
--- a/sldns/str2wire.h
+++ b/sldns/str2wire.h
@@ -554,6 +554,12 @@ int sldns_str2wire_hip_buf(const char* str, uint8_t* rd, size_t* len);
*/
int sldns_str2wire_int16_data_buf(const char* str, uint8_t* rd, size_t* len);
+/**
+ * Strip whitespace from the start and the end of line.
+ * @param line: modified with 0 to shorten it.
+ * @return new start with spaces skipped.
+ */
+char * sldns_strip_ws(char *line);
#ifdef __cplusplus
}
#endif
diff --git a/sldns/wire2str.c b/sldns/wire2str.c
index 861b7648adec..832239f9b76a 100644
--- a/sldns/wire2str.c
+++ b/sldns/wire2str.c
@@ -255,6 +255,12 @@ int sldns_wire2str_rr_buf(uint8_t* d, size_t dlen, char* s, size_t slen)
return sldns_wire2str_rr_scan(&d, &dlen, &s, &slen, NULL, 0);
}
+int sldns_wire2str_rrquestion_buf(uint8_t* d, size_t dlen, char* s, size_t slen)
+{
+ /* use arguments as temporary variables */
+ return sldns_wire2str_rrquestion_scan(&d, &dlen, &s, &slen, NULL, 0);
+}
+
int sldns_wire2str_rdata_buf(uint8_t* rdata, size_t rdata_len, char* str,
size_t str_len, uint16_t rrtype)
{
diff --git a/sldns/wire2str.h b/sldns/wire2str.h
index aac13c548acd..a64f5807269c 100644
--- a/sldns/wire2str.h
+++ b/sldns/wire2str.h
@@ -359,6 +359,22 @@ int sldns_wire2str_rr_buf(uint8_t* rr, size_t rr_len, char* str,
size_t str_len);
/**
+ * Convert question RR to string presentation format, on one line. User buffer.
+ * @param rr: wireformat RR data
+ * @param rr_len: length of the rr wire data.
+ * @param str: the string buffer to write to.
+ * If you pass NULL as the str, the return value of the function is
+ * the str_len you need for the entire packet. It does not include
+ * the 0 byte at the end.
+ * @param str_len: the size of the string buffer. If more is needed, it'll
+ * silently truncate the output to fit in the buffer.
+ * @return the number of characters for this element, excluding zerobyte.
+ * Is larger or equal than str_len if output was truncated.
+ */
+int sldns_wire2str_rrquestion_buf(uint8_t* rr, size_t rr_len, char* str,
+ size_t str_len);
+
+/**
* 3597 printout of an RR in unknown rr format.
* There are more format and comment options available for printout
* with the function: TBD(TODO)