resolved-dns-server.h revision 6bb2c08597c999c429e889cd2403b2fef5f3e1a0
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek#pragma once
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek/***
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek This file is part of systemd.
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek Copyright 2014 Lennart Poettering
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek systemd is free software; you can redistribute it and/or modify it
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek under the terms of the GNU Lesser General Public License as published by
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek the Free Software Foundation; either version 2.1 of the License, or
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek (at your option) any later version.
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek systemd is distributed in the hope that it will be useful, but
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek WITHOUT ANY WARRANTY; without even the implied warranty of
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek Lesser General Public License for more details.
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek You should have received a copy of the GNU Lesser General Public License
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek along with systemd; If not, see <http://www.gnu.org/licenses/>.
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek***/
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek#include "in-addr-util.h"
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmektypedef struct DnsServer DnsServer;
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmektypedef enum DnsServerType {
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek DNS_SERVER_SYSTEM,
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek DNS_SERVER_FALLBACK,
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek DNS_SERVER_LINK,
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek} DnsServerType;
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmektypedef enum DnsServerFeatureLevel {
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek DNS_SERVER_FEATURE_LEVEL_TCP,
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek DNS_SERVER_FEATURE_LEVEL_UDP,
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek DNS_SERVER_FEATURE_LEVEL_EDNS0,
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek DNS_SERVER_FEATURE_LEVEL_DO,
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek DNS_SERVER_FEATURE_LEVEL_LARGE,
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek _DNS_SERVER_FEATURE_LEVEL_MAX,
5e65c93a433447b15180249166f7b3944c3e6156Zbigniew Jędrzejewski-Szmek _DNS_SERVER_FEATURE_LEVEL_INVALID = -1
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek} DnsServerFeatureLevel;
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek#define DNS_SERVER_FEATURE_LEVEL_WORST 0
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek#define DNS_SERVER_FEATURE_LEVEL_BEST (_DNS_SERVER_FEATURE_LEVEL_MAX - 1)
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmekconst char* dns_server_feature_level_to_string(int i) _const_;
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmekint dns_server_feature_level_from_string(const char *s) _pure_;
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek#include "resolved-link.h"
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek#include "resolved-manager.h"
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmekstruct DnsServer {
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek Manager *manager;
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek unsigned n_ref;
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek DnsServerType type;
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek Link *link;
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek int family;
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek union in_addr_union address;
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek usec_t resend_timeout;
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek usec_t max_rtt;
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek DnsServerFeatureLevel verified_feature_level;
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek DnsServerFeatureLevel possible_feature_level;
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek size_t received_udp_packet_max;
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek unsigned n_failed_udp;
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek unsigned n_failed_tcp;
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek bool packet_failed:1;
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek bool packet_truncated:1;
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek usec_t verified_usec;
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek usec_t features_grace_period_usec;
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek /* Indicates whether responses are augmented with RRSIG by
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek * server or not. Note that this is orthogonal to the feature
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek * level stuff, as it's only information describing responses,
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek * and has no effect on how the questions are asked. */
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek bool rrsig_missing:1;
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek /* Used when GC'ing old DNS servers when configuration changes. */
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek bool marked:1;
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek /* If linked is set, then this server appears in the servers linked list */
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek bool linked:1;
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek LIST_FIELDS(DnsServer, servers);
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek};
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmekint dns_server_new(
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek Manager *m,
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek DnsServer **ret,
175a3d25d0e8596d4ba0759aea3f89ee228e7d6dLennart Poettering DnsServerType type,
175a3d25d0e8596d4ba0759aea3f89ee228e7d6dLennart Poettering Link *link,
175a3d25d0e8596d4ba0759aea3f89ee228e7d6dLennart Poettering int family,
175a3d25d0e8596d4ba0759aea3f89ee228e7d6dLennart Poettering const union in_addr_union *address);
175a3d25d0e8596d4ba0759aea3f89ee228e7d6dLennart Poettering
175a3d25d0e8596d4ba0759aea3f89ee228e7d6dLennart PoetteringDnsServer* dns_server_ref(DnsServer *s);
175a3d25d0e8596d4ba0759aea3f89ee228e7d6dLennart PoetteringDnsServer* dns_server_unref(DnsServer *s);
175a3d25d0e8596d4ba0759aea3f89ee228e7d6dLennart Poettering
175a3d25d0e8596d4ba0759aea3f89ee228e7d6dLennart Poetteringvoid dns_server_unlink(DnsServer *s);
175a3d25d0e8596d4ba0759aea3f89ee228e7d6dLennart Poetteringvoid dns_server_move_back_and_unmark(DnsServer *s);
175a3d25d0e8596d4ba0759aea3f89ee228e7d6dLennart Poettering
175a3d25d0e8596d4ba0759aea3f89ee228e7d6dLennart Poetteringvoid dns_server_packet_received(DnsServer *s, int protocol, DnsServerFeatureLevel level, usec_t rtt, size_t size);
175a3d25d0e8596d4ba0759aea3f89ee228e7d6dLennart Poetteringvoid dns_server_packet_lost(DnsServer *s, int protocol, DnsServerFeatureLevel level, usec_t usec);
175a3d25d0e8596d4ba0759aea3f89ee228e7d6dLennart Poetteringvoid dns_server_packet_failed(DnsServer *s, DnsServerFeatureLevel level);
175a3d25d0e8596d4ba0759aea3f89ee228e7d6dLennart Poetteringvoid dns_server_packet_truncated(DnsServer *s, DnsServerFeatureLevel level);
175a3d25d0e8596d4ba0759aea3f89ee228e7d6dLennart Poetteringvoid dns_server_packet_rrsig_missing(DnsServer *s);
175a3d25d0e8596d4ba0759aea3f89ee228e7d6dLennart Poettering
175a3d25d0e8596d4ba0759aea3f89ee228e7d6dLennart PoetteringDnsServerFeatureLevel dns_server_possible_feature_level(DnsServer *s);
175a3d25d0e8596d4ba0759aea3f89ee228e7d6dLennart Poettering
175a3d25d0e8596d4ba0759aea3f89ee228e7d6dLennart Poetteringint dns_server_adjust_opt(DnsServer *server, DnsPacket *packet, DnsServerFeatureLevel level);
175a3d25d0e8596d4ba0759aea3f89ee228e7d6dLennart Poettering
175a3d25d0e8596d4ba0759aea3f89ee228e7d6dLennart PoetteringDnsServer *dns_server_find(DnsServer *first, int family, const union in_addr_union *in_addr);
175a3d25d0e8596d4ba0759aea3f89ee228e7d6dLennart Poettering
175a3d25d0e8596d4ba0759aea3f89ee228e7d6dLennart Poetteringvoid dns_server_unlink_all(DnsServer *first);
175a3d25d0e8596d4ba0759aea3f89ee228e7d6dLennart Poetteringvoid dns_server_unlink_marked(DnsServer *first);
175a3d25d0e8596d4ba0759aea3f89ee228e7d6dLennart Poetteringvoid dns_server_mark_all(DnsServer *first);
175a3d25d0e8596d4ba0759aea3f89ee228e7d6dLennart Poettering
175a3d25d0e8596d4ba0759aea3f89ee228e7d6dLennart PoetteringDnsServer *manager_get_first_dns_server(Manager *m, DnsServerType t);
175a3d25d0e8596d4ba0759aea3f89ee228e7d6dLennart Poettering
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-SzmekDnsServer *manager_set_dns_server(Manager *m, DnsServer *s);
29a5ca9baa58e55c4d9e1d008cdd014aa9c3c3e1Lennart PoetteringDnsServer *manager_get_dns_server(Manager *m);
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmekvoid manager_next_dns_server(Manager *m);
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-SzmekDEFINE_TRIVIAL_CLEANUP_FUNC(DnsServer*, dns_server_unref);
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmekextern const struct hash_ops dns_server_hash_ops;
2ca0435be9359bde3020eeb528c2a6d72ac1e0b0Zbigniew Jędrzejewski-Szmek