rcode.c revision b01d422daf27d22015999cb9d4441c8aa82d1ad0
/*
* Copyright (C) 2004-2011 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1998-2003 Internet Software Consortium.
*
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: rcode.c,v 1.18 2011/02/21 23:47:45 tbox Exp $ */
#include <config.h>
#include <ctype.h>
#include <isc/parseint.h>
#include <dns/keyflags.h>
#include <dns/keyvalues.h>
#include <dns/rdataclass.h>
#include <dns/secproto.h>
#define RETERR(x) \
do { \
isc_result_t _r = (x); \
if (_r != ISC_R_SUCCESS) \
return (_r); \
} while (0)
#define RCODENAMES \
/* standard rcodes */ \
{ dns_rcode_noerror, "NOERROR", 0}, \
{ dns_rcode_formerr, "FORMERR", 0}, \
{ dns_rcode_servfail, "SERVFAIL", 0}, \
{ dns_rcode_nxdomain, "NXDOMAIN", 0}, \
{ dns_rcode_notimp, "NOTIMP", 0}, \
{ dns_rcode_refused, "REFUSED", 0}, \
{ dns_rcode_yxdomain, "YXDOMAIN", 0}, \
{ dns_rcode_yxrrset, "YXRRSET", 0}, \
{ dns_rcode_nxrrset, "NXRRSET", 0}, \
{ dns_rcode_notauth, "NOTAUTH", 0}, \
{ dns_rcode_notzone, "NOTZONE", 0},
#define ERCODENAMES \
/* extended rcodes */ \
{ dns_rcode_badvers, "BADVERS", 0}, \
{ 0, NULL, 0 }
#define TSIGRCODENAMES \
/* extended rcodes */ \
{ dns_tsigerror_badsig, "BADSIG", 0}, \
{ dns_tsigerror_badkey, "BADKEY", 0}, \
{ dns_tsigerror_badtime, "BADTIME", 0}, \
{ dns_tsigerror_badmode, "BADMODE", 0}, \
{ dns_tsigerror_badname, "BADNAME", 0}, \
{ dns_tsigerror_badalg, "BADALG", 0}, \
{ dns_tsigerror_badtrunc, "BADTRUNC", 0}, \
{ 0, NULL, 0 }
/* RFC4398 section 2.1 */
#define CERTNAMES \
{ 1, "PKIX", 0}, \
{ 2, "SPKI", 0}, \
{ 3, "PGP", 0}, \
{ 4, "IPKIX", 0}, \
{ 5, "ISPKI", 0}, \
{ 6, "IPGP", 0}, \
{ 7, "ACPKIX", 0}, \
{ 8, "IACPKIX", 0}, \
{ 253, "URI", 0}, \
{ 254, "OID", 0}, \
{ 0, NULL, 0}
/* RFC2535 section 7, RFC3110 */
#define SECALGNAMES \
{ DNS_KEYALG_RSAMD5, "RSAMD5", 0 }, \
{ DNS_KEYALG_RSAMD5, "RSA", 0 }, \
{ DNS_KEYALG_DH, "DH", 0 }, \
{ DNS_KEYALG_DSA, "DSA", 0 }, \
{ DNS_KEYALG_NSEC3DSA, "NSEC3DSA", 0 }, \
{ DNS_KEYALG_ECC, "ECC", 0 }, \
{ DNS_KEYALG_RSASHA1, "RSASHA1", 0 }, \
{ DNS_KEYALG_NSEC3RSASHA1, "NSEC3RSASHA1", 0 }, \
{ DNS_KEYALG_RSASHA256, "RSASHA256", 0 }, \
{ DNS_KEYALG_RSASHA512, "RSASHA512", 0 }, \
{ DNS_KEYALG_ECCGOST, "ECCGOST", 0 }, \
{ DNS_KEYALG_INDIRECT, "INDIRECT", 0 }, \
{ DNS_KEYALG_PRIVATEDNS, "PRIVATEDNS", 0 }, \
{ DNS_KEYALG_PRIVATEOID, "PRIVATEOID", 0 }, \
{ 0, NULL, 0}
/* RFC2535 section 7.1 */
#define SECPROTONAMES \
{ 0, "NONE", 0 }, \
{ 1, "TLS", 0 }, \
{ 2, "EMAIL", 0 }, \
{ 3, "DNSSEC", 0 }, \
{ 4, "IPSEC", 0 }, \
{ 255, "ALL", 0 }, \
{ 0, NULL, 0}
#define HASHALGNAMES \
{ 1, "SHA-1", 0 }, \
{ 0, NULL, 0 }
struct tbl {
unsigned int value;
const char *name;
int flags;
};
static struct keyflag {
const char *name;
unsigned int value;
unsigned int mask;
} keyflags[] = {
{ "NOCONF", 0x4000, 0xC000 },
{ "NOAUTH", 0x8000, 0xC000 },
{ "NOKEY", 0xC000, 0xC000 },
{ "FLAG2", 0x2000, 0x2000 },
{ "EXTEND", 0x1000, 0x1000 },
{ "FLAG4", 0x0800, 0x0800 },
{ "FLAG5", 0x0400, 0x0400 },
{ "USER", 0x0000, 0x0300 },
{ "ZONE", 0x0100, 0x0300 },
{ "HOST", 0x0200, 0x0300 },
{ "NTYP3", 0x0300, 0x0300 },
{ "FLAG8", 0x0080, 0x0080 },
{ "FLAG9", 0x0040, 0x0040 },
{ "FLAG10", 0x0020, 0x0020 },
{ "FLAG11", 0x0010, 0x0010 },
{ "SIG0", 0x0000, 0x000F },
{ "SIG1", 0x0001, 0x000F },
{ "SIG2", 0x0002, 0x000F },
{ "SIG3", 0x0003, 0x000F },
{ "SIG4", 0x0004, 0x000F },
{ "SIG5", 0x0005, 0x000F },
{ "SIG6", 0x0006, 0x000F },
{ "SIG7", 0x0007, 0x000F },
{ "SIG8", 0x0008, 0x000F },
{ "SIG9", 0x0009, 0x000F },
{ "SIG10", 0x000A, 0x000F },
{ "SIG11", 0x000B, 0x000F },
{ "SIG12", 0x000C, 0x000F },
{ "SIG13", 0x000D, 0x000F },
{ "SIG14", 0x000E, 0x000F },
{ "SIG15", 0x000F, 0x000F },
{ NULL, 0, 0 }
};
static isc_result_t
unsigned int l;
return (ISC_R_NOSPACE);
isc_buffer_add(target, l);
return (ISC_R_SUCCESS);
}
static isc_result_t
{
isc_uint32_t n;
char buffer[NUMBERSIZE];
return (ISC_R_BADNUMBER);
/*
* We have a potential number. Try to parse it with
* isc_parse_uint32(). isc_parse_uint32() requires
* null termination, so we must make a copy.
*/
if (result != ISC_R_SUCCESS)
return (result);
if (n > max)
return (ISC_R_RANGE);
*valuep = n;
return (ISC_R_SUCCESS);
}
static isc_result_t
{
int i;
if (result != ISC_R_BADNUMBER)
return (result);
unsigned int n;
return (ISC_R_SUCCESS);
}
}
return (DNS_R_UNKNOWN);
}
static isc_result_t
{
int i = 0;
char buf[sizeof("4294967296")];
}
i++;
}
}
unsigned int value;
return (ISC_R_SUCCESS);
}
}
unsigned int value;
return (ISC_R_SUCCESS);
}
}
unsigned int value;
return (ISC_R_SUCCESS);
}
}
unsigned int value;
return (ISC_R_SUCCESS);
}
}
void
isc_buffer_t b;
isc_region_t r;
isc_buffer_usedregion(&b, &r);
if (result != ISC_R_SUCCESS)
r.base[0] = 0;
}
unsigned int value;
return (ISC_R_SUCCESS);
}
}
unsigned int value;
return (ISC_R_SUCCESS);
}
{
if (result == ISC_R_SUCCESS) {
return (ISC_R_SUCCESS);
}
if (result != ISC_R_BADNUMBER)
return (result);
struct keyflag *p;
unsigned int len;
else
break;
}
return (DNS_R_UNKNOWNFLAG);
#ifdef notyet
warn("overlapping key flags");
#endif
text++; /* Skip "|" */
}
return (ISC_R_SUCCESS);
}
/*
* This uses lots of hard coded values, but how often do we actually
* add classes?
*/
return (ISC_R_SUCCESS); \
}
case 'a':
break;
case 'c':
/*
* RFC1035 says the mnemonic for the CHAOS class is CH,
* but historical BIND practice is to call it CHAOS.
* We will accept both forms, but only generate CH.
*/
char buf[sizeof("65000")];
char *endp;
unsigned int val;
return (ISC_R_SUCCESS);
}
}
break;
case 'h':
break;
case 'i':
break;
case 'n':
break;
case 'r':
break;
}
return (DNS_R_UNKNOWN);
}
char buf[sizeof("CLASS65535")];
switch (rdclass) {
case dns_rdataclass_any:
case dns_rdataclass_chaos:
case dns_rdataclass_hs:
case dns_rdataclass_in:
case dns_rdataclass_none:
case dns_rdataclass_reserved0:
default:
}
}
void
{
if (size == 0U)
return;
/*
* Null terminate.
*/
if (result == ISC_R_SUCCESS) {
isc_buffer_putuint8(&buf, 0);
else
}
if (result != ISC_R_SUCCESS)
}