summaryrefslogtreecommitdiff
path: root/src/resolve
diff options
context:
space:
mode:
Diffstat (limited to 'src/resolve')
-rw-r--r--src/resolve/resolved-dns-packet.c14
-rw-r--r--src/resolve/resolved-dns-rr.c17
-rw-r--r--src/resolve/resolved-dns-rr.h5
3 files changed, 36 insertions, 0 deletions
diff --git a/src/resolve/resolved-dns-packet.c b/src/resolve/resolved-dns-packet.c
index 3e6c9a480b..217bdafcb8 100644
--- a/src/resolve/resolved-dns-packet.c
+++ b/src/resolve/resolved-dns-packet.c
@@ -549,6 +549,13 @@ int dns_packet_append_rr(DnsPacket *p, const DnsResourceRecord *rr, size_t *star
break;
case DNS_TYPE_MX:
+ r = dns_packet_append_uint16(p, rr->mx.priority, NULL);
+ if (r < 0)
+ goto fail;
+
+ r = dns_packet_append_name(p, rr->mx.exchange, NULL);
+ break;
+
case DNS_TYPE_TXT:
case DNS_TYPE_SRV:
case DNS_TYPE_DNAME:
@@ -951,6 +958,13 @@ int dns_packet_read_rr(DnsPacket *p, DnsResourceRecord **ret, size_t *start) {
break;
case DNS_TYPE_MX:
+ r = dns_packet_read_uint16(p, &rr->mx.priority, NULL);
+ if (r < 0)
+ goto fail;
+
+ r = dns_packet_read_name(p, &rr->mx.exchange, NULL);
+ break;
+
case DNS_TYPE_TXT:
case DNS_TYPE_SRV:
case DNS_TYPE_DNAME:
diff --git a/src/resolve/resolved-dns-rr.c b/src/resolve/resolved-dns-rr.c
index e1200c9bc0..2e13b9c51a 100644
--- a/src/resolve/resolved-dns-rr.c
+++ b/src/resolve/resolved-dns-rr.c
@@ -237,6 +237,8 @@ DnsResourceRecord* dns_resource_record_unref(DnsResourceRecord *rr) {
} else if (rr->key->type == DNS_TYPE_SOA) {
free(rr->soa.mname);
free(rr->soa.rname);
+ } else if (rr->key->type == DNS_TYPE_MX) {
+ free(rr->mx.exchange);
} else if (!IN_SET(rr->key->type, DNS_TYPE_A, DNS_TYPE_AAAA))
free(rr->generic.data);
@@ -322,6 +324,12 @@ int dns_resource_record_equal(const DnsResourceRecord *a, const DnsResourceRecor
a->soa.retry == b->soa.retry &&
a->soa.expire == b->soa.expire &&
a->soa.minimum == b->soa.minimum;
+ case DNS_TYPE_MX:
+ if (a->mx.priority != b->mx.priority)
+ return 0;
+
+ return dns_name_equal(a->mx.exchange, b->mx.exchange);
+
default:
return a->generic.size == b->generic.size &&
memcmp(a->generic.data, b->generic.data, a->generic.size) == 0;
@@ -396,6 +404,15 @@ int dns_resource_record_to_string(const DnsResourceRecord *rr, char **ret) {
return -ENOMEM;
break;
+ case DNS_TYPE_MX:
+ r = asprintf(&s, "%s %u %s",
+ k,
+ rr->mx.priority,
+ rr->mx.exchange);
+ if (r < 0)
+ return -ENOMEM;
+ break;
+
default: {
_cleanup_free_ char *x = NULL;
diff --git a/src/resolve/resolved-dns-rr.h b/src/resolve/resolved-dns-rr.h
index 7b73cdc6ca..359d662a60 100644
--- a/src/resolve/resolved-dns-rr.h
+++ b/src/resolve/resolved-dns-rr.h
@@ -119,6 +119,11 @@ struct DnsResourceRecord {
uint32_t expire;
uint32_t minimum;
} soa;
+
+ struct {
+ uint16_t priority;
+ char *exchange;
+ } mx;
};
};