1:255.13-alt1
[systemd_ALT.git] / src / resolve / dns-type.h
blobc6be19063dd9f66024e44dfc9417c0966405a734
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
4 #include "macro.h"
6 /* DNS record types, taken from
7 * http://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml.
8 */
9 enum {
10 /* 0 is reserved */
11 DNS_TYPE_A = 0x01,
12 DNS_TYPE_NS,
13 DNS_TYPE_MD,
14 DNS_TYPE_MF,
15 DNS_TYPE_CNAME,
16 DNS_TYPE_SOA,
17 DNS_TYPE_MB,
18 DNS_TYPE_MG,
19 DNS_TYPE_MR,
20 DNS_TYPE_NULL,
21 DNS_TYPE_WKS,
22 DNS_TYPE_PTR,
23 DNS_TYPE_HINFO,
24 DNS_TYPE_MINFO,
25 DNS_TYPE_MX,
26 DNS_TYPE_TXT,
27 DNS_TYPE_RP,
28 DNS_TYPE_AFSDB,
29 DNS_TYPE_X25,
30 DNS_TYPE_ISDN,
31 DNS_TYPE_RT,
32 DNS_TYPE_NSAP,
33 DNS_TYPE_NSAP_PTR,
34 DNS_TYPE_SIG,
35 DNS_TYPE_KEY,
36 DNS_TYPE_PX,
37 DNS_TYPE_GPOS,
38 DNS_TYPE_AAAA,
39 DNS_TYPE_LOC,
40 DNS_TYPE_NXT,
41 DNS_TYPE_EID,
42 DNS_TYPE_NIMLOC,
43 DNS_TYPE_SRV,
44 DNS_TYPE_ATMA,
45 DNS_TYPE_NAPTR,
46 DNS_TYPE_KX,
47 DNS_TYPE_CERT,
48 DNS_TYPE_A6,
49 DNS_TYPE_DNAME,
50 DNS_TYPE_SINK,
51 DNS_TYPE_OPT, /* EDNS0 option */
52 DNS_TYPE_APL,
53 DNS_TYPE_DS,
54 DNS_TYPE_SSHFP,
55 DNS_TYPE_IPSECKEY,
56 DNS_TYPE_RRSIG,
57 DNS_TYPE_NSEC,
58 DNS_TYPE_DNSKEY,
59 DNS_TYPE_DHCID,
60 DNS_TYPE_NSEC3,
61 DNS_TYPE_NSEC3PARAM,
62 DNS_TYPE_TLSA,
63 DNS_TYPE_SMIMEA, /* RFC 8162 */
64 /* 0x36 (54) is not assigned */
65 DNS_TYPE_HIP = 0x37,
66 DNS_TYPE_NINFO,
67 DNS_TYPE_RKEY,
68 DNS_TYPE_TALINK,
69 DNS_TYPE_CDS,
70 DNS_TYPE_CDNSKEY,
71 DNS_TYPE_OPENPGPKEY,
72 DNS_TYPE_CSYNC,
73 DNS_TYPE_ZONEMD,
74 DNS_TYPE_SVCB, /* RFC 9460 */
75 DNS_TYPE_HTTPS, /* RFC 9460 */
76 /* 0x42…0x62 (66…98) are not assigned */
77 DNS_TYPE_SPF = 0x63,
78 DNS_TYPE_UINFO,
79 DNS_TYPE_UID,
80 DNS_TYPE_GID,
81 DNS_TYPE_UNSPEC,
82 DNS_TYPE_NID,
83 DNS_TYPE_L32,
84 DNS_TYPE_L64,
85 DNS_TYPE_LP,
86 DNS_TYPE_EUI48,
87 DNS_TYPE_EUI64,
88 /* 0x6e…0xf8 (110…248) are not assigned */
89 DNS_TYPE_TKEY = 0xF9,
90 DNS_TYPE_TSIG,
91 DNS_TYPE_IXFR,
92 DNS_TYPE_AXFR,
93 DNS_TYPE_MAILB,
94 DNS_TYPE_MAILA,
95 DNS_TYPE_ANY,
96 DNS_TYPE_URI,
97 DNS_TYPE_CAA,
98 DNS_TYPE_AVC,
99 DNS_TYPE_DOA,
100 DNS_TYPE_AMTRELAY,
101 DNS_TYPE_RESINFO,
102 /* 0x106…0x7fff (262…32767) are not assigned */
103 DNS_TYPE_TA = 0x8000,
104 DNS_TYPE_DLV,
105 /* 32770…65279 are not assigned */
106 /* 65280…65534 are for private use */
107 /* 65535 is reserved */
108 _DNS_TYPE_MAX,
109 _DNS_TYPE_INVALID = -EINVAL,
112 assert_cc(DNS_TYPE_SMIMEA == 53);
113 assert_cc(DNS_TYPE_HTTPS == 65);
114 assert_cc(DNS_TYPE_EUI64 == 109);
115 assert_cc(DNS_TYPE_RESINFO == 261);
116 assert_cc(DNS_TYPE_ANY == 255);
118 /* DNS record classes, see RFC 1035 */
119 enum {
120 DNS_CLASS_IN = 0x01,
121 DNS_CLASS_ANY = 0xFF,
123 _DNS_CLASS_MAX,
124 _DNS_CLASS_INVALID = -EINVAL,
127 #define _DNS_CLASS_STRING_MAX (sizeof "CLASS" + DECIMAL_STR_MAX(uint16_t))
128 #define _DNS_TYPE_STRING_MAX (sizeof "CLASS" + DECIMAL_STR_MAX(uint16_t))
130 bool dns_type_is_pseudo(uint16_t type);
131 bool dns_type_is_valid_query(uint16_t type);
132 bool dns_type_is_valid_rr(uint16_t type);
133 bool dns_type_may_redirect(uint16_t type);
134 bool dns_type_is_dnssec(uint16_t type);
135 bool dns_type_is_obsolete(uint16_t type);
136 bool dns_type_may_wildcard(uint16_t type);
137 bool dns_type_apex_only(uint16_t type);
138 bool dns_type_needs_authentication(uint16_t type);
139 bool dns_type_is_zone_transer(uint16_t type);
140 int dns_type_to_af(uint16_t type);
142 bool dns_class_is_pseudo(uint16_t class);
143 bool dns_class_is_valid_rr(uint16_t class);
145 /* TYPE?? follows http://tools.ietf.org/html/rfc3597#section-5 */
146 const char *dns_type_to_string(int type);
147 int dns_type_from_string(const char *s);
149 const char *dns_class_to_string(uint16_t class);
150 int dns_class_from_string(const char *name);
152 /* https://tools.ietf.org/html/draft-ietf-dane-protocol-23#section-7.2 */
153 const char *tlsa_cert_usage_to_string(uint8_t cert_usage);
155 /* https://tools.ietf.org/html/draft-ietf-dane-protocol-23#section-7.3 */
156 const char *tlsa_selector_to_string(uint8_t selector);
158 /* https://tools.ietf.org/html/draft-ietf-dane-protocol-23#section-7.4 */
159 const char *tlsa_matching_type_to_string(uint8_t selector);
161 /* https://tools.ietf.org/html/rfc6844#section-5.1 */
162 #define CAA_FLAG_CRITICAL (1u << 7)