result.c revision c5223c9cb7c22620d5ee6611228673e95b48a270
1ccbfca64ae86ace521053773001cb995352f96fBob Halley/*
633c5dc507fa3133a6d49a55cfe84bf4fd522c72Tinderbox User * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * Copyright (C) 1998-2003 Internet Software Consortium.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence *
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater * Permission to use, copy, modify, and distribute this software for any
1ccbfca64ae86ace521053773001cb995352f96fBob Halley * purpose with or without fee is hereby granted, provided that the above
1ccbfca64ae86ace521053773001cb995352f96fBob Halley * copyright notice and this permission notice appear in all copies.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence *
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * PERFORMANCE OF THIS SOFTWARE.
1ccbfca64ae86ace521053773001cb995352f96fBob Halley */
1ccbfca64ae86ace521053773001cb995352f96fBob Halley
7829fad4093f2c1985b1efb7cea00287ff015d2bckb/* $Id: result.c,v 1.120 2005/05/19 04:59:03 marka Exp $ */
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein/*! \file */
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley#include <config.h>
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley#include <isc/once.h>
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley#include <isc/util.h>
1ccbfca64ae86ace521053773001cb995352f96fBob Halley
1ccbfca64ae86ace521053773001cb995352f96fBob Halley#include <dns/result.h>
341323e0e7ef69f7c425cd3462afe06d0930c528Michael Graff#include <dns/lib.h>
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington
77ac297199fc44809d9628558223627c10ae3f31Brian Wellingtonstatic const char *text[DNS_R_NRESULTS] = {
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "label too long", /*%< 0 DNS_R_LABELTOOLONG */
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence "bad escape", /*%< 1 DNS_R_BADESCAPE */
364a82f7c25b62967678027043425201a5e5171aBob Halley /*!
1ccbfca64ae86ace521053773001cb995352f96fBob Halley * Note that DNS_R_BADBITSTRING and DNS_R_BITSTRINGTOOLONG are
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence * deprecated.
793814f80703afdd69b59ade91e63efa81ae4178Evan Hunt */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "bad bitstring", /*%< 2 DNS_R_BADBITSTRING */
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt "bitstring too long", /*%< 3 DNS_R_BITSTRINGTOOLONG */
c03ce72a3b1bd639d5bc430ed37f791051125c56Andreas Gustafsson "empty label", /*%< 4 DNS_R_EMPTYLABEL */
7d44d8aacda98eb2b526af34757a6bbcc97cd388Bob Halley
341323e0e7ef69f7c425cd3462afe06d0930c528Michael Graff "bad dotted quad", /*%< 5 DNS_R_BADDOTTEDQUAD */
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley "invalid NS owner name (wildcard)", /*%< 6 DNS_R_INVALIDNS */
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt "unknown class/type", /*%< 7 DNS_R_UNKNOWN */
b20ee662a7c847c9ef7b96ab9e5e34543efe5c0dMark Andrews "bad label type", /*%< 8 DNS_R_BADLABELTYPE */
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley "bad compression pointer", /*%< 9 DNS_R_BADPOINTER */
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley "too many hops", /*%< 10 DNS_R_TOOMANYHOPS */
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley "disallowed (by application policy)", /*%< 11 DNS_R_DISALLOWED */
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley "extra input text", /*%< 12 DNS_R_EXTRATOKEN */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "extra input data", /*%< 13 DNS_R_EXTRADATA */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "text too long", /*%< 14 DNS_R_TEXTTOOLONG */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "not at top of zone", /*%< 15 DNS_R_NOTZONETOP */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "syntax error", /*%< 16 DNS_R_SYNTAX */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "bad checksum", /*%< 17 DNS_R_BADCKSUM */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "bad IPv6 address", /*%< 18 DNS_R_BADAAAA */
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley "no owner", /*%< 19 DNS_R_NOOWNER */
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley "no ttl", /*%< 20 DNS_R_NOTTL */
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley "bad class", /*%< 21 DNS_R_BADCLASS */
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley "name too long", /*%< 22 DNS_R_NAMETOOLONG */
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley "partial match", /*%< 23 DNS_R_PARTIALMATCH */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "new origin", /*%< 24 DNS_R_NEWORIGIN */
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley
1ccbfca64ae86ace521053773001cb995352f96fBob Halley "unchanged", /*%< 25 DNS_R_UNCHANGED */
1ccbfca64ae86ace521053773001cb995352f96fBob Halley "bad ttl", /*%< 26 DNS_R_BADTTL */
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 "more data needed/to be rendered", /*%< 27 DNS_R_NOREDATA */
0e3ad060581e366d3e682caf2dd5d9ea2e0f4893Bob Halley "continue", /*%< 28 DNS_R_CONTINUE */
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 "delegation", /*%< 29 DNS_R_DELEGATION */
1ccbfca64ae86ace521053773001cb995352f96fBob Halley
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "glue", /*%< 30 DNS_R_GLUE */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "dname", /*%< 31 DNS_R_DNAME */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "cname", /*%< 32 DNS_R_CNAME */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "bad database", /*%< 33 DNS_R_BADDB */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "zonecut", /*%< 34 DNS_R_ZONECUT */
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "bad zone", /*%< 35 DNS_R_BADZONE */
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 "more data", /*%< 36 DNS_R_MOREDATA */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "up to date", /*%< 37 DNS_R_UPTODATE */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "tsig verify failure", /*%< 38 DNS_R_TSIGVERIFYFAILURE */
b61c97cebd9c23e7bbfbdc9508cf022c68461d46Danny Mayer "tsig indicates error", /*%< 39 DNS_R_TSIGERRORSET */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "RRSIG failed to verify", /*%< 40 DNS_R_SIGINVALID */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "RRSIG has expired", /*%< 41 DNS_R_SIGEXPIRED */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "RRSIG validity period has not begun", /*%< 42 DNS_R_SIGFUTURE */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "key is unauthorized to sign data", /*%< 43 DNS_R_KEYUNAUTHORIZED */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "invalid time", /*%< 44 DNS_R_INVALIDTIME */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "expected a TSIG or SIG(0)", /*%< 45 DNS_R_EXPECTEDTSIG */
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 "did not expect a TSIG or SIG(0)", /*%< 46 DNS_R_UNEXPECTEDTSIG */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "TKEY is unacceptable", /*%< 47 DNS_R_INVALIDTKEY */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "hint", /*%< 48 DNS_R_HINT */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "drop", /*%< 49 DNS_R_DROP */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "zone not loaded", /*%< 50 DNS_R_NOTLOADED */
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 "ncache nxdomain", /*%< 51 DNS_R_NCACHENXDOMAIN */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "ncache nxrrset", /*%< 52 DNS_R_NCACHENXRRSET */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "wait", /*%< 53 DNS_R_WAIT */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "not verified yet", /*%< 54 DNS_R_NOTVERIFIEDYET */
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "no identity", /*%< 55 DNS_R_NOIDENTITY */
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 "no journal", /*%< 56 DNS_R_NOJOURNAL */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "alias", /*%< 57 DNS_R_ALIAS */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "use TCP", /*%< 58 DNS_R_USETCP */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "no valid RRSIG", /*%< 59 DNS_R_NOVALIDSIG */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "no valid NSEC", /*%< 60 DNS_R_NOVALIDNSEC */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "not insecure", /*%< 61 DNS_R_NOTINSECURE */
e672951ed28b2e9cc7a19c3d7fa4a258382f981cAutomatic Updater "unknown service", /*%< 62 DNS_R_UNKNOWNSERVICE */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "recoverable error occurred", /*%< 63 DNS_R_RECOVERABLE */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "unknown opt attribute record", /*%< 64 DNS_R_UNKNOWNOPT */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "unexpected message id", /*%< 65 DNS_R_UNEXPECTEDID */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "seen include file", /*%< 66 DNS_R_SEENINCLUDE */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "not exact", /*%< 67 DNS_R_NOTEXACT */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "address blackholed", /*%< 68 DNS_R_BLACKHOLED */
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley "bad algorithm", /*%< 69 DNS_R_BADALG */
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley "invalid use of a meta type", /*%< 70 DNS_R_METATYPE */
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley "CNAME and other data", /*%< 71 DNS_R_CNAMEANDOTHER */
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley "multiple RRs of singleton type", /*%< 72 DNS_R_SINGLETON */
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff "hint nxrrset", /*%< 73 DNS_R_HINTNXRRSET */
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence "no master file configured", /*%< 74 DNS_R_NOMASTERFILE */
a6733246eafeb43755ce6d7ec3627ac4209cbccbMark Andrews
1ccbfca64ae86ace521053773001cb995352f96fBob Halley "unknown protocol", /*%< 75 DNS_R_UNKNOWNPROTO */
1ccbfca64ae86ace521053773001cb995352f96fBob Halley "clocks are unsynchronized", /*%< 76 DNS_R_CLOCKSKEW */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "IXFR failed", /*%< 77 DNS_R_BADIXFR */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "not authoritative", /*%< 78 DNS_R_NOTAUTHORITATIVE */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "no valid KEY", /*%< 79 DNS_R_NOVALIDKEY */
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley "obsolete", /*%< 80 DNS_R_OBSOLETE */
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley "already frozen", /*%< 81 DNS_R_FROZEN */
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley "unknown flag", /*%< 82 DNS_R_UNKNOWNFLAG */
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley "expected a response", /*%< 83 DNS_R_EXPECTEDRESPONSE */
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley "no valid DS", /*%< 84 DNS_R_NOVALIDDS */
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley
1ccbfca64ae86ace521053773001cb995352f96fBob Halley "NS is an address", /*%< 85 DNS_R_NSISADDRESS */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "received FORMERR", /*%< 86 DNS_R_REMOTEFORMERR */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "truncated TCP response", /*%< 87 DNS_R_TRUNCATEDTCP */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "lame server detected", /*%< 88 DNS_R_LAME */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "unexpected RCODE", /*%< 89 DNS_R_UNEXPECTEDRCODE */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "unexpected OPCODE", /*%< 90 DNS_R_UNEXPECTEDOPCODE */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "chase DS servers", /*%< 91 DNS_R_CHASEDSSERVERS */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "empty name", /*%< 92 DNS_R_EMPTYNAME */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "empty wild", /*%< 93 DNS_R_EMPTYWILD */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "bad bitmap", /*%< 94 DNS_R_BADBITMAP */
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington "from wildcard", /*%< 95 DNS_R_FROMWILDCARD */
1ccbfca64ae86ace521053773001cb995352f96fBob Halley "bad owner name (check-names)", /*%< 96 DNS_R_BADOWNERNAME */
c03ce72a3b1bd639d5bc430ed37f791051125c56Andreas Gustafsson "bad name (check-names)", /*%< 97 DNS_R_BADNAME */
c03ce72a3b1bd639d5bc430ed37f791051125c56Andreas Gustafsson "dynamic zone", /*%< 98 DNS_R_DYNAMIC */
c03ce72a3b1bd639d5bc430ed37f791051125c56Andreas Gustafsson "unknown command", /*%< 99 DNS_R_UNKNOWNCOMMAND */
c03ce72a3b1bd639d5bc430ed37f791051125c56Andreas Gustafsson
419590499823ce15b5d2ad4fe71eaf04bd5a86c0Michael Graff "must-be-secure", /*%< 100 DNS_R_MUSTBESECURE */
1ccbfca64ae86ace521053773001cb995352f96fBob Halley "covering NSEC record returned", /*%< 101 DNS_R_COVERINGNSEC */
1ccbfca64ae86ace521053773001cb995352f96fBob Halley "MX is an address" /*%< 102 DNS_R_MXISADDRESS */
1ccbfca64ae86ace521053773001cb995352f96fBob Halley};
1ccbfca64ae86ace521053773001cb995352f96fBob Halley
1ccbfca64ae86ace521053773001cb995352f96fBob Halleystatic const char *rcode_text[DNS_R_NRCODERESULTS] = {
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley "NOERROR", /*%< 0 DNS_R_NOEROR */
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley "FORMERR", /*%< 1 DNS_R_FORMERR */
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley "SERVFAIL", /*%< 2 DNS_R_SERVFAIL */
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley "NXDOMAIN", /*%< 3 DNS_R_NXDOMAIN */
1ccbfca64ae86ace521053773001cb995352f96fBob Halley "NOTIMP", /*%< 4 DNS_R_NOTIMP */
2d63e8f8d2a8ef70e404182caf5b0d95dbcf2027Andreas Gustafsson
1ccbfca64ae86ace521053773001cb995352f96fBob Halley "REFUSED", /*%< 5 DNS_R_REFUSED */
1ccbfca64ae86ace521053773001cb995352f96fBob Halley "YXDOMAIN", /*%< 6 DNS_R_YXDOMAIN */
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley "YXRRSET", /*%< 7 DNS_R_YXRRSET */
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley "NXRRSET", /*%< 8 DNS_R_NXRRSET */
1ccbfca64ae86ace521053773001cb995352f96fBob Halley "NOTAUTH", /*%< 9 DNS_R_NOTAUTH */
1ccbfca64ae86ace521053773001cb995352f96fBob Halley
1ccbfca64ae86ace521053773001cb995352f96fBob Halley "NOTZONE", /*%< 10 DNS_R_NOTZONE */
1ccbfca64ae86ace521053773001cb995352f96fBob Halley "<rcode 11>", /*%< 11 has no macro */
1ccbfca64ae86ace521053773001cb995352f96fBob Halley "<rcode 12>", /*%< 12 has no macro */
1ccbfca64ae86ace521053773001cb995352f96fBob Halley "<rcode 13>", /*%< 13 has no macro */
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley "<rcode 14>", /*%< 14 has no macro */
1ccbfca64ae86ace521053773001cb995352f96fBob Halley
1ccbfca64ae86ace521053773001cb995352f96fBob Halley "<rcode 15>", /*%< 15 has no macro */
1ccbfca64ae86ace521053773001cb995352f96fBob Halley "BADVERS", /*%< 16 DNS_R_BADVERS */
1ccbfca64ae86ace521053773001cb995352f96fBob Halley};
1ccbfca64ae86ace521053773001cb995352f96fBob Halley
1ccbfca64ae86ace521053773001cb995352f96fBob Halley#define DNS_RESULT_RESULTSET 2
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley#define DNS_RESULT_RCODERESULTSET 3
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley
1ccbfca64ae86ace521053773001cb995352f96fBob Halleystatic isc_once_t once = ISC_ONCE_INIT;
1ccbfca64ae86ace521053773001cb995352f96fBob Halley
d549c3734869b48e740c64e80890bcb6f3ce672cJames Bristerstatic void
d549c3734869b48e740c64e80890bcb6f3ce672cJames Bristerinitialize_action(void) {
d549c3734869b48e740c64e80890bcb6f3ce672cJames Brister isc_result_t result;
d549c3734869b48e740c64e80890bcb6f3ce672cJames Brister
d549c3734869b48e740c64e80890bcb6f3ce672cJames Brister result = isc_result_register(ISC_RESULTCLASS_DNS, DNS_R_NRESULTS,
d549c3734869b48e740c64e80890bcb6f3ce672cJames Brister text, dns_msgcat, DNS_RESULT_RESULTSET);
d549c3734869b48e740c64e80890bcb6f3ce672cJames Brister if (result == ISC_R_SUCCESS)
d549c3734869b48e740c64e80890bcb6f3ce672cJames Brister result = isc_result_register(ISC_RESULTCLASS_DNSRCODE,
d549c3734869b48e740c64e80890bcb6f3ce672cJames Brister DNS_R_NRCODERESULTS,
1ccbfca64ae86ace521053773001cb995352f96fBob Halley rcode_text, dns_msgcat,
1ccbfca64ae86ace521053773001cb995352f96fBob Halley DNS_RESULT_RCODERESULTSET);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley if (result != ISC_R_SUCCESS)
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley UNEXPECTED_ERROR(__FILE__, __LINE__,
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley "isc_result_register() failed: %u", result);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley}
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence
1ccbfca64ae86ace521053773001cb995352f96fBob Halleystatic void
1ccbfca64ae86ace521053773001cb995352f96fBob Halleyinitialize(void) {
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley dns_lib_initmsgcat();
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley}
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley
1ccbfca64ae86ace521053773001cb995352f96fBob Halleyconst char *
1ccbfca64ae86ace521053773001cb995352f96fBob Halleydns_result_totext(isc_result_t result) {
1ccbfca64ae86ace521053773001cb995352f96fBob Halley initialize();
1ccbfca64ae86ace521053773001cb995352f96fBob Halley
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley return (isc_result_totext(result));
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley}
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halleyvoid
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrencedns_result_register(void) {
1ccbfca64ae86ace521053773001cb995352f96fBob Halley initialize();
1ccbfca64ae86ace521053773001cb995352f96fBob Halley}
a6733246eafeb43755ce6d7ec3627ac4209cbccbMark Andrews
a6733246eafeb43755ce6d7ec3627ac4209cbccbMark Andrewsdns_rcode_t
a6733246eafeb43755ce6d7ec3627ac4209cbccbMark Andrewsdns_result_torcode(isc_result_t result) {
a6733246eafeb43755ce6d7ec3627ac4209cbccbMark Andrews dns_rcode_t rcode = dns_rcode_servfail;
a6733246eafeb43755ce6d7ec3627ac4209cbccbMark Andrews
a6733246eafeb43755ce6d7ec3627ac4209cbccbMark Andrews if (DNS_RESULT_ISRCODE(result)) {
a6733246eafeb43755ce6d7ec3627ac4209cbccbMark Andrews /*
a6733246eafeb43755ce6d7ec3627ac4209cbccbMark Andrews * Rcodes can't be bigger than 12 bits, which is why we
a6733246eafeb43755ce6d7ec3627ac4209cbccbMark Andrews * AND with 0xFFF instead of 0xFFFF.
a6733246eafeb43755ce6d7ec3627ac4209cbccbMark Andrews */
a6733246eafeb43755ce6d7ec3627ac4209cbccbMark Andrews return ((dns_rcode_t)((result) & 0xFFF));
a6733246eafeb43755ce6d7ec3627ac4209cbccbMark Andrews }
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence /*
a6733246eafeb43755ce6d7ec3627ac4209cbccbMark Andrews * Try to supply an appropriate rcode.
a6733246eafeb43755ce6d7ec3627ac4209cbccbMark Andrews */
a6733246eafeb43755ce6d7ec3627ac4209cbccbMark Andrews switch (result) {
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley case ISC_R_SUCCESS:
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley rcode = dns_rcode_noerror;
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley break;
1ccbfca64ae86ace521053773001cb995352f96fBob Halley case ISC_R_BADBASE64:
1ccbfca64ae86ace521053773001cb995352f96fBob Halley case ISC_R_NOSPACE:
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews case ISC_R_RANGE:
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews case ISC_R_UNEXPECTEDEND:
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews case DNS_R_BADAAAA:
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews /* case DNS_R_BADBITSTRING: deprecated */
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews case DNS_R_BADCKSUM:
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews case DNS_R_BADCLASS:
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews case DNS_R_BADLABELTYPE:
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews case DNS_R_BADPOINTER:
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews case DNS_R_BADTTL:
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews case DNS_R_BADZONE:
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews /* case DNS_R_BITSTRINGTOOLONG: deprecated */
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews case DNS_R_EXTRADATA:
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews case DNS_R_LABELTOOLONG:
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews case DNS_R_NOREDATA:
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews case DNS_R_SYNTAX:
b3e2e7c4d6b5c5ee90ba5bb775d635834dccec81Bob Halley case DNS_R_TEXTTOOLONG:
b3e2e7c4d6b5c5ee90ba5bb775d635834dccec81Bob Halley case DNS_R_TOOMANYHOPS:
b3e2e7c4d6b5c5ee90ba5bb775d635834dccec81Bob Halley case DNS_R_TSIGERRORSET:
b3e2e7c4d6b5c5ee90ba5bb775d635834dccec81Bob Halley case DNS_R_UNKNOWN:
b3e2e7c4d6b5c5ee90ba5bb775d635834dccec81Bob Halley rcode = dns_rcode_formerr;
b3e2e7c4d6b5c5ee90ba5bb775d635834dccec81Bob Halley break;
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence case DNS_R_DISALLOWED:
b3e2e7c4d6b5c5ee90ba5bb775d635834dccec81Bob Halley rcode = dns_rcode_refused;
b3e2e7c4d6b5c5ee90ba5bb775d635834dccec81Bob Halley break;
b3e2e7c4d6b5c5ee90ba5bb775d635834dccec81Bob Halley case DNS_R_TSIGVERIFYFAILURE:
b3e2e7c4d6b5c5ee90ba5bb775d635834dccec81Bob Halley case DNS_R_CLOCKSKEW:
b3e2e7c4d6b5c5ee90ba5bb775d635834dccec81Bob Halley rcode = dns_rcode_notauth;
b3e2e7c4d6b5c5ee90ba5bb775d635834dccec81Bob Halley break;
fe12eb4fc27f49c6b3e42b1d7a6b40310e41e6dfBrian Wellington default:
fe12eb4fc27f49c6b3e42b1d7a6b40310e41e6dfBrian Wellington rcode = dns_rcode_servfail;
fe12eb4fc27f49c6b3e42b1d7a6b40310e41e6dfBrian Wellington }
fe12eb4fc27f49c6b3e42b1d7a6b40310e41e6dfBrian Wellington
fe12eb4fc27f49c6b3e42b1d7a6b40310e41e6dfBrian Wellington return (rcode);
fe12eb4fc27f49c6b3e42b1d7a6b40310e41e6dfBrian Wellington}
fe12eb4fc27f49c6b3e42b1d7a6b40310e41e6dfBrian Wellington