summaryrefslogtreecommitdiff
path: root/src/resolve/resolved-dns-packet.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-07-31 21:36:58 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-07-31 08:56:03 -0400
commit2e276efc7b0398a3086629a52970bdd4ab7252f9 (patch)
tree72df97e7316d21826096dba6b2f9c3627941e835 /src/resolve/resolved-dns-packet.c
parent946c70944ebdf428ffeb9991a7449edbd4011461 (diff)
resolved: TXT records
Diffstat (limited to 'src/resolve/resolved-dns-packet.c')
-rw-r--r--src/resolve/resolved-dns-packet.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/resolve/resolved-dns-packet.c b/src/resolve/resolved-dns-packet.c
index 217bdafcb8..3d64c27ceb 100644
--- a/src/resolve/resolved-dns-packet.c
+++ b/src/resolve/resolved-dns-packet.c
@@ -21,6 +21,7 @@
#include "utf8.h"
#include "util.h"
+#include "strv.h"
#include "resolved-dns-domain.h"
#include "resolved-dns-packet.h"
@@ -512,6 +513,18 @@ int dns_packet_append_rr(DnsPacket *p, const DnsResourceRecord *rr, size_t *star
r = dns_packet_append_string(p, rr->hinfo.os, NULL);
break;
+ case DNS_TYPE_TXT: {
+ char **s;
+
+ STRV_FOREACH(s, rr->txt.strings) {
+ r = dns_packet_append_string(p, *s, NULL);
+ if (r < 0)
+ goto fail;
+ }
+
+ break;
+ }
+
case DNS_TYPE_A:
r = dns_packet_append_blob(p, &rr->a.in_addr, sizeof(struct in_addr), NULL);
break;
@@ -556,7 +569,6 @@ int dns_packet_append_rr(DnsPacket *p, const DnsResourceRecord *rr, size_t *star
r = dns_packet_append_name(p, rr->mx.exchange, NULL);
break;
- case DNS_TYPE_TXT:
case DNS_TYPE_SRV:
case DNS_TYPE_DNAME:
case DNS_TYPE_SSHFP:
@@ -921,6 +933,21 @@ int dns_packet_read_rr(DnsPacket *p, DnsResourceRecord **ret, size_t *start) {
r = dns_packet_read_string(p, &rr->hinfo.os, NULL);
break;
+ case DNS_TYPE_TXT: {
+ char *s;
+
+ while (p->rindex < p->size) {
+ r = dns_packet_read_string(p, &s, NULL);
+ if (r < 0)
+ goto fail;
+
+ r = strv_consume(&rr->txt.strings, s);
+ if (r < 0)
+ goto fail;
+ };
+ break;
+ }
+
case DNS_TYPE_A:
r = dns_packet_read_blob(p, &rr->a.in_addr, sizeof(struct in_addr), NULL);
break;
@@ -965,7 +992,6 @@ int dns_packet_read_rr(DnsPacket *p, DnsResourceRecord **ret, size_t *start) {
r = dns_packet_read_name(p, &rr->mx.exchange, NULL);
break;
- case DNS_TYPE_TXT:
case DNS_TYPE_SRV:
case DNS_TYPE_DNAME:
case DNS_TYPE_SSHFP: