| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
#pragma once |
| 3 |
|
| 4 |
#include "shared-forward.h" |
| 5 |
|
| 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, |
| 110 |
}; |
| 111 |
|
| 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); |
| 117 |
|
| 118 |
/* DNS record classes, see RFC 1035 */ |
| 119 |
enum { |
| 120 |
DNS_CLASS_IN = 0x01, |
| 121 |
DNS_CLASS_ANY = 0xFF, |
| 122 |
|
| 123 |
_DNS_CLASS_MAX, |
| 124 |
_DNS_CLASS_INVALID = -EINVAL, |
| 125 |
}; |
| 126 |
|
| 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 |
|
| 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_transfer(uint16_t type); |
| 140 |
int dns_type_to_af(uint16_t type); |
| 141 |
|
| 142 |
bool dns_class_is_pseudo(uint16_t class); |
| 143 |
bool dns_class_is_valid_rr(uint16_t class); |
| 144 |
|
| 145 |
/* TYPE?? follows http://tools.ietf.org/html/rfc3597#section-5 */ |
| 146 |
DECLARE_STRING_TABLE_LOOKUP(dns_type, int); |
| 147 |
|
| 148 |
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(dns_class, uint16_t); |
| 149 |
DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(dns_class, int); |
| 150 |
|
| 151 |
/* https://tools.ietf.org/html/draft-ietf-dane-protocol-23#section-7.2 */ |
| 152 |
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(tlsa_cert_usage, uint8_t); |
| 153 |
|
| 154 |
/* https://tools.ietf.org/html/draft-ietf-dane-protocol-23#section-7.3 */ |
| 155 |
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(tlsa_selector, uint8_t); |
| 156 |
|
| 157 |
/* https://tools.ietf.org/html/draft-ietf-dane-protocol-23#section-7.4 */ |
| 158 |
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(tlsa_matching_type, uint8_t); |
| 159 |
|
| 160 |
/* https://tools.ietf.org/html/rfc6844#section-5.1 */ |
| 161 |
#define CAA_FLAG_CRITICAL (1u << 7) |