2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

Add functions to check that a type is only or is not allowed in a question section

This commit is contained in:
Michael Graff
2000-04-14 20:13:49 +00:00
parent 3bb3b7ac46
commit 7ec579cd5d
6 changed files with 91 additions and 29 deletions

View File

@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: gen.c,v 1.33 2000/04/07 03:54:03 explorer Exp $ */
/* $Id: gen.c,v 1.34 2000/04/14 20:13:43 explorer Exp $ */
#include <config.h>
@@ -560,6 +560,9 @@ main(int argc, char **argv) {
#define PRINT_COMMA(x) (x == 255 ? "" : ",")
#define METANOTQUESTION "DNS_RDATATYPEATTR_META | DNS_RDATATYPEATTR_NOTQUESTION"
#define METAQUESTIONONLY "DNS_RDATATYPEATTR_META | DNS_RDATATYPEATTR_QUESTIONONLY"
printf("\ntypedef struct {\n");
printf("\tchar *name;\n");
printf("\tunsigned int flags;\n");
@@ -613,13 +616,13 @@ main(int argc, char **argv) {
break;
case 251:
printf("\t{ \"IXFR\", "
"DNS_RDATATYPEATTR_META }%s\n",
METANOTQUESTION " }%s\n",
PRINT_COMMA(i));
special = 1;
break;
case 252:
printf("\t{ \"AXFR\", "
"DNS_RDATATYPEATTR_META }%s\n",
METANOTQUESTION " }%s\n",
PRINT_COMMA(i));
special = 1;
break;
@@ -637,7 +640,7 @@ main(int argc, char **argv) {
break;
case 255:
printf("\t{ \"ANY\", "
"DNS_RDATATYPEATTR_META }%s\n",
METAQUESTIONONLY " }%s\n",
PRINT_COMMA(i));
special = 1;
break;

View File

@@ -538,6 +538,28 @@ dns_rdata_digest(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg);
* Many other results are possible if not successful.
*/
isc_boolean_t
dns_rdatatype_questiononly(dns_rdatatype_t type);
/*
* Return true iff rdata of type 'type' can only appear in the question
* section of a properly formatted message.
*
* Requires:
* 'type' is a valid rdata type.
*
*/
isc_boolean_t
dns_rdatatype_notquestion(dns_rdatatype_t type);
/*
* Return true iff rdata of type 'type' can not appear in the question
* section of a properly formatted message.
*
* Requires:
* 'type' is a valid rdata type.
*
*/
unsigned int
dns_rdatatype_attributes(dns_rdatatype_t rdtype);
/*
@@ -558,12 +580,16 @@ dns_rdatatype_attributes(dns_rdatatype_t rdtype);
#define DNS_RDATATYPEATTR_META 0x00000004U
/* Is a DNSSEC type, like SIG or NXT */
#define DNS_RDATATYPEATTR_DNSSEC 0x00000008U
/* Is a zone cut authority type XXXMLG */
/* Is a zone cut authority type */
#define DNS_RDATATYPEATTR_ZONECUTAUTH 0x00000010U
/* Is reserved (unusable) */
#define DNS_RDATATYPEATTR_RESERVED 0x00000020U
/* Is an unknown type */
#define DNS_RDATATYPEATTR_UNKNOWN 0x00000040U
/* Is META, and can only be in a question section */
#define DNS_RDATATYPEATTR_QUESTIONONLY 0x00000080U
/* is META, and can NOT be in a question section */
#define DNS_RDATATYPEATTR_NOTQUESTION 0x00000100U
dns_rdatatype_t
dns_rdata_covers(dns_rdata_t *rdata);

View File

@@ -891,6 +891,15 @@ getquestions(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx)
goto cleanup;
}
/*
* If this is a type that cannot occur in a question section,
* return failure.
*/
if (dns_rdatatype_notquestion(rdtype)) {
result = DNS_R_FORMERR;
goto cleanup;
}
/*
* Can't ask the same question twice.
*/
@@ -1186,6 +1195,15 @@ getsection(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx,
skip_type_search)
result = ISC_R_NOTFOUND;
else {
/*
* If this is a type that can only occur in
* the question section, fail.
*/
if (dns_rdatatype_questiononly(rdtype)) {
result = DNS_R_FORMERR;
goto cleanup;
}
rdataset = NULL;
result = dns_message_findtype(name, rdtype, covers,
&rdataset);

View File

@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: rdata.c,v 1.76 2000/04/14 18:36:00 explorer Exp $ */
/* $Id: rdata.c,v 1.77 2000/04/14 20:13:45 explorer Exp $ */
#include <config.h>
@@ -1553,18 +1553,6 @@ dns_rdata_covers(dns_rdata_t *rdata)
return (covers_sig(rdata));
}
static isc_boolean_t
ismeta(unsigned int code, struct tbl *table)
{
struct tbl *t;
REQUIRE(code < 65536);
for (t = table; t->name != NULL; t++) {
if (code == t->value)
return ((t->flags & META) ? ISC_TRUE : ISC_FALSE);
}
return (ISC_FALSE); /* Unknown, assume non-meta. */
}
isc_boolean_t
dns_rdatatype_ismeta(dns_rdatatype_t type)
{
@@ -1582,10 +1570,37 @@ dns_rdatatype_issingleton(dns_rdatatype_t type)
return (ISC_FALSE);
}
isc_boolean_t
dns_rdatatype_notquestion(dns_rdatatype_t type)
{
if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_NOTQUESTION)
!= 0)
return (ISC_TRUE);
return (ISC_FALSE);
}
isc_boolean_t
dns_rdatatype_questiononly(dns_rdatatype_t type)
{
if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_QUESTIONONLY)
!= 0)
return (ISC_TRUE);
return (ISC_FALSE);
}
isc_boolean_t
dns_rdataclass_ismeta(dns_rdataclass_t rdclass)
{
return (ismeta(rdclass, classes));
struct tbl *t;
REQUIRE(rdclass < 65536);
for (t = classes; t->name != NULL; t++) {
if (rdclass == t->value)
return ((t->flags & META) ? ISC_TRUE : ISC_FALSE);
}
return (ISC_FALSE); /* assume it is not a meta class */
}
isc_boolean_t

View File

@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: tsig_250.c,v 1.27 2000/04/07 03:54:06 explorer Exp $ */
/* $Id: tsig_250.c,v 1.28 2000/04/14 20:13:48 explorer Exp $ */
/* Reviewed: Thu Mar 16 13:39:43 PST 2000 by gson */
@@ -26,7 +26,7 @@
#include <isc/str.h>
#define RRTYPE_TSIG_ATTRIBUTES (DNS_RDATATYPEATTR_META)
#define RRTYPE_TSIG_ATTRIBUTES (DNS_RDATATYPEATTR_META | DNS_RDATATYPEATTR_NOTQUESTION)
static inline isc_result_t
fromtext_any_tsig(dns_rdataclass_t rdclass, dns_rdatatype_t type,

View File

@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: opt_41.c,v 1.7 2000/04/07 03:54:28 explorer Exp $ */
/* $Id: opt_41.c,v 1.8 2000/04/14 20:13:49 explorer Exp $ */
/* Reviewed: Thu Mar 16 14:06:44 PST 2000 by gson */
@@ -24,7 +24,7 @@
#ifndef RDATA_GENERIC_OPT_41_C
#define RDATA_GENERIC_OPT_41_C
#define RRTYPE_OPT_ATTRIBUTES (DNS_RDATATYPEATTR_SINGLETON)
#define RRTYPE_OPT_ATTRIBUTES (DNS_RDATATYPEATTR_SINGLETON | DNS_RDATATYPEATTR_META | DNS_RDATATYPEATTR_NOTQUESTION)
static inline isc_result_t
fromtext_opt(dns_rdataclass_t rdclass, dns_rdatatype_t type,