static void
logfmtpacket(dns_message_t *message, const char *description,
- const isc_sockaddr_t *address, isc_logcategory_t category,
- isc_logmodule_t module, const dns_master_style_t *style, int level,
- isc_mem_t *mctx);
+ const isc_sockaddr_t *from, const isc_sockaddr_t *to,
+ isc_logcategory_t category, isc_logmodule_t module,
+ const dns_master_style_t *style, int level, isc_mem_t *mctx);
/*
* Allocate a new dns_msgblock_t, and return a pointer to it. If no memory
isc_logmodule_t module, int level, isc_mem_t *mctx) {
REQUIRE(address != NULL);
- logfmtpacket(message, description, address, category, module,
+ logfmtpacket(message, description, address, NULL, category, module,
&dns_master_style_debug, level, mctx);
}
void
dns_message_logfmtpacket(dns_message_t *message, const char *description,
- const isc_sockaddr_t *address,
+ const isc_sockaddr_t *from, const isc_sockaddr_t *to,
isc_logcategory_t category, isc_logmodule_t module,
int level, isc_mem_t *mctx) {
- REQUIRE(address != NULL);
+ REQUIRE(from != NULL && to != NULL);
- logfmtpacket(message, description, address, category, module,
+ logfmtpacket(message, description, from, to, category, module,
&dns_master_style_comment, level, mctx);
}
static void
logfmtpacket(dns_message_t *message, const char *description,
- const isc_sockaddr_t *address, isc_logcategory_t category,
- isc_logmodule_t module, const dns_master_style_t *style, int level,
- isc_mem_t *mctx) {
- char addrbuf[ISC_SOCKADDR_FORMATSIZE] = { 0 };
+ const isc_sockaddr_t *from, const isc_sockaddr_t *to,
+ isc_logcategory_t category, isc_logmodule_t module,
+ const dns_master_style_t *style, int level, isc_mem_t *mctx) {
+ char frombuf[ISC_SOCKADDR_FORMATSIZE] = { 0 };
+ char tobuf[ISC_SOCKADDR_FORMATSIZE] = { 0 };
isc_buffer_t buffer;
char *buf = NULL;
int len = 1024;
* to appear in the log after each message.
*/
- if (address != NULL) {
- isc_sockaddr_format(address, addrbuf, sizeof(addrbuf));
+ if (from != NULL) {
+ isc_sockaddr_format(from, frombuf, sizeof(frombuf));
+ }
+ if (to != NULL) {
+ isc_sockaddr_format(to, tobuf, sizeof(tobuf));
}
do {
isc_mem_put(mctx, buf, len);
len += 1024;
} else if (result == ISC_R_SUCCESS) {
- isc_log_write(category, module, level, "%s %s\n%.*s",
- description, addrbuf,
+ isc_log_write(category, module, level,
+ "%s%s%s%s%s\n%.*s", description,
+ (from != NULL ? " from " : ""), frombuf,
+ (to != NULL ? " to " : ""), tobuf,
(int)isc_buffer_usedlength(&buffer), buf);
}
} while (result == ISC_R_NOSPACE);
* Log the outgoing packet.
*/
dns_message_logfmtpacket(
- fctx->qmessage, "sending packet to", &query->addrinfo->sockaddr,
+ fctx->qmessage, "sending packet to", NULL, &query->addrinfo->sockaddr,
DNS_LOGCATEGORY_RESOLVER, DNS_LOGMODULE_PACKETS,
ISC_LOG_DEBUG(11), fctx->mctx);
dns_message_logfmtpacket(
rctx->query->rmessage, "received packet from",
- &rctx->query->addrinfo->sockaddr, DNS_LOGCATEGORY_RESOLVER,
+ &rctx->query->addrinfo->sockaddr, NULL, DNS_LOGCATEGORY_RESOLVER,
DNS_LOGMODULE_PACKETS, ISC_LOG_DEBUG(10), fctx->mctx);
#ifdef HAVE_DNSTAP