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:
@@ -15,7 +15,7 @@
|
|||||||
* SOFTWARE.
|
* 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>
|
#include <config.h>
|
||||||
|
|
||||||
@@ -560,6 +560,9 @@ main(int argc, char **argv) {
|
|||||||
|
|
||||||
#define PRINT_COMMA(x) (x == 255 ? "" : ",")
|
#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("\ntypedef struct {\n");
|
||||||
printf("\tchar *name;\n");
|
printf("\tchar *name;\n");
|
||||||
printf("\tunsigned int flags;\n");
|
printf("\tunsigned int flags;\n");
|
||||||
@@ -613,13 +616,13 @@ main(int argc, char **argv) {
|
|||||||
break;
|
break;
|
||||||
case 251:
|
case 251:
|
||||||
printf("\t{ \"IXFR\", "
|
printf("\t{ \"IXFR\", "
|
||||||
"DNS_RDATATYPEATTR_META }%s\n",
|
METANOTQUESTION " }%s\n",
|
||||||
PRINT_COMMA(i));
|
PRINT_COMMA(i));
|
||||||
special = 1;
|
special = 1;
|
||||||
break;
|
break;
|
||||||
case 252:
|
case 252:
|
||||||
printf("\t{ \"AXFR\", "
|
printf("\t{ \"AXFR\", "
|
||||||
"DNS_RDATATYPEATTR_META }%s\n",
|
METANOTQUESTION " }%s\n",
|
||||||
PRINT_COMMA(i));
|
PRINT_COMMA(i));
|
||||||
special = 1;
|
special = 1;
|
||||||
break;
|
break;
|
||||||
@@ -637,7 +640,7 @@ main(int argc, char **argv) {
|
|||||||
break;
|
break;
|
||||||
case 255:
|
case 255:
|
||||||
printf("\t{ \"ANY\", "
|
printf("\t{ \"ANY\", "
|
||||||
"DNS_RDATATYPEATTR_META }%s\n",
|
METAQUESTIONONLY " }%s\n",
|
||||||
PRINT_COMMA(i));
|
PRINT_COMMA(i));
|
||||||
special = 1;
|
special = 1;
|
||||||
break;
|
break;
|
||||||
|
@@ -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.
|
* 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
|
unsigned int
|
||||||
dns_rdatatype_attributes(dns_rdatatype_t rdtype);
|
dns_rdatatype_attributes(dns_rdatatype_t rdtype);
|
||||||
/*
|
/*
|
||||||
@@ -551,19 +573,23 @@ dns_rdatatype_attributes(dns_rdatatype_t rdtype);
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* only one may exist for a name */
|
/* only one may exist for a name */
|
||||||
#define DNS_RDATATYPEATTR_SINGLETON 0x00000001U
|
#define DNS_RDATATYPEATTR_SINGLETON 0x00000001U
|
||||||
/* requires no other data be present */
|
/* requires no other data be present */
|
||||||
#define DNS_RDATATYPEATTR_EXCLUSIVE 0x00000002U
|
#define DNS_RDATATYPEATTR_EXCLUSIVE 0x00000002U
|
||||||
/* Is a meta type */
|
/* Is a meta type */
|
||||||
#define DNS_RDATATYPEATTR_META 0x00000004U
|
#define DNS_RDATATYPEATTR_META 0x00000004U
|
||||||
/* Is a DNSSEC type, like SIG or NXT */
|
/* Is a DNSSEC type, like SIG or NXT */
|
||||||
#define DNS_RDATATYPEATTR_DNSSEC 0x00000008U
|
#define DNS_RDATATYPEATTR_DNSSEC 0x00000008U
|
||||||
/* Is a zone cut authority type XXXMLG */
|
/* Is a zone cut authority type */
|
||||||
#define DNS_RDATATYPEATTR_ZONECUTAUTH 0x00000010U
|
#define DNS_RDATATYPEATTR_ZONECUTAUTH 0x00000010U
|
||||||
/* Is reserved (unusable) */
|
/* Is reserved (unusable) */
|
||||||
#define DNS_RDATATYPEATTR_RESERVED 0x00000020U
|
#define DNS_RDATATYPEATTR_RESERVED 0x00000020U
|
||||||
/* Is an unknown type */
|
/* Is an unknown type */
|
||||||
#define DNS_RDATATYPEATTR_UNKNOWN 0x00000040U
|
#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_rdatatype_t
|
||||||
dns_rdata_covers(dns_rdata_t *rdata);
|
dns_rdata_covers(dns_rdata_t *rdata);
|
||||||
|
@@ -890,6 +890,15 @@ getquestions(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx)
|
|||||||
result = DNS_R_FORMERR;
|
result = DNS_R_FORMERR;
|
||||||
goto cleanup;
|
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.
|
* 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)
|
skip_type_search)
|
||||||
result = ISC_R_NOTFOUND;
|
result = ISC_R_NOTFOUND;
|
||||||
else {
|
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;
|
rdataset = NULL;
|
||||||
result = dns_message_findtype(name, rdtype, covers,
|
result = dns_message_findtype(name, rdtype, covers,
|
||||||
&rdataset);
|
&rdataset);
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* SOFTWARE.
|
* 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>
|
#include <config.h>
|
||||||
|
|
||||||
@@ -1553,25 +1553,13 @@ dns_rdata_covers(dns_rdata_t *rdata)
|
|||||||
return (covers_sig(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
|
isc_boolean_t
|
||||||
dns_rdatatype_ismeta(dns_rdatatype_t type)
|
dns_rdatatype_ismeta(dns_rdatatype_t type)
|
||||||
{
|
{
|
||||||
if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_META) != 0)
|
if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_META) != 0)
|
||||||
return (ISC_TRUE);
|
return (ISC_TRUE);
|
||||||
return (ISC_FALSE);
|
return (ISC_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_boolean_t
|
isc_boolean_t
|
||||||
dns_rdatatype_issingleton(dns_rdatatype_t type)
|
dns_rdatatype_issingleton(dns_rdatatype_t type)
|
||||||
@@ -1580,12 +1568,39 @@ dns_rdatatype_issingleton(dns_rdatatype_t type)
|
|||||||
!= 0)
|
!= 0)
|
||||||
return (ISC_TRUE);
|
return (ISC_TRUE);
|
||||||
return (ISC_FALSE);
|
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
|
isc_boolean_t
|
||||||
dns_rdataclass_ismeta(dns_rdataclass_t rdclass)
|
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
|
isc_boolean_t
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* SOFTWARE.
|
* 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 */
|
/* Reviewed: Thu Mar 16 13:39:43 PST 2000 by gson */
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#include <isc/str.h>
|
#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
|
static inline isc_result_t
|
||||||
fromtext_any_tsig(dns_rdataclass_t rdclass, dns_rdatatype_t type,
|
fromtext_any_tsig(dns_rdataclass_t rdclass, dns_rdatatype_t type,
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* SOFTWARE.
|
* 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 */
|
/* Reviewed: Thu Mar 16 14:06:44 PST 2000 by gson */
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
#ifndef RDATA_GENERIC_OPT_41_C
|
#ifndef RDATA_GENERIC_OPT_41_C
|
||||||
#define 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
|
static inline isc_result_t
|
||||||
fromtext_opt(dns_rdataclass_t rdclass, dns_rdatatype_t type,
|
fromtext_opt(dns_rdataclass_t rdclass, dns_rdatatype_t type,
|
||||||
|
Reference in New Issue
Block a user