]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/resolve/resolved-dns-question.h
resolved: fix the rcode to SUCCESS if we find at least one matching RR in a DNS response
[thirdparty/systemd.git] / src / resolve / resolved-dns-question.h
CommitLineData
faa133f3
LP
1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3#pragma once
4
5/***
6 This file is part of systemd.
7
8 Copyright 2014 Lennart Poettering
9
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22***/
23
24typedef struct DnsQuestion DnsQuestion;
25
92aea95e 26#include "macro.h"
faa133f3
LP
27#include "resolved-dns-rr.h"
28
92aea95e 29/* A simple array of resource keys */
faa133f3
LP
30
31struct DnsQuestion {
32 unsigned n_ref;
33 unsigned n_keys, n_allocated;
34 DnsResourceKey* keys[0];
35};
36
37DnsQuestion *dns_question_new(unsigned n);
38DnsQuestion *dns_question_ref(DnsQuestion *q);
39DnsQuestion *dns_question_unref(DnsQuestion *q);
40
23b298bc 41int dns_question_new_address(DnsQuestion **ret, int family, const char *name, bool convert_idna);
45ec7efb 42int dns_question_new_reverse(DnsQuestion **ret, int family, const union in_addr_union *a);
23b298bc 43int dns_question_new_service(DnsQuestion **ret, const char *service, const char *type, const char *domain, bool with_txt, bool convert_idna);
45ec7efb 44
faa133f3
LP
45int dns_question_add(DnsQuestion *q, DnsResourceKey *key);
46
801ad6a6 47int dns_question_matches_rr(DnsQuestion *q, DnsResourceRecord *rr, const char *search_domain);
542e0c84 48int dns_question_matches_cname_or_dname(DnsQuestion *q, DnsResourceRecord *rr, const char* search_domain);
703e4f5e 49int dns_question_is_valid_for_query(DnsQuestion *q);
6a21960c 50int dns_question_contains(DnsQuestion *a, const DnsResourceKey *k);
1086182d 51int dns_question_is_equal(DnsQuestion *a, DnsQuestion *b);
faa133f3 52
36d9205d 53int dns_question_cname_redirect(DnsQuestion *q, const DnsResourceRecord *cname, DnsQuestion **ret);
faa133f3 54
703e4f5e 55const char *dns_question_first_name(DnsQuestion *q);
45ec7efb 56
23b298bc
LP
57static inline unsigned dns_question_size(DnsQuestion *q) {
58 return q ? q->n_keys : 0;
59}
60
faa133f3 61DEFINE_TRIVIAL_CLEANUP_FUNC(DnsQuestion*, dns_question_unref);
801ad6a6 62
92aea95e
LP
63#define _DNS_QUESTION_FOREACH(u, key, q) \
64 for (unsigned UNIQ_T(i, u) = ({ \
801ad6a6
LP
65 (key) = ((q) && (q)->n_keys > 0) ? (q)->keys[0] : NULL; \
66 0; \
67 }); \
92aea95e
LP
68 (q) && (UNIQ_T(i, u) < (q)->n_keys); \
69 UNIQ_T(i, u)++, (key) = (UNIQ_T(i, u) < (q)->n_keys ? (q)->keys[UNIQ_T(i, u)] : NULL))
70
71#define DNS_QUESTION_FOREACH(key, q) _DNS_QUESTION_FOREACH(UNIQ, key, q)