00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <config.h>
00023
00024 #include <isc/once.h>
00025 #include <isc/util.h>
00026
00027 #include <dns/result.h>
00028 #include <dns/lib.h>
00029
00030 static const char *text[DNS_R_NRESULTS] = {
00031 "label too long",
00032 "bad escape",
00033
00034
00035
00036
00037 "bad bitstring",
00038 "bitstring too long",
00039 "empty label",
00040
00041 "bad dotted quad",
00042 "invalid NS owner name (wildcard)",
00043 "unknown class/type",
00044 "bad label type",
00045 "bad compression pointer",
00046
00047 "too many hops",
00048 "disallowed (by application policy)",
00049 "extra input text",
00050 "extra input data",
00051 "text too long",
00052
00053 "not at top of zone",
00054 "syntax error",
00055 "bad checksum",
00056 "bad IPv6 address",
00057 "no owner",
00058
00059 "no ttl",
00060 "bad class",
00061 "name too long",
00062 "partial match",
00063 "new origin",
00064
00065 "unchanged",
00066 "bad ttl",
00067 "more data needed/to be rendered",
00068 "continue",
00069 "delegation",
00070
00071 "glue",
00072 "dname",
00073 "cname",
00074 "bad database",
00075 "zonecut",
00076
00077 "bad zone",
00078 "more data",
00079 "up to date",
00080 "tsig verify failure",
00081 "tsig indicates error",
00082
00083 "RRSIG failed to verify",
00084 "RRSIG has expired",
00085 "RRSIG validity period has not begun",
00086 "key is unauthorized to sign data",
00087 "invalid time",
00088
00089 "expected a TSIG or SIG(0)",
00090 "did not expect a TSIG or SIG(0)",
00091 "TKEY is unacceptable",
00092 "hint",
00093 "drop",
00094
00095 "zone not loaded",
00096 "ncache nxdomain",
00097 "ncache nxrrset",
00098 "wait",
00099 "not verified yet",
00100
00101 "no identity",
00102 "no journal",
00103 "alias",
00104 "use TCP",
00105 "no valid RRSIG",
00106
00107 "no valid NSEC",
00108 "insecurity proof failed",
00109 "unknown service",
00110 "recoverable error occurred",
00111 "unknown opt attribute record",
00112
00113 "unexpected message id",
00114 "seen include file",
00115 "not exact",
00116 "address blackholed",
00117 "bad algorithm",
00118
00119 "invalid use of a meta type",
00120 "CNAME and other data",
00121 "multiple RRs of singleton type",
00122 "hint nxrrset",
00123 "no master file configured",
00124
00125 "unknown protocol",
00126 "clocks are unsynchronized",
00127 "IXFR failed",
00128 "not authoritative",
00129 "no valid KEY",
00130
00131 "obsolete",
00132 "already frozen",
00133 "unknown flag",
00134 "expected a response",
00135 "no valid DS",
00136
00137 "NS is an address",
00138 "received FORMERR",
00139 "truncated TCP response",
00140 "lame server detected",
00141 "unexpected RCODE",
00142
00143 "unexpected OPCODE",
00144 "chase DS servers",
00145 "empty name",
00146 "empty wild",
00147 "bad bitmap",
00148
00149 "from wildcard",
00150 "bad owner name (check-names)",
00151 "bad name (check-names)",
00152 "dynamic zone",
00153 "unknown command",
00154
00155 "must-be-secure",
00156 "covering NSEC record returned",
00157 "MX is an address",
00158 "duplicate query",
00159 "invalid NSEC3 owner name (wildcard)",
00160
00161 "not master",
00162 "broken trust chain",
00163 "expired",
00164 "not dynamic",
00165 "bad EUI",
00166
00167 "covered by negative trust anchor"
00168 };
00169
00170 static const char *rcode_text[DNS_R_NRCODERESULTS] = {
00171 "NOERROR",
00172 "FORMERR",
00173 "SERVFAIL",
00174 "NXDOMAIN",
00175 "NOTIMP",
00176
00177 "REFUSED",
00178 "YXDOMAIN",
00179 "YXRRSET",
00180 "NXRRSET",
00181 "NOTAUTH",
00182
00183 "NOTZONE",
00184 "<rcode 11>",
00185 "<rcode 12>",
00186 "<rcode 13>",
00187 "<rcode 14>",
00188
00189 "<rcode 15>",
00190 "BADVERS",
00191 };
00192
00193 #define DNS_RESULT_RESULTSET 2
00194 #define DNS_RESULT_RCODERESULTSET 3
00195
00196 static isc_once_t once = ISC_ONCE_INIT;
00197
00198 static void
00199 initialize_action(void) {
00200 isc_result_t result;
00201
00202 result = isc_result_register(ISC_RESULTCLASS_DNS, DNS_R_NRESULTS,
00203 text, dns_msgcat, DNS_RESULT_RESULTSET);
00204 if (result == ISC_R_SUCCESS)
00205 result = isc_result_register(ISC_RESULTCLASS_DNSRCODE,
00206 DNS_R_NRCODERESULTS,
00207 rcode_text, dns_msgcat,
00208 DNS_RESULT_RCODERESULTSET);
00209 if (result != ISC_R_SUCCESS)
00210 UNEXPECTED_ERROR(__FILE__, __LINE__,
00211 "isc_result_register() failed: %u", result);
00212 }
00213
00214 static void
00215 initialize(void) {
00216 dns_lib_initmsgcat();
00217 RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS);
00218 }
00219
00220 const char *
00221 dns_result_totext(isc_result_t result) {
00222 initialize();
00223
00224 return (isc_result_totext(result));
00225 }
00226
00227 void
00228 dns_result_register(void) {
00229 initialize();
00230 }
00231
00232 dns_rcode_t
00233 dns_result_torcode(isc_result_t result) {
00234 dns_rcode_t rcode = dns_rcode_servfail;
00235
00236 if (DNS_RESULT_ISRCODE(result)) {
00237
00238
00239
00240
00241 return ((dns_rcode_t)((result) & 0xFFF));
00242 }
00243
00244
00245
00246 switch (result) {
00247 case ISC_R_SUCCESS:
00248 rcode = dns_rcode_noerror;
00249 break;
00250 case ISC_R_BADBASE64:
00251 case ISC_R_NOSPACE:
00252 case ISC_R_RANGE:
00253 case ISC_R_UNEXPECTEDEND:
00254 case DNS_R_BADAAAA:
00255
00256 case DNS_R_BADCKSUM:
00257 case DNS_R_BADCLASS:
00258 case DNS_R_BADLABELTYPE:
00259 case DNS_R_BADPOINTER:
00260 case DNS_R_BADTTL:
00261 case DNS_R_BADZONE:
00262
00263 case DNS_R_EXTRADATA:
00264 case DNS_R_LABELTOOLONG:
00265 case DNS_R_NOREDATA:
00266 case DNS_R_SYNTAX:
00267 case DNS_R_TEXTTOOLONG:
00268 case DNS_R_TOOMANYHOPS:
00269 case DNS_R_TSIGERRORSET:
00270 case DNS_R_UNKNOWN:
00271 case DNS_R_NAMETOOLONG:
00272 rcode = dns_rcode_formerr;
00273 break;
00274 case DNS_R_DISALLOWED:
00275 rcode = dns_rcode_refused;
00276 break;
00277 case DNS_R_TSIGVERIFYFAILURE:
00278 case DNS_R_CLOCKSKEW:
00279 rcode = dns_rcode_notauth;
00280 break;
00281 default:
00282 rcode = dns_rcode_servfail;
00283 }
00284
00285 return (rcode);
00286 }