diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-07-23 01:59:36 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-07-23 02:00:40 +0200 |
commit | 934e9b10b4f4bfb48e21883670c7f45b6911fa9b (patch) | |
tree | f029033e76fabe439548400c6d7a1c6916f90087 /src/resolve/resolved-dns-answer.c | |
parent | 7e8e0422aeb16f2a09a40546c61df753d10029b6 (diff) |
resolved: most DNS servers can't handle more than one question per packet, hence let's not generate that
Diffstat (limited to 'src/resolve/resolved-dns-answer.c')
-rw-r--r-- | src/resolve/resolved-dns-answer.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/resolve/resolved-dns-answer.c b/src/resolve/resolved-dns-answer.c index 34c854cb3a..d907664527 100644 --- a/src/resolve/resolved-dns-answer.c +++ b/src/resolve/resolved-dns-answer.c @@ -138,3 +138,40 @@ int dns_answer_find_soa(DnsAnswer *a, DnsResourceKey *key, DnsResourceRecord **r return 0; } + +DnsAnswer *dns_answer_merge(DnsAnswer *a, DnsAnswer *b) { + _cleanup_(dns_answer_unrefp) DnsAnswer *ret = NULL; + DnsAnswer *k; + unsigned i; + int r; + + if (a && (!b || b->n_rrs <= 0)) + return dns_answer_ref(a); + if ((!a || a->n_rrs <= 0) && b) + return dns_answer_ref(b); + + ret = dns_answer_new((a ? a->n_rrs : 0) + (b ? b->n_rrs : 0)); + if (!ret) + return NULL; + + if (a) { + for (i = 0; i < a->n_rrs; i++) { + r = dns_answer_add(ret, a->rrs[i]); + if (r < 0) + return NULL; + } + } + + if (b) { + for (i = 0; i < b->n_rrs; i++) { + r = dns_answer_add(ret, b->rrs[i]); + if (r < 0) + return NULL; + } + } + + k = ret; + ret = NULL; + + return k; +} |