#include "gettime.hh"
#include "dnstap.hh"
-DnstapMessage::DnstapMessage(const std::string& identity, const ComboAddress* requestor, const ComboAddress* responder, bool isTCP, const char* packet, const size_t len, const struct timespec* queryTime, const struct timespec* responseTime, bool recursor)
+DnstapMessage::DnstapMessage(const std::string& identity, const ComboAddress* requestor, const ComboAddress* responder, bool isTCP, const char* packet, const size_t len, const struct timespec* queryTime, const struct timespec* responseTime)
{
#ifdef HAVE_PROTOBUF
const struct dnsheader* dh = reinterpret_cast<const struct dnsheader*>(packet);
dnstap::Message* message = proto_message.mutable_message();
- if (recursor) {
- message->set_type(!dh->qr ? dnstap::Message_Type_RESOLVER_QUERY : dnstap::Message_Type_RESOLVER_RESPONSE);
- } else {
- message->set_type(!dh->qr ? dnstap::Message_Type_CLIENT_QUERY : dnstap::Message_Type_CLIENT_RESPONSE);
- }
+ message->set_type(!dh->qr ? dnstap::Message_Type_CLIENT_QUERY : dnstap::Message_Type_CLIENT_RESPONSE);
message->set_socket_protocol(isTCP ? dnstap::TCP : dnstap::UDP);
if (requestor != nullptr) {
class DnstapMessage
{
public:
- DnstapMessage(const std::string& identity, const ComboAddress* requestor, const ComboAddress* responder, bool isTCP, const char* packet, const size_t len, const struct timespec* queryTime, const struct timespec* responseTime, bool recursor = false);
+ DnstapMessage(const std::string& identity, const ComboAddress* requestor, const ComboAddress* responder, bool isTCP, const char* packet, const size_t len, const struct timespec* queryTime, const struct timespec* responseTime);
void serialize(std::string& data) const;
std::string toDebugString() const;
#include "uuid-utils.hh"
#ifdef HAVE_FSTRM
-#include "dnstap.hh"
+#include "rec-dnstap.hh"
#include "fstrm_logger.hh"
bool g_syslog;
struct timespec ts;
TIMEVAL_TO_TIMESPEC(&queryTime, &ts);
- DnstapMessage message(SyncRes::s_serverID, nullptr, &ip, doTCP, reinterpret_cast<const char*>(&*packet.begin()), packet.size(), &ts, nullptr, true);
+ DnstapMessage message(SyncRes::s_serverID, nullptr, &ip, doTCP, reinterpret_cast<const char*>(&*packet.begin()), packet.size(), &ts, nullptr);
std::string str;
message.serialize(str);
struct timespec ts1, ts2;
TIMEVAL_TO_TIMESPEC(&queryTime, &ts1);
TIMEVAL_TO_TIMESPEC(&replyTime, &ts2);
- DnstapMessage message(SyncRes::s_serverID, nullptr, &ip, doTCP, static_cast<const char*>(&*packet.begin()), packet.size(), &ts1, &ts2, true);
+ RecDnstapMessage message(SyncRes::s_serverID, nullptr, &ip, doTCP, static_cast<const char*>(&*packet.begin()), packet.size(), &ts1, &ts2);
std::string str;
message.serialize(str);
--- /dev/null
+/*
+ * This file is part of PowerDNS or dnsdist.
+ * Copyright -- PowerDNS.COM B.V. and its contributors
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * In addition, for the avoidance of any doubt, permission is granted to
+ * link this program with OpenSSL and to (re)distribute the binaries
+ * produced as the result of such linking.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#pragma once
+
+#ifdef HAVE_FSTRM
+#include "dnstap.hh"
+#endif /* HAVE_FSTRM */
+
+class RecDnstapMessage : public DnstapMessage
+{
+public:
+ RecDnstapMessage(const std::string& identity, const ComboAddress* requestor, const ComboAddress* responder, bool isTCP, const char* packet, const size_t len, const struct timespec* queryTime, const struct timespec* responseTime)
+ : DnstapMessage(identity, requestor, responder, isTCP, packet, len, queryTime, responseTime) {
+ const struct dnsheader* dh = reinterpret_cast<const struct dnsheader*>(packet);
+ dnstap::Message* message = proto_message.mutable_message();
+ message->set_type(!dh->qr ? dnstap::Message_Type_RESOLVER_QUERY : dnstap::Message_Type_RESOLVER_RESPONSE);
+ }
+};
if FSTRM
BUILT_SOURCES += dnstap.pb.cc
-pdns_recursor.$(OBJEXT): dnstap.pb.cc dnsmessage.pb.cc
+pdns_recursor.$(OBJEXT): dnstap.pb.cc dnsmessage.pb.cc
testrunner$(OBJEXT): dnstap.pb.cc dnsmessage.pb.cc
nodist_pdns_recursor_SOURCES += dnstap.pb.cc dnstap.pb.h
nodist_testrunner_SOURCES += dnstap.pb.cc dnstap.pb.h
if FSTRM
pdns_recursor_SOURCES += \
- dnstap.cc dnstap.hh fstrm_logger.cc fstrm_logger.hh
+ dnstap.cc dnstap.hh fstrm_logger.cc fstrm_logger.hh rec-dnstap.hh
pdns_recursor_LDADD += \
$(FSTRM_LIBS)
--- /dev/null
+../rec-dnstap.hh
\ No newline at end of file