322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering#pragma once
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering/***
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering This file is part of systemd.
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering Copyright 2014 Lennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering systemd is free software; you can redistribute it and/or modify it
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering under the terms of the GNU Lesser General Public License as published by
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering (at your option) any later version.
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering systemd is distributed in the hope that it will be useful, but
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering Lesser General Public License for more details.
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering You should have received a copy of the GNU Lesser General Public License
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering***/
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering#include "hashmap.h"
71d35b6b5563817dfbe757ab9e3b9f018b2db491Thomas Hindoe Paaboel Andersen#include "list.h"
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering#include "prioq.h"
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering#include "time-util.h"
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poetteringtypedef struct DnsCache {
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering Hashmap *by_key;
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering Prioq *by_expiry;
a150ff5e4e2481eb28d6ed6e0d3e176623e25f5aLennart Poettering unsigned n_hit;
a150ff5e4e2481eb28d6ed6e0d3e176623e25f5aLennart Poettering unsigned n_miss;
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering} DnsCache;
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering#include "resolved-dns-answer.h"
7778dffff3d8bd7438fe19a248c16203668324c9Daniel Mack#include "resolved-dns-packet.h"
71d35b6b5563817dfbe757ab9e3b9f018b2db491Thomas Hindoe Paaboel Andersen#include "resolved-dns-question.h"
71d35b6b5563817dfbe757ab9e3b9f018b2db491Thomas Hindoe Paaboel Andersen#include "resolved-dns-rr.h"
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poetteringvoid dns_cache_flush(DnsCache *c);
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poetteringvoid dns_cache_prune(DnsCache *c);
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering
d3760be01b120df8980c056ecc85a4229d660264Lennart Poetteringint dns_cache_put(DnsCache *c, 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);
931851e8e492a4d2715e22dcde50a5e7ccef4b49Lennart Poetteringint dns_cache_lookup(DnsCache *c, DnsResourceKey *key, int *rcode, DnsAnswer **answer, bool *authenticated);
a407657425a3e47fd2b559cd3bc800f791303f63Lennart Poettering
a407657425a3e47fd2b559cd3bc800f791303f63Lennart Poetteringint dns_cache_check_conflicts(DnsCache *cache, DnsResourceRecord *rr, int owner_family, const union in_addr_union *owner_address);
4d506d6bb757af3b99e0876234c465e6898c5ea4Lennart Poettering
4d506d6bb757af3b99e0876234c465e6898c5ea4Lennart Poetteringvoid dns_cache_dump(DnsCache *cache, FILE *f);
4d506d6bb757af3b99e0876234c465e6898c5ea4Lennart Poetteringbool dns_cache_is_empty(DnsCache *cache);
7778dffff3d8bd7438fe19a248c16203668324c9Daniel Mack
a150ff5e4e2481eb28d6ed6e0d3e176623e25f5aLennart Poetteringunsigned dns_cache_size(DnsCache *cache);
a150ff5e4e2481eb28d6ed6e0d3e176623e25f5aLennart Poettering
7778dffff3d8bd7438fe19a248c16203668324c9Daniel Mackint dns_cache_export_shared_to_packet(DnsCache *cache, DnsPacket *p);