Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
BIND
Commits
8d3e74b1
Commit
8d3e74b1
authored
Feb 04, 1999
by
Mark Andrews
Browse files
gen to generate dns_rdata{type,class}_{type,class}
dns_rcode_{to,from}text() TKEY was missing the Algorithm
parent
f427e785
Changes
9
Hide whitespace changes
Inline
Side-by-side
lib/dns/gen.c
View file @
8d3e74b1
...
...
@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: gen.c,v 1.1
2
1999/02/0
2 22:34:20
marka Exp $ */
/* $Id: gen.c,v 1.1
3
1999/02/0
4 06:38:41
marka Exp $ */
#include
<sys/types.h>
...
...
@@ -430,7 +430,7 @@ main(int argc, char **argv) {
lasttype
=
0
;
for
(
tt
=
types
;
tt
!=
NULL
;
tt
=
tt
->
next
)
if
(
tt
->
type
!=
lasttype
)
fprintf
(
stdout
,
"
\t
ns_
t
_%s = %d,%s
\n
"
,
fprintf
(
stdout
,
"
\t
d
ns_
rdatatype
_%s = %d,%s
\n
"
,
funname
(
tt
->
typename
,
buf1
),
lasttype
=
tt
->
type
,
tt
->
next
!=
NULL
?
"
\\
"
:
""
);
...
...
@@ -441,7 +441,7 @@ main(int argc, char **argv) {
classes
!=
NULL
?
"
\\
"
:
""
);
for
(
cc
=
classes
;
cc
!=
NULL
;
cc
=
cc
->
next
)
fprintf
(
stdout
,
"
\t
ns_
c
_%s = %d,%s
\n
"
,
fprintf
(
stdout
,
"
\t
d
ns_
rdataclass
_%s = %d,%s
\n
"
,
funname
(
cc
->
classname
,
buf1
),
cc
->
class
,
cc
->
next
!=
NULL
?
"
\\
"
:
""
);
...
...
lib/dns/include/dns/rcode.h
0 → 100644
View file @
8d3e74b1
/*
* 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 */
lib/dns/include/dns/types.h
View file @
8d3e74b1
...
...
@@ -39,8 +39,8 @@ typedef void dns_dbversion_t;
typedef
unsigned
char
dns_offsets_t
[
128
];
typedef
struct
dns_compress
dns_compress_t
;
typedef
struct
dns_decompress
dns_decompress_t
;
typedef
isc_uint16_t
dns_rdataclass_t
;
typedef
isc_uint16_t
dns_rdatatype_t
;
/*
typedef isc_uint16_t dns_rdataclass_t;
*/
/*
typedef isc_uint16_t dns_rdatatype_t;
*/
typedef
isc_uint32_t
dns_ttl_t
;
typedef
struct
dns_rdata
dns_rdata_t
;
typedef
struct
dns_rdatalist
dns_rdatalist_t
;
...
...
@@ -65,17 +65,37 @@ typedef enum {
}
dns_addmode_t
;
#include
<dns/enumtype.h>
enum
{
ns_
t
_none
=
0
,
typedef
enum
{
d
ns_
rdatatype
_none
=
0
,
TYPEENUM
ns_
t
_any
=
255
}
ns_type_t
;
d
ns_
rdatatype
_any
=
255
}
d
ns_
rdata
type_t
;
#include
<dns/enumclass.h>
enum
{
typedef
enum
{
CLASSENUM
ns_c_none
=
0
,
/* ns_c_any = 255 TSIG is class ANY specific */
}
ns_class_t
;
dns_rdataclass_none
=
0
,
/* dns_rdataclass_any = 255 TSIG is class ANY specific */
}
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 */
lib/dns/master.c
View file @
8d3e74b1
...
...
@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: master.c,v 1.
7
1999/0
1/30 13:11:24
marka Exp $ */
/* $Id: master.c,v 1.
8
1999/0
2/04 06:38:41
marka Exp $ */
#include
<config.h>
...
...
@@ -370,17 +370,17 @@ dns_load_master(char *master_file, dns_name_t *top, dns_name_t *origin,
goto
cleanup
;
}
if
(
!
in_glue
&&
type
==
ns_
t
_soa
&&
if
(
!
in_glue
&&
type
==
d
ns_
rdatatype
_soa
&&
dns_name_compare
(
top
,
&
current_name
)
==
0
)
{
(
*
soacount
)
++
;
}
if
(
!
in_glue
&&
type
==
ns_
t
_ns
&&
if
(
!
in_glue
&&
type
==
d
ns_
rdatatype
_ns
&&
dns_name_compare
(
top
,
&
current_name
)
==
0
)
{
(
*
nscount
)
++
;
}
if
(
type
==
ns_
t
_ns
&&
!
in_glue
)
if
(
type
==
d
ns_
rdatatype
_ns
&&
!
in_glue
)
current_has_delegation
=
ISC_TRUE
;
if
(
in_glue
)
...
...
@@ -617,7 +617,7 @@ is_glue(rdatalist_head_t *head, dns_name_t *owner) {
/* find NS rrset */
this
=
ISC_LIST_HEAD
(
*
head
);
while
(
this
!=
NULL
)
{
if
(
this
->
type
==
ns_
t
_ns
)
if
(
this
->
type
==
d
ns_
rdatatype
_ns
)
break
;
this
=
ISC_LIST_NEXT
(
this
,
link
);
}
...
...
lib/dns/rdata.c
View file @
8d3e74b1
...
...
@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: rdata.c,v 1.2
4
1999/02/04 0
0:03:28
marka Exp $ */
/* $Id: rdata.c,v 1.2
5
1999/02/04 0
6:38:42
marka Exp $ */
#include
<config.h>
...
...
@@ -32,6 +32,7 @@
#include
<dns/region.h>
#include
<dns/rdataclass.h>
#include
<dns/rdatatype.h>
#include
<dns/rcode.h>
#define RETERR(x) do { \
dns_result_t __r = (x); \
...
...
@@ -106,12 +107,34 @@ static const char octdigits[] = "01234567";
{ 0, "NONE", 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
{
int
value
;
unsigned
int
value
;
char
*
name
;
int
flags
;
}
types
[]
=
{
TYPENAMES
METATYPES
{
0
,
NULL
,
0
}
},
classes
[]
=
{
CLASSNAMES
METACLASSES
{
0
,
NULL
,
0
}
};
classes
[]
=
{
CLASSNAMES
METACLASSES
{
0
,
NULL
,
0
}
},
rcodes
[]
=
{
RCODENAMES
};
/***
*** Initialization
***/
...
...
@@ -368,21 +391,16 @@ dns_rdataclass_fromtext(dns_rdataclass_t *classp, isc_textregion_t *source) {
dns_result_t
dns_rdataclass_totext
(
dns_rdataclass_t
class
,
isc_buffer_t
*
target
)
{
int
i
=
0
;
unsigned
int
n
;
isc_region_t
region
;
char
buf
[
sizeof
"65000"
];
while
(
classes
[
i
].
name
!=
NULL
)
{
if
(
classes
[
i
].
value
==
class
)
{
isc_buffer_available
(
target
,
&
region
);
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
);
return
(
str_totext
(
classes
[
i
].
name
,
target
));
}
i
++
;
}
return
(
DNS_R_UNKNOWN
);
sprintf
(
buf
,
"%u"
,
class
);
return
(
str_totext
(
buf
,
target
));
}
dns_result_t
...
...
@@ -407,16 +425,28 @@ dns_rdatatype_fromtext(dns_rdatatype_t *typep, isc_textregion_t *source) {
dns_result_t
dns_rdatatype_totext
(
dns_rdatatype_t
type
,
isc_buffer_t
*
target
)
{
int
i
=
0
;
unsigned
int
n
;
isc_region_t
region
;
char
buf
[
sizeof
"65000"
];
while
(
types
[
i
].
name
!=
NULL
)
{
if
(
types
[
i
].
value
==
type
)
{
isc_buffer_available
(
target
,
&
region
);
if
((
n
=
strlen
(
types
[
i
].
name
))
>
region
.
length
)
return
(
DNS_R_NOSPACE
);
memcpy
(
region
.
base
,
types
[
i
].
name
,
n
);
isc_buffer_add
(
target
,
n
);
return
(
str_totext
(
types
[
i
].
name
,
target
));
}
i
++
;
}
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
);
}
i
++
;
...
...
@@ -424,6 +454,21 @@ dns_rdatatype_totext(dns_rdatatype_t type, isc_buffer_t *target) {
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 */
static
unsigned
int
...
...
lib/dns/rdata/generic/nxt_30.c
View file @
8d3e74b1
...
...
@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: nxt_30.c,v 1.
2
1999/02/0
2 13
:3
1
:4
5
marka Exp $ */
/* $Id: nxt_30.c,v 1.
3
1999/02/0
4 06
:3
8
:4
3
marka Exp $ */
/* RFC 2065 */
...
...
@@ -32,7 +32,8 @@ fromtext_nxt(dns_rdataclass_t class, dns_rdatatype_t type,
char
*
e
;
unsigned
char
bm
[
8
*
1024
];
/* 64k bits */
dns_rdatatype_t
covered
;
long
maxcovered
=
-
1
;
dns_rdatatype_t
maxcovered
=
dns_rdatatype_none
;
isc_boolean_t
first
=
ISC_TRUE
;
unsigned
int
n
;
REQUIRE
(
type
==
30
);
...
...
@@ -59,11 +60,14 @@ fromtext_nxt(dns_rdataclass_t class, dns_rdatatype_t type,
else
if
(
dns_rdatatype_fromtext
(
&
covered
,
&
token
.
value
.
as_textregion
)
==
DNS_R_UNKNOWN
)
return
(
DNS_R_UNKNOWN
);
if
(
covered
>
maxcovered
)
if
(
first
||
covered
>
maxcovered
)
maxcovered
=
covered
;
first
=
ISC_FALSE
;
bm
[
covered
/
8
]
|=
(
0x80
>>
(
covered
%
8
));
}
isc_lex_ungettoken
(
lexer
,
&
token
);
if
(
first
)
return
(
DNS_R_SUCCESS
);
n
=
(
maxcovered
+
8
)
/
8
;
return
(
mem_tobuffer
(
target
,
bm
,
n
));
}
...
...
lib/dns/rdata/generic/nxt_30.h
View file @
8d3e74b1
...
...
@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: nxt_30.h,v 1.
2
1999/02/0
2 13
:3
1
:4
5
marka Exp $ */
/* $Id: nxt_30.h,v 1.
3
1999/02/0
4 06
:3
8
:4
3
marka Exp $ */
/* RFC 2065 */
...
...
@@ -32,7 +32,8 @@ fromtext_nxt(dns_rdataclass_t class, dns_rdatatype_t type,
char
*
e
;
unsigned
char
bm
[
8
*
1024
];
/* 64k bits */
dns_rdatatype_t
covered
;
long
maxcovered
=
-
1
;
dns_rdatatype_t
maxcovered
=
dns_rdatatype_none
;
isc_boolean_t
first
=
ISC_TRUE
;
unsigned
int
n
;
REQUIRE
(
type
==
30
);
...
...
@@ -59,11 +60,14 @@ fromtext_nxt(dns_rdataclass_t class, dns_rdatatype_t type,
else
if
(
dns_rdatatype_fromtext
(
&
covered
,
&
token
.
value
.
as_textregion
)
==
DNS_R_UNKNOWN
)
return
(
DNS_R_UNKNOWN
);
if
(
covered
>
maxcovered
)
if
(
first
||
covered
>
maxcovered
)
maxcovered
=
covered
;
first
=
ISC_FALSE
;
bm
[
covered
/
8
]
|=
(
0x80
>>
(
covered
%
8
));
}
isc_lex_ungettoken
(
lexer
,
&
token
);
if
(
first
)
return
(
DNS_R_SUCCESS
);
n
=
(
maxcovered
+
8
)
/
8
;
return
(
mem_tobuffer
(
target
,
bm
,
n
));
}
...
...
lib/dns/rdata/generic/tkey_249.c
View file @
8d3e74b1
...
...
@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: tkey_249.c,v 1.
1
1999/02/04 0
2:09:04
marka Exp $ */
/* $Id: tkey_249.c,v 1.
2
1999/02/04 0
6:38:43
marka Exp $ */
/* 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_token_t
token
;
dns_rcode_t
rcode
;
dns_name_t
name
;
isc_buffer_t
buffer
;
char
*
e
;
REQUIRE
(
type
==
249
);
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 */
...
...
@@ -51,10 +62,16 @@ fromtext_tkey(dns_rdataclass_t class, dns_rdatatype_t type,
RETERR
(
uint16_tobuffer
(
token
.
value
.
as_ulong
,
target
));
/* Error */
RETERR
(
gettoken
(
lexer
,
&
token
,
isc_tokentype_number
,
ISC_FALSE
));
if
(
token
.
value
.
as_ulong
>
0xffff
)
return
(
DNS_R_RANGE
);
RETERR
(
uint16_tobuffer
(
token
.
value
.
as_ulong
,
target
));
RETERR
(
gettoken
(
lexer
,
&
token
,
isc_tokentype_string
,
ISC_FALSE
));
if
(
dns_rcode_fromtext
(
&
rcode
,
&
token
.
value
.
as_textregion
)
!=
DNS_R_SUCCESS
)
{
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 */
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
;
char
buf
[
sizeof
"4294967295 "
];
unsigned
long
n
;
dns_name_t
name
;
dns_name_t
prefix
;
isc_boolean_t
sub
;
REQUIRE
(
rdata
->
type
==
249
);
origin
=
origin
;
/*unused*/
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 */
n
=
uint32_fromregion
(
&
sr
);
isc_region_consume
(
&
sr
,
4
);
sprintf
(
buf
,
"%lu "
,
n
);
RETERR
(
str_totext
(
buf
,
target
));
/* E
rror
*/
/* E
xpiration
*/
n
=
uint32_fromregion
(
&
sr
);
isc_region_consume
(
&
sr
,
4
);
sprintf
(
buf
,
"%lu "
,
n
);
...
...
@@ -109,8 +134,12 @@ totext_tkey(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
/* Error */
n
=
uint16_fromregion
(
&
sr
);
isc_region_consume
(
&
sr
,
2
);
sprintf
(
buf
,
"%lu "
,
n
);
RETERR
(
str_totext
(
buf
,
target
));
if
(
dns_rcode_totext
(
n
,
target
)
==
DNS_R_SUCCESS
)
RETERR
(
str_totext
(
" "
,
target
));
else
{
sprintf
(
buf
,
"%lu "
,
n
);
RETERR
(
str_totext
(
buf
,
target
));
}
/* Signature Size */
n
=
uint16_fromregion
(
&
sr
);
...
...
@@ -143,20 +172,23 @@ fromwire_tkey(dns_rdataclass_t class, dns_rdatatype_t type,
{
isc_region_t
sr
;
unsigned
long
n
;
dns_name_t
name
;
REQUIRE
(
type
==
249
);
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
* Expiration: 4
* Mode: 2
* Error: 2
*/
isc_buffer_active
(
source
,
&
sr
);
if
(
sr
.
length
<
12
)
return
(
DNS_R_UNEXPECTEDEND
);
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
towire_tkey
(
dns_rdata_t
*
rdata
,
dns_compress_t
*
cctx
,
isc_buffer_t
*
target
)
{
isc_region_t
sr
;
dns_name_t
name
;
REQUIRE
(
rdata
->
type
==
249
);
cctx
=
cctx
;
/*unused*/
/* Algorithm */
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
));
}
...
...
@@ -199,13 +236,25 @@ static int
compare_tkey
(
dns_rdata_t
*
rdata1
,
dns_rdata_t
*
rdata2
)
{
isc_region_t
r1
;
isc_region_t
r2
;
dns_name_t
name1
;
dns_name_t
name2
;
int
result
;
REQUIRE
(
rdata1
->
type
==
rdata2
->
type
);
REQUIRE
(
rdata1
->
class
==
rdata2
->
class
);
REQUIRE
(
rdata1
->
type
==
249
);
/* Algorithm */
dns_rdata_toregion
(
rdata1
,
&
r1
);
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
));
}
...
...
lib/dns/rdata/generic/tkey_249.h
View file @
8d3e74b1
...
...
@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: tkey_249.h,v 1.
1
1999/02/04 0
2:09:04
marka Exp $ */
/* $Id: tkey_249.h,v 1.
2
1999/02/04 0
6:38:43
marka Exp $ */
/* 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_token_t
token
;
dns_rcode_t
rcode
;
dns_name_t
name
;
isc_buffer_t
buffer
;
char
*
e
;
REQUIRE
(
type
==
249
);
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 */
...
...
@@ -51,10 +62,16 @@ fromtext_tkey(dns_rdataclass_t class, dns_rdatatype_t type,
RETERR
(
uint16_tobuffer
(
token
.
value
.
as_ulong
,
target
));
/* Error */
RETERR
(
gettoken
(
lexer
,
&
token
,
isc_tokentype_number
,
ISC_FALSE
));
if
(
token
.
value
.
as_ulong
>
0xffff
)
return
(
DNS_R_RANGE
);
RETERR
(
uint16_tobuffer
(
token
.
value
.
as_ulong
,
target
));
RETERR
(
gettoken
(
lexer
,
&
token
,
isc_tokentype_string
,
ISC_FALSE
));
if
(
dns_rcode_fromtext
(
&
rcode
,
&
token
.
value
.
as_textregion
)
!=
DNS_R_SUCCESS
)
{
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 */
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
;
char
buf
[
sizeof
"4294967295 "
];
unsigned
long
n
;
dns_name_t
name
;
dns_name_t
prefix
;
isc_boolean_t
sub
;
REQUIRE
(
rdata
->
type
==
249
);
origin
=
origin
;
/*unused*/
dns_rdata_toregion
(
rdata
,
&
sr
);