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
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#include "list.h"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringtypedef struct DnsScope DnsScope;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering#include "resolved-dns-cache.h"
24710c48ed16be5fa461fbb303a744a907541dafLennart Poettering#include "resolved-dns-dnssec.h"
71d35b6b5563817dfbe757ab9e3b9f018b2db491Thomas Hindoe Paaboel Andersen#include "resolved-dns-packet.h"
71d35b6b5563817dfbe757ab9e3b9f018b2db491Thomas Hindoe Paaboel Andersen#include "resolved-dns-server.h"
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poettering#include "resolved-dns-zone.h"
39d8db043b599a7382f94bfc904d5e108af438bdLennart Poettering#include "resolved-link.h"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringtypedef enum DnsScopeMatch {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering DNS_SCOPE_NO,
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering DNS_SCOPE_MAYBE,
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering DNS_SCOPE_YES,
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering _DNS_SCOPE_MATCH_MAX,
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering _DNS_SCOPE_INVALID = -1
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering} DnsScopeMatch;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringstruct DnsScope {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Manager *manager;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering DnsProtocol protocol;
0dd25fb9f005d8ab7ac4bc10a609d00569f8c56aLennart Poettering int family;
24710c48ed16be5fa461fbb303a744a907541dafLennart Poettering DnssecMode dnssec_mode;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Link *link;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering DnsCache cache;
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poettering DnsZone zone;
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering
1e43061b67336052b5b231840a38508a5397a363Michal Schmidt OrderedHashmap *conflict_queue;
a407657425a3e47fd2b559cd3bc800f791303f63Lennart Poettering sd_event_source *conflict_event_source;
a407657425a3e47fd2b559cd3bc800f791303f63Lennart Poettering
aea2429d6ec32261dbf6b9caa125fcc6ea9ea76aLennart Poettering RateLimit ratelimit;
aea2429d6ec32261dbf6b9caa125fcc6ea9ea76aLennart Poettering
9df3ba6c6cb65eecec06f39dfe85a3596cedac4eTom Gundersen usec_t resend_timeout;
9df3ba6c6cb65eecec06f39dfe85a3596cedac4eTom Gundersen usec_t max_rtt;
9df3ba6c6cb65eecec06f39dfe85a3596cedac4eTom Gundersen
801ad6a6a9cd8fbd58b9f9c27f20dbb3c87d47ddLennart Poettering LIST_HEAD(DnsQueryCandidate, query_candidates);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
f9ebb22ab4758bc5bbaaf8eeead74b5b4f81d5c3Lennart Poettering /* Note that we keep track of ongoing transactions in two
f9ebb22ab4758bc5bbaaf8eeead74b5b4f81d5c3Lennart Poettering * ways: once in a hashmap, indexed by the rr key, and once in
f9ebb22ab4758bc5bbaaf8eeead74b5b4f81d5c3Lennart Poettering * a linked list. We use the hashmap to quickly find
f9ebb22ab4758bc5bbaaf8eeead74b5b4f81d5c3Lennart Poettering * transactions we can reuse for a key. But note that there
f9ebb22ab4758bc5bbaaf8eeead74b5b4f81d5c3Lennart Poettering * might be multiple transactions for the same key (because
f9ebb22ab4758bc5bbaaf8eeead74b5b4f81d5c3Lennart Poettering * the zone probing can't reuse a transaction answered from
f9ebb22ab4758bc5bbaaf8eeead74b5b4f81d5c3Lennart Poettering * the zone or the cache), and the hashmap only tracks the
f9ebb22ab4758bc5bbaaf8eeead74b5b4f81d5c3Lennart Poettering * most recent entry. */
f9ebb22ab4758bc5bbaaf8eeead74b5b4f81d5c3Lennart Poettering Hashmap *transactions_by_key;
f9ebb22ab4758bc5bbaaf8eeead74b5b4f81d5c3Lennart Poettering LIST_HEAD(DnsTransaction, transactions);
f9ebb22ab4758bc5bbaaf8eeead74b5b4f81d5c3Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering LIST_FIELDS(DnsScope, scopes);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering};
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
0dd25fb9f005d8ab7ac4bc10a609d00569f8c56aLennart Poetteringint dns_scope_new(Manager *m, DnsScope **ret, Link *l, DnsProtocol p, int family);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart PoetteringDnsScope* dns_scope_free(DnsScope *s);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
9df3ba6c6cb65eecec06f39dfe85a3596cedac4eTom Gundersenvoid dns_scope_packet_received(DnsScope *s, usec_t rtt);
9df3ba6c6cb65eecec06f39dfe85a3596cedac4eTom Gundersenvoid dns_scope_packet_lost(DnsScope *s, usec_t usec);
9df3ba6c6cb65eecec06f39dfe85a3596cedac4eTom Gundersen
519ef04651b07a547f010d6462603669d7fde4e5Lennart Poetteringint dns_scope_emit_udp(DnsScope *s, int fd, DnsPacket *p);
519ef04651b07a547f010d6462603669d7fde4e5Lennart Poetteringint dns_scope_socket_tcp(DnsScope *s, int family, const union in_addr_union *address, DnsServer *server, uint16_t port);
519ef04651b07a547f010d6462603669d7fde4e5Lennart Poetteringint dns_scope_socket_udp(DnsScope *s, DnsServer *server, uint16_t port);
ad867662936a4c7ab2c7116d804c272338801231Lennart Poettering
51323288fc628a5cac50914df915545d685b793eLennart PoetteringDnsScopeMatch dns_scope_good_domain(DnsScope *s, int ifindex, uint64_t flags, const char *domain);
011696f76233486bc56c266b18a328924f70269cLennart Poetteringbool dns_scope_good_key(DnsScope *s, const DnsResourceKey *key);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
2c27fbca2d88214bd305272308a370a962818f1eLennart PoetteringDnsServer *dns_scope_get_dns_server(DnsScope *s);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringvoid dns_scope_next_dns_server(DnsScope *s);
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poetteringint dns_scope_llmnr_membership(DnsScope *s, bool b);
0db4c90afd7d9c7c8884bf8b3ec459edc74a03daDaniel Mackint dns_scope_mdns_membership(DnsScope *s, bool b);
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poettering
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poetteringvoid dns_scope_process_query(DnsScope *s, DnsStream *stream, DnsPacket *p);
ec2c5e4398f9d65e5dfe61530f2556224733d1e6Lennart Poettering
f52e61da047d7fc74e83f12dbbf87e0cbcc51c73Lennart PoetteringDnsTransaction *dns_scope_find_transaction(DnsScope *scope, DnsResourceKey *key, bool cache_ok);
a407657425a3e47fd2b559cd3bc800f791303f63Lennart Poettering
a407657425a3e47fd2b559cd3bc800f791303f63Lennart Poetteringint dns_scope_notify_conflict(DnsScope *scope, DnsResourceRecord *rr);
a407657425a3e47fd2b559cd3bc800f791303f63Lennart Poetteringvoid dns_scope_check_conflicts(DnsScope *scope, DnsPacket *p);
4d506d6bb757af3b99e0876234c465e6898c5ea4Lennart Poettering
4d506d6bb757af3b99e0876234c465e6898c5ea4Lennart Poetteringvoid dns_scope_dump(DnsScope *s, FILE *f);
a51c10485af349eb15faa4d1a63b9818bcf3e589Lennart Poettering
a51c10485af349eb15faa4d1a63b9818bcf3e589Lennart PoetteringDnsSearchDomain *dns_scope_get_search_domains(DnsScope *s);
801ad6a6a9cd8fbd58b9f9c27f20dbb3c87d47ddLennart Poettering
dc477e7385e8ab29efb8fadb72ec994077a105c6Lennart Poetteringbool dns_scope_name_needs_search_domain(DnsScope *s, const char *name);
edbcc1fdd94355c5cf22263ba2c1cfa4ec2eb010Lennart Poettering
edbcc1fdd94355c5cf22263ba2c1cfa4ec2eb010Lennart Poetteringbool dns_scope_network_good(DnsScope *s);