mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-03-08 20:58:20 +03:00
resolved: add new helper dns_answer_min_ttl()
This commit is contained in:
parent
301e7cd047
commit
1499a0a99a
@ -963,3 +963,22 @@ void dns_answer_randomize(DnsAnswer *a) {
|
||||
SWAP_TWO(a->items[i], a->items[k]);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t dns_answer_min_ttl(DnsAnswer *a) {
|
||||
uint32_t ttl = UINT32_MAX;
|
||||
DnsResourceRecord *rr;
|
||||
|
||||
/* Return the smallest TTL of all RRs in this answer */
|
||||
|
||||
DNS_ANSWER_FOREACH(rr, a) {
|
||||
/* Don't consider OPT (where the TTL field is used for other purposes than an actual TTL) */
|
||||
|
||||
if (dns_type_is_pseudo(rr->key->type) ||
|
||||
dns_class_is_pseudo(rr->key->class))
|
||||
continue;
|
||||
|
||||
ttl = MIN(ttl, rr->ttl);
|
||||
}
|
||||
|
||||
return ttl;
|
||||
}
|
||||
|
@ -87,6 +87,8 @@ void dns_answer_dump(DnsAnswer *answer, FILE *f);
|
||||
|
||||
void dns_answer_randomize(DnsAnswer *a);
|
||||
|
||||
uint32_t dns_answer_min_ttl(DnsAnswer *a);
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(DnsAnswer*, dns_answer_unref);
|
||||
|
||||
#define _DNS_ANSWER_FOREACH(q, kk, a) \
|
||||
|
Loading…
x
Reference in New Issue
Block a user