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