Commit 8d6fe3f3 authored by Brian Wellington's avatar Brian Wellington

Pointers to regions are silly. Use regions instead. This removes 1 small

allocation per query.
parent 065958bd
......@@ -16,7 +16,7 @@
*/
/*
* $Id: dnssec.c,v 1.56 2000/12/11 19:24:05 bwelling Exp $
* $Id: dnssec.c,v 1.57 2001/01/03 20:42:07 bwelling Exp $
*/
......@@ -527,7 +527,7 @@ dns_dnssec_signmessage(dns_message_t *msg, dst_key_t *key) {
REQUIRE(key != NULL);
if (is_response(msg))
REQUIRE(msg->query != NULL);
REQUIRE(msg->query.base != NULL);
mctx = msg->mctx;
......@@ -560,7 +560,7 @@ dns_dnssec_signmessage(dns_message_t *msg, dst_key_t *key) {
RETERR(dst_context_create(key, mctx, &ctx));
if (is_response(msg))
RETERR(dst_context_adddata(ctx, msg->query));
RETERR(dst_context_adddata(ctx, &msg->query));
/*
* Digest the header.
......@@ -658,7 +658,7 @@ dns_dnssec_verifymessage(isc_buffer_t *source, dns_message_t *msg,
REQUIRE(key != NULL);
if (is_response(msg))
REQUIRE(msg->query != NULL);
REQUIRE(msg->query.base != NULL);
mctx = msg->mctx;
......@@ -701,7 +701,7 @@ dns_dnssec_verifymessage(isc_buffer_t *source, dns_message_t *msg,
* If this is a response, digest the query.
*/
if (is_response(msg))
RETERR(dst_context_adddata(ctx, msg->query));
RETERR(dst_context_adddata(ctx, &msg->query));
/*
* Extract the header.
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: message.h,v 1.83 2000/11/13 21:34:01 bwelling Exp $ */
/* $Id: message.h,v 1.84 2001/01/03 20:42:10 bwelling Exp $ */
#ifndef DNS_MESSAGE_H
#define DNS_MESSAGE_H 1
......@@ -217,9 +217,8 @@ struct dns_message {
dns_name_t *sig0name;
dst_key_t *sig0key;
dns_rcode_t sig0status;
isc_region_t *query;
isc_region_t *saved;
isc_buffer_t *rawmessge;
isc_region_t query;
isc_region_t saved;
dns_rdatasetorderfunc_t order;
void * order_arg;
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: message.c,v 1.164 2000/12/11 19:24:13 bwelling Exp $ */
/* $Id: message.c,v 1.165 2001/01/03 20:42:08 bwelling Exp $ */
/***
*** Imports
......@@ -355,8 +355,10 @@ msginittsig(dns_message_t *m) {
m->sigstart = -1;
m->sig0key = NULL;
m->sig0status = dns_rcode_noerror;
m->query = NULL;
m->saved = NULL;
m->query.base = NULL;
m->query.length = 0;
m->saved.base = NULL;
m->saved.length = 0;
m->querytsig = NULL;
}
......@@ -555,16 +557,16 @@ msgreset(dns_message_t *msg, isc_boolean_t everything) {
msg->tsigkey = NULL;
}
if (msg->query != NULL) {
isc_mem_put(msg->mctx, msg->query->base, msg->query->length);
isc_mem_put(msg->mctx, msg->query, sizeof(isc_region_t));
msg->query = NULL;
if (msg->query.base != NULL) {
isc_mem_put(msg->mctx, msg->query.base, msg->query.length);
msg->query.base = NULL;
msg->query.length = 0;
}
if (msg->saved != NULL) {
isc_mem_put(msg->mctx, msg->saved->base, msg->saved->length);
isc_mem_put(msg->mctx, msg->saved, sizeof(isc_region_t));
msg->saved = NULL;
if (msg->saved.base != NULL) {
isc_mem_put(msg->mctx, msg->saved.base, msg->saved.length);
msg->saved.base = NULL;
msg->saved.length = 0;
}
/*
......@@ -1538,19 +1540,14 @@ dns_message_parse(dns_message_t *msg, isc_buffer_t *source,
r.length);
}
msg->saved = isc_mem_get(msg->mctx, sizeof(isc_region_t));
if (msg->saved == NULL)
return (ISC_R_NOMEMORY);
isc_buffer_usedregion(&origsource, &r);
msg->saved->length = r.length;
msg->saved->base = isc_mem_get(msg->mctx, msg->saved->length);
if (msg->saved->base == NULL) {
isc_mem_put(msg->mctx, msg->saved,
sizeof(isc_region_t));
msg->saved = NULL;
msg->saved.length = r.length;
msg->saved.base = isc_mem_get(msg->mctx, msg->saved.length);
if (msg->saved.base == NULL) {
msg->saved.length = 0;
return (ISC_R_NOMEMORY);
}
memcpy(msg->saved->base, r.base, msg->saved->length);
memcpy(msg->saved.base, r.base, msg->saved.length);
if (seen_problem == ISC_TRUE)
return (DNS_R_RECOVERABLE);
......@@ -2264,9 +2261,11 @@ dns_message_reply(dns_message_t *msg, isc_boolean_t want_question_section) {
return (result);
}
}
if (msg->saved != NULL) {
msg->query = msg->saved;
msg->saved = NULL;
if (msg->saved.base != NULL) {
msg->query.base = msg->saved.base;
msg->query.length = msg->saved.length;
msg->saved.base = NULL;
msg->saved.length = 0;
}
return (ISC_R_SUCCESS);
......@@ -2642,9 +2641,9 @@ dns_message_checksig(dns_message_t *msg, dns_view_t *view) {
if (msg->tsigkey == NULL && msg->tsig == NULL && msg->sig0 == NULL)
return (ISC_R_SUCCESS);
INSIST(msg->saved != NULL);
isc_buffer_init(&msgb, msg->saved->base, msg->saved->length);
isc_buffer_add(&msgb, msg->saved->length);
INSIST(msg->saved.base != NULL);
isc_buffer_init(&msgb, msg->saved.base, msg->saved.length);
isc_buffer_add(&msgb, msg->saved.length);
if (msg->tsigkey != NULL || msg->tsig != NULL) {
if (view != NULL)
return (dns_view_checksig(view, &msgb, msg));
......@@ -2963,7 +2962,7 @@ dns_message_totext(dns_message_t *msg, dns_messagetextflag_t flags,
isc_region_t *
dns_message_getrawmessage(dns_message_t *msg) {
REQUIRE(DNS_MESSAGE_VALID(msg));
return (msg->saved);
return (&msg->saved);
}
void
......
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