]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/resolve/resolved-dns-rr.h
resolved: don't accept expired RRSIGs
[thirdparty/systemd.git] / src / resolve / resolved-dns-rr.h
CommitLineData
74b2466e
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
74b2466e
LP
24#include <netinet/in.h>
25
50f1e641 26#include "bitmap.h"
71d35b6b 27#include "dns-type.h"
322345fd 28#include "hashmap.h"
623a4c97 29#include "in-addr-util.h"
2001c805 30#include "list.h"
74b2466e
LP
31
32typedef struct DnsResourceKey DnsResourceKey;
33typedef struct DnsResourceRecord DnsResourceRecord;
2001c805 34typedef struct DnsTxtItem DnsTxtItem;
74b2466e
LP
35
36/* DNS record classes, see RFC 1035 */
37enum {
38 DNS_CLASS_IN = 0x01,
322345fd 39 DNS_CLASS_ANY = 0xFF,
b93312f5
ZJS
40 _DNS_CLASS_MAX,
41 _DNS_CLASS_INVALID = -1
74b2466e
LP
42};
43
74b2466e 44struct DnsResourceKey {
faa133f3
LP
45 unsigned n_ref;
46 uint16_t class, type;
47 char *_name; /* don't access directy, use DNS_RESOURCE_KEY_NAME()! */
74b2466e
LP
48};
49
2001c805
LP
50struct DnsTxtItem {
51 size_t length;
52 LIST_FIELDS(DnsTxtItem, items);
53 uint8_t data[];
54};
55
74b2466e
LP
56struct DnsResourceRecord {
57 unsigned n_ref;
faa133f3 58 DnsResourceKey *key;
74b2466e 59 uint32_t ttl;
a8812dd7
LP
60 bool unparseable:1;
61 bool wire_format_canonical:1;
62 void *wire_format;
63 size_t wire_format_size;
64 size_t wire_format_rdata_offset;
74b2466e
LP
65 union {
66 struct {
67 void *data;
f5430a3e 68 size_t size;
74b2466e
LP
69 } generic;
70
9c92ce6d
LP
71 struct {
72 uint16_t priority;
73 uint16_t weight;
74 uint16_t port;
75 char *name;
76 } srv;
74b2466e
LP
77
78 struct {
79 char *name;
8ac4e9e1 80 } ptr, ns, cname, dname;
74b2466e
LP
81
82 struct {
83 char *cpu;
84 char *os;
85 } hinfo;
86
2e276efc 87 struct {
2001c805 88 DnsTxtItem *items;
c0eb11cf 89 } txt, spf;
74b2466e
LP
90
91 struct {
92 struct in_addr in_addr;
93 } a;
94
95 struct {
96 struct in6_addr in6_addr;
97 } aaaa;
7e8e0422
LP
98
99 struct {
100 char *mname;
101 char *rname;
102 uint32_t serial;
103 uint32_t refresh;
104 uint32_t retry;
105 uint32_t expire;
106 uint32_t minimum;
107 } soa;
946c7094
ZJS
108
109 struct {
110 uint16_t priority;
111 char *exchange;
112 } mx;
0dae31d4
ZJS
113
114 struct {
115 uint8_t version;
116 uint8_t size;
117 uint8_t horiz_pre;
118 uint8_t vert_pre;
119 uint32_t latitude;
120 uint32_t longitude;
121 uint32_t altitude;
122 } loc;
42cc2eeb 123
abf126a3
TG
124 struct {
125 uint16_t key_tag;
126 uint8_t algorithm;
127 uint8_t digest_type;
128 void *digest;
129 size_t digest_size;
130 } ds;
131
549c1a25 132 /* https://tools.ietf.org/html/rfc4255#section-3.1 */
42cc2eeb
LP
133 struct {
134 uint8_t algorithm;
135 uint8_t fptype;
549c1a25
TG
136 void *fingerprint;
137 size_t fingerprint_size;
42cc2eeb 138 } sshfp;
8db0d2f5
ZJS
139
140 /* http://tools.ietf.org/html/rfc4034#section-2.1 */
141 struct {
f91dc240
LP
142 uint16_t flags;
143 uint8_t protocol;
8db0d2f5
ZJS
144 uint8_t algorithm;
145 void* key;
146 size_t key_size;
147 } dnskey;
151226ab
ZJS
148
149 /* http://tools.ietf.org/html/rfc4034#section-3.1 */
150 struct {
151 uint16_t type_covered;
152 uint8_t algorithm;
153 uint8_t labels;
154 uint32_t original_ttl;
155 uint32_t expiration;
156 uint32_t inception;
157 uint16_t key_tag;
158 char *signer;
159 void *signature;
160 size_t signature_size;
161 } rrsig;
50f1e641 162
9ead3519 163 /* https://tools.ietf.org/html/rfc4034#section-4.1 */
50f1e641
TG
164 struct {
165 char *next_domain_name;
166 Bitmap *types;
167 } nsec;
5d45a880
TG
168
169 struct {
170 uint8_t algorithm;
171 uint8_t flags;
172 uint16_t iterations;
173 void *salt;
174 size_t salt_size;
175 void *next_hashed_name;
176 size_t next_hashed_name_size;
177 Bitmap *types;
178 } nsec3;
74b2466e
LP
179 };
180};
181
faa133f3
LP
182static inline const char* DNS_RESOURCE_KEY_NAME(const DnsResourceKey *key) {
183 if (_unlikely_(!key))
184 return NULL;
185
186 if (key->_name)
187 return key->_name;
188
189 return (char*) key + sizeof(DnsResourceKey);
190}
74b2466e 191
faa133f3 192DnsResourceKey* dns_resource_key_new(uint16_t class, uint16_t type, const char *name);
7c1ff6ac 193DnsResourceKey* dns_resource_key_new_cname(const DnsResourceKey *key);
58db254a 194DnsResourceKey* dns_resource_key_new_dname(const DnsResourceKey *key);
36d9205d 195DnsResourceKey* dns_resource_key_new_redirect(const DnsResourceKey *key, const DnsResourceRecord *cname);
801ad6a6 196int dns_resource_key_new_append_suffix(DnsResourceKey **ret, DnsResourceKey *key, char *name);
faa133f3
LP
197DnsResourceKey* dns_resource_key_new_consume(uint16_t class, uint16_t type, char *name);
198DnsResourceKey* dns_resource_key_ref(DnsResourceKey *key);
199DnsResourceKey* dns_resource_key_unref(DnsResourceKey *key);
200int dns_resource_key_equal(const DnsResourceKey *a, const DnsResourceKey *b);
801ad6a6
LP
201int dns_resource_key_match_rr(const DnsResourceKey *key, const DnsResourceRecord *rr, const char *search_domain);
202int dns_resource_key_match_cname(const DnsResourceKey *key, const DnsResourceRecord *rr, const char *search_domain);
2d4c5cbc 203int dns_resource_key_to_string(const DnsResourceKey *key, char **ret);
faa133f3 204DEFINE_TRIVIAL_CLEANUP_FUNC(DnsResourceKey*, dns_resource_key_unref);
322345fd 205
faa133f3 206DnsResourceRecord* dns_resource_record_new(DnsResourceKey *key);
8bf52d3d 207DnsResourceRecord* dns_resource_record_new_full(uint16_t class, uint16_t type, const char *name);
74b2466e
LP
208DnsResourceRecord* dns_resource_record_ref(DnsResourceRecord *rr);
209DnsResourceRecord* dns_resource_record_unref(DnsResourceRecord *rr);
623a4c97 210int dns_resource_record_new_reverse(DnsResourceRecord **ret, int family, const union in_addr_union *address, const char *name);
78c6a153 211int dns_resource_record_new_address(DnsResourceRecord **ret, int family, const union in_addr_union *address, const char *name);
322345fd 212int dns_resource_record_equal(const DnsResourceRecord *a, const DnsResourceRecord *b);
2d4c5cbc 213int dns_resource_record_to_string(const DnsResourceRecord *rr, char **ret);
faa133f3 214DEFINE_TRIVIAL_CLEANUP_FUNC(DnsResourceRecord*, dns_resource_record_unref);
322345fd 215
a8812dd7
LP
216int dns_resource_record_to_wire_format(DnsResourceRecord *rr, bool canonical);
217
2001c805
LP
218DnsTxtItem *dns_txt_item_free_all(DnsTxtItem *i);
219bool dns_txt_item_equal(DnsTxtItem *a, DnsTxtItem *b);
220
322345fd 221const char *dns_class_to_string(uint16_t type);
2d4c5cbc 222int dns_class_from_string(const char *name, uint16_t *class);
d5099efc
MS
223
224extern const struct hash_ops dns_resource_key_hash_ops;