1 /* SPDX-License-Identifier: LGPL-2.1-or-later */ 2 #pragma once 3 4 #include "macro.h" 5 6 /* DNS record types, taken from 7 * http://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml. 8 */ 9 enum { 10 /* Normal records */ 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 64 DNS_TYPE_HIP = 0x37, 65 DNS_TYPE_NINFO, 66 DNS_TYPE_RKEY, 67 DNS_TYPE_TALINK, 68 DNS_TYPE_CDS, 69 DNS_TYPE_CDNSKEY, 70 DNS_TYPE_OPENPGPKEY, 71 72 DNS_TYPE_SPF = 0x63, 73 DNS_TYPE_NID, 74 DNS_TYPE_L32, 75 DNS_TYPE_L64, 76 DNS_TYPE_LP, 77 DNS_TYPE_EUI48, 78 DNS_TYPE_EUI64, 79 80 DNS_TYPE_TKEY = 0xF9, 81 DNS_TYPE_TSIG, 82 DNS_TYPE_IXFR, 83 DNS_TYPE_AXFR, 84 DNS_TYPE_MAILB, 85 DNS_TYPE_MAILA, 86 DNS_TYPE_ANY, 87 DNS_TYPE_URI, 88 DNS_TYPE_CAA, 89 DNS_TYPE_TA = 0x8000, 90 DNS_TYPE_DLV, 91 92 _DNS_TYPE_MAX, 93 _DNS_TYPE_INVALID = -EINVAL, 94 }; 95 96 assert_cc(DNS_TYPE_SSHFP == 44); 97 assert_cc(DNS_TYPE_TLSA == 52); 98 assert_cc(DNS_TYPE_ANY == 255); 99 100 /* DNS record classes, see RFC 1035 */ 101 enum { 102 DNS_CLASS_IN = 0x01, 103 DNS_CLASS_ANY = 0xFF, 104 105 _DNS_CLASS_MAX, 106 _DNS_CLASS_INVALID = -EINVAL, 107 }; 108 109 #define _DNS_CLASS_STRING_MAX (sizeof "CLASS" + DECIMAL_STR_MAX(uint16_t)) 110 #define _DNS_TYPE_STRING_MAX (sizeof "CLASS" + DECIMAL_STR_MAX(uint16_t)) 111 112 bool dns_type_is_pseudo(uint16_t type); 113 bool dns_type_is_valid_query(uint16_t type); 114 bool dns_type_is_valid_rr(uint16_t type); 115 bool dns_type_may_redirect(uint16_t type); 116 bool dns_type_is_dnssec(uint16_t type); 117 bool dns_type_is_obsolete(uint16_t type); 118 bool dns_type_may_wildcard(uint16_t type); 119 bool dns_type_apex_only(uint16_t type); 120 bool dns_type_needs_authentication(uint16_t type); 121 bool dns_type_is_zone_transer(uint16_t type); 122 int dns_type_to_af(uint16_t type); 123 124 bool dns_class_is_pseudo(uint16_t class); 125 bool dns_class_is_valid_rr(uint16_t class); 126 127 /* TYPE?? follows http://tools.ietf.org/html/rfc3597#section-5 */ 128 const char *dns_type_to_string(int type); 129 int dns_type_from_string(const char *s); 130 131 const char *dns_class_to_string(uint16_t class); 132 int dns_class_from_string(const char *name); 133 134 /* https://tools.ietf.org/html/draft-ietf-dane-protocol-23#section-7.2 */ 135 const char *tlsa_cert_usage_to_string(uint8_t cert_usage); 136 137 /* https://tools.ietf.org/html/draft-ietf-dane-protocol-23#section-7.3 */ 138 const char *tlsa_selector_to_string(uint8_t selector); 139 140 /* https://tools.ietf.org/html/draft-ietf-dane-protocol-23#section-7.4 */ 141 const char *tlsa_matching_type_to_string(uint8_t selector); 142 143 /* https://tools.ietf.org/html/rfc6844#section-5.1 */ 144 #define CAA_FLAG_CRITICAL (1u << 7) 145