]>
Commit | Line | Data |
---|---|---|
0ef6f454 LP |
1 | #pragma once |
2 | ||
7263f724 ZJS |
3 | /*** |
4 | This file is part of systemd. | |
5 | ||
6 | Copyright 2014 Zbigniew Jędrzejewski-Szmek | |
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 | ||
7263f724 ZJS |
22 | #include "macro.h" |
23 | ||
7263f724 ZJS |
24 | /* DNS record types, taken from |
25 | * http://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml. | |
26 | */ | |
27 | enum { | |
28 | /* Normal records */ | |
29 | DNS_TYPE_A = 0x01, | |
30 | DNS_TYPE_NS, | |
31 | DNS_TYPE_MD, | |
32 | DNS_TYPE_MF, | |
33 | DNS_TYPE_CNAME, | |
34 | DNS_TYPE_SOA, | |
35 | DNS_TYPE_MB, | |
36 | DNS_TYPE_MG, | |
37 | DNS_TYPE_MR, | |
38 | DNS_TYPE_NULL, | |
39 | DNS_TYPE_WKS, | |
40 | DNS_TYPE_PTR, | |
41 | DNS_TYPE_HINFO, | |
42 | DNS_TYPE_MINFO, | |
43 | DNS_TYPE_MX, | |
44 | DNS_TYPE_TXT, | |
45 | DNS_TYPE_RP, | |
46 | DNS_TYPE_AFSDB, | |
47 | DNS_TYPE_X25, | |
48 | DNS_TYPE_ISDN, | |
49 | DNS_TYPE_RT, | |
50 | DNS_TYPE_NSAP, | |
51 | DNS_TYPE_NSAP_PTR, | |
52 | DNS_TYPE_SIG, | |
53 | DNS_TYPE_KEY, | |
54 | DNS_TYPE_PX, | |
55 | DNS_TYPE_GPOS, | |
56 | DNS_TYPE_AAAA, | |
57 | DNS_TYPE_LOC, | |
58 | DNS_TYPE_NXT, | |
59 | DNS_TYPE_EID, | |
60 | DNS_TYPE_NIMLOC, | |
61 | DNS_TYPE_SRV, | |
62 | DNS_TYPE_ATMA, | |
63 | DNS_TYPE_NAPTR, | |
64 | DNS_TYPE_KX, | |
65 | DNS_TYPE_CERT, | |
66 | DNS_TYPE_A6, | |
67 | DNS_TYPE_DNAME, | |
68 | DNS_TYPE_SINK, | |
69 | DNS_TYPE_OPT, /* EDNS0 option */ | |
70 | DNS_TYPE_APL, | |
71 | DNS_TYPE_DS, | |
72 | DNS_TYPE_SSHFP, | |
73 | DNS_TYPE_IPSECKEY, | |
74 | DNS_TYPE_RRSIG, | |
75 | DNS_TYPE_NSEC, | |
76 | DNS_TYPE_DNSKEY, | |
77 | DNS_TYPE_DHCID, | |
78 | DNS_TYPE_NSEC3, | |
79 | DNS_TYPE_NSEC3PARAM, | |
80 | DNS_TYPE_TLSA, | |
81 | ||
82 | DNS_TYPE_HIP = 0x37, | |
83 | DNS_TYPE_NINFO, | |
84 | DNS_TYPE_RKEY, | |
85 | DNS_TYPE_TALINK, | |
86 | DNS_TYPE_CDS, | |
87 | DNS_TYPE_CDNSKEY, | |
d93a16b8 | 88 | DNS_TYPE_OPENPGPKEY, |
7263f724 ZJS |
89 | |
90 | DNS_TYPE_SPF = 0x63, | |
91 | DNS_TYPE_NID, | |
92 | DNS_TYPE_L32, | |
93 | DNS_TYPE_L64, | |
94 | DNS_TYPE_LP, | |
95 | DNS_TYPE_EUI48, | |
96 | DNS_TYPE_EUI64, | |
97 | ||
98 | DNS_TYPE_TKEY = 0xF9, | |
99 | DNS_TYPE_TSIG, | |
100 | DNS_TYPE_IXFR, | |
101 | DNS_TYPE_AXFR, | |
102 | DNS_TYPE_MAILB, | |
103 | DNS_TYPE_MAILA, | |
104 | DNS_TYPE_ANY, | |
105 | DNS_TYPE_URI, | |
106 | DNS_TYPE_CAA, | |
107 | DNS_TYPE_TA = 0x8000, | |
108 | DNS_TYPE_DLV, | |
109 | ||
110 | _DNS_TYPE_MAX, | |
111 | _DNS_TYPE_INVALID = -1 | |
112 | }; | |
113 | ||
114 | assert_cc(DNS_TYPE_SSHFP == 44); | |
115 | assert_cc(DNS_TYPE_TLSA == 52); | |
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 LP |
123 | _DNS_CLASS_MAX, |
124 | _DNS_CLASS_INVALID = -1 | |
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); |
5259c055 | 139 | int dns_type_to_af(uint16_t type); |
222148b6 | 140 | |
4b548ef3 LP |
141 | bool dns_class_is_pseudo(uint16_t class); |
142 | bool dns_class_is_valid_rr(uint16_t class); | |
143 | ||
869b3b67 | 144 | /* TYPE?? follows http://tools.ietf.org/html/rfc3597#section-5 */ |
222148b6 LP |
145 | const char *dns_type_to_string(int type); |
146 | int dns_type_from_string(const char *s); | |
147 | ||
5259c055 | 148 | const char *dns_class_to_string(uint16_t class); |
4b548ef3 | 149 | int dns_class_from_string(const char *name); |
cfb90da3 ZJS |
150 | |
151 | /* https://tools.ietf.org/html/draft-ietf-dane-protocol-23#section-7.2 */ | |
152 | const char *tlsa_cert_usage_to_string(uint8_t cert_usage); | |
153 | ||
154 | /* https://tools.ietf.org/html/draft-ietf-dane-protocol-23#section-7.3 */ | |
155 | const char *tlsa_selector_to_string(uint8_t selector); | |
156 | ||
157 | /* https://tools.ietf.org/html/draft-ietf-dane-protocol-23#section-7.4 */ | |
158 | const char *tlsa_matching_type_to_string(uint8_t selector); | |
718af59e ZJS |
159 | |
160 | /* https://tools.ietf.org/html/rfc6844#section-5.1 */ | |
161 | #define CAA_FLAG_CRITICAL (1u << 7) |