From: Daniel Salzman Date: Thu, 4 Mar 2021 15:29:05 +0000 (+0100) Subject: mod-dnstap: fill out the destination address X-Git-Tag: v3.1.0~205 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d05d6abe9305fe2dfd7a0610a4e4373a84ca33f6;p=thirdparty%2Fknot-dns.git mod-dnstap: fill out the destination address --- diff --git a/src/knot/modules/dnstap/dnstap.c b/src/knot/modules/dnstap/dnstap.c index 35eb2cbbe3..0b3fdc7d6c 100644 --- a/src/knot/modules/dnstap/dnstap.c +++ b/src/knot/modules/dnstap/dnstap.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2020 CZ.NIC, z.s.p.o. +/* Copyright (C) 2021 CZ.NIC, z.s.p.o. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,6 +15,7 @@ */ #include +#include #include "contrib/dnstap/dnstap.h" #include "contrib/dnstap/dnstap.pb-c.h" @@ -88,12 +89,18 @@ static knotd_state_t log_message(knotd_state_t state, const knot_pkt_t *pkt, protocol = IPPROTO_UDP; } + /* Try to get the destination address. */ + struct sockaddr_storage dst_addr; + socklen_t dst_addr_len = sizeof(dst_addr); + (void)getsockname(qdata->params->socket, (struct sockaddr *)&dst_addr, + &dst_addr_len); + /* Create a dnstap message. */ Dnstap__Message msg; int ret = dt_message_fill(&msg, msgtype, (const struct sockaddr *)qdata->params->remote, - NULL, /* todo: fill me! */ - protocol, pkt->wire, pkt->size, &tv); + (struct sockaddr *)&dst_addr, protocol, pkt->wire, + pkt->size, &tv); if (ret != KNOT_EOK) { return state; }