Commit 2eae3ad0 authored by Mark Andrews's avatar Mark Andrews

Merge remote-tracking branch 'origin/rt28040'

parents a26e1cac 8a468907
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: message.h,v 1.132 2010/03/04 23:50:34 tbox Exp $ */
/* $Id: message.h,v 1.132.528.1 2012/02/22 05:03:39 marka Exp $ */
#ifndef DNS_MESSAGE_H
#define DNS_MESSAGE_H 1
......@@ -1349,6 +1349,16 @@ dns_message_gettimeadjust(dns_message_t *msg);
* Requires:
*\li msg be a valid message.
*/
void
dns_message_logpacket(dns_message_t *message, const char *description,
isc_logcategory_t *category, isc_logmodule_t *module,
int level, isc_mem_t *mctx);
/*%<
* Log 'message' at the specified logging parameters.
* 'description' will be emitted at the start of the message and will
* normally end with a newline.
*/
ISC_LANG_ENDDECLS
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: message.c,v 1.257 2011/06/08 22:13:50 each Exp $ */
/* $Id: message.c,v 1.257.214.1 2012/02/22 05:03:38 marka Exp $ */
/*! \file */
......@@ -3449,3 +3449,43 @@ dns_opcode_totext(dns_opcode_t opcode, isc_buffer_t *target) {
isc_buffer_putstr(target, opcodetext[opcode]);
return (ISC_R_SUCCESS);
}
void
dns_message_logpacket(dns_message_t *message, const char *description,
isc_logcategory_t *category, isc_logmodule_t *module,
int level, isc_mem_t *mctx)
{
isc_buffer_t buffer;
char *buf = NULL;
int len = 1024;
isc_result_t result;
if (! isc_log_wouldlog(dns_lctx, level))
return;
/*
* Note that these are multiline debug messages. We want a newline
* to appear in the log after each message.
*/
do {
buf = isc_mem_get(mctx, len);
if (buf == NULL)
break;
isc_buffer_init(&buffer, buf, len);
result = dns_message_totext(message, &dns_master_style_debug,
0, &buffer);
if (result == ISC_R_NOSPACE) {
isc_mem_put(mctx, buf, len);
len += 1024;
} else if (result == ISC_R_SUCCESS)
isc_log_write(dns_lctx, category, module, level,
"%s%.*s", description,
(int)isc_buffer_usedlength(&buffer),
buf);
} while (result == ISC_R_NOSPACE);
if (buf != NULL)
isc_mem_put(mctx, buf, len);
}
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: resolver.c,v 1.448 2012/02/14 23:47:15 tbox Exp $ */
/* $Id: resolver.c,v 1.448.8.1 2012/02/22 05:03:38 marka Exp $ */
/*! \file */
......@@ -6463,43 +6463,6 @@ log_nsid(dns_rdataset_t *opt, resquery_t *query, int level, isc_mem_t *mctx)
return (ISC_R_SUCCESS);
}
static void
log_packet(dns_message_t *message, int level, isc_mem_t *mctx) {
isc_buffer_t buffer;
char *buf = NULL;
int len = 1024;
isc_result_t result;
if (! isc_log_wouldlog(dns_lctx, level))
return;
/*
* Note that these are multiline debug messages. We want a newline
* to appear in the log after each message.
*/
do {
buf = isc_mem_get(mctx, len);
if (buf == NULL)
break;
isc_buffer_init(&buffer, buf, len);
result = dns_message_totext(message, &dns_master_style_debug,
0, &buffer);
if (result == ISC_R_NOSPACE) {
isc_mem_put(mctx, buf, len);
len += 1024;
} else if (result == ISC_R_SUCCESS)
isc_log_write(dns_lctx, DNS_LOGCATEGORY_RESOLVER,
DNS_LOGMODULE_RESOLVER, level,
"received packet:\n%.*s",
(int)isc_buffer_usedlength(&buffer),
buf);
} while (result == ISC_R_NOSPACE);
if (buf != NULL)
isc_mem_put(mctx, buf, len);
}
static isc_boolean_t
iscname(fetchctx_t *fctx) {
isc_result_t result;
......@@ -6734,11 +6697,12 @@ resquery_response(isc_task_t *task, isc_event_t *event) {
}
}
/*
* Log the incoming packet.
*/
log_packet(message, ISC_LOG_DEBUG(10), fctx->res->mctx);
dns_message_logpacket(message, "received packet:\n",
DNS_LOGCATEGORY_RESOLVER, DNS_LOGMODULE_RESOLVER,
ISC_LOG_DEBUG(10), fctx->res->mctx);
/*
* Did we request NSID? If so, and if the response contains
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: xfrin.c,v 1.172 2011/12/22 07:32:41 each Exp $ */
/* $Id: xfrin.c,v 1.172.54.1 2012/02/22 05:03:39 marka Exp $ */
/*! \file */
......@@ -1240,6 +1240,15 @@ xfrin_recv_done(isc_task_t *task, isc_event_t *ev) {
result = dns_message_parse(msg, &tcpmsg->buffer,
DNS_MESSAGEPARSE_PRESERVEORDER);
if (result == ISC_R_SUCCESS)
dns_message_logpacket(msg, "received message:\n",
DNS_LOGCATEGORY_XFER_IN,
DNS_LOGMODULE_XFER_IN,
ISC_LOG_DEBUG(10), xfr->mctx);
else
xfrin_log(xfr, ISC_LOG_DEBUG(10), "dns_message_parse: %s",
dns_result_totext(result));
if (result != ISC_R_SUCCESS || msg->rcode != dns_rcode_noerror ||
(xfr->checkid && msg->id != xfr->id)) {
if (result == ISC_R_SUCCESS)
......
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