result.c 13.4 KB
Newer Older
Bob Halley's avatar
Bob Halley committed
1
/*
2
 * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
3
 *
4
5
6
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
8
9
 *
 * See the COPYRIGHT file distributed with this work for additional
 * information regarding copyright ownership.
Bob Halley's avatar
Bob Halley committed
10
 */
Bob Halley's avatar
add    
Bob Halley committed
11

12
/*! \file */
David Lawrence's avatar
David Lawrence committed
13

Bob Halley's avatar
Bob Halley committed
14
15
#include <config.h>

Bob Halley's avatar
Bob Halley committed
16
#include <isc/once.h>
Bob Halley's avatar
Bob Halley committed
17
#include <isc/util.h>
Bob Halley's avatar
Bob Halley committed
18

Bob Halley's avatar
add    
Bob Halley committed
19
#include <dns/result.h>
Bob Halley's avatar
Bob Halley committed
20
#include <dns/lib.h>
Bob Halley's avatar
add    
Bob Halley committed
21

David Lawrence's avatar
David Lawrence committed
22
static const char *text[DNS_R_NRESULTS] = {
23
24
25
	"label too long",		       /*%< 0 DNS_R_LABELTOOLONG */
	"bad escape",			       /*%< 1 DNS_R_BADESCAPE */
	/*!
Mark Andrews's avatar
Mark Andrews committed
26
27
28
	 * Note that DNS_R_BADBITSTRING and DNS_R_BITSTRINGTOOLONG are
	 * deprecated.
	 */
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
	"bad bitstring",		       /*%< 2 DNS_R_BADBITSTRING */
	"bitstring too long",		       /*%< 3 DNS_R_BITSTRINGTOOLONG */
	"empty label",			       /*%< 4 DNS_R_EMPTYLABEL */

	"bad dotted quad",		       /*%< 5 DNS_R_BADDOTTEDQUAD */
	"invalid NS owner name (wildcard)",    /*%< 6 DNS_R_INVALIDNS */
	"unknown class/type",		       /*%< 7 DNS_R_UNKNOWN */
	"bad label type",		       /*%< 8 DNS_R_BADLABELTYPE */
	"bad compression pointer",	       /*%< 9 DNS_R_BADPOINTER */

	"too many hops",		       /*%< 10 DNS_R_TOOMANYHOPS */
	"disallowed (by application policy)",  /*%< 11 DNS_R_DISALLOWED */
	"extra input text",		       /*%< 12 DNS_R_EXTRATOKEN */
	"extra input data",		       /*%< 13 DNS_R_EXTRADATA */
	"text too long",		       /*%< 14 DNS_R_TEXTTOOLONG */

	"not at top of zone",		       /*%< 15 DNS_R_NOTZONETOP */
	"syntax error",			       /*%< 16 DNS_R_SYNTAX */
	"bad checksum",			       /*%< 17 DNS_R_BADCKSUM */
	"bad IPv6 address",		       /*%< 18 DNS_R_BADAAAA */
	"no owner",			       /*%< 19 DNS_R_NOOWNER */

	"no ttl",			       /*%< 20 DNS_R_NOTTL */
	"bad class",			       /*%< 21 DNS_R_BADCLASS */
	"name too long",		       /*%< 22 DNS_R_NAMETOOLONG */
	"partial match",		       /*%< 23 DNS_R_PARTIALMATCH */
	"new origin",			       /*%< 24 DNS_R_NEWORIGIN */

	"unchanged",			       /*%< 25 DNS_R_UNCHANGED */
	"bad ttl",			       /*%< 26 DNS_R_BADTTL */
	"more data needed/to be rendered",     /*%< 27 DNS_R_NOREDATA */
	"continue",			       /*%< 28 DNS_R_CONTINUE */
	"delegation",			       /*%< 29 DNS_R_DELEGATION */

	"glue",				       /*%< 30 DNS_R_GLUE */
	"dname",			       /*%< 31 DNS_R_DNAME */
	"cname",			       /*%< 32 DNS_R_CNAME */
	"bad database",			       /*%< 33 DNS_R_BADDB */
	"zonecut",			       /*%< 34 DNS_R_ZONECUT */

	"bad zone",			       /*%< 35 DNS_R_BADZONE */
	"more data",			       /*%< 36 DNS_R_MOREDATA */
	"up to date",			       /*%< 37 DNS_R_UPTODATE */
	"tsig verify failure",		       /*%< 38 DNS_R_TSIGVERIFYFAILURE */
	"tsig indicates error",		       /*%< 39 DNS_R_TSIGERRORSET */

	"RRSIG failed to verify",	       /*%< 40 DNS_R_SIGINVALID */
	"RRSIG has expired",		       /*%< 41 DNS_R_SIGEXPIRED */
	"RRSIG validity period has not begun", /*%< 42 DNS_R_SIGFUTURE */
	"key is unauthorized to sign data",    /*%< 43 DNS_R_KEYUNAUTHORIZED */
	"invalid time",			       /*%< 44 DNS_R_INVALIDTIME */

	"expected a TSIG or SIG(0)",	       /*%< 45 DNS_R_EXPECTEDTSIG */
	"did not expect a TSIG or SIG(0)",     /*%< 46 DNS_R_UNEXPECTEDTSIG */
	"TKEY is unacceptable",		       /*%< 47 DNS_R_INVALIDTKEY */
	"hint",				       /*%< 48 DNS_R_HINT */
	"drop",				       /*%< 49 DNS_R_DROP */

	"zone not loaded",		       /*%< 50 DNS_R_NOTLOADED */
	"ncache nxdomain",		       /*%< 51 DNS_R_NCACHENXDOMAIN */
	"ncache nxrrset",		       /*%< 52 DNS_R_NCACHENXRRSET */
	"wait",				       /*%< 53 DNS_R_WAIT */
	"not verified yet",		       /*%< 54 DNS_R_NOTVERIFIEDYET */

	"no identity",			       /*%< 55 DNS_R_NOIDENTITY */
	"no journal",			       /*%< 56 DNS_R_NOJOURNAL */
	"alias",			       /*%< 57 DNS_R_ALIAS */
	"use TCP",			       /*%< 58 DNS_R_USETCP */
	"no valid RRSIG",		       /*%< 59 DNS_R_NOVALIDSIG */

	"no valid NSEC",		       /*%< 60 DNS_R_NOVALIDNSEC */
100
	"insecurity proof failed",	       /*%< 61 DNS_R_NOTINSECURE */
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
	"unknown service",		       /*%< 62 DNS_R_UNKNOWNSERVICE */
	"recoverable error occurred",	       /*%< 63 DNS_R_RECOVERABLE */
	"unknown opt attribute record",	       /*%< 64 DNS_R_UNKNOWNOPT */

	"unexpected message id",	       /*%< 65 DNS_R_UNEXPECTEDID */
	"seen include file",		       /*%< 66 DNS_R_SEENINCLUDE */
	"not exact",		       	       /*%< 67 DNS_R_NOTEXACT */
	"address blackholed",	       	       /*%< 68 DNS_R_BLACKHOLED */
	"bad algorithm",		       /*%< 69 DNS_R_BADALG */

	"invalid use of a meta type",	       /*%< 70 DNS_R_METATYPE */
	"CNAME and other data",		       /*%< 71 DNS_R_CNAMEANDOTHER */
	"multiple RRs of singleton type",      /*%< 72 DNS_R_SINGLETON */
	"hint nxrrset",			       /*%< 73 DNS_R_HINTNXRRSET */
	"no master file configured",	       /*%< 74 DNS_R_NOMASTERFILE */

	"unknown protocol",		       /*%< 75 DNS_R_UNKNOWNPROTO */
	"clocks are unsynchronized",	       /*%< 76 DNS_R_CLOCKSKEW */
	"IXFR failed",			       /*%< 77 DNS_R_BADIXFR */
	"not authoritative",		       /*%< 78 DNS_R_NOTAUTHORITATIVE */
	"no valid KEY",		       	       /*%< 79 DNS_R_NOVALIDKEY */

	"obsolete",			       /*%< 80 DNS_R_OBSOLETE */
	"already frozen",		       /*%< 81 DNS_R_FROZEN */
	"unknown flag",			       /*%< 82 DNS_R_UNKNOWNFLAG */
	"expected a response",		       /*%< 83 DNS_R_EXPECTEDRESPONSE */
	"no valid DS",			       /*%< 84 DNS_R_NOVALIDDS */

	"NS is an address",		       /*%< 85 DNS_R_NSISADDRESS */
	"received FORMERR",		       /*%< 86 DNS_R_REMOTEFORMERR */
	"truncated TCP response",	       /*%< 87 DNS_R_TRUNCATEDTCP */
	"lame server detected",		       /*%< 88 DNS_R_LAME */
	"unexpected RCODE",		       /*%< 89 DNS_R_UNEXPECTEDRCODE */

	"unexpected OPCODE",		       /*%< 90 DNS_R_UNEXPECTEDOPCODE */
	"chase DS servers",		       /*%< 91 DNS_R_CHASEDSSERVERS */
	"empty name",			       /*%< 92 DNS_R_EMPTYNAME */
	"empty wild",			       /*%< 93 DNS_R_EMPTYWILD */
	"bad bitmap",			       /*%< 94 DNS_R_BADBITMAP */

	"from wildcard",		       /*%< 95 DNS_R_FROMWILDCARD */
	"bad owner name (check-names)",	       /*%< 96 DNS_R_BADOWNERNAME */
	"bad name (check-names)",	       /*%< 97 DNS_R_BADNAME */
	"dynamic zone",			       /*%< 98 DNS_R_DYNAMIC */
	"unknown command",		       /*%< 99 DNS_R_UNKNOWNCOMMAND */

	"must-be-secure",		       /*%< 100 DNS_R_MUSTBESECURE */
148
	"covering NSEC record returned",       /*%< 101 DNS_R_COVERINGNSEC */
149
	"MX is an address",		       /*%< 102 DNS_R_MXISADDRESS */
150
151
	"duplicate query",		       /*%< 103 DNS_R_DUPLICATE */
	"invalid NSEC3 owner name (wildcard)", /*%< 104 DNS_R_INVALIDNSEC3 */
152

153
	"not master",			       /*%< 105 DNS_R_NOTMASTER */
154
	"broken trust chain",		       /*%< 106 DNS_R_BROKENCHAIN */
155
	"expired",			       /*%< 107 DNS_R_EXPIRED */
156
	"not dynamic",			       /*%< 108 DNS_R_NOTDYNAMIC */
Mark Andrews's avatar
Mark Andrews committed
157
158
	"bad EUI",			       /*%< 109 DNS_R_BADEUI */

159
	"covered by negative trust anchor",    /*%< 110 DNS_R_NTACOVERED */
Evan Hunt's avatar
Evan Hunt committed
160
	"bad CDS",			       /*%< 111 DNS_R_BADCDS */
161
	"bad CDNSKEY",			       /*%< 112 DNS_R_BADCDNSKEY */
Evan Hunt's avatar
Evan Hunt committed
162
	"malformed OPT option",		       /*%< 113 DNS_R_OPTERR */
163
164
165
166
	"malformed DNSTAP data",	       /*%< 114 DNS_R_BADDNSTAP */

	"TSIG in wrong location",	       /*%< 115 DNS_R_BADTSIG */
	"SIG(0) in wrong location",	       /*%< 116 DNS_R_BADSIG0 */
167
	"too many records",	               /*%< 117 DNS_R_TOOMANYRECORDS */
Michał Kępień's avatar
Michał Kępień committed
168
	"verify failure",	               /*%< 118 DNS_R_VERIFYFAILURE */
169
170
};

171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
static const char *ids[DNS_R_NRESULTS] = {
	"DNS_R_LABELTOOLONG",
	"DNS_R_BADESCAPE",
	/*!
	 * Note that DNS_R_BADBITSTRING and DNS_R_BITSTRINGTOOLONG are
	 * deprecated.
	 */
	"DNS_R_BADBITSTRING",
	"DNS_R_BITSTRINGTOOLONG",
	"DNS_R_EMPTYLABEL",
	"DNS_R_BADDOTTEDQUAD",
	"DNS_R_INVALIDNS",
	"DNS_R_UNKNOWN",
	"DNS_R_BADLABELTYPE",
	"DNS_R_BADPOINTER",
	"DNS_R_TOOMANYHOPS",
	"DNS_R_DISALLOWED",
	"DNS_R_EXTRATOKEN",
	"DNS_R_EXTRADATA",
	"DNS_R_TEXTTOOLONG",
	"DNS_R_NOTZONETOP",
	"DNS_R_SYNTAX",
	"DNS_R_BADCKSUM",
	"DNS_R_BADAAAA",
	"DNS_R_NOOWNER",
	"DNS_R_NOTTL",
	"DNS_R_BADCLASS",
	"DNS_R_NAMETOOLONG",
	"DNS_R_PARTIALMATCH",
	"DNS_R_NEWORIGIN",
	"DNS_R_UNCHANGED",
	"DNS_R_BADTTL",
	"DNS_R_NOREDATA",
	"DNS_R_CONTINUE",
	"DNS_R_DELEGATION",
	"DNS_R_GLUE",
	"DNS_R_DNAME",
	"DNS_R_CNAME",
	"DNS_R_BADDB",
	"DNS_R_ZONECUT",
	"DNS_R_BADZONE",
	"DNS_R_MOREDATA",
	"DNS_R_UPTODATE",
	"DNS_R_TSIGVERIFYFAILURE",
	"DNS_R_TSIGERRORSET",
	"DNS_R_SIGINVALID",
	"DNS_R_SIGEXPIRED",
	"DNS_R_SIGFUTURE",
	"DNS_R_KEYUNAUTHORIZED",
	"DNS_R_INVALIDTIME",
	"DNS_R_EXPECTEDTSIG",
	"DNS_R_UNEXPECTEDTSIG",
	"DNS_R_INVALIDTKEY",
	"DNS_R_HINT",
	"DNS_R_DROP",
	"DNS_R_NOTLOADED",
	"DNS_R_NCACHENXDOMAIN",
	"DNS_R_NCACHENXRRSET",
	"DNS_R_WAIT",
	"DNS_R_NOTVERIFIEDYET",
	"DNS_R_NOIDENTITY",
	"DNS_R_NOJOURNAL",
	"DNS_R_ALIAS",
	"DNS_R_USETCP",
	"DNS_R_NOVALIDSIG",
	"DNS_R_NOVALIDNSEC",
	"DNS_R_NOTINSECURE",
	"DNS_R_UNKNOWNSERVICE",
	"DNS_R_RECOVERABLE",
	"DNS_R_UNKNOWNOPT",
	"DNS_R_UNEXPECTEDID",
	"DNS_R_SEENINCLUDE",
	"DNS_R_NOTEXACT",
	"DNS_R_BLACKHOLED",
	"DNS_R_BADALG",
	"DNS_R_METATYPE",
	"DNS_R_CNAMEANDOTHER",
	"DNS_R_SINGLETON",
	"DNS_R_HINTNXRRSET",
	"DNS_R_NOMASTERFILE",
	"DNS_R_UNKNOWNPROTO",
	"DNS_R_CLOCKSKEW",
	"DNS_R_BADIXFR",
	"DNS_R_NOTAUTHORITATIVE",
	"DNS_R_NOVALIDKEY",
	"DNS_R_OBSOLETE",
	"DNS_R_FROZEN",
	"DNS_R_UNKNOWNFLAG",
	"DNS_R_EXPECTEDRESPONSE",
	"DNS_R_NOVALIDDS",
	"DNS_R_NSISADDRESS",
	"DNS_R_REMOTEFORMERR",
	"DNS_R_TRUNCATEDTCP",
	"DNS_R_LAME",
	"DNS_R_UNEXPECTEDRCODE",
	"DNS_R_UNEXPECTEDOPCODE",
	"DNS_R_CHASEDSSERVERS",
	"DNS_R_EMPTYNAME",
	"DNS_R_EMPTYWILD",
	"DNS_R_BADBITMAP",
	"DNS_R_FROMWILDCARD",
	"DNS_R_BADOWNERNAME",
	"DNS_R_BADNAME",
	"DNS_R_DYNAMIC",
	"DNS_R_UNKNOWNCOMMAND",
	"DNS_R_MUSTBESECURE",
	"DNS_R_COVERINGNSEC",
	"DNS_R_MXISADDRESS",
	"DNS_R_DUPLICATE",
	"DNS_R_INVALIDNSEC3",
	"DNS_R_NOTMASTER",
	"DNS_R_BROKENCHAIN",
	"DNS_R_EXPIRED",
	"DNS_R_NOTDYNAMIC",
	"DNS_R_BADEUI",
	"DNS_R_NTACOVERED",
Evan Hunt's avatar
Evan Hunt committed
287
	"DNS_R_BADCDS",
Evan Hunt's avatar
Evan Hunt committed
288
289
290
	"DNS_R_BADCDNSKEY",
	"DNS_R_OPTERR",
	"DNS_R_BADDNSTAP",
291
292
	"DNS_R_BADTSIG",
	"DNS_R_BADSIG0",
293
294
	"DNS_R_TOOMANYRECORDS",
	"DNS_R_VERIFYFAILURE",
295
296
};

David Lawrence's avatar
David Lawrence committed
297
static const char *rcode_text[DNS_R_NRCODERESULTS] = {
298
	"NOERROR",				/*%< 0 DNS_R_NOERROR */
299
300
301
302
303
304
305
306
307
308
309
310
	"FORMERR",				/*%< 1 DNS_R_FORMERR */
	"SERVFAIL",				/*%< 2 DNS_R_SERVFAIL */
	"NXDOMAIN",				/*%< 3 DNS_R_NXDOMAIN */
	"NOTIMP",				/*%< 4 DNS_R_NOTIMP */

	"REFUSED",				/*%< 5 DNS_R_REFUSED */
	"YXDOMAIN",				/*%< 6 DNS_R_YXDOMAIN */
	"YXRRSET",				/*%< 7 DNS_R_YXRRSET */
	"NXRRSET",				/*%< 8 DNS_R_NXRRSET */
	"NOTAUTH",				/*%< 9 DNS_R_NOTAUTH */

	"NOTZONE",				/*%< 10 DNS_R_NOTZONE */
311
312
313
314
	"<rcode 11>",				/*%< 11 DNS_R_RCODE11 */
	"<rcode 12>",				/*%< 12 DNS_R_RCODE12 */
	"<rcode 13>",				/*%< 13 DNS_R_RCODE13 */
	"<rcode 14>",				/*%< 14 DNS_R_RCODE14 */
315

316
	"<rcode 15>",				/*%< 15 DNS_R_RCODE15 */
317
	"BADVERS",				/*%< 16 DNS_R_BADVERS */
Bob Halley's avatar
add    
Bob Halley committed
318
319
};

320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
static const char *rcode_ids[DNS_R_NRCODERESULTS] = {
	"DNS_R_NOERROR",
	"DNS_R_FORMERR",
	"DNS_R_SERVFAIL",
	"DNS_R_NXDOMAIN",
	"DNS_R_NOTIMP",
	"DNS_R_REFUSED",
	"DNS_R_YXDOMAIN",
	"DNS_R_YXRRSET",
	"DNS_R_NXRRSET",
	"DNS_R_NOTAUTH",
	"DNS_R_NOTZONE",
	"DNS_R_RCODE11",
	"RNS_R_RCODE12",
	"DNS_R_RCODE13",
	"DNS_R_RCODE14",
	"DNS_R_RCODE15",
	"DNS_R_BADVERS",
};

Bob Halley's avatar
Bob Halley committed
340
#define DNS_RESULT_RESULTSET			2
341
#define DNS_RESULT_RCODERESULTSET		3
Bob Halley's avatar
Bob Halley committed
342

Bob Halley's avatar
Bob Halley committed
343
static isc_once_t		once = ISC_ONCE_INIT;
Bob Halley's avatar
Bob Halley committed
344
345
346
347
348
349

static void
initialize_action(void) {
	isc_result_t result;

	result = isc_result_register(ISC_RESULTCLASS_DNS, DNS_R_NRESULTS,
Bob Halley's avatar
Bob Halley committed
350
				     text, dns_msgcat, DNS_RESULT_RESULTSET);
351
352
353
354
355
	if (result == ISC_R_SUCCESS)
		result = isc_result_register(ISC_RESULTCLASS_DNSRCODE,
					     DNS_R_NRCODERESULTS,
					     rcode_text, dns_msgcat,
					     DNS_RESULT_RCODERESULTSET);
Bob Halley's avatar
Bob Halley committed
356
357
358
	if (result != ISC_R_SUCCESS)
		UNEXPECTED_ERROR(__FILE__, __LINE__,
				 "isc_result_register() failed: %u", result);
359
360
361
362
363
364
365
366
367
368
369

	result = isc_result_registerids(ISC_RESULTCLASS_DNS, DNS_R_NRESULTS,
					ids, dns_msgcat, DNS_RESULT_RESULTSET);
	if (result == ISC_R_SUCCESS)
		result = isc_result_registerids(ISC_RESULTCLASS_DNSRCODE,
						DNS_R_NRCODERESULTS,
						rcode_ids, dns_msgcat,
						DNS_RESULT_RCODERESULTSET);
	if (result != ISC_R_SUCCESS)
		UNEXPECTED_ERROR(__FILE__, __LINE__,
				 "isc_result_registerids() failed: %u", result);
Bob Halley's avatar
Bob Halley committed
370
371
372
373
}

static void
initialize(void) {
Bob Halley's avatar
Bob Halley committed
374
	dns_lib_initmsgcat();
Bob Halley's avatar
Bob Halley committed
375
376
377
	RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS);
}

David Lawrence's avatar
David Lawrence committed
378
const char *
379
dns_result_totext(isc_result_t result) {
Bob Halley's avatar
Bob Halley committed
380
381
382
383
384
385
386
387
	initialize();

	return (isc_result_totext(result));
}

void
dns_result_register(void) {
	initialize();
Bob Halley's avatar
add    
Bob Halley committed
388
}
389
390
391

dns_rcode_t
dns_result_torcode(isc_result_t result) {
392
	dns_rcode_t rcode = dns_rcode_servfail;
393
394
395
396
397
398
399
400

	if (DNS_RESULT_ISRCODE(result)) {
		/*
		 * Rcodes can't be bigger than 12 bits, which is why we
		 * AND with 0xFFF instead of 0xFFFF.
		 */
		return ((dns_rcode_t)((result) & 0xFFF));
	}
401

402
403
404
405
	/*
	 * Try to supply an appropriate rcode.
	 */
	switch (result) {
406
	case ISC_R_SUCCESS:
Mark Andrews's avatar
Mark Andrews committed
407
		rcode = dns_rcode_noerror;
408
		break;
David Lawrence's avatar
David Lawrence committed
409
410
	case ISC_R_BADBASE64:
	case ISC_R_RANGE:
411
	case ISC_R_UNEXPECTEDEND:
David Lawrence's avatar
David Lawrence committed
412
	case DNS_R_BADAAAA:
Mark Andrews's avatar
Mark Andrews committed
413
	/* case DNS_R_BADBITSTRING: deprecated */
414
415
	case DNS_R_BADCKSUM:
	case DNS_R_BADCLASS:
David Lawrence's avatar
David Lawrence committed
416
417
	case DNS_R_BADLABELTYPE:
	case DNS_R_BADPOINTER:
418
419
	case DNS_R_BADTTL:
	case DNS_R_BADZONE:
Mark Andrews's avatar
Mark Andrews committed
420
	/* case DNS_R_BITSTRINGTOOLONG: deprecated */
David Lawrence's avatar
David Lawrence committed
421
422
423
424
425
426
	case DNS_R_EXTRADATA:
	case DNS_R_LABELTOOLONG:
	case DNS_R_NOREDATA:
	case DNS_R_SYNTAX:
	case DNS_R_TEXTTOOLONG:
	case DNS_R_TOOMANYHOPS:
427
	case DNS_R_TSIGERRORSET:
David Lawrence's avatar
David Lawrence committed
428
	case DNS_R_UNKNOWN:
429
	case DNS_R_NAMETOOLONG:
430
	case DNS_R_OPTERR:
431
		rcode = dns_rcode_formerr;
432
		break;
433
434
	case DNS_R_DISALLOWED:
		rcode = dns_rcode_refused;
435
		break;
436
	case DNS_R_TSIGVERIFYFAILURE:
437
	case DNS_R_CLOCKSKEW:
438
439
		rcode = dns_rcode_notauth;
		break;
440
441
442
443
444
445
	default:
		rcode = dns_rcode_servfail;
	}

	return (rcode);
}