mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 14:35:26 +00:00
gen to generate dns_rdata{type,class}_{type,class}
dns_rcode_{to,from}text() TKEY was missing the Algorithm
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: gen.c,v 1.12 1999/02/02 22:34:20 marka Exp $ */
|
/* $Id: gen.c,v 1.13 1999/02/04 06:38:41 marka Exp $ */
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
@@ -430,7 +430,7 @@ main(int argc, char **argv) {
|
|||||||
lasttype = 0;
|
lasttype = 0;
|
||||||
for (tt = types; tt != NULL ; tt = tt->next)
|
for (tt = types; tt != NULL ; tt = tt->next)
|
||||||
if (tt->type != lasttype)
|
if (tt->type != lasttype)
|
||||||
fprintf(stdout, "\t ns_t_%s = %d,%s\n",
|
fprintf(stdout, "\t dns_rdatatype_%s = %d,%s\n",
|
||||||
funname(tt->typename, buf1),
|
funname(tt->typename, buf1),
|
||||||
lasttype = tt->type,
|
lasttype = tt->type,
|
||||||
tt->next != NULL ? " \\" : "");
|
tt->next != NULL ? " \\" : "");
|
||||||
@@ -441,7 +441,7 @@ main(int argc, char **argv) {
|
|||||||
classes != NULL ? " \\" : "");
|
classes != NULL ? " \\" : "");
|
||||||
|
|
||||||
for (cc = classes; cc != NULL; cc = cc->next)
|
for (cc = classes; cc != NULL; cc = cc->next)
|
||||||
fprintf(stdout, "\t ns_c_%s = %d,%s\n",
|
fprintf(stdout, "\t dns_rdataclass_%s = %d,%s\n",
|
||||||
funname(cc->classname, buf1),
|
funname(cc->classname, buf1),
|
||||||
cc->class,
|
cc->class,
|
||||||
cc->next != NULL ? " \\" : "");
|
cc->next != NULL ? " \\" : "");
|
||||||
|
55
lib/dns/include/dns/rcode.h
Normal file
55
lib/dns/include/dns/rcode.h
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 1998, 1999 Internet Software Consortium.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||||
|
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||||
|
* CONSORTIUM 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DNS_RCODE_H
|
||||||
|
#define DNS_RCODE_H 1
|
||||||
|
|
||||||
|
#include <dns/types.h>
|
||||||
|
|
||||||
|
dns_result_t dns_rcode_fromtext(dns_rcode_t *rcodep, isc_textregion_t *source);
|
||||||
|
/*
|
||||||
|
* Convert the text 'source' refers to into a DNS error value.
|
||||||
|
*
|
||||||
|
* Requires:
|
||||||
|
* 'rcodep' is a valid pointer.
|
||||||
|
*
|
||||||
|
* 'source' is a valid text region.
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* DNS_R_SUCCESS on success
|
||||||
|
* DNS_R_UNKNOWN type is unknown
|
||||||
|
*/
|
||||||
|
|
||||||
|
dns_result_t dns_rcode_totext(dns_rcode_t rcode, isc_buffer_t *target);
|
||||||
|
/*
|
||||||
|
* Put a textual representation of error 'rcode' into 'target'.
|
||||||
|
*
|
||||||
|
* Requires:
|
||||||
|
* 'rcode' is a valid rcode.
|
||||||
|
*
|
||||||
|
* 'target' is a valid text buffer.
|
||||||
|
*
|
||||||
|
* Ensures:
|
||||||
|
* If the result is success:
|
||||||
|
* The used space in 'target' is updated.
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* DNS_R_SUCCESS on success
|
||||||
|
* DNS_R_NOSPACE target buffer is too small
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif /* DNS_RCODE_H */
|
@@ -39,8 +39,8 @@ typedef void dns_dbversion_t;
|
|||||||
typedef unsigned char dns_offsets_t[128];
|
typedef unsigned char dns_offsets_t[128];
|
||||||
typedef struct dns_compress dns_compress_t;
|
typedef struct dns_compress dns_compress_t;
|
||||||
typedef struct dns_decompress dns_decompress_t;
|
typedef struct dns_decompress dns_decompress_t;
|
||||||
typedef isc_uint16_t dns_rdataclass_t;
|
/* typedef isc_uint16_t dns_rdataclass_t; */
|
||||||
typedef isc_uint16_t dns_rdatatype_t;
|
/* typedef isc_uint16_t dns_rdatatype_t; */
|
||||||
typedef isc_uint32_t dns_ttl_t;
|
typedef isc_uint32_t dns_ttl_t;
|
||||||
typedef struct dns_rdata dns_rdata_t;
|
typedef struct dns_rdata dns_rdata_t;
|
||||||
typedef struct dns_rdatalist dns_rdatalist_t;
|
typedef struct dns_rdatalist dns_rdatalist_t;
|
||||||
@@ -65,17 +65,37 @@ typedef enum {
|
|||||||
} dns_addmode_t;
|
} dns_addmode_t;
|
||||||
|
|
||||||
#include <dns/enumtype.h>
|
#include <dns/enumtype.h>
|
||||||
enum {
|
typedef enum {
|
||||||
ns_t_none = 0,
|
dns_rdatatype_none = 0,
|
||||||
TYPEENUM
|
TYPEENUM
|
||||||
ns_t_any = 255
|
dns_rdatatype_any = 255
|
||||||
} ns_type_t;
|
} dns_rdatatype_t;
|
||||||
|
|
||||||
#include <dns/enumclass.h>
|
#include <dns/enumclass.h>
|
||||||
enum {
|
typedef enum {
|
||||||
CLASSENUM
|
CLASSENUM
|
||||||
ns_c_none = 0,
|
dns_rdataclass_none = 0,
|
||||||
/* ns_c_any = 255 TSIG is class ANY specific */
|
/* dns_rdataclass_any = 255 TSIG is class ANY specific */
|
||||||
} ns_class_t;
|
} dns_rdataclass_t;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
/* standard rcodes */
|
||||||
|
dns_rcode_noerror = 0,
|
||||||
|
dns_rcode_formerr = 1,
|
||||||
|
dns_rcode_servfail = 2,
|
||||||
|
dns_rcode_nxdomain = 3,
|
||||||
|
dns_rcode_notimp = 4,
|
||||||
|
dns_rcode_refused = 5,
|
||||||
|
dns_rcode_yxdomain = 6,
|
||||||
|
dns_rcode_yxrrset = 7,
|
||||||
|
dns_rcode_nxrrset = 8,
|
||||||
|
dns_rcode_notauth = 9,
|
||||||
|
dns_rcode_notzone = 10,
|
||||||
|
/* extended rcodes */
|
||||||
|
dns_rcode_badsig = 16,
|
||||||
|
dns_rcode_badkey = 17,
|
||||||
|
dns_rcode_badtime = 18,
|
||||||
|
dns_rcode_badmode = 19
|
||||||
|
} dns_rcode_t;
|
||||||
|
|
||||||
#endif /* DNS_TYPES_H */
|
#endif /* DNS_TYPES_H */
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: master.c,v 1.7 1999/01/30 13:11:24 marka Exp $ */
|
/* $Id: master.c,v 1.8 1999/02/04 06:38:41 marka Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
@@ -370,17 +370,17 @@ dns_load_master(char *master_file, dns_name_t *top, dns_name_t *origin,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_glue && type == ns_t_soa &&
|
if (!in_glue && type == dns_rdatatype_soa &&
|
||||||
dns_name_compare(top, ¤t_name) == 0) {
|
dns_name_compare(top, ¤t_name) == 0) {
|
||||||
(*soacount)++;
|
(*soacount)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_glue && type == ns_t_ns &&
|
if (!in_glue && type == dns_rdatatype_ns &&
|
||||||
dns_name_compare(top, ¤t_name) == 0) {
|
dns_name_compare(top, ¤t_name) == 0) {
|
||||||
(*nscount)++;
|
(*nscount)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == ns_t_ns && !in_glue)
|
if (type == dns_rdatatype_ns && !in_glue)
|
||||||
current_has_delegation = ISC_TRUE;
|
current_has_delegation = ISC_TRUE;
|
||||||
|
|
||||||
if (in_glue)
|
if (in_glue)
|
||||||
@@ -617,7 +617,7 @@ is_glue(rdatalist_head_t *head, dns_name_t *owner) {
|
|||||||
/* find NS rrset */
|
/* find NS rrset */
|
||||||
this = ISC_LIST_HEAD(*head);
|
this = ISC_LIST_HEAD(*head);
|
||||||
while (this != NULL) {
|
while (this != NULL) {
|
||||||
if (this->type == ns_t_ns)
|
if (this->type == dns_rdatatype_ns)
|
||||||
break;
|
break;
|
||||||
this = ISC_LIST_NEXT(this, link);
|
this = ISC_LIST_NEXT(this, link);
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: rdata.c,v 1.24 1999/02/04 00:03:28 marka Exp $ */
|
/* $Id: rdata.c,v 1.25 1999/02/04 06:38:42 marka Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
#include <dns/region.h>
|
#include <dns/region.h>
|
||||||
#include <dns/rdataclass.h>
|
#include <dns/rdataclass.h>
|
||||||
#include <dns/rdatatype.h>
|
#include <dns/rdatatype.h>
|
||||||
|
#include <dns/rcode.h>
|
||||||
|
|
||||||
#define RETERR(x) do { \
|
#define RETERR(x) do { \
|
||||||
dns_result_t __r = (x); \
|
dns_result_t __r = (x); \
|
||||||
@@ -106,12 +107,34 @@ static const char octdigits[] = "01234567";
|
|||||||
{ 0, "NONE", META }, \
|
{ 0, "NONE", META }, \
|
||||||
{ 255, "ANY", META },
|
{ 255, "ANY", META },
|
||||||
|
|
||||||
|
#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}, \
|
||||||
|
/* extended rcodes */ \
|
||||||
|
{ dns_rcode_badsig, "BADSIG", 0}, \
|
||||||
|
{ dns_rcode_badkey, "BADKEY", 0}, \
|
||||||
|
{ dns_rcode_badtime, "BADTIME", 0}, \
|
||||||
|
{ dns_rcode_badmode, "BADMODE", 0}, \
|
||||||
|
{ 0, NULL, 0 }
|
||||||
|
|
||||||
struct tbl {
|
struct tbl {
|
||||||
int value;
|
unsigned int value;
|
||||||
char *name;
|
char *name;
|
||||||
int flags;
|
int flags;
|
||||||
} types[] = { TYPENAMES METATYPES {0, NULL, 0} },
|
} types[] = { TYPENAMES METATYPES {0, NULL, 0} },
|
||||||
classes[] = { CLASSNAMES METACLASSES { 0, NULL, 0} };
|
classes[] = { CLASSNAMES METACLASSES { 0, NULL, 0} },
|
||||||
|
rcodes[] = { RCODENAMES };
|
||||||
|
|
||||||
/***
|
/***
|
||||||
*** Initialization
|
*** Initialization
|
||||||
***/
|
***/
|
||||||
@@ -368,21 +391,16 @@ dns_rdataclass_fromtext(dns_rdataclass_t *classp, isc_textregion_t *source) {
|
|||||||
dns_result_t
|
dns_result_t
|
||||||
dns_rdataclass_totext(dns_rdataclass_t class, isc_buffer_t *target) {
|
dns_rdataclass_totext(dns_rdataclass_t class, isc_buffer_t *target) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
unsigned int n;
|
char buf[sizeof "65000"];
|
||||||
isc_region_t region;
|
|
||||||
|
|
||||||
while (classes[i].name != NULL) {
|
while (classes[i].name != NULL) {
|
||||||
if (classes[i].value == class) {
|
if (classes[i].value == class) {
|
||||||
isc_buffer_available(target, ®ion);
|
return (str_totext(classes[i].name, target));
|
||||||
if ((n = strlen(classes[i].name)) > region.length)
|
|
||||||
return (DNS_R_NOSPACE);
|
|
||||||
memcpy(region.base, classes[i].name, n);
|
|
||||||
isc_buffer_add(target, n);
|
|
||||||
return (DNS_R_SUCCESS);
|
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
return (DNS_R_UNKNOWN);
|
sprintf(buf, "%u", class);
|
||||||
|
return (str_totext(buf, target));
|
||||||
}
|
}
|
||||||
|
|
||||||
dns_result_t
|
dns_result_t
|
||||||
@@ -407,16 +425,28 @@ dns_rdatatype_fromtext(dns_rdatatype_t *typep, isc_textregion_t *source) {
|
|||||||
dns_result_t
|
dns_result_t
|
||||||
dns_rdatatype_totext(dns_rdatatype_t type, isc_buffer_t *target) {
|
dns_rdatatype_totext(dns_rdatatype_t type, isc_buffer_t *target) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
unsigned int n;
|
char buf[sizeof "65000"];
|
||||||
isc_region_t region;
|
|
||||||
|
|
||||||
while (types[i].name != NULL) {
|
while (types[i].name != NULL) {
|
||||||
if (types[i].value == type) {
|
if (types[i].value == type) {
|
||||||
isc_buffer_available(target, ®ion);
|
return (str_totext(types[i].name, target));
|
||||||
if ((n = strlen(types[i].name)) > region.length)
|
}
|
||||||
return (DNS_R_NOSPACE);
|
i++;
|
||||||
memcpy(region.base, types[i].name, n);
|
}
|
||||||
isc_buffer_add(target, n);
|
sprintf(buf, "%u", type);
|
||||||
|
return (str_totext(buf, target));
|
||||||
|
}
|
||||||
|
|
||||||
|
dns_result_t
|
||||||
|
dns_rcode_fromtext(dns_rcode_t *rcodep, isc_textregion_t *source) {
|
||||||
|
int i = 0;
|
||||||
|
unsigned int n;
|
||||||
|
|
||||||
|
while (rcodes[i].name != NULL) {
|
||||||
|
n = strlen(rcodes[i].name);
|
||||||
|
if (n == source->length &&
|
||||||
|
strncasecmp(source->base, rcodes[i].name, n) == 0) {
|
||||||
|
*rcodep = rcodes[i].value;
|
||||||
return (DNS_R_SUCCESS);
|
return (DNS_R_SUCCESS);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
@@ -424,6 +454,21 @@ dns_rdatatype_totext(dns_rdatatype_t type, isc_buffer_t *target) {
|
|||||||
return (DNS_R_UNKNOWN);
|
return (DNS_R_UNKNOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dns_result_t
|
||||||
|
dns_rcode_totext(dns_rcode_t rcode, isc_buffer_t *target) {
|
||||||
|
int i = 0;
|
||||||
|
char buf[sizeof "65000"];
|
||||||
|
|
||||||
|
while (rcodes[i].name != NULL) {
|
||||||
|
if (rcodes[i].value == rcode) {
|
||||||
|
return (str_totext(rcodes[i].name, target));
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
sprintf(buf, "%u", rcode);
|
||||||
|
return (str_totext(buf, target));
|
||||||
|
}
|
||||||
|
|
||||||
/* Private function */
|
/* Private function */
|
||||||
|
|
||||||
static unsigned int
|
static unsigned int
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: nxt_30.c,v 1.2 1999/02/02 13:31:45 marka Exp $ */
|
/* $Id: nxt_30.c,v 1.3 1999/02/04 06:38:43 marka Exp $ */
|
||||||
|
|
||||||
/* RFC 2065 */
|
/* RFC 2065 */
|
||||||
|
|
||||||
@@ -32,7 +32,8 @@ fromtext_nxt(dns_rdataclass_t class, dns_rdatatype_t type,
|
|||||||
char *e;
|
char *e;
|
||||||
unsigned char bm[8*1024]; /* 64k bits */
|
unsigned char bm[8*1024]; /* 64k bits */
|
||||||
dns_rdatatype_t covered;
|
dns_rdatatype_t covered;
|
||||||
long maxcovered = -1;
|
dns_rdatatype_t maxcovered = dns_rdatatype_none;
|
||||||
|
isc_boolean_t first = ISC_TRUE;
|
||||||
unsigned int n;
|
unsigned int n;
|
||||||
|
|
||||||
REQUIRE(type == 30);
|
REQUIRE(type == 30);
|
||||||
@@ -59,11 +60,14 @@ fromtext_nxt(dns_rdataclass_t class, dns_rdatatype_t type,
|
|||||||
else if (dns_rdatatype_fromtext(&covered,
|
else if (dns_rdatatype_fromtext(&covered,
|
||||||
&token.value.as_textregion) == DNS_R_UNKNOWN)
|
&token.value.as_textregion) == DNS_R_UNKNOWN)
|
||||||
return (DNS_R_UNKNOWN);
|
return (DNS_R_UNKNOWN);
|
||||||
if (covered > maxcovered)
|
if (first || covered > maxcovered)
|
||||||
maxcovered = covered;
|
maxcovered = covered;
|
||||||
|
first = ISC_FALSE;
|
||||||
bm[covered/8] |= (0x80>>(covered%8));
|
bm[covered/8] |= (0x80>>(covered%8));
|
||||||
}
|
}
|
||||||
isc_lex_ungettoken(lexer, &token);
|
isc_lex_ungettoken(lexer, &token);
|
||||||
|
if (first)
|
||||||
|
return (DNS_R_SUCCESS);
|
||||||
n = (maxcovered + 8) / 8;
|
n = (maxcovered + 8) / 8;
|
||||||
return (mem_tobuffer(target, bm, n));
|
return (mem_tobuffer(target, bm, n));
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: nxt_30.h,v 1.2 1999/02/02 13:31:45 marka Exp $ */
|
/* $Id: nxt_30.h,v 1.3 1999/02/04 06:38:43 marka Exp $ */
|
||||||
|
|
||||||
/* RFC 2065 */
|
/* RFC 2065 */
|
||||||
|
|
||||||
@@ -32,7 +32,8 @@ fromtext_nxt(dns_rdataclass_t class, dns_rdatatype_t type,
|
|||||||
char *e;
|
char *e;
|
||||||
unsigned char bm[8*1024]; /* 64k bits */
|
unsigned char bm[8*1024]; /* 64k bits */
|
||||||
dns_rdatatype_t covered;
|
dns_rdatatype_t covered;
|
||||||
long maxcovered = -1;
|
dns_rdatatype_t maxcovered = dns_rdatatype_none;
|
||||||
|
isc_boolean_t first = ISC_TRUE;
|
||||||
unsigned int n;
|
unsigned int n;
|
||||||
|
|
||||||
REQUIRE(type == 30);
|
REQUIRE(type == 30);
|
||||||
@@ -59,11 +60,14 @@ fromtext_nxt(dns_rdataclass_t class, dns_rdatatype_t type,
|
|||||||
else if (dns_rdatatype_fromtext(&covered,
|
else if (dns_rdatatype_fromtext(&covered,
|
||||||
&token.value.as_textregion) == DNS_R_UNKNOWN)
|
&token.value.as_textregion) == DNS_R_UNKNOWN)
|
||||||
return (DNS_R_UNKNOWN);
|
return (DNS_R_UNKNOWN);
|
||||||
if (covered > maxcovered)
|
if (first || covered > maxcovered)
|
||||||
maxcovered = covered;
|
maxcovered = covered;
|
||||||
|
first = ISC_FALSE;
|
||||||
bm[covered/8] |= (0x80>>(covered%8));
|
bm[covered/8] |= (0x80>>(covered%8));
|
||||||
}
|
}
|
||||||
isc_lex_ungettoken(lexer, &token);
|
isc_lex_ungettoken(lexer, &token);
|
||||||
|
if (first)
|
||||||
|
return (DNS_R_SUCCESS);
|
||||||
n = (maxcovered + 8) / 8;
|
n = (maxcovered + 8) / 8;
|
||||||
return (mem_tobuffer(target, bm, n));
|
return (mem_tobuffer(target, bm, n));
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: tkey_249.c,v 1.1 1999/02/04 02:09:04 marka Exp $ */
|
/* $Id: tkey_249.c,v 1.2 1999/02/04 06:38:43 marka Exp $ */
|
||||||
|
|
||||||
/* draft-ietf-dnssec-tkey-01.txt */
|
/* draft-ietf-dnssec-tkey-01.txt */
|
||||||
|
|
||||||
@@ -28,12 +28,23 @@ fromtext_tkey(dns_rdataclass_t class, dns_rdatatype_t type,
|
|||||||
isc_boolean_t downcase, isc_buffer_t *target)
|
isc_boolean_t downcase, isc_buffer_t *target)
|
||||||
{
|
{
|
||||||
isc_token_t token;
|
isc_token_t token;
|
||||||
|
dns_rcode_t rcode;
|
||||||
|
dns_name_t name;
|
||||||
|
isc_buffer_t buffer;
|
||||||
|
char *e;
|
||||||
|
|
||||||
REQUIRE(type == 249);
|
REQUIRE(type == 249);
|
||||||
|
|
||||||
class = class; /*unused*/
|
class = class; /*unused*/
|
||||||
origin = origin; /*unused*/
|
|
||||||
downcase = downcase; /*unused*/
|
|
||||||
|
/* Algorithm */
|
||||||
|
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
|
||||||
|
dns_name_init(&name, NULL);
|
||||||
|
buffer_fromregion(&buffer, &token.value.as_region,
|
||||||
|
ISC_BUFFERTYPE_TEXT);
|
||||||
|
origin = (origin != NULL) ? origin : dns_rootname;
|
||||||
|
RETERR(dns_name_fromtext(&name, &buffer, origin, downcase, target));
|
||||||
|
|
||||||
|
|
||||||
/* Inception */
|
/* Inception */
|
||||||
@@ -51,10 +62,16 @@ fromtext_tkey(dns_rdataclass_t class, dns_rdatatype_t type,
|
|||||||
RETERR(uint16_tobuffer(token.value.as_ulong, target));
|
RETERR(uint16_tobuffer(token.value.as_ulong, target));
|
||||||
|
|
||||||
/* Error */
|
/* Error */
|
||||||
RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE));
|
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
|
||||||
if (token.value.as_ulong > 0xffff)
|
if (dns_rcode_fromtext(&rcode, &token.value.as_textregion)
|
||||||
return (DNS_R_RANGE);
|
!= DNS_R_SUCCESS) {
|
||||||
RETERR(uint16_tobuffer(token.value.as_ulong, target));
|
rcode = strtol(token.value.as_pointer, &e, 10);
|
||||||
|
if (*e != 0)
|
||||||
|
return (DNS_R_UNKNOWN);
|
||||||
|
if (rcode > 0xffff)
|
||||||
|
return (DNS_R_RANGE);
|
||||||
|
}
|
||||||
|
RETERR(uint16_tobuffer(rcode, target));
|
||||||
|
|
||||||
/* Signature Size */
|
/* Signature Size */
|
||||||
RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE));
|
RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE));
|
||||||
@@ -81,20 +98,28 @@ totext_tkey(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
|
|||||||
isc_region_t sigr;
|
isc_region_t sigr;
|
||||||
char buf[sizeof "4294967295 "];
|
char buf[sizeof "4294967295 "];
|
||||||
unsigned long n;
|
unsigned long n;
|
||||||
|
dns_name_t name;
|
||||||
|
dns_name_t prefix;
|
||||||
|
isc_boolean_t sub;
|
||||||
|
|
||||||
REQUIRE(rdata->type == 249);
|
REQUIRE(rdata->type == 249);
|
||||||
|
|
||||||
origin = origin; /*unused*/
|
|
||||||
|
|
||||||
dns_rdata_toregion(rdata, &sr);
|
dns_rdata_toregion(rdata, &sr);
|
||||||
|
|
||||||
|
/* Algorithm */
|
||||||
|
dns_name_init(&name, NULL);
|
||||||
|
dns_name_init(&prefix, NULL);
|
||||||
|
sub = name_prefix(&name, origin, &prefix);
|
||||||
|
RETERR(dns_name_totext(&prefix, sub, target));
|
||||||
|
isc_region_consume(&sr, name_length(&name));
|
||||||
|
|
||||||
/* Inception */
|
/* Inception */
|
||||||
n = uint32_fromregion(&sr);
|
n = uint32_fromregion(&sr);
|
||||||
isc_region_consume(&sr, 4);
|
isc_region_consume(&sr, 4);
|
||||||
sprintf(buf, "%lu ", n);
|
sprintf(buf, "%lu ", n);
|
||||||
RETERR(str_totext(buf, target));
|
RETERR(str_totext(buf, target));
|
||||||
|
|
||||||
/* Error */
|
/* Expiration */
|
||||||
n = uint32_fromregion(&sr);
|
n = uint32_fromregion(&sr);
|
||||||
isc_region_consume(&sr, 4);
|
isc_region_consume(&sr, 4);
|
||||||
sprintf(buf, "%lu ", n);
|
sprintf(buf, "%lu ", n);
|
||||||
@@ -109,8 +134,12 @@ totext_tkey(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
|
|||||||
/* Error */
|
/* Error */
|
||||||
n = uint16_fromregion(&sr);
|
n = uint16_fromregion(&sr);
|
||||||
isc_region_consume(&sr, 2);
|
isc_region_consume(&sr, 2);
|
||||||
sprintf(buf, "%lu ", n);
|
if (dns_rcode_totext(n, target) == DNS_R_SUCCESS)
|
||||||
RETERR(str_totext(buf, target));
|
RETERR(str_totext(" ", target));
|
||||||
|
else {
|
||||||
|
sprintf(buf, "%lu ", n);
|
||||||
|
RETERR(str_totext(buf, target));
|
||||||
|
}
|
||||||
|
|
||||||
/* Signature Size */
|
/* Signature Size */
|
||||||
n = uint16_fromregion(&sr);
|
n = uint16_fromregion(&sr);
|
||||||
@@ -143,20 +172,23 @@ fromwire_tkey(dns_rdataclass_t class, dns_rdatatype_t type,
|
|||||||
{
|
{
|
||||||
isc_region_t sr;
|
isc_region_t sr;
|
||||||
unsigned long n;
|
unsigned long n;
|
||||||
|
dns_name_t name;
|
||||||
|
|
||||||
REQUIRE(type == 249);
|
REQUIRE(type == 249);
|
||||||
|
|
||||||
class = class; /*unused*/
|
class = class; /*unused*/
|
||||||
dctx = dctx; /*unused*/
|
|
||||||
downcase = downcase; /*unused*/
|
|
||||||
|
|
||||||
isc_buffer_active(source, &sr);
|
/* Algorithm */
|
||||||
|
dns_name_init(&name, NULL);
|
||||||
|
RETERR(dns_name_fromwire(&name, source, dctx, downcase, target));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Inception: 4
|
* Inception: 4
|
||||||
* Expiration: 4
|
* Expiration: 4
|
||||||
* Mode: 2
|
* Mode: 2
|
||||||
* Error: 2
|
* Error: 2
|
||||||
*/
|
*/
|
||||||
|
isc_buffer_active(source, &sr);
|
||||||
if (sr.length < 12)
|
if (sr.length < 12)
|
||||||
return (DNS_R_UNEXPECTEDEND);
|
return (DNS_R_UNEXPECTEDEND);
|
||||||
RETERR(mem_tobuffer(target, sr.base, 12));
|
RETERR(mem_tobuffer(target, sr.base, 12));
|
||||||
@@ -186,12 +218,17 @@ fromwire_tkey(dns_rdataclass_t class, dns_rdatatype_t type,
|
|||||||
static dns_result_t
|
static dns_result_t
|
||||||
towire_tkey(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
|
towire_tkey(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
|
||||||
isc_region_t sr;
|
isc_region_t sr;
|
||||||
|
dns_name_t name;
|
||||||
|
|
||||||
REQUIRE(rdata->type == 249);
|
REQUIRE(rdata->type == 249);
|
||||||
|
|
||||||
cctx = cctx; /*unused*/
|
/* Algorithm */
|
||||||
|
|
||||||
dns_rdata_toregion(rdata, &sr);
|
dns_rdata_toregion(rdata, &sr);
|
||||||
|
dns_name_init(&name, NULL);
|
||||||
|
dns_name_fromregion(&name, &sr);
|
||||||
|
RETERR(dns_name_towire(&name, cctx, target));
|
||||||
|
isc_region_consume(&sr, name_length(&name));
|
||||||
|
|
||||||
return (mem_tobuffer(target, sr.base, sr.length));
|
return (mem_tobuffer(target, sr.base, sr.length));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,13 +236,25 @@ static int
|
|||||||
compare_tkey(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
|
compare_tkey(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
|
||||||
isc_region_t r1;
|
isc_region_t r1;
|
||||||
isc_region_t r2;
|
isc_region_t r2;
|
||||||
|
dns_name_t name1;
|
||||||
|
dns_name_t name2;
|
||||||
|
int result;
|
||||||
|
|
||||||
REQUIRE(rdata1->type == rdata2->type);
|
REQUIRE(rdata1->type == rdata2->type);
|
||||||
REQUIRE(rdata1->class == rdata2->class);
|
REQUIRE(rdata1->class == rdata2->class);
|
||||||
REQUIRE(rdata1->type == 249);
|
REQUIRE(rdata1->type == 249);
|
||||||
|
|
||||||
|
/* Algorithm */
|
||||||
dns_rdata_toregion(rdata1, &r1);
|
dns_rdata_toregion(rdata1, &r1);
|
||||||
dns_rdata_toregion(rdata2, &r2);
|
dns_rdata_toregion(rdata2, &r2);
|
||||||
|
dns_name_init(&name1, NULL);
|
||||||
|
dns_name_init(&name2, NULL);
|
||||||
|
dns_name_fromregion(&name1, &r1);
|
||||||
|
dns_name_fromregion(&name1, &r1);
|
||||||
|
if ((result = dns_name_compare(&name1, &name2)) != 0)
|
||||||
|
return (result);
|
||||||
|
isc_region_consume(&r1, name_length(&name1));
|
||||||
|
isc_region_consume(&r2, name_length(&name2));
|
||||||
return (compare_region(&r1, &r2));
|
return (compare_region(&r1, &r2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: tkey_249.h,v 1.1 1999/02/04 02:09:04 marka Exp $ */
|
/* $Id: tkey_249.h,v 1.2 1999/02/04 06:38:43 marka Exp $ */
|
||||||
|
|
||||||
/* draft-ietf-dnssec-tkey-01.txt */
|
/* draft-ietf-dnssec-tkey-01.txt */
|
||||||
|
|
||||||
@@ -28,12 +28,23 @@ fromtext_tkey(dns_rdataclass_t class, dns_rdatatype_t type,
|
|||||||
isc_boolean_t downcase, isc_buffer_t *target)
|
isc_boolean_t downcase, isc_buffer_t *target)
|
||||||
{
|
{
|
||||||
isc_token_t token;
|
isc_token_t token;
|
||||||
|
dns_rcode_t rcode;
|
||||||
|
dns_name_t name;
|
||||||
|
isc_buffer_t buffer;
|
||||||
|
char *e;
|
||||||
|
|
||||||
REQUIRE(type == 249);
|
REQUIRE(type == 249);
|
||||||
|
|
||||||
class = class; /*unused*/
|
class = class; /*unused*/
|
||||||
origin = origin; /*unused*/
|
|
||||||
downcase = downcase; /*unused*/
|
|
||||||
|
/* Algorithm */
|
||||||
|
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
|
||||||
|
dns_name_init(&name, NULL);
|
||||||
|
buffer_fromregion(&buffer, &token.value.as_region,
|
||||||
|
ISC_BUFFERTYPE_TEXT);
|
||||||
|
origin = (origin != NULL) ? origin : dns_rootname;
|
||||||
|
RETERR(dns_name_fromtext(&name, &buffer, origin, downcase, target));
|
||||||
|
|
||||||
|
|
||||||
/* Inception */
|
/* Inception */
|
||||||
@@ -51,10 +62,16 @@ fromtext_tkey(dns_rdataclass_t class, dns_rdatatype_t type,
|
|||||||
RETERR(uint16_tobuffer(token.value.as_ulong, target));
|
RETERR(uint16_tobuffer(token.value.as_ulong, target));
|
||||||
|
|
||||||
/* Error */
|
/* Error */
|
||||||
RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE));
|
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
|
||||||
if (token.value.as_ulong > 0xffff)
|
if (dns_rcode_fromtext(&rcode, &token.value.as_textregion)
|
||||||
return (DNS_R_RANGE);
|
!= DNS_R_SUCCESS) {
|
||||||
RETERR(uint16_tobuffer(token.value.as_ulong, target));
|
rcode = strtol(token.value.as_pointer, &e, 10);
|
||||||
|
if (*e != 0)
|
||||||
|
return (DNS_R_UNKNOWN);
|
||||||
|
if (rcode > 0xffff)
|
||||||
|
return (DNS_R_RANGE);
|
||||||
|
}
|
||||||
|
RETERR(uint16_tobuffer(rcode, target));
|
||||||
|
|
||||||
/* Signature Size */
|
/* Signature Size */
|
||||||
RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE));
|
RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE));
|
||||||
@@ -81,20 +98,28 @@ totext_tkey(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
|
|||||||
isc_region_t sigr;
|
isc_region_t sigr;
|
||||||
char buf[sizeof "4294967295 "];
|
char buf[sizeof "4294967295 "];
|
||||||
unsigned long n;
|
unsigned long n;
|
||||||
|
dns_name_t name;
|
||||||
|
dns_name_t prefix;
|
||||||
|
isc_boolean_t sub;
|
||||||
|
|
||||||
REQUIRE(rdata->type == 249);
|
REQUIRE(rdata->type == 249);
|
||||||
|
|
||||||
origin = origin; /*unused*/
|
|
||||||
|
|
||||||
dns_rdata_toregion(rdata, &sr);
|
dns_rdata_toregion(rdata, &sr);
|
||||||
|
|
||||||
|
/* Algorithm */
|
||||||
|
dns_name_init(&name, NULL);
|
||||||
|
dns_name_init(&prefix, NULL);
|
||||||
|
sub = name_prefix(&name, origin, &prefix);
|
||||||
|
RETERR(dns_name_totext(&prefix, sub, target));
|
||||||
|
isc_region_consume(&sr, name_length(&name));
|
||||||
|
|
||||||
/* Inception */
|
/* Inception */
|
||||||
n = uint32_fromregion(&sr);
|
n = uint32_fromregion(&sr);
|
||||||
isc_region_consume(&sr, 4);
|
isc_region_consume(&sr, 4);
|
||||||
sprintf(buf, "%lu ", n);
|
sprintf(buf, "%lu ", n);
|
||||||
RETERR(str_totext(buf, target));
|
RETERR(str_totext(buf, target));
|
||||||
|
|
||||||
/* Error */
|
/* Expiration */
|
||||||
n = uint32_fromregion(&sr);
|
n = uint32_fromregion(&sr);
|
||||||
isc_region_consume(&sr, 4);
|
isc_region_consume(&sr, 4);
|
||||||
sprintf(buf, "%lu ", n);
|
sprintf(buf, "%lu ", n);
|
||||||
@@ -109,8 +134,12 @@ totext_tkey(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
|
|||||||
/* Error */
|
/* Error */
|
||||||
n = uint16_fromregion(&sr);
|
n = uint16_fromregion(&sr);
|
||||||
isc_region_consume(&sr, 2);
|
isc_region_consume(&sr, 2);
|
||||||
sprintf(buf, "%lu ", n);
|
if (dns_rcode_totext(n, target) == DNS_R_SUCCESS)
|
||||||
RETERR(str_totext(buf, target));
|
RETERR(str_totext(" ", target));
|
||||||
|
else {
|
||||||
|
sprintf(buf, "%lu ", n);
|
||||||
|
RETERR(str_totext(buf, target));
|
||||||
|
}
|
||||||
|
|
||||||
/* Signature Size */
|
/* Signature Size */
|
||||||
n = uint16_fromregion(&sr);
|
n = uint16_fromregion(&sr);
|
||||||
@@ -143,20 +172,23 @@ fromwire_tkey(dns_rdataclass_t class, dns_rdatatype_t type,
|
|||||||
{
|
{
|
||||||
isc_region_t sr;
|
isc_region_t sr;
|
||||||
unsigned long n;
|
unsigned long n;
|
||||||
|
dns_name_t name;
|
||||||
|
|
||||||
REQUIRE(type == 249);
|
REQUIRE(type == 249);
|
||||||
|
|
||||||
class = class; /*unused*/
|
class = class; /*unused*/
|
||||||
dctx = dctx; /*unused*/
|
|
||||||
downcase = downcase; /*unused*/
|
|
||||||
|
|
||||||
isc_buffer_active(source, &sr);
|
/* Algorithm */
|
||||||
|
dns_name_init(&name, NULL);
|
||||||
|
RETERR(dns_name_fromwire(&name, source, dctx, downcase, target));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Inception: 4
|
* Inception: 4
|
||||||
* Expiration: 4
|
* Expiration: 4
|
||||||
* Mode: 2
|
* Mode: 2
|
||||||
* Error: 2
|
* Error: 2
|
||||||
*/
|
*/
|
||||||
|
isc_buffer_active(source, &sr);
|
||||||
if (sr.length < 12)
|
if (sr.length < 12)
|
||||||
return (DNS_R_UNEXPECTEDEND);
|
return (DNS_R_UNEXPECTEDEND);
|
||||||
RETERR(mem_tobuffer(target, sr.base, 12));
|
RETERR(mem_tobuffer(target, sr.base, 12));
|
||||||
@@ -186,12 +218,17 @@ fromwire_tkey(dns_rdataclass_t class, dns_rdatatype_t type,
|
|||||||
static dns_result_t
|
static dns_result_t
|
||||||
towire_tkey(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
|
towire_tkey(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
|
||||||
isc_region_t sr;
|
isc_region_t sr;
|
||||||
|
dns_name_t name;
|
||||||
|
|
||||||
REQUIRE(rdata->type == 249);
|
REQUIRE(rdata->type == 249);
|
||||||
|
|
||||||
cctx = cctx; /*unused*/
|
/* Algorithm */
|
||||||
|
|
||||||
dns_rdata_toregion(rdata, &sr);
|
dns_rdata_toregion(rdata, &sr);
|
||||||
|
dns_name_init(&name, NULL);
|
||||||
|
dns_name_fromregion(&name, &sr);
|
||||||
|
RETERR(dns_name_towire(&name, cctx, target));
|
||||||
|
isc_region_consume(&sr, name_length(&name));
|
||||||
|
|
||||||
return (mem_tobuffer(target, sr.base, sr.length));
|
return (mem_tobuffer(target, sr.base, sr.length));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,13 +236,25 @@ static int
|
|||||||
compare_tkey(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
|
compare_tkey(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
|
||||||
isc_region_t r1;
|
isc_region_t r1;
|
||||||
isc_region_t r2;
|
isc_region_t r2;
|
||||||
|
dns_name_t name1;
|
||||||
|
dns_name_t name2;
|
||||||
|
int result;
|
||||||
|
|
||||||
REQUIRE(rdata1->type == rdata2->type);
|
REQUIRE(rdata1->type == rdata2->type);
|
||||||
REQUIRE(rdata1->class == rdata2->class);
|
REQUIRE(rdata1->class == rdata2->class);
|
||||||
REQUIRE(rdata1->type == 249);
|
REQUIRE(rdata1->type == 249);
|
||||||
|
|
||||||
|
/* Algorithm */
|
||||||
dns_rdata_toregion(rdata1, &r1);
|
dns_rdata_toregion(rdata1, &r1);
|
||||||
dns_rdata_toregion(rdata2, &r2);
|
dns_rdata_toregion(rdata2, &r2);
|
||||||
|
dns_name_init(&name1, NULL);
|
||||||
|
dns_name_init(&name2, NULL);
|
||||||
|
dns_name_fromregion(&name1, &r1);
|
||||||
|
dns_name_fromregion(&name1, &r1);
|
||||||
|
if ((result = dns_name_compare(&name1, &name2)) != 0)
|
||||||
|
return (result);
|
||||||
|
isc_region_consume(&r1, name_length(&name1));
|
||||||
|
isc_region_consume(&r2, name_length(&name2));
|
||||||
return (compare_region(&r1, &r2));
|
return (compare_region(&r1, &r2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user