2020-11-09 05:23:58 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
2014-07-17 19:38:37 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "hashmap.h"
|
2015-11-18 22:46:33 +01:00
|
|
|
#include "list.h"
|
2014-07-17 19:38:37 +02:00
|
|
|
#include "prioq.h"
|
2019-07-12 21:34:24 +02:00
|
|
|
#include "resolve-util.h"
|
2014-07-17 19:38:37 +02:00
|
|
|
#include "time-util.h"
|
|
|
|
|
|
|
|
typedef struct DnsCache {
|
2014-07-23 00:57:25 +02:00
|
|
|
Hashmap *by_key;
|
|
|
|
Prioq *by_expiry;
|
2015-12-23 19:06:36 +01:00
|
|
|
unsigned n_hit;
|
|
|
|
unsigned n_miss;
|
2014-07-17 19:38:37 +02:00
|
|
|
} DnsCache;
|
|
|
|
|
2014-07-22 21:48:41 +02:00
|
|
|
#include "resolved-dns-answer.h"
|
2015-12-01 00:53:42 +01:00
|
|
|
#include "resolved-dns-packet.h"
|
2015-11-18 22:46:33 +01:00
|
|
|
#include "resolved-dns-question.h"
|
|
|
|
#include "resolved-dns-rr.h"
|
2014-07-17 19:38:37 +02:00
|
|
|
|
|
|
|
void dns_cache_flush(DnsCache *c);
|
|
|
|
void dns_cache_prune(DnsCache *c);
|
|
|
|
|
2019-07-12 21:34:24 +02:00
|
|
|
int dns_cache_put(DnsCache *c, DnsCacheMode cache_mode, DnsResourceKey *key, int rcode, DnsAnswer *answer, bool authenticated, uint32_t nsec_ttl, usec_t timestamp, int owner_family, const union in_addr_union *owner_address);
|
2016-06-20 21:24:46 +02:00
|
|
|
int dns_cache_lookup(DnsCache *c, DnsResourceKey *key, bool clamp_ttl, int *rcode, DnsAnswer **answer, bool *authenticated);
|
2014-08-06 16:15:35 +02:00
|
|
|
|
|
|
|
int dns_cache_check_conflicts(DnsCache *cache, DnsResourceRecord *rr, int owner_family, const union in_addr_union *owner_address);
|
2015-08-26 09:41:45 +02:00
|
|
|
|
|
|
|
void dns_cache_dump(DnsCache *cache, FILE *f);
|
|
|
|
bool dns_cache_is_empty(DnsCache *cache);
|
2015-12-01 00:53:42 +01:00
|
|
|
|
2015-12-23 19:06:36 +01:00
|
|
|
unsigned dns_cache_size(DnsCache *cache);
|
|
|
|
|
2015-12-01 00:53:42 +01:00
|
|
|
int dns_cache_export_shared_to_packet(DnsCache *cache, DnsPacket *p);
|