resolved-dns-query.c revision 26b1c471cdddedf1bb9aebf10f4c3073bdf7a29e
6033N/A along with systemd; If not, see <http://www.gnu.org/licenses/>.
6033N/A#include "hostname-util.h"
6033N/A#include "dns-domain.h"
6033N/A#include "local-addresses.h"
6033N/A#include "resolved-dns-query.h"
if (q->manager) {
free(q);
return NULL;
assert(m);
return -EBUSY;
return -ENOMEM;
_cleanup_free_ char *p;
m->n_dns_queries++;
q->manager = m;
if (ret)
*ret = q;
q = NULL;
assert(q);
dns_query_stop(q);
if (q->complete)
q->complete(q);
assert(s);
assert(q);
DnsTransaction *t;
assert(q);
assert(s);
goto gc;
goto gc;
goto gc;
gc:
assert(q);
assert(s);
if (ifindex > 0)
return ifindex;
return LOOPBACK_IFINDEX;
return AF_INET;
return AF_INET6;
return AF_UNSPEC;
return DNS_PROTOCOL_DNS;
return DNS_PROTOCOL_LLMNR;
return DNS_PROTOCOL_DNS;
case DNS_TYPE_A:
return AF_INET;
case DNS_TYPE_AAAA:
return AF_INET6;
case DNS_TYPE_ANY:
return AF_UNSPEC;
return -EINVAL;
assert(q);
if (!rr)
return -ENOMEM;
if (!rr)
return -ENOMEM;
if (!rr)
return -ENOMEM;
return -ENOMEM;
assert(q);
r = answer_add_ptr(answer, DNS_RESOURCE_KEY_NAME(key), "localhost", SYNTHESIZE_IFINDEX(q->ifindex));
static int answer_add_addresses_rr(
const char *name,
unsigned n_addresses) {
for (j = 0; j < n_addresses; j++) {
static int answer_add_addresses_ptr(
const char *name,
unsigned n_addresses,
for (j = 0; j < n_addresses; j++) {
int n = 0, af;
assert(q);
if (af >= 0) {
static int synthesize_system_hostname_ptr(DnsQuery *q, int af, const union in_addr_union *address, DnsAnswer **answer) {
assert(q);
r = answer_add_ptr(answer, "2.0.0.127.in-addr.arpa", q->manager->llmnr_hostname, SYNTHESIZE_IFINDEX(q->ifindex));
r = answer_add_ptr(answer, "2.0.0.127.in-addr.arpa", q->manager->mdns_hostname, SYNTHESIZE_IFINDEX(q->ifindex));
int n = 0, af;
assert(q);
if (af >= 0) {
static int synthesize_gateway_ptr(DnsQuery *q, int af, const union in_addr_union *address, DnsAnswer **answer) {
assert(q);
assert(q);
const char *name;
int af;
} else if ((dns_name_endswith(name, "127.in-addr.arpa") > 0 && dns_name_equal(name, "2.0.0.127.in-addr.arpa") == 0) ||
dns_name_equal(name, "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa") > 0) {
if (!answer)
DnsTransaction *t;
const char *name;
Iterator i;
assert(q);
if (match < 0)
return match;
first = s;
if (!first)
first = s;
return -ESRCH;
goto fail;
if (match < 0)
goto fail;
r = dns_query_add_transaction_split(q, s);
goto fail;
q->answer_rcode = 0;
r = sd_event_add_time(
&q->timeout_event_source,
on_query_timeout, q);
goto fail;
q->block_ready++;
r = dns_transaction_go(t);
goto fail;
q->block_ready--;
dns_query_ready(q);
fail:
dns_query_stop(q);
DnsTransaction *t;
int rcode = 0;
bool pending = false;
Iterator i;
assert(q);
if (q->block_ready > 0)
pending = true;
DnsAnswer *a;
if (t->received) {
a = t->cached;
if (!merged) {
DnsAnswer *a;
if (t->received) {
a = t->cached;
if (pending) {
assert(q);
return -ELOOP;
q->n_cname_redirects++;
dns_query_stop(q);
assert(t);
assert(q);
assert(q);
assert(m);
if (!q->bus_track) {