[systemd-commits] 4 commits - src/resolve
Lennart Poettering
lennart at kemper.freedesktop.org
Thu Jul 31 09:23:50 PDT 2014
src/resolve/resolved-dns-packet.c | 40 +++++++++++++++++++++++++++++++++-----
src/resolve/resolved-dns-rr.c | 38 ++++++++++++++++++++++++++++++++++--
src/resolve/resolved-dns-rr.h | 16 +++++++--------
3 files changed, 79 insertions(+), 15 deletions(-)
New commits:
commit 9c92ce6d67f88beb31dd6555d12ae3f632218a39
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Jul 31 18:23:00 2014 +0200
resolved: properly process SRV records
diff --git a/src/resolve/resolved-dns-packet.c b/src/resolve/resolved-dns-packet.c
index 05c62a4..024ab0d 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);
diff --git a/src/resolve/resolved-dns-rr.c b/src/resolve/resolved-dns-rr.c
index d282244..9ef3135 100644
--- a/src/resolve/resolved-dns-rr.c
+++ b/src/resolve/resolved-dns-rr.c
@@ -234,31 +234,42 @@ DnsResourceRecord* dns_resource_record_unref(DnsResourceRecord *rr) {
if (rr->key) {
switch(rr->key->type) {
+
+ case DNS_TYPE_SRV:
+ free(rr->srv.name);
+ break;
+
case DNS_TYPE_PTR:
case DNS_TYPE_NS:
case DNS_TYPE_CNAME:
case DNS_TYPE_DNAME:
free(rr->ptr.name);
break;
+
case DNS_TYPE_HINFO:
free(rr->hinfo.cpu);
free(rr->hinfo.os);
break;
- case DNS_TYPE_SPF:
+
case DNS_TYPE_TXT:
+ case DNS_TYPE_SPF:
strv_free(rr->txt.strings);
break;
+
case DNS_TYPE_SOA:
free(rr->soa.mname);
free(rr->soa.rname);
break;
+
case DNS_TYPE_MX:
free(rr->mx.exchange);
break;
+
case DNS_TYPE_LOC:
case DNS_TYPE_A:
case DNS_TYPE_AAAA:
break;
+
default:
free(rr->generic.data);
}
@@ -317,6 +328,15 @@ int dns_resource_record_equal(const DnsResourceRecord *a, const DnsResourceRecor
switch (a->key->type) {
+ case DNS_TYPE_SRV:
+ r = dns_name_equal(a->srv.name, b->srv.name);
+ if (r <= 0)
+ return r;
+
+ return a->srv.priority == b->srv.priority &&
+ a->srv.weight == b->srv.weight &&
+ a->srv.port == b->srv.port;
+
case DNS_TYPE_PTR:
case DNS_TYPE_NS:
case DNS_TYPE_CNAME:
@@ -356,6 +376,7 @@ 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;
@@ -423,6 +444,17 @@ int dns_resource_record_to_string(const DnsResourceRecord *rr, char **ret) {
switch (rr->unparseable ? _DNS_TYPE_INVALID : rr->key->type) {
+ case DNS_TYPE_SRV:
+ r = asprintf(&s, "%s %u %u %u %s",
+ k,
+ rr->srv.priority,
+ rr->srv.weight,
+ rr->srv.port,
+ strna(rr->srv.name));
+ if (r < 0)
+ return -ENOMEM;
+ break;
+
case DNS_TYPE_PTR:
case DNS_TYPE_NS:
case DNS_TYPE_CNAME:
diff --git a/src/resolve/resolved-dns-rr.h b/src/resolve/resolved-dns-rr.h
index 47885fc..a001433 100644
--- a/src/resolve/resolved-dns-rr.h
+++ b/src/resolve/resolved-dns-rr.h
@@ -86,12 +86,12 @@ struct DnsResourceRecord {
uint16_t size;
} generic;
- /* struct { */
- /* uint16_t priority; */
- /* uint16_t weight; */
- /* uint16_t port; */
- /* char *name; */
- /* } srv; */
+ struct {
+ uint16_t priority;
+ uint16_t weight;
+ uint16_t port;
+ char *name;
+ } srv;
struct {
char *name;
commit c0eb11cfd016381fe02875a4ef29c1ade00c94e7
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Jul 31 18:03:09 2014 +0200
resolved: provide properly named way to access SPF data in RRs
diff --git a/src/resolve/resolved-dns-rr.h b/src/resolve/resolved-dns-rr.h
index 027f6ca..47885fc 100644
--- a/src/resolve/resolved-dns-rr.h
+++ b/src/resolve/resolved-dns-rr.h
@@ -104,7 +104,7 @@ struct DnsResourceRecord {
struct {
char **strings;
- } txt;
+ } txt, spf;
struct {
struct in_addr in_addr;
commit 6a6fc3df74c8ed91d4ea1813b3f6a6c3bf48a288
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Jul 31 18:02:42 2014 +0200
resolved: make sure we always initialize r when parsing TXT records
diff --git a/src/resolve/resolved-dns-packet.c b/src/resolve/resolved-dns-packet.c
index 5d4e097..05c62a4 100644
--- a/src/resolve/resolved-dns-packet.c
+++ b/src/resolve/resolved-dns-packet.c
@@ -524,6 +524,7 @@ int dns_packet_append_rr(DnsPacket *p, const DnsResourceRecord *rr, size_t *star
goto fail;
}
+ r = 0;
break;
}
@@ -977,7 +978,9 @@ int dns_packet_read_rr(DnsPacket *p, DnsResourceRecord **ret, size_t *start) {
r = strv_consume(&rr->txt.strings, s);
if (r < 0)
goto fail;
- };
+ }
+
+ r = 0;
break;
}
commit 8ac4e9e1e54397f6d1745c2a7a806132418c7da2
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Jul 31 18:02:24 2014 +0200
resolved: properly process DNAME RRs
diff --git a/src/resolve/resolved-dns-packet.c b/src/resolve/resolved-dns-packet.c
index 32c4876..5d4e097 100644
--- a/src/resolve/resolved-dns-packet.c
+++ b/src/resolve/resolved-dns-packet.c
@@ -502,6 +502,7 @@ int dns_packet_append_rr(DnsPacket *p, const DnsResourceRecord *rr, size_t *star
case DNS_TYPE_PTR:
case DNS_TYPE_NS:
case DNS_TYPE_CNAME:
+ case DNS_TYPE_DNAME:
r = dns_packet_append_name(p, rr->ptr.name, NULL);
break;
@@ -599,7 +600,6 @@ int dns_packet_append_rr(DnsPacket *p, const DnsResourceRecord *rr, size_t *star
break;
case DNS_TYPE_SRV:
- case DNS_TYPE_DNAME:
case DNS_TYPE_SSHFP:
case _DNS_TYPE_INVALID: /* unparseable */
default:
@@ -953,6 +953,7 @@ int dns_packet_read_rr(DnsPacket *p, DnsResourceRecord **ret, size_t *start) {
case DNS_TYPE_PTR:
case DNS_TYPE_NS:
case DNS_TYPE_CNAME:
+ case DNS_TYPE_DNAME:
r = dns_packet_read_name(p, &rr->ptr.name, NULL);
break;
@@ -1068,7 +1069,6 @@ int dns_packet_read_rr(DnsPacket *p, DnsResourceRecord **ret, size_t *start) {
}
case DNS_TYPE_SRV:
- case DNS_TYPE_DNAME:
case DNS_TYPE_SSHFP:
default:
r = dns_packet_read(p, rdlength, &d, NULL);
diff --git a/src/resolve/resolved-dns-rr.c b/src/resolve/resolved-dns-rr.c
index b6a2c04..d282244 100644
--- a/src/resolve/resolved-dns-rr.c
+++ b/src/resolve/resolved-dns-rr.c
@@ -237,6 +237,7 @@ DnsResourceRecord* dns_resource_record_unref(DnsResourceRecord *rr) {
case DNS_TYPE_PTR:
case DNS_TYPE_NS:
case DNS_TYPE_CNAME:
+ case DNS_TYPE_DNAME:
free(rr->ptr.name);
break;
case DNS_TYPE_HINFO:
@@ -319,6 +320,7 @@ int dns_resource_record_equal(const DnsResourceRecord *a, const DnsResourceRecor
case DNS_TYPE_PTR:
case DNS_TYPE_NS:
case DNS_TYPE_CNAME:
+ case DNS_TYPE_DNAME:
return dns_name_equal(a->ptr.name, b->ptr.name);
case DNS_TYPE_HINFO:
@@ -424,6 +426,7 @@ int dns_resource_record_to_string(const DnsResourceRecord *rr, char **ret) {
case DNS_TYPE_PTR:
case DNS_TYPE_NS:
case DNS_TYPE_CNAME:
+ case DNS_TYPE_DNAME:
s = strjoin(k, " ", rr->ptr.name, NULL);
if (!s)
return -ENOMEM;
@@ -591,7 +594,6 @@ static const struct {
{ DNS_TYPE_AXFR, "AXFR" },
};
-
const char *dns_type_to_string(uint16_t type) {
unsigned i;
diff --git a/src/resolve/resolved-dns-rr.h b/src/resolve/resolved-dns-rr.h
index 8fb4639..027f6ca 100644
--- a/src/resolve/resolved-dns-rr.h
+++ b/src/resolve/resolved-dns-rr.h
@@ -95,7 +95,7 @@ struct DnsResourceRecord {
struct {
char *name;
- } ptr, ns, cname;
+ } ptr, ns, cname, dname;
struct {
char *cpu;
More information about the systemd-commits
mailing list