bind9/lib/dns/result.c

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

122 lines
2.9 KiB
C
Raw Normal View History

1998-12-12 15:48:14 -05:00
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* SPDX-License-Identifier: MPL-2.0
*
* 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 https://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
1998-12-12 15:48:14 -05:00
*/
1998-12-03 21:27:01 -05:00
/*! \file */
2000-06-22 18:00:42 -04:00
1999-06-18 18:35:18 -04:00
#include <isc/once.h>
#include <isc/result.h>
2000-04-27 21:12:23 -04:00
#include <isc/util.h>
1999-06-23 18:28:27 -04:00
#include <dns/result.h>
1998-12-03 21:27:01 -05:00
1999-07-23 20:59:26 -04:00
dns_rcode_t
2020-02-13 17:44:37 -05:00
dns_result_torcode(isc_result_t result) {
/* Try to supply an appropriate rcode. */
1999-07-23 20:59:26 -04:00
switch (result) {
case DNS_R_NOERROR:
case ISC_R_SUCCESS:
return (dns_rcode_noerror);
case DNS_R_FORMERR:
2000-05-15 17:14:38 -04:00
case ISC_R_BADBASE64:
case ISC_R_RANGE:
1999-07-23 20:59:26 -04:00
case ISC_R_UNEXPECTEDEND:
2000-05-15 17:14:38 -04:00
case DNS_R_BADAAAA:
/* case DNS_R_BADBITSTRING: deprecated */
1999-07-23 20:59:26 -04:00
case DNS_R_BADCKSUM:
case DNS_R_BADCLASS:
2000-05-15 17:14:38 -04:00
case DNS_R_BADLABELTYPE:
case DNS_R_BADPOINTER:
1999-07-23 20:59:26 -04:00
case DNS_R_BADTTL:
case DNS_R_BADZONE:
/* case DNS_R_BITSTRINGTOOLONG: deprecated */
2000-05-15 17:14:38 -04:00
case DNS_R_EXTRADATA:
case DNS_R_LABELTOOLONG:
case DNS_R_NOREDATA:
case DNS_R_SYNTAX:
case DNS_R_TEXTTOOLONG:
case DNS_R_TOOMANYHOPS:
1999-08-20 13:02:15 -04:00
case DNS_R_TSIGERRORSET:
2000-05-15 17:14:38 -04:00
case DNS_R_UNKNOWN:
case DNS_R_NAMETOOLONG:
case DNS_R_OPTERR:
return (dns_rcode_formerr);
case DNS_R_SERVFAIL:
return (dns_rcode_servfail);
case DNS_R_NXDOMAIN:
return (dns_rcode_nxdomain);
case DNS_R_NOTIMP:
return (dns_rcode_notimp);
case DNS_R_REFUSED:
1999-07-23 20:59:26 -04:00
case DNS_R_DISALLOWED:
return (dns_rcode_refused);
case DNS_R_YXDOMAIN:
return (dns_rcode_yxdomain);
case DNS_R_YXRRSET:
return (dns_rcode_yxrrset);
case DNS_R_NXRRSET:
return (dns_rcode_nxrrset);
case DNS_R_NOTAUTH:
1999-08-20 13:02:15 -04:00
case DNS_R_TSIGVERIFYFAILURE:
case DNS_R_CLOCKSKEW:
return (dns_rcode_notauth);
case DNS_R_NOTZONE:
return (dns_rcode_notzone);
case DNS_R_RCODE11:
case DNS_R_RCODE12:
case DNS_R_RCODE13:
case DNS_R_RCODE14:
case DNS_R_RCODE15:
return (result - DNS_R_NOERROR);
case DNS_R_BADVERS:
return (dns_rcode_badvers);
case DNS_R_BADCOOKIE:
return (dns_rcode_badcookie);
1999-07-23 20:59:26 -04:00
default:
return (dns_rcode_servfail);
1999-07-23 20:59:26 -04:00
}
}
isc_result_t
dns_result_fromrcode(dns_rcode_t rcode) {
switch (rcode) {
case dns_rcode_noerror:
return (DNS_R_NOERROR);
case dns_rcode_formerr:
return (DNS_R_FORMERR);
case dns_rcode_servfail:
return (DNS_R_SERVFAIL);
case dns_rcode_nxdomain:
return (DNS_R_NXDOMAIN);
case dns_rcode_notimp:
return (DNS_R_NOTIMP);
case dns_rcode_refused:
return (DNS_R_REFUSED);
case dns_rcode_yxdomain:
return (DNS_R_YXDOMAIN);
case dns_rcode_yxrrset:
return (DNS_R_YXRRSET);
case dns_rcode_nxrrset:
return (DNS_R_NXRRSET);
case dns_rcode_notauth:
return (DNS_R_NOTAUTH);
case dns_rcode_notzone:
return (DNS_R_NOTZONE);
case dns_rcode_badvers:
return (DNS_R_BADVERS);
case dns_rcode_badcookie:
return (DNS_R_BADCOOKIE);
default:
return (DNS_R_SERVFAIL);
}
}