summaryrefslogtreecommitdiff
path: root/src/resolve/resolved-dns-packet.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-07-31 18:23:00 +0200
committerLennart Poettering <lennart@poettering.net>2014-07-31 18:23:34 +0200
commit9c92ce6d67f88beb31dd6555d12ae3f632218a39 (patch)
tree1dda48f7b696ec1ba9b09abbb08b864bd333ca0e /src/resolve/resolved-dns-packet.c
parentc0eb11cfd016381fe02875a4ef29c1ade00c94e7 (diff)
resolved: properly process SRV records
Diffstat (limited to 'src/resolve/resolved-dns-packet.c')
-rw-r--r--src/resolve/resolved-dns-packet.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/resolve/resolved-dns-packet.c b/src/resolve/resolved-dns-packet.c
index 05c62a497f..024ab0d0e6 100644
--- a/src/resolve/resolved-dns-packet.c
+++ b/src/resolve/resolved-dns-packet.c
@@ -499,6 +499,22 @@ int dns_packet_append_rr(DnsPacket *p, const DnsResourceRecord *rr, size_t *star
switch (rr->unparseable ? _DNS_TYPE_INVALID : rr->key->type) {
+ case DNS_TYPE_SRV:
+ r = dns_packet_append_uint16(p, rr->srv.priority, NULL);
+ if (r < 0)
+ goto fail;
+
+ r = dns_packet_append_uint16(p, rr->srv.weight, NULL);
+ if (r < 0)
+ goto fail;
+
+ r = dns_packet_append_uint16(p, rr->srv.port, NULL);
+ if (r < 0)
+ goto fail;
+
+ r = dns_packet_append_name(p, rr->srv.name, NULL);
+ break;
+
case DNS_TYPE_PTR:
case DNS_TYPE_NS:
case DNS_TYPE_CNAME:
@@ -600,7 +616,6 @@ int dns_packet_append_rr(DnsPacket *p, const DnsResourceRecord *rr, size_t *star
r = dns_packet_append_uint16(p, rr->loc.altitude, NULL);
break;
- case DNS_TYPE_SRV:
case DNS_TYPE_SSHFP:
case _DNS_TYPE_INVALID: /* unparseable */
default:
@@ -951,6 +966,19 @@ int dns_packet_read_rr(DnsPacket *p, DnsResourceRecord **ret, size_t *start) {
switch (rr->key->type) {
+ case DNS_TYPE_SRV:
+ r = dns_packet_read_uint16(p, &rr->srv.priority, NULL);
+ if (r < 0)
+ goto fail;
+ r = dns_packet_read_uint16(p, &rr->srv.weight, NULL);
+ if (r < 0)
+ goto fail;
+ r = dns_packet_read_uint16(p, &rr->srv.port, NULL);
+ if (r < 0)
+ goto fail;
+ r = dns_packet_read_name(p, &rr->srv.name, NULL);
+ break;
+
case DNS_TYPE_PTR:
case DNS_TYPE_NS:
case DNS_TYPE_CNAME:
@@ -1071,7 +1099,6 @@ int dns_packet_read_rr(DnsPacket *p, DnsResourceRecord **ret, size_t *start) {
}
}
- case DNS_TYPE_SRV:
case DNS_TYPE_SSHFP:
default:
r = dns_packet_read(p, rdlength, &d, NULL);