]>
Commit | Line | Data |
---|---|---|
db9ecf05 | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
0ef6f454 LP |
2 | #pragma once |
3 | ||
284d7641 | 4 | #include "forward.h" |
7263f724 | 5 | |
7263f724 ZJS |
6 | /* DNS record types, taken from |
7 | * http://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml. | |
8 | */ | |
9 | enum { | |
d05649ca | 10 | /* 0 is reserved */ |
7263f724 ZJS |
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, | |
818bb6f4 | 63 | DNS_TYPE_SMIMEA, /* RFC 8162 */ |
d05649ca | 64 | /* 0x36 (54) is not assigned */ |
7263f724 ZJS |
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, | |
d93a16b8 | 71 | DNS_TYPE_OPENPGPKEY, |
818bb6f4 RP |
72 | DNS_TYPE_CSYNC, |
73 | DNS_TYPE_ZONEMD, | |
74 | DNS_TYPE_SVCB, /* RFC 9460 */ | |
75 | DNS_TYPE_HTTPS, /* RFC 9460 */ | |
d05649ca | 76 | /* 0x42…0x62 (66…98) are not assigned */ |
7263f724 | 77 | DNS_TYPE_SPF = 0x63, |
818bb6f4 RP |
78 | DNS_TYPE_UINFO, |
79 | DNS_TYPE_UID, | |
80 | DNS_TYPE_GID, | |
81 | DNS_TYPE_UNSPEC, | |
7263f724 ZJS |
82 | DNS_TYPE_NID, |
83 | DNS_TYPE_L32, | |
84 | DNS_TYPE_L64, | |
85 | DNS_TYPE_LP, | |
86 | DNS_TYPE_EUI48, | |
87 | DNS_TYPE_EUI64, | |
d05649ca | 88 | /* 0x6e…0xf8 (110…248) are not assigned */ |
7263f724 ZJS |
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, | |
818bb6f4 RP |
98 | DNS_TYPE_AVC, |
99 | DNS_TYPE_DOA, | |
100 | DNS_TYPE_AMTRELAY, | |
101 | DNS_TYPE_RESINFO, | |
d05649ca | 102 | /* 0x106…0x7fff (262…32767) are not assigned */ |
7263f724 ZJS |
103 | DNS_TYPE_TA = 0x8000, |
104 | DNS_TYPE_DLV, | |
d05649ca YW |
105 | /* 32770…65279 are not assigned */ |
106 | /* 65280…65534 are for private use */ | |
107 | /* 65535 is reserved */ | |
7263f724 | 108 | _DNS_TYPE_MAX, |
2d93c20e | 109 | _DNS_TYPE_INVALID = -EINVAL, |
7263f724 ZJS |
110 | }; |
111 | ||
d05649ca YW |
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); | |
7263f724 | 116 | assert_cc(DNS_TYPE_ANY == 255); |
4b548ef3 LP |
117 | |
118 | /* DNS record classes, see RFC 1035 */ | |
119 | enum { | |
120 | DNS_CLASS_IN = 0x01, | |
121 | DNS_CLASS_ANY = 0xFF, | |
222148b6 | 122 | |
4b548ef3 | 123 | _DNS_CLASS_MAX, |
2d93c20e | 124 | _DNS_CLASS_INVALID = -EINVAL, |
4b548ef3 LP |
125 | }; |
126 | ||
202b76ae ZJS |
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)) | |
129 | ||
222148b6 LP |
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); | |
d3c7e913 | 133 | bool dns_type_may_redirect(uint16_t type); |
91adc4db | 134 | bool dns_type_is_dnssec(uint16_t type); |
d0129ddb | 135 | bool dns_type_is_obsolete(uint16_t type); |
e8233bce | 136 | bool dns_type_may_wildcard(uint16_t type); |
588c53d0 | 137 | bool dns_type_apex_only(uint16_t type); |
41815a4a | 138 | bool dns_type_needs_authentication(uint16_t type); |
d4fd7fb5 | 139 | bool dns_type_is_zone_transfer(uint16_t type); |
5259c055 | 140 | int dns_type_to_af(uint16_t type); |
222148b6 | 141 | |
4b548ef3 LP |
142 | bool dns_class_is_pseudo(uint16_t class); |
143 | bool dns_class_is_valid_rr(uint16_t class); | |
144 | ||
869b3b67 | 145 | /* TYPE?? follows http://tools.ietf.org/html/rfc3597#section-5 */ |
bfd5a068 | 146 | const char* dns_type_to_string(int type); |
222148b6 LP |
147 | int dns_type_from_string(const char *s); |
148 | ||
bfd5a068 | 149 | const char* dns_class_to_string(uint16_t class); |
4b548ef3 | 150 | int dns_class_from_string(const char *name); |
cfb90da3 ZJS |
151 | |
152 | /* https://tools.ietf.org/html/draft-ietf-dane-protocol-23#section-7.2 */ | |
bfd5a068 | 153 | const char* tlsa_cert_usage_to_string(uint8_t cert_usage); |
cfb90da3 ZJS |
154 | |
155 | /* https://tools.ietf.org/html/draft-ietf-dane-protocol-23#section-7.3 */ | |
bfd5a068 | 156 | const char* tlsa_selector_to_string(uint8_t selector); |
cfb90da3 ZJS |
157 | |
158 | /* https://tools.ietf.org/html/draft-ietf-dane-protocol-23#section-7.4 */ | |
bfd5a068 | 159 | const char* tlsa_matching_type_to_string(uint8_t selector); |
718af59e ZJS |
160 | |
161 | /* https://tools.ietf.org/html/rfc6844#section-5.1 */ | |
162 | #define CAA_FLAG_CRITICAL (1u << 7) |