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