resolved-dns-cache.h revision a150ff5e4e2481eb28d6ed6e0d3e176623e25f5a
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#pragma once
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering/***
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering This file is part of systemd.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Copyright 2014 Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering systemd is free software; you can redistribute it and/or modify it
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering under the terms of the GNU Lesser General Public License as published by
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering (at your option) any later version.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering systemd is distributed in the hope that it will be useful, but
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Lesser General Public License for more details.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering You should have received a copy of the GNU Lesser General Public License
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering***/
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
3c0cf502796be355431d4a64d738e75f543aa51dLennart Poettering#include "hashmap.h"
3c0cf502796be355431d4a64d738e75f543aa51dLennart Poettering#include "list.h"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#include "prioq.h"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#include "time-util.h"
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poetteringtypedef struct DnsCache {
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering Hashmap *by_key;
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering Prioq *by_expiry;
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering unsigned n_hit;
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering unsigned n_miss;
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen} DnsCache;
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen#include "resolved-dns-answer.h"
9c5e12a4314e7192e834e1b855e5e80111e636a6Tom Gundersen#include "resolved-dns-packet.h"
7586f4d172dd9c3ccc3126fc47dca9e49adec132Tom Gundersen#include "resolved-dns-question.h"
d74fb368b18f0fbd9a4fe6f15691bbea7f3c4a01Tom Gundersen#include "resolved-dns-rr.h"
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersenvoid dns_cache_flush(DnsCache *c);
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersenvoid dns_cache_prune(DnsCache *c);
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersenint dns_cache_put(DnsCache *c, DnsResourceKey *key, int rcode, DnsAnswer *answer, bool authenticated, usec_t timestamp, int owner_family, const union in_addr_union *owner_address);
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersenint dns_cache_lookup(DnsCache *c, DnsResourceKey *key, int *rcode, DnsAnswer **answer, bool *authenticated);
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersenint dns_cache_check_conflicts(DnsCache *cache, DnsResourceRecord *rr, int owner_family, const union in_addr_union *owner_address);
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersenvoid dns_cache_dump(DnsCache *cache, FILE *f);
3e684349c2cead2e6fd2f816c34eb17daba23a49Lennart Poetteringbool dns_cache_is_empty(DnsCache *cache);
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen
3e684349c2cead2e6fd2f816c34eb17daba23a49Lennart Poetteringunsigned dns_cache_size(DnsCache *cache);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringint dns_cache_export_shared_to_packet(DnsCache *cache, DnsPacket *p);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering