1 /* 2 * Copyright (C) Internet Systems Consortium, Inc. ("ISC") 3 * 4 * Permission to use, copy, modify, and/or distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 9 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 10 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 11 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 12 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 13 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 14 * PERFORMANCE OF THIS SOFTWARE. 15 */ 16 17 /* $Id: dns_result.c,v 1.4 2020/02/23 19:54:25 jung Exp $ */ 18 19 /*! \file */ 20 #include <isc/util.h> 21 22 #include <dns/result.h> 23 24 static const char *text[DNS_R_NRESULTS] = { 25 "label too long", /*%< 0 DNS_R_LABELTOOLONG */ 26 "bad escape", /*%< 1 DNS_R_BADESCAPE */ 27 /*! 28 * Note that DNS_R_BADBITSTRING and DNS_R_BITSTRINGTOOLONG are 29 * deprecated. 30 */ 31 "bad bitstring", /*%< 2 DNS_R_BADBITSTRING */ 32 "bitstring too long", /*%< 3 DNS_R_BITSTRINGTOOLONG */ 33 "empty label", /*%< 4 DNS_R_EMPTYLABEL */ 34 35 "bad dotted quad", /*%< 5 DNS_R_BADDOTTEDQUAD */ 36 "invalid NS owner name (wildcard)", /*%< 6 DNS_R_INVALIDNS */ 37 "unknown class/type", /*%< 7 DNS_R_UNKNOWN */ 38 "bad label type", /*%< 8 DNS_R_BADLABELTYPE */ 39 "bad compression pointer", /*%< 9 DNS_R_BADPOINTER */ 40 41 "too many hops", /*%< 10 DNS_R_TOOMANYHOPS */ 42 "disallowed (by application policy)", /*%< 11 DNS_R_DISALLOWED */ 43 "extra input text", /*%< 12 DNS_R_EXTRATOKEN */ 44 "extra input data", /*%< 13 DNS_R_EXTRADATA */ 45 "text too long", /*%< 14 DNS_R_TEXTTOOLONG */ 46 47 "not at top of zone", /*%< 15 DNS_R_NOTZONETOP */ 48 "syntax error", /*%< 16 DNS_R_SYNTAX */ 49 "bad checksum", /*%< 17 DNS_R_BADCKSUM */ 50 "bad IPv6 address", /*%< 18 DNS_R_BADAAAA */ 51 "no owner", /*%< 19 DNS_R_NOOWNER */ 52 53 "no ttl", /*%< 20 DNS_R_NOTTL */ 54 "bad class", /*%< 21 DNS_R_BADCLASS */ 55 "name too long", /*%< 22 DNS_R_NAMETOOLONG */ 56 "partial match", /*%< 23 DNS_R_PARTIALMATCH */ 57 "new origin", /*%< 24 DNS_R_NEWORIGIN */ 58 59 "unchanged", /*%< 25 DNS_R_UNCHANGED */ 60 "bad ttl", /*%< 26 DNS_R_BADTTL */ 61 "more data needed/to be rendered", /*%< 27 DNS_R_NOREDATA */ 62 "continue", /*%< 28 DNS_R_CONTINUE */ 63 "delegation", /*%< 29 DNS_R_DELEGATION */ 64 65 "glue", /*%< 30 DNS_R_GLUE */ 66 "dname", /*%< 31 DNS_R_DNAME */ 67 "cname", /*%< 32 DNS_R_CNAME */ 68 "bad database", /*%< 33 DNS_R_BADDB */ 69 "zonecut", /*%< 34 DNS_R_ZONECUT */ 70 71 "bad zone", /*%< 35 DNS_R_BADZONE */ 72 "more data", /*%< 36 DNS_R_MOREDATA */ 73 "up to date", /*%< 37 DNS_R_UPTODATE */ 74 "tsig verify failure", /*%< 38 DNS_R_TSIGVERIFYFAILURE */ 75 "tsig indicates error", /*%< 39 DNS_R_TSIGERRORSET */ 76 77 "RRSIG failed to verify", /*%< 40 DNS_R_SIGINVALID */ 78 "RRSIG has expired", /*%< 41 DNS_R_SIGEXPIRED */ 79 "RRSIG validity period has not begun", /*%< 42 DNS_R_SIGFUTURE */ 80 "key is unauthorized to sign data", /*%< 43 DNS_R_KEYUNAUTHORIZED */ 81 "invalid time", /*%< 44 DNS_R_INVALIDTIME */ 82 83 "expected a TSIG or SIG(0)", /*%< 45 DNS_R_EXPECTEDTSIG */ 84 "did not expect a TSIG or SIG(0)", /*%< 46 DNS_R_UNEXPECTEDTSIG */ 85 "TKEY is unacceptable", /*%< 47 DNS_R_INVALIDTKEY */ 86 "hint", /*%< 48 DNS_R_HINT */ 87 "drop", /*%< 49 DNS_R_DROP */ 88 89 "zone not loaded", /*%< 50 DNS_R_NOTLOADED */ 90 "ncache nxdomain", /*%< 51 DNS_R_NCACHENXDOMAIN */ 91 "ncache nxrrset", /*%< 52 DNS_R_NCACHENXRRSET */ 92 "wait", /*%< 53 DNS_R_WAIT */ 93 "not verified yet", /*%< 54 DNS_R_NOTVERIFIEDYET */ 94 95 "no identity", /*%< 55 DNS_R_NOIDENTITY */ 96 "no journal", /*%< 56 DNS_R_NOJOURNAL */ 97 "alias", /*%< 57 DNS_R_ALIAS */ 98 "use TCP", /*%< 58 DNS_R_USETCP */ 99 "no valid RRSIG", /*%< 59 DNS_R_NOVALIDSIG */ 100 101 "no valid NSEC", /*%< 60 DNS_R_NOVALIDNSEC */ 102 "insecurity proof failed", /*%< 61 DNS_R_NOTINSECURE */ 103 "unknown service", /*%< 62 DNS_R_UNKNOWNSERVICE */ 104 "recoverable error occurred", /*%< 63 DNS_R_RECOVERABLE */ 105 "unknown opt attribute record", /*%< 64 DNS_R_UNKNOWNOPT */ 106 107 "unexpected message id", /*%< 65 DNS_R_UNEXPECTEDID */ 108 "seen include file", /*%< 66 DNS_R_SEENINCLUDE */ 109 "not exact", /*%< 67 DNS_R_NOTEXACT */ 110 "address blackholed", /*%< 68 DNS_R_BLACKHOLED */ 111 "bad algorithm", /*%< 69 DNS_R_BADALG */ 112 113 "invalid use of a meta type", /*%< 70 DNS_R_METATYPE */ 114 "CNAME and other data", /*%< 71 DNS_R_CNAMEANDOTHER */ 115 "multiple RRs of singleton type", /*%< 72 DNS_R_SINGLETON */ 116 "hint nxrrset", /*%< 73 DNS_R_HINTNXRRSET */ 117 "no master file configured", /*%< 74 DNS_R_NOMASTERFILE */ 118 119 "unknown protocol", /*%< 75 DNS_R_UNKNOWNPROTO */ 120 "clocks are unsynchronized", /*%< 76 DNS_R_CLOCKSKEW */ 121 "IXFR failed", /*%< 77 DNS_R_BADIXFR */ 122 "not authoritative", /*%< 78 DNS_R_NOTAUTHORITATIVE */ 123 "no valid KEY", /*%< 79 DNS_R_NOVALIDKEY */ 124 125 "obsolete", /*%< 80 DNS_R_OBSOLETE */ 126 "already frozen", /*%< 81 DNS_R_FROZEN */ 127 "unknown flag", /*%< 82 DNS_R_UNKNOWNFLAG */ 128 "expected a response", /*%< 83 DNS_R_EXPECTEDRESPONSE */ 129 "no valid DS", /*%< 84 DNS_R_NOVALIDDS */ 130 131 "NS is an address", /*%< 85 DNS_R_NSISADDRESS */ 132 "received FORMERR", /*%< 86 DNS_R_REMOTEFORMERR */ 133 "truncated TCP response", /*%< 87 DNS_R_TRUNCATEDTCP */ 134 "lame server detected", /*%< 88 DNS_R_LAME */ 135 "unexpected RCODE", /*%< 89 DNS_R_UNEXPECTEDRCODE */ 136 137 "unexpected OPCODE", /*%< 90 DNS_R_UNEXPECTEDOPCODE */ 138 "chase DS servers", /*%< 91 DNS_R_CHASEDSSERVERS */ 139 "empty name", /*%< 92 DNS_R_EMPTYNAME */ 140 "empty wild", /*%< 93 DNS_R_EMPTYWILD */ 141 "bad bitmap", /*%< 94 DNS_R_BADBITMAP */ 142 143 "from wildcard", /*%< 95 DNS_R_FROMWILDCARD */ 144 "bad owner name (check-names)", /*%< 96 DNS_R_BADOWNERNAME */ 145 "bad name (check-names)", /*%< 97 DNS_R_BADNAME */ 146 "dynamic zone", /*%< 98 DNS_R_DYNAMIC */ 147 "unknown command", /*%< 99 DNS_R_UNKNOWNCOMMAND */ 148 149 "must-be-secure", /*%< 100 DNS_R_MUSTBESECURE */ 150 "covering NSEC record returned", /*%< 101 DNS_R_COVERINGNSEC */ 151 "MX is an address", /*%< 102 DNS_R_MXISADDRESS */ 152 "duplicate query", /*%< 103 DNS_R_DUPLICATE */ 153 "invalid NSEC3 owner name (wildcard)", /*%< 104 DNS_R_INVALIDNSEC3 */ 154 155 "not master", /*%< 105 DNS_R_NOTMASTER */ 156 "broken trust chain", /*%< 106 DNS_R_BROKENCHAIN */ 157 "expired", /*%< 107 DNS_R_EXPIRED */ 158 "not dynamic", /*%< 108 DNS_R_NOTDYNAMIC */ 159 "bad EUI", /*%< 109 DNS_R_BADEUI */ 160 161 "covered by negative trust anchor", /*%< 110 DNS_R_NTACOVERED */ 162 "bad CDS", /*%< 111 DNS_R_BADCDS */ 163 "bad CDNSKEY", /*%< 112 DNS_R_BADCDNSKEY */ 164 "malformed OPT option", /*%< 113 DNS_R_OPTERR */ 165 "malformed DNSTAP data", /*%< 114 DNS_R_BADDNSTAP */ 166 167 "TSIG in wrong location", /*%< 115 DNS_R_BADTSIG */ 168 "SIG(0) in wrong location", /*%< 116 DNS_R_BADSIG0 */ 169 "too many records", /*%< 117 DNS_R_TOOMANYRECORDS */ 170 }; 171 172 static const char *rcode_text[DNS_R_NRCODERESULTS] = { 173 "NOERROR", /*%< 0 DNS_R_NOERROR */ 174 "FORMERR", /*%< 1 DNS_R_FORMERR */ 175 "SERVFAIL", /*%< 2 DNS_R_SERVFAIL */ 176 "NXDOMAIN", /*%< 3 DNS_R_NXDOMAIN */ 177 "NOTIMP", /*%< 4 DNS_R_NOTIMP */ 178 179 "REFUSED", /*%< 5 DNS_R_REFUSED */ 180 "YXDOMAIN", /*%< 6 DNS_R_YXDOMAIN */ 181 "YXRRSET", /*%< 7 DNS_R_YXRRSET */ 182 "NXRRSET", /*%< 8 DNS_R_NXRRSET */ 183 "NOTAUTH", /*%< 9 DNS_R_NOTAUTH */ 184 185 "NOTZONE", /*%< 10 DNS_R_NOTZONE */ 186 "<rcode 11>", /*%< 11 has no macro */ 187 "<rcode 12>", /*%< 12 has no macro */ 188 "<rcode 13>", /*%< 13 has no macro */ 189 "<rcode 14>", /*%< 14 has no macro */ 190 191 "<rcode 15>", /*%< 15 has no macro */ 192 "BADVERS", /*%< 16 DNS_R_BADVERS */ 193 }; 194 195 #define DNS_RESULT_RESULTSET 2 196 #define DNS_RESULT_RCODERESULTSET 3 197 198 static isc_boolean_t once = ISC_FALSE; 199 200 static void 201 initialize_action(void) { 202 isc_result_t result; 203 204 result = isc_result_register(ISC_RESULTCLASS_DNS, DNS_R_NRESULTS, 205 text, DNS_RESULT_RESULTSET); 206 if (result == ISC_R_SUCCESS) 207 result = isc_result_register(ISC_RESULTCLASS_DNSRCODE, 208 DNS_R_NRCODERESULTS, 209 rcode_text, 210 DNS_RESULT_RCODERESULTSET); 211 if (result != ISC_R_SUCCESS) 212 UNEXPECTED_ERROR(__FILE__, __LINE__, 213 "isc_result_register() failed: %u", result); 214 } 215 216 static void 217 initialize(void) { 218 if (!once) { 219 once = ISC_TRUE; 220 initialize_action(); 221 } 222 } 223 224 void 225 dns_result_register(void) { 226 initialize(); 227 } 228