mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-02 15:45:25 +00:00
Added dns_tsigrcode_totext/fromtext
This commit is contained in:
@@ -56,6 +56,39 @@ isc_result_t dns_rcode_totext(dns_rcode_t rcode, isc_buffer_t *target);
|
|||||||
* ISC_R_NOSPACE target buffer is too small
|
* ISC_R_NOSPACE target buffer is too small
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
isc_result_t dns_tsigrcode_fromtext(dns_rcode_t *rcodep,
|
||||||
|
isc_textregion_t *source);
|
||||||
|
/*
|
||||||
|
* Convert the text 'source' refers to into a TSIG/TKEY error value.
|
||||||
|
*
|
||||||
|
* Requires:
|
||||||
|
* 'rcodep' is a valid pointer.
|
||||||
|
*
|
||||||
|
* 'source' is a valid text region.
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* ISC_R_SUCCESS on success
|
||||||
|
* DNS_R_UNKNOWN type is unknown
|
||||||
|
*/
|
||||||
|
|
||||||
|
isc_result_t dns_tsigrcode_totext(dns_rcode_t rcode, isc_buffer_t *target);
|
||||||
|
/*
|
||||||
|
* Put a textual representation of TSIG/TKEY error 'rcode' into 'target'.
|
||||||
|
*
|
||||||
|
* Requires:
|
||||||
|
* 'rcode' is a valid TSIG/TKEY error code.
|
||||||
|
*
|
||||||
|
* 'target' is a valid text buffer.
|
||||||
|
*
|
||||||
|
* Ensures:
|
||||||
|
* If the result is success:
|
||||||
|
* The used space in 'target' is updated.
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* ISC_R_SUCCESS on success
|
||||||
|
* ISC_R_NOSPACE target buffer is too small
|
||||||
|
*/
|
||||||
|
|
||||||
ISC_LANG_ENDDECLS
|
ISC_LANG_ENDDECLS
|
||||||
|
|
||||||
#endif /* DNS_RCODE_H */
|
#endif /* DNS_RCODE_H */
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: rdata.c,v 1.96 2000/05/24 15:07:56 tale Exp $ */
|
/* $Id: rdata.c,v 1.97 2000/05/25 00:46:28 bwelling Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@@ -180,11 +180,23 @@ static const char decdigits[] = "0123456789";
|
|||||||
{ dns_rcode_yxrrset, "YXRRSET", 0}, \
|
{ dns_rcode_yxrrset, "YXRRSET", 0}, \
|
||||||
{ dns_rcode_nxrrset, "NXRRSET", 0}, \
|
{ dns_rcode_nxrrset, "NXRRSET", 0}, \
|
||||||
{ dns_rcode_notauth, "NOTAUTH", 0}, \
|
{ dns_rcode_notauth, "NOTAUTH", 0}, \
|
||||||
{ dns_rcode_notzone, "NOTZONE", 0}, \
|
{ dns_rcode_notzone, "NOTZONE", 0},
|
||||||
|
|
||||||
|
#define ERCODENAMES \
|
||||||
/* extended rcodes */ \
|
/* extended rcodes */ \
|
||||||
{ dns_rcode_badvers, "BADVERS", 0}, \
|
{ dns_rcode_badvers, "BADVERS", 0}, \
|
||||||
{ 0, NULL, 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}, \
|
||||||
|
{ 0, NULL, 0 }
|
||||||
|
|
||||||
#define CERTNAMES \
|
#define CERTNAMES \
|
||||||
{ 1, "SKIX", 0}, \
|
{ 1, "SKIX", 0}, \
|
||||||
{ 2, "SPKI", 0}, \
|
{ 2, "SPKI", 0}, \
|
||||||
@@ -222,7 +234,8 @@ struct tbl {
|
|||||||
int flags;
|
int flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct tbl rcodes[] = { RCODENAMES };
|
static struct tbl rcodes[] = { RCODENAMES ERCODENAMES };
|
||||||
|
static struct tbl tsigrcodes[] = { RCODENAMES TSIGRCODENAMES };
|
||||||
static struct tbl certs[] = { CERTNAMES };
|
static struct tbl certs[] = { CERTNAMES };
|
||||||
static struct tbl secalgs[] = { SECALGNAMES };
|
static struct tbl secalgs[] = { SECALGNAMES };
|
||||||
static struct tbl secprotos[] = { SECPROTONAMES };
|
static struct tbl secprotos[] = { SECPROTONAMES };
|
||||||
@@ -851,26 +864,30 @@ dns_rdatatype_totext(dns_rdatatype_t type, isc_buffer_t *target) {
|
|||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
dns_rcode_fromtext(dns_rcode_t *rcodep, isc_textregion_t *source) {
|
dns_rcode_fromtext(dns_rcode_t *rcodep, isc_textregion_t *source) {
|
||||||
int i = 0;
|
unsigned int value;
|
||||||
unsigned int n;
|
RETERR(dns_mnemonic_fromtext(&value, source, rcodes, 0xffff));
|
||||||
|
*rcodep = value;
|
||||||
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 (ISC_R_SUCCESS);
|
return (ISC_R_SUCCESS);
|
||||||
}
|
}
|
||||||
i++;
|
|
||||||
}
|
|
||||||
return (DNS_R_UNKNOWN);
|
|
||||||
}
|
|
||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
dns_rcode_totext(dns_rcode_t rcode, isc_buffer_t *target) {
|
dns_rcode_totext(dns_rcode_t rcode, isc_buffer_t *target) {
|
||||||
return (dns_mnemonic_totext(rcode, target, rcodes));
|
return (dns_mnemonic_totext(rcode, target, rcodes));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isc_result_t
|
||||||
|
dns_tsigrcode_fromtext(dns_rcode_t *rcodep, isc_textregion_t *source) {
|
||||||
|
unsigned int value;
|
||||||
|
RETERR(dns_mnemonic_fromtext(&value, source, tsigrcodes, 0xffff));
|
||||||
|
*rcodep = value;
|
||||||
|
return (ISC_R_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
isc_result_t
|
||||||
|
dns_tsigrcode_totext(dns_rcode_t rcode, isc_buffer_t *target) {
|
||||||
|
return (dns_mnemonic_totext(rcode, target, tsigrcodes));
|
||||||
|
}
|
||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
dns_cert_fromtext(dns_cert_t *certp, isc_textregion_t *source) {
|
dns_cert_fromtext(dns_cert_t *certp, isc_textregion_t *source) {
|
||||||
unsigned int value;
|
unsigned int value;
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: tsig_250.c,v 1.38 2000/05/22 12:37:28 marka Exp $ */
|
/* $Id: tsig_250.c,v 1.39 2000/05/25 00:46:31 bwelling Exp $ */
|
||||||
|
|
||||||
/* Reviewed: Thu Mar 16 13:39:43 PST 2000 by gson */
|
/* Reviewed: Thu Mar 16 13:39:43 PST 2000 by gson */
|
||||||
|
|
||||||
@@ -36,6 +36,8 @@ fromtext_any_tsig(dns_rdataclass_t rdclass, dns_rdatatype_t type,
|
|||||||
dns_name_t name;
|
dns_name_t name;
|
||||||
isc_uint64_t sigtime;
|
isc_uint64_t sigtime;
|
||||||
isc_buffer_t buffer;
|
isc_buffer_t buffer;
|
||||||
|
dns_rcode_t rcode;
|
||||||
|
long i;
|
||||||
char *e;
|
char *e;
|
||||||
|
|
||||||
REQUIRE(type == 250);
|
REQUIRE(type == 250);
|
||||||
@@ -94,10 +96,18 @@ fromtext_any_tsig(dns_rdataclass_t rdclass, dns_rdatatype_t type,
|
|||||||
/*
|
/*
|
||||||
* 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_tsigrcode_fromtext(&rcode, &token.value.as_textregion)
|
||||||
|
!= ISC_R_SUCCESS)
|
||||||
|
{
|
||||||
|
i = strtol(token.value.as_pointer, &e, 10);
|
||||||
|
if (*e != 0)
|
||||||
|
return (DNS_R_UNKNOWN);
|
||||||
|
if (i < 0 || i > 0xffff)
|
||||||
return (ISC_R_RANGE);
|
return (ISC_R_RANGE);
|
||||||
RETERR(uint16_tobuffer(token.value.as_ulong, target));
|
rcode = (dns_rcode_t)i;
|
||||||
|
}
|
||||||
|
RETERR(uint16_tobuffer(rcode, target));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Other Len.
|
* Other Len.
|
||||||
@@ -206,8 +216,12 @@ totext_any_tsig(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
|
|||||||
*/
|
*/
|
||||||
n = uint16_fromregion(&sr);
|
n = uint16_fromregion(&sr);
|
||||||
isc_region_consume(&sr, 2);
|
isc_region_consume(&sr, 2);
|
||||||
|
if (dns_tsigrcode_totext((dns_rcode_t)n, target) == ISC_R_SUCCESS)
|
||||||
|
RETERR(str_totext(" ", target));
|
||||||
|
else {
|
||||||
sprintf(buf, "%u ", n);
|
sprintf(buf, "%u ", n);
|
||||||
RETERR(str_totext(buf, target));
|
RETERR(str_totext(buf, target));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Other Size.
|
* Other Size.
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: tkey_249.c,v 1.34 2000/05/22 12:37:59 marka Exp $ */
|
/* $Id: tkey_249.c,v 1.35 2000/05/25 00:46:32 bwelling Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reviewed: Thu Mar 16 17:35:30 PST 2000 by halley.
|
* Reviewed: Thu Mar 16 17:35:30 PST 2000 by halley.
|
||||||
@@ -78,8 +78,9 @@ fromtext_tkey(dns_rdataclass_t rdclass, dns_rdatatype_t type,
|
|||||||
* Error.
|
* Error.
|
||||||
*/
|
*/
|
||||||
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
|
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
|
||||||
if (dns_rcode_fromtext(&rcode, &token.value.as_textregion)
|
if (dns_tsigrcode_fromtext(&rcode, &token.value.as_textregion)
|
||||||
!= ISC_R_SUCCESS) {
|
!= ISC_R_SUCCESS)
|
||||||
|
{
|
||||||
i = strtol(token.value.as_pointer, &e, 10);
|
i = strtol(token.value.as_pointer, &e, 10);
|
||||||
if (*e != 0)
|
if (*e != 0)
|
||||||
return (DNS_R_UNKNOWN);
|
return (DNS_R_UNKNOWN);
|
||||||
@@ -171,7 +172,7 @@ totext_tkey(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
|
|||||||
*/
|
*/
|
||||||
n = uint16_fromregion(&sr);
|
n = uint16_fromregion(&sr);
|
||||||
isc_region_consume(&sr, 2);
|
isc_region_consume(&sr, 2);
|
||||||
if (dns_rcode_totext((dns_rcode_t)n, target) == ISC_R_SUCCESS)
|
if (dns_tsigrcode_totext((dns_rcode_t)n, target) == ISC_R_SUCCESS)
|
||||||
RETERR(str_totext(" ", target));
|
RETERR(str_totext(" ", target));
|
||||||
else {
|
else {
|
||||||
sprintf(buf, "%lu ", n);
|
sprintf(buf, "%lu ", n);
|
||||||
|
Reference in New Issue
Block a user