Commit cf3f1410 authored by Brian Wellington's avatar Brian Wellington
Browse files

Changed 'dns_name_t *' in structs to 'dns_name_t'

parent be519935
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: tsig_250.c,v 1.18 1999/09/15 23:03:26 explorer Exp $ */
/* $Id: tsig_250.c,v 1.19 1999/10/07 21:49:38 bwelling Exp $ */
/* draft-ietf-dnsind-tsig-07.txt */
......@@ -308,7 +308,7 @@ fromstruct_any_tsig(dns_rdataclass_t rdclass, dns_rdatatype_t type,
/* Algorithm Name */
RETERR(dns_compress_init(&cctx, -1, tsig->mctx));
dns_compress_setmethods(&cctx, DNS_COMPRESS_NONE);
RETERR(dns_name_towire(tsig->algorithm, &cctx, target));
RETERR(dns_name_towire(&tsig->algorithm, &cctx, target));
dns_compress_invalidate(&cctx);
isc_buffer_available(target, &tr);
......@@ -381,13 +381,10 @@ tostruct_any_tsig(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) {
/* Algorithm Name */
dns_name_init(&alg, NULL);
dns_name_fromregion(&alg, &sr);
tsig->algorithm = (dns_name_t *) isc_mem_get(mctx, sizeof(dns_name_t));
if (tsig->algorithm == NULL)
return (DNS_R_NOMEMORY);
dns_name_init(tsig->algorithm, NULL);
RETERR(dns_name_dup(&alg, mctx, tsig->algorithm));
dns_name_init(&tsig->algorithm, NULL);
RETERR(dns_name_dup(&alg, mctx, &tsig->algorithm));
isc_region_consume(&sr, name_length(tsig->algorithm));
isc_region_consume(&sr, name_length(&tsig->algorithm));
/* Time Signed */
if (sr.length < 6)
......@@ -465,8 +462,7 @@ freestruct_any_tsig(void *source) {
REQUIRE(tsig->common.rdclass == 255);
REQUIRE(tsig->common.rdtype == 250);
dns_name_free(tsig->algorithm, tsig->mctx);
isc_mem_put(tsig->mctx, tsig->algorithm, sizeof(dns_name_t));
dns_name_free(&tsig->algorithm, tsig->mctx);
if (tsig->siglen > 0)
isc_mem_put(tsig->mctx, tsig->signature, tsig->siglen);
if (tsig->otherlen > 0)
......
......@@ -15,14 +15,14 @@
* SOFTWARE.
*/
/* $Id: tsig_250.h,v 1.11 1999/09/15 23:03:26 explorer Exp $ */
/* $Id: tsig_250.h,v 1.12 1999/10/07 21:49:38 bwelling Exp $ */
/* draft-ietf-dnsind-tsig-10.txt */
typedef struct dns_rdata_any_tsig {
dns_rdatacommon_t common;
isc_mem_t * mctx;
dns_name_t * algorithm;
dns_name_t algorithm;
isc_uint64_t timesigned;
isc_uint16_t fudge;
isc_uint16_t siglen;
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: sig_24.c,v 1.22 1999/09/17 09:22:40 gson Exp $ */
/* $Id: sig_24.c,v 1.23 1999/10/07 21:49:38 bwelling Exp $ */
/* RFC 2065 */
......@@ -342,7 +342,7 @@ fromstruct_sig(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source,
/* Signer name */
RETERR(dns_compress_init(&cctx, -1, sig->mctx));
dns_compress_setmethods(&cctx, DNS_COMPRESS_NONE);
RETERR(dns_name_towire(sig->signer, &cctx, target));
RETERR(dns_name_towire(&sig->signer, &cctx, target));
dns_compress_invalidate(&cctx);
/* Signature */
......@@ -419,12 +419,9 @@ tostruct_sig(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) {
dns_name_init(&signer, NULL);
dns_name_fromregion(&signer, &sr);
sig->signer = (dns_name_t *) isc_mem_get(mctx, sizeof(dns_name_t));
if (sig->signer == NULL)
return (DNS_R_NOMEMORY);
dns_name_init(sig->signer, NULL);
RETERR(dns_name_dup(&signer, mctx, sig->signer));
isc_region_consume(&sr, name_length(sig->signer));
dns_name_init(&sig->signer, NULL);
RETERR(dns_name_dup(&signer, mctx, &sig->signer));
isc_region_consume(&sr, name_length(&sig->signer));
/* Signature */
sig->siglen = sr.length;
......@@ -448,8 +445,7 @@ freestruct_sig(void *source) {
REQUIRE(source != NULL);
REQUIRE(sig->common.rdtype == 24);
dns_name_free(sig->signer, sig->mctx);
isc_mem_put(sig->mctx, sig->signer, sizeof(dns_name_t));
dns_name_free(&sig->signer, sig->mctx);
if (sig->siglen > 0)
isc_mem_put(sig->mctx, sig->signature, sig->siglen);
}
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: sig_24.h,v 1.13 1999/09/15 23:03:32 explorer Exp $ */
/* $Id: sig_24.h,v 1.14 1999/10/07 21:49:38 bwelling Exp $ */
/* RFC 2065 */
......@@ -29,7 +29,7 @@ typedef struct dns_rdata_generic_sig_t {
isc_uint32_t timeexpire;
isc_uint32_t timesigned;
isc_uint16_t keyid;
dns_name_t * signer;
dns_name_t signer;
isc_uint16_t siglen;
unsigned char * signature;
} dns_rdata_generic_sig_t;
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: tkey_249.c,v 1.16 1999/09/15 23:03:33 explorer Exp $ */
/* $Id: tkey_249.c,v 1.17 1999/10/07 21:49:38 bwelling Exp $ */
/* draft-ietf-dnssec-tkey-01.txt */
......@@ -281,7 +281,11 @@ compare_tkey(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
static inline dns_result_t
fromstruct_tkey(dns_rdataclass_t rdclass, dns_rdatatype_t type,
void *source, isc_buffer_t *target) {
void *source, isc_buffer_t *target)
{
isc_region_t tr;
dns_rdata_generic_tkey_t *tkey;
dns_compress_t cctx;
REQUIRE(type == 249);
......@@ -290,24 +294,152 @@ fromstruct_tkey(dns_rdataclass_t rdclass, dns_rdatatype_t type,
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
tkey = (dns_rdata_generic_tkey_t *) source;
REQUIRE(tkey->mctx != NULL);
/* Algorithm Name */
RETERR(dns_compress_init(&cctx, -1, tkey->mctx));
dns_compress_setmethods(&cctx, DNS_COMPRESS_NONE);
RETERR(dns_name_towire(&tkey->algorithm, &cctx, target));
dns_compress_invalidate(&cctx);
/* Inception: 32 bits */
RETERR(uint32_tobuffer(tkey->inception, target));
/* Expire: 32 bits */
RETERR(uint32_tobuffer(tkey->expire, target));
/* Mode: 16 bits */
RETERR(uint16_tobuffer(tkey->mode, target));
/* Error: 16 bits */
RETERR(uint16_tobuffer(tkey->error, target));
/* Key size: 16 bits */
RETERR(uint16_tobuffer(tkey->keylen, target));
/* Key */
if (tkey->keylen > 0) {
isc_buffer_available(target, &tr);
if (tr.length < tkey->keylen)
return (DNS_R_NOSPACE);
memcpy(tr.base, tkey->key, tkey->keylen);
isc_buffer_add(target, tkey->keylen);
}
/* Other size: 16 bits */
RETERR(uint16_tobuffer(tkey->otherlen, target));
/* Other data */
if (tkey->otherlen > 0) {
isc_buffer_available(target, &tr);
if (tr.length < tkey->otherlen)
return (DNS_R_NOSPACE);
memcpy(tr.base, tkey->other, tkey->otherlen);
isc_buffer_add(target, tkey->otherlen);
}
return (DNS_R_SUCCESS);
}
static inline dns_result_t
tostruct_tkey(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) {
dns_rdata_generic_tkey_t *tkey;
dns_name_t alg;
isc_region_t sr;
REQUIRE(rdata->type == 249);
target = target;
mctx = mctx;
return (DNS_R_NOTIMPLEMENTED);
tkey = (dns_rdata_generic_tkey_t *) target;
tkey->common.rdclass = rdata->rdclass;
tkey->common.rdtype = rdata->type;
ISC_LINK_INIT(&tkey->common, link);
tkey->mctx = mctx;
dns_rdata_toregion(rdata, &sr);
/* Algorithm Name */
dns_name_init(&alg, NULL);
dns_name_fromregion(&alg, &sr);
dns_name_init(&tkey->algorithm, NULL);
RETERR(dns_name_dup(&alg, mctx, &tkey->algorithm));
isc_region_consume(&sr, name_length(&tkey->algorithm));
/* Inception */
if (sr.length < 4)
return (ISC_R_UNEXPECTEDEND);
tkey->inception = uint32_fromregion(&sr);
isc_region_consume(&sr, 4);
/* Expire */
if (sr.length < 4)
return (ISC_R_UNEXPECTEDEND);
tkey->expire = uint32_fromregion(&sr);
isc_region_consume(&sr, 4);
/* Mode */
if (sr.length < 2)
return (ISC_R_UNEXPECTEDEND);
tkey->mode = uint16_fromregion(&sr);
isc_region_consume(&sr, 2);
/* Error */
if (sr.length < 2)
return (ISC_R_UNEXPECTEDEND);
tkey->error = uint16_fromregion(&sr);
isc_region_consume(&sr, 2);
/* Key size */
if (sr.length < 2)
return (ISC_R_UNEXPECTEDEND);
tkey->keylen = uint16_fromregion(&sr);
isc_region_consume(&sr, 2);
/* Key */
if (tkey->keylen > 0) {
tkey->key = isc_mem_get(mctx, tkey->keylen);
if (tkey->key == NULL)
return (DNS_R_NOMEMORY);
memcpy(tkey->key, sr.base, tkey->keylen);
isc_region_consume(&sr, tkey->keylen);
}
else
tkey->key = NULL;
/* Other size */
if (sr.length < 2)
return (ISC_R_UNEXPECTEDEND);
tkey->otherlen = uint16_fromregion(&sr);
isc_region_consume(&sr, 2);
/* Other */
if (tkey->otherlen > 0) {
tkey->other = isc_mem_get(mctx, tkey->otherlen);
if (tkey->other == NULL)
return (DNS_R_NOMEMORY);
memcpy(tkey->other, sr.base, tkey->otherlen);
isc_region_consume(&sr, tkey->otherlen);
}
else
tkey->other = NULL;
return (DNS_R_SUCCESS);
}
static inline void
freestruct_tkey(void *source) {
dns_rdata_generic_tkey_t *tkey = (dns_rdata_generic_tkey_t *) source;
REQUIRE(source != NULL);
REQUIRE(ISC_FALSE); /*XXX*/
dns_name_free(&tkey->algorithm, tkey->mctx);
if (tkey->keylen > 0)
isc_mem_put(tkey->mctx, tkey->key, tkey->keylen);
if (tkey->otherlen > 0)
isc_mem_put(tkey->mctx, tkey->other, tkey->otherlen);
}
static inline dns_result_t
......
......@@ -15,7 +15,21 @@
* SOFTWARE.
*/
/* $Id: tkey_249.h,v 1.10 1999/09/15 23:03:33 explorer Exp $ */
/* $Id: tkey_249.h,v 1.11 1999/10/07 21:49:39 bwelling Exp $ */
/* draft-ietf-dnssec-tkey-01.txt */
/* draft-ietf-dnsind-tkey-00.txt */
typedef struct dns_rdata_generic_tkey {
dns_rdatacommon_t common;
isc_mem_t * mctx;
dns_name_t algorithm;
isc_uint32_t inception;
isc_uint32_t expire;
isc_uint16_t mode;
isc_uint16_t error;
isc_uint16_t keylen;
unsigned char * key;
isc_uint16_t otherlen;
unsigned char * other;
} dns_rdata_generic_tkey_t;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment