resolved-dns-scope.h revision 28b9b7640603f88cb49f95609331fa5072715f15
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering#pragma once
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering/***
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering This file is part of systemd.
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering Copyright 2014 Lennart Poettering
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering systemd is free software; you can redistribute it and/or modify it
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering under the terms of the GNU Lesser General Public License as published by
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering the Free Software Foundation; either version 2.1 of the License, or
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering (at your option) any later version.
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering systemd is distributed in the hope that it will be useful, but
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering Lesser General Public License for more details.
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering You should have received a copy of the GNU Lesser General Public License
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering***/
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering#include "list.h"
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering
0dad12c190b7493955cd60d2a1625199b1709f69Lennart Poetteringtypedef struct DnsScope DnsScope;
0dad12c190b7493955cd60d2a1625199b1709f69Lennart Poettering
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering#include "resolved-dns-cache.h"
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering#include "resolved-dns-packet.h"
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering#include "resolved-dns-server.h"
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering#include "resolved-dns-zone.h"
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering#include "resolved-link.h"
fe6521272ba203ec8f0d5a94f0729960b3f90525Lennart Poettering
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poetteringtypedef enum DnsScopeMatch {
bb99a35a873c35e80b0b47fe045081022660374dLennart Poettering DNS_SCOPE_NO,
bb99a35a873c35e80b0b47fe045081022660374dLennart Poettering DNS_SCOPE_MAYBE,
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering DNS_SCOPE_YES,
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering _DNS_SCOPE_MATCH_MAX,
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering _DNS_SCOPE_INVALID = -1
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering} DnsScopeMatch;
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poetteringstruct DnsScope {
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering Manager *manager;
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering DnsProtocol protocol;
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering int family;
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering Link *link;
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering DnsCache cache;
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering DnsZone zone;
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering OrderedHashmap *conflict_queue;
bb99a35a873c35e80b0b47fe045081022660374dLennart Poettering sd_event_source *conflict_event_source;
bb99a35a873c35e80b0b47fe045081022660374dLennart Poettering
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering RateLimit ratelimit;
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering usec_t resend_timeout;
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering usec_t max_rtt;
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering LIST_HEAD(DnsQueryCandidate, query_candidates);
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering /* Note that we keep track of ongoing transactions in two
a5344d2c3b0f14e954ce1c0ef905c5b44bc5bf0aLennart Poettering * ways: once in a hashmap, indexed by the rr key, and once in
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering * a linked list. We use the hashmap to quickly find
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering * transactions we can reuse for a key. But note that there
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering * might be multiple transactions for the same key (because
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering * the zone probing can't reuse a transaction answered from
d0bbc21caa6e68693a47db60c93e99422bf2a858Lennart Poettering * the zone or the cache), and the hashmap only tracks the
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering * most recent entry. */
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering Hashmap *transactions_by_key;
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering LIST_HEAD(DnsTransaction, transactions);
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering LIST_FIELDS(DnsScope, scopes);
a5344d2c3b0f14e954ce1c0ef905c5b44bc5bf0aLennart Poettering};
d0bbc21caa6e68693a47db60c93e99422bf2a858Lennart Poettering
d0bbc21caa6e68693a47db60c93e99422bf2a858Lennart Poetteringint dns_scope_new(Manager *m, DnsScope **ret, Link *l, DnsProtocol p, int family);
d0bbc21caa6e68693a47db60c93e99422bf2a858Lennart PoetteringDnsScope* dns_scope_free(DnsScope *s);
fe6521272ba203ec8f0d5a94f0729960b3f90525Lennart Poettering
fe6521272ba203ec8f0d5a94f0729960b3f90525Lennart Poetteringvoid dns_scope_packet_received(DnsScope *s, usec_t rtt);
fe6521272ba203ec8f0d5a94f0729960b3f90525Lennart Poetteringvoid dns_scope_packet_lost(DnsScope *s, usec_t usec);
fe6521272ba203ec8f0d5a94f0729960b3f90525Lennart Poettering
fe6521272ba203ec8f0d5a94f0729960b3f90525Lennart Poetteringint dns_scope_emit(DnsScope *s, int fd, DnsServer *server, DnsPacket *p);
fe6521272ba203ec8f0d5a94f0729960b3f90525Lennart Poetteringint dns_scope_tcp_socket(DnsScope *s, int family, const union in_addr_union *address, uint16_t port, DnsServer **server);
d0bbc21caa6e68693a47db60c93e99422bf2a858Lennart Poetteringint dns_scope_udp_dns_socket(DnsScope *s, DnsServer **server);
d0bbc21caa6e68693a47db60c93e99422bf2a858Lennart Poettering
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart PoetteringDnsScopeMatch dns_scope_good_domain(DnsScope *s, int ifindex, uint64_t flags, const char *domain);
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poetteringint dns_scope_good_key(DnsScope *s, DnsResourceKey *key);
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart PoetteringDnsServer *dns_scope_get_dns_server(DnsScope *s);
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poetteringvoid dns_scope_next_dns_server(DnsScope *s);
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering
d0bbc21caa6e68693a47db60c93e99422bf2a858Lennart Poetteringint dns_scope_llmnr_membership(DnsScope *s, bool b);
d0bbc21caa6e68693a47db60c93e99422bf2a858Lennart Poettering
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poetteringvoid dns_scope_process_query(DnsScope *s, DnsStream *stream, DnsPacket *p);
d0bbc21caa6e68693a47db60c93e99422bf2a858Lennart Poettering
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart PoetteringDnsTransaction *dns_scope_find_transaction(DnsScope *scope, DnsResourceKey *key, bool cache_ok);
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poetteringint dns_scope_notify_conflict(DnsScope *scope, DnsResourceRecord *rr);
25d042e81516246b1ebf706a57c47ac19abb0b8aLennart Poetteringvoid dns_scope_check_conflicts(DnsScope *scope, DnsPacket *p);
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poetteringvoid dns_scope_dump(DnsScope *s, FILE *f);
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering
b070e7f3c9ed680c821bd89d42506695f2438506Lennart PoetteringDnsSearchDomain *dns_scope_get_search_domains(DnsScope *s);
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poetteringbool dns_scope_name_needs_search_domain(DnsScope *s, const char *name);
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering