bin_PROGRAMS += \
dnsgram \
dnspcap2calidns \
+ dnspcap2protobuf \
dnsreplay \
dnsscan \
dnsscope \
dnsdemog \
dnsgram \
dnspcap2calidns \
+ dnspcap2protobuf \
dnsreplay \
dnsscan \
dnsscope \
$(LIBCRYPTO_LIBS) \
$(BOOST_PROGRAM_OPTIONS_LIBS)
-if HAVE_PROTOBUF
-if HAVE_PROTOC
-bin_PROGRAMS += dnspcap2protobuf
-
-dnsmessage.pb.cc: dnsmessage.proto
- $(AM_V_GEN)$(PROTOC) --cpp_out=./ $<
-
-BUILT_SOURCES += dnsmessage.pb.cc
-dnspcap2protobuf.$(OBJEXT): dnsmessage.pb.cc
-
dnspcap2protobuf_SOURCES = \
base32.cc \
base64.cc base64.hh \
logger.cc \
misc.cc \
nsecrecords.cc \
- protobuf.cc protobuf.hh \
+ protozero.cc protozero.hh \
qtype.cc \
rcpgenerator.cc rcpgenerator.hh \
sillyrecords.cc \
utility.hh \
uuid-utils.hh uuid-utils.cc
-nodist_dnspcap2protobuf_SOURCES=dnsmessage.pb.cc dnsmessage.pb.h
-
dnspcap2protobuf_LDFLAGS = \
$(AM_LDFLAGS) \
$(LIBCRYPTO_LDFLAGS) \
dnspcap2protobuf_LDADD = \
$(LIBCRYPTO_LIBS) \
- $(PROTOBUF_LIBS) \
$(BOOST_PROGRAM_OPTIONS_LIBS) \
$(RT_LIBS)
-endif
-endif
pdns.conf-dist: pdns_server
$(AM_V_GEN)./pdns_server --config=default 2>/dev/null > $@
#include "iputils.hh"
#include "misc.hh"
-#include "protobuf.hh"
#include "dns.hh"
#include "dnspcap.hh"
#include "dnsparser.hh"
-#include "protobuf.hh"
+#include "protozero.hh"
#include "uuid-utils.hh"
#include "statbag.hh"
ind=atoi(argv[3]);
std::map<uint16_t,std::pair<boost::uuids::uuid,struct timeval> > ids;
+ std::string pbBuffer;
try {
while (pr.getUDPPacket()) {
const dnsheader* dh=(dnsheader*)pr.d_payload;
*((char*)&requestor.sin4.sin_addr.s_addr)|=ind;
*((char*)&responder.sin4.sin_addr.s_addr)|=ind;
- DNSProtoBufMessage message(dh->qr ? DNSProtoBufMessage::DNSProtoBufMessageType::Response : DNSProtoBufMessage::DNSProtoBufMessageType::Query, uniqueId, &requestor, &responder, qname, qtype, qclass, dh->id, false, pr.d_len);
- message.setTime(pr.d_pheader.ts.tv_sec, pr.d_pheader.ts.tv_usec);
+ pbBuffer.clear();
+ pdns::ProtoZero::Message pbMessage(pbBuffer);
+ pbMessage.setType(dh->qr ? 2 : 1);
+ pbMessage.setRequest(uniqueId, requestor, responder, qname, qtype, qclass, dh->id, false, pr.d_len);
+ pbMessage.setTime(pr.d_pheader.ts.tv_sec, pr.d_pheader.ts.tv_usec);
if (dh->qr) {
- message.setResponseCode(dh->rcode);
+ pbMessage.startResponse();
+ pbMessage.setResponseCode(dh->rcode);
if (hasQueryTime) {
- message.setQueryTime(queryTime.tv_sec, queryTime.tv_usec);
+ pbMessage.setQueryTime(queryTime.tv_sec, queryTime.tv_usec);
}
try {
- message.addRRsFromPacket((const char*) dh, pr.d_len, true);
+ pbMessage.addRRsFromPacket((const char*) dh, pr.d_len, true);
}
- catch(std::exception& e)
+ catch (const std::exception& e)
{
cerr<<"Error parsing response records: "<<e.what()<<endl;
}
}
}
- std::string str;
- message.serialize(str);
-
- uint16_t mlen = htons(str.length());
+ uint16_t mlen = htons(pbBuffer.length());
fwrite(&mlen, 1, sizeof(mlen), fp.get());
- fwrite(str.c_str(), 1, str.length(), fp.get());
+ fwrite(pbBuffer.c_str(), 1, pbBuffer.length(), fp.get());
}
}
catch (const std::exception& e) {