summaryrefslogtreecommitdiff
path: root/src/libs6dns/s6dns_fmt_caa.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2018-04-12 00:09:40 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2018-04-12 00:09:40 +0000
commit665f12a744dea29a4e5437ecca918ed5d57b5744 (patch)
tree1e327fa9a76cda9c7d67a766f7ab289986f43284 /src/libs6dns/s6dns_fmt_caa.c
parent8cb636aa0671ac3c23009d8ca75245b2c08168c8 (diff)
downloads6-dns-665f12a744dea29a4e5437ecca918ed5d57b5744.tar.xz
Add CAA record support
Diffstat (limited to 'src/libs6dns/s6dns_fmt_caa.c')
-rw-r--r--src/libs6dns/s6dns_fmt_caa.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/libs6dns/s6dns_fmt_caa.c b/src/libs6dns/s6dns_fmt_caa.c
new file mode 100644
index 0000000..7fbf36b
--- /dev/null
+++ b/src/libs6dns/s6dns_fmt_caa.c
@@ -0,0 +1,22 @@
+/* ISC license. */
+
+#include <stdint.h>
+#include <string.h>
+#include <errno.h>
+#include <skalibs/uint16.h>
+#include <s6-dns/s6dns-fmt.h>
+
+size_t s6dns_fmt_caa (char *s, size_t max, s6dns_message_rr_caa_t const *caa)
+{
+ size_t len = 0, taglen = strlen(caa->tag), valuelen = strlen(caa->value) ;
+ char fmt[UINT16_FMT] ;
+ size_t r = uint16_fmt(fmt, (uint16_t)caa->flags) ;
+ if (r + taglen + valuelen + 2 > max) return (errno = ENAMETOOLONG, 0) ;
+ memcpy(s + len, fmt, r) ;
+ len += r ; s[len++] = ' ' ;
+ memcpy(s + len, caa->tag, taglen) ;
+ len += taglen ; s[len++] = ' ' ;
+ memcpy(s + len, caa->value, valuelen) ;
+ len += valuelen ;
+ return len ;
+}