summaryrefslogtreecommitdiff
path: root/src/resolve/resolved-dns-answer.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-07-30 16:30:25 +0200
committerLennart Poettering <lennart@poettering.net>2014-07-30 16:47:21 +0200
commit8bf52d3d17d364438191077d0750b8b80b5dc53a (patch)
tree65fdbe0ce790585840ed2f96febafbb9ead8d41b /src/resolve/resolved-dns-answer.c
parentab0cf8f8ff819c386d53b9ca29e9ac2d6b6e8f0f (diff)
resolved: include SOA records in LLMNR replies for non-existing RRs to allow negative caching
Diffstat (limited to 'src/resolve/resolved-dns-answer.c')
-rw-r--r--src/resolve/resolved-dns-answer.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/resolve/resolved-dns-answer.c b/src/resolve/resolved-dns-answer.c
index 6096959355..b6883a3aba 100644
--- a/src/resolve/resolved-dns-answer.c
+++ b/src/resolve/resolved-dns-answer.c
@@ -97,6 +97,30 @@ int dns_answer_add(DnsAnswer *a, DnsResourceRecord *rr) {
return 1;
}
+int dns_answer_add_soa(DnsAnswer *a, const char *name) {
+ _cleanup_(dns_resource_record_unrefp) DnsResourceRecord *soa = NULL;
+
+ soa = dns_resource_record_new_full(DNS_CLASS_IN, DNS_TYPE_SOA, name);
+ if (!soa)
+ return -ENOMEM;
+
+ soa->soa.mname = strdup(name);
+ if (!soa->soa.mname)
+ return -ENOMEM;
+
+ soa->soa.rname = strappend("root.", name);
+ if (!soa->soa.rname)
+ return -ENOMEM;
+
+ soa->soa.serial = 1;
+ soa->soa.refresh = 1;
+ soa->soa.retry = 1;
+ soa->soa.expire = 1;
+ soa->soa.minimum = 1;
+
+ return dns_answer_add(a, soa);
+}
+
int dns_answer_contains(DnsAnswer *a, DnsResourceKey *key) {
unsigned i;
int r;