2014-07-16 00:26:02 +02:00
|
|
|
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
/***
|
|
|
|
This file is part of systemd.
|
|
|
|
|
|
|
|
Copyright 2014 Lennart Poettering
|
|
|
|
|
|
|
|
systemd is free software; you can redistribute it and/or modify it
|
|
|
|
under the terms of the GNU Lesser General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2.1 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
systemd is distributed in the hope that it will be useful, but
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
|
|
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
***/
|
|
|
|
|
|
|
|
|
|
|
|
#include "sd-bus.h"
|
2015-11-18 22:46:33 +01:00
|
|
|
|
2014-07-22 21:48:41 +02:00
|
|
|
#include "set.h"
|
2014-07-16 00:26:02 +02:00
|
|
|
|
2015-11-25 20:47:27 +01:00
|
|
|
typedef struct DnsQueryCandidate DnsQueryCandidate;
|
2014-07-16 00:26:02 +02:00
|
|
|
typedef struct DnsQuery DnsQuery;
|
|
|
|
|
2014-07-22 21:48:41 +02:00
|
|
|
#include "resolved-dns-answer.h"
|
2015-11-18 22:46:33 +01:00
|
|
|
#include "resolved-dns-question.h"
|
2014-07-29 14:24:02 +02:00
|
|
|
#include "resolved-dns-stream.h"
|
2015-11-25 20:47:27 +01:00
|
|
|
#include "resolved-dns-search-domain.h"
|
|
|
|
|
|
|
|
struct DnsQueryCandidate {
|
|
|
|
DnsQuery *query;
|
|
|
|
DnsScope *scope;
|
|
|
|
|
|
|
|
DnsSearchDomain *search_domain;
|
|
|
|
|
|
|
|
int error_code;
|
|
|
|
Set *transactions;
|
|
|
|
|
|
|
|
LIST_FIELDS(DnsQueryCandidate, candidates_by_query);
|
|
|
|
LIST_FIELDS(DnsQueryCandidate, candidates_by_scope);
|
|
|
|
};
|
2014-07-16 00:26:02 +02:00
|
|
|
|
|
|
|
struct DnsQuery {
|
|
|
|
Manager *manager;
|
resolved: add ResolveService() bus call for resolving SRV and DNS-SD services
This also adds client-side support for this to systemd-resolve-host.
Note that the ResolveService() API can deal both with DNS-SD service
(consisting of service name, type and domain), as well as classic SRV
services (consisting just of a type and a domain), all exposed in the
same call.
This patch also reworks CNAME handling in order to reuse it between
hostname, RR and service lookups.
In contrast to Avahi and Bonjour, this new API will actually reolve the
A/AAAA RRs the SRV RRs point to in one go (unless this is explicitly
disabled). This normally comes for free, as these RRs are sent along
the SRV responses anyway, hence let's make use of that. This makes the
API considerably easier to use, as a single ResolveService() invocation
will return all necessary data to pick a server and connect() to it.
Note that this only implements the DNS-SD resolving step, it does not
implement DNS-SD browsing, as that makes sense primarily on mDNS, due to
its continuous nature.
2015-11-23 21:25:40 +01:00
|
|
|
|
|
|
|
/* When resolving a service, we first create a TXT+SRV query,
|
|
|
|
* and then for the hostnames we discover auxiliary A+AAAA
|
|
|
|
* queries. This pointer always points from the auxiliary
|
|
|
|
* queries back to the TXT+SRV query. */
|
|
|
|
DnsQuery *auxiliary_for;
|
|
|
|
LIST_HEAD(DnsQuery, auxiliary_queries);
|
|
|
|
unsigned n_auxiliary_queries;
|
|
|
|
int auxiliary_result;
|
|
|
|
|
2014-07-22 21:48:41 +02:00
|
|
|
DnsQuestion *question;
|
2014-08-14 01:00:15 +02:00
|
|
|
uint64_t flags;
|
|
|
|
int ifindex;
|
|
|
|
|
2014-07-31 17:46:40 +02:00
|
|
|
DnsTransactionState state;
|
2014-07-22 21:48:41 +02:00
|
|
|
unsigned n_cname_redirects;
|
2014-07-16 00:26:02 +02:00
|
|
|
|
2015-11-25 20:47:27 +01:00
|
|
|
LIST_HEAD(DnsQueryCandidate, candidates);
|
2014-07-16 00:26:02 +02:00
|
|
|
sd_event_source *timeout_event_source;
|
|
|
|
|
2014-07-17 19:38:37 +02:00
|
|
|
/* Discovered data */
|
2014-07-22 21:48:41 +02:00
|
|
|
DnsAnswer *answer;
|
2014-08-14 01:00:15 +02:00
|
|
|
int answer_family;
|
|
|
|
DnsProtocol answer_protocol;
|
2014-07-22 21:48:41 +02:00
|
|
|
int answer_rcode;
|
2015-11-25 20:47:27 +01:00
|
|
|
DnsSearchDomain *answer_search_domain;
|
2014-07-16 00:26:02 +02:00
|
|
|
|
2014-07-16 22:09:00 +02:00
|
|
|
/* Bus client information */
|
2014-07-16 00:26:02 +02:00
|
|
|
sd_bus_message *request;
|
2014-07-18 16:09:30 +02:00
|
|
|
int request_family;
|
resolved: add ResolveService() bus call for resolving SRV and DNS-SD services
This also adds client-side support for this to systemd-resolve-host.
Note that the ResolveService() API can deal both with DNS-SD service
(consisting of service name, type and domain), as well as classic SRV
services (consisting just of a type and a domain), all exposed in the
same call.
This patch also reworks CNAME handling in order to reuse it between
hostname, RR and service lookups.
In contrast to Avahi and Bonjour, this new API will actually reolve the
A/AAAA RRs the SRV RRs point to in one go (unless this is explicitly
disabled). This normally comes for free, as these RRs are sent along
the SRV responses anyway, hence let's make use of that. This makes the
API considerably easier to use, as a single ResolveService() invocation
will return all necessary data to pick a server and connect() to it.
Note that this only implements the DNS-SD resolving step, it does not
implement DNS-SD browsing, as that makes sense primarily on mDNS, due to
its continuous nature.
2015-11-23 21:25:40 +01:00
|
|
|
bool request_address_valid;
|
2014-07-16 00:26:02 +02:00
|
|
|
union in_addr_union request_address;
|
resolved: add ResolveService() bus call for resolving SRV and DNS-SD services
This also adds client-side support for this to systemd-resolve-host.
Note that the ResolveService() API can deal both with DNS-SD service
(consisting of service name, type and domain), as well as classic SRV
services (consisting just of a type and a domain), all exposed in the
same call.
This patch also reworks CNAME handling in order to reuse it between
hostname, RR and service lookups.
In contrast to Avahi and Bonjour, this new API will actually reolve the
A/AAAA RRs the SRV RRs point to in one go (unless this is explicitly
disabled). This normally comes for free, as these RRs are sent along
the SRV responses anyway, hence let's make use of that. This makes the
API considerably easier to use, as a single ResolveService() invocation
will return all necessary data to pick a server and connect() to it.
Note that this only implements the DNS-SD resolving step, it does not
implement DNS-SD browsing, as that makes sense primarily on mDNS, due to
its continuous nature.
2015-11-23 21:25:40 +01:00
|
|
|
unsigned block_all_complete;
|
2014-07-16 00:26:02 +02:00
|
|
|
|
2014-07-17 19:38:37 +02:00
|
|
|
/* Completion callback */
|
2014-07-16 00:26:02 +02:00
|
|
|
void (*complete)(DnsQuery* q);
|
2014-07-22 21:48:41 +02:00
|
|
|
unsigned block_ready;
|
|
|
|
|
2014-08-06 16:32:55 +02:00
|
|
|
sd_bus_track *bus_track;
|
|
|
|
|
2014-07-16 00:26:02 +02:00
|
|
|
LIST_FIELDS(DnsQuery, queries);
|
resolved: add ResolveService() bus call for resolving SRV and DNS-SD services
This also adds client-side support for this to systemd-resolve-host.
Note that the ResolveService() API can deal both with DNS-SD service
(consisting of service name, type and domain), as well as classic SRV
services (consisting just of a type and a domain), all exposed in the
same call.
This patch also reworks CNAME handling in order to reuse it between
hostname, RR and service lookups.
In contrast to Avahi and Bonjour, this new API will actually reolve the
A/AAAA RRs the SRV RRs point to in one go (unless this is explicitly
disabled). This normally comes for free, as these RRs are sent along
the SRV responses anyway, hence let's make use of that. This makes the
API considerably easier to use, as a single ResolveService() invocation
will return all necessary data to pick a server and connect() to it.
Note that this only implements the DNS-SD resolving step, it does not
implement DNS-SD browsing, as that makes sense primarily on mDNS, due to
its continuous nature.
2015-11-23 21:25:40 +01:00
|
|
|
LIST_FIELDS(DnsQuery, auxiliary_queries);
|
2014-07-16 00:26:02 +02:00
|
|
|
};
|
|
|
|
|
2015-11-25 20:47:27 +01:00
|
|
|
DnsQueryCandidate* dns_query_candidate_free(DnsQueryCandidate *c);
|
|
|
|
void dns_query_candidate_ready(DnsQueryCandidate *c);
|
|
|
|
|
2014-08-14 01:00:15 +02:00
|
|
|
int dns_query_new(Manager *m, DnsQuery **q, DnsQuestion *question, int family, uint64_t flags);
|
2014-07-16 00:26:02 +02:00
|
|
|
DnsQuery *dns_query_free(DnsQuery *q);
|
2014-07-17 19:38:37 +02:00
|
|
|
|
resolved: add ResolveService() bus call for resolving SRV and DNS-SD services
This also adds client-side support for this to systemd-resolve-host.
Note that the ResolveService() API can deal both with DNS-SD service
(consisting of service name, type and domain), as well as classic SRV
services (consisting just of a type and a domain), all exposed in the
same call.
This patch also reworks CNAME handling in order to reuse it between
hostname, RR and service lookups.
In contrast to Avahi and Bonjour, this new API will actually reolve the
A/AAAA RRs the SRV RRs point to in one go (unless this is explicitly
disabled). This normally comes for free, as these RRs are sent along
the SRV responses anyway, hence let's make use of that. This makes the
API considerably easier to use, as a single ResolveService() invocation
will return all necessary data to pick a server and connect() to it.
Note that this only implements the DNS-SD resolving step, it does not
implement DNS-SD browsing, as that makes sense primarily on mDNS, due to
its continuous nature.
2015-11-23 21:25:40 +01:00
|
|
|
int dns_query_make_auxiliary(DnsQuery *q, DnsQuery *auxiliary_for);
|
|
|
|
|
2014-07-17 19:38:37 +02:00
|
|
|
int dns_query_go(DnsQuery *q);
|
2014-07-22 21:48:41 +02:00
|
|
|
void dns_query_ready(DnsQuery *q);
|
2014-07-16 00:26:02 +02:00
|
|
|
|
resolved: add ResolveService() bus call for resolving SRV and DNS-SD services
This also adds client-side support for this to systemd-resolve-host.
Note that the ResolveService() API can deal both with DNS-SD service
(consisting of service name, type and domain), as well as classic SRV
services (consisting just of a type and a domain), all exposed in the
same call.
This patch also reworks CNAME handling in order to reuse it between
hostname, RR and service lookups.
In contrast to Avahi and Bonjour, this new API will actually reolve the
A/AAAA RRs the SRV RRs point to in one go (unless this is explicitly
disabled). This normally comes for free, as these RRs are sent along
the SRV responses anyway, hence let's make use of that. This makes the
API considerably easier to use, as a single ResolveService() invocation
will return all necessary data to pick a server and connect() to it.
Note that this only implements the DNS-SD resolving step, it does not
implement DNS-SD browsing, as that makes sense primarily on mDNS, due to
its continuous nature.
2015-11-23 21:25:40 +01:00
|
|
|
int dns_query_process_cname(DnsQuery *q);
|
2014-07-16 00:26:02 +02:00
|
|
|
|
2015-04-29 19:10:09 +02:00
|
|
|
int dns_query_bus_track(DnsQuery *q, sd_bus_message *m);
|
2014-08-06 16:32:55 +02:00
|
|
|
|
2014-07-16 00:26:02 +02:00
|
|
|
DEFINE_TRIVIAL_CLEANUP_FUNC(DnsQuery*, dns_query_free);
|