dnsseckeeper.hh dnssecinfra.hh base32.hh dns.cc dnssecsigner.cc polarrsakeyinfra.cc \
md5.hh signingpipe.cc signingpipe.hh dnslabeltext.cc lua-pdns.cc lua-auth.cc lua-auth.hh serialtweaker.cc \
ednssubnet.cc ednssubnet.hh cachecleaner.hh json.cc json.hh \
-version.hh version.cc rfc2136handler.cc
+version.hh version.cc rfc2136handler.cc responsestats.cc responsestats.hh
#
pdns_server_LDFLAGS=@moduleobjects@ @modulelibs@ @DYNLINKFLAGS@ @LIBDL@ @THREADFLAGS@ $(BOOST_SERIALIZATION_LDFLAGS) -rdynamic
toysdig_SOURCES=toysdig.cc sstuff.hh dnsparser.cc dnsparser.hh dnsrecords.cc dnswriter.cc dnslabeltext.cc dnswriter.hh \
misc.cc misc.hh rcpgenerator.cc rcpgenerator.hh base64.cc base64.hh unix_utility.cc \
logger.cc statbag.cc qtype.cc sillyrecords.cc nsecrecords.cc base32.cc \
- ednssubnet.cc ednssubnet.hh
+ ednssubnet.cc ednssubnet.hh aes/aescpp.h \
+ aes/aescrypt.c aes/aes.h aes/aeskey.c aes/aes_modes.c aes/aesopt.h \
+ aes/aestab.c aes/aestab.h aes/brg_endian.h aes/brg_types.h aes/dns_random.cc \
+ randomhelper.cc
#tcptorture_SOURCES=tcptorture.cc sstuff.hh dnsparser.cc dnsparser.hh dnsrecords.cc dnswriter.cc dnslabeltext.cc dnswriter.hh \
#include <iostream>
#include <string>
#include <sys/types.h>
+#include "responsestats.hh"
#include <boost/shared_ptr.hpp>
#include "dns.hh"
#include "dnsbackend.hh"
if(::arg()["local-address"].empty() && ::arg()["local-ipv6"].empty())
L<<Logger::Critical<<"PDNS is deaf and mute! Not listening on any interfaces"<<endl;
}
+
+ResponseStats g_rs;
+
void UDPNameserver::send(DNSPacket *p)
{
const string& buffer=p->getString();
+ g_rs.submitResponse(p->qtype.getCode(), buffer.length(), true);
+
struct msghdr msgh;
struct cmsghdr *cmsg;
struct iovec iov;
}
DLOG(L<<Logger::Notice<<"Sending a packet to "<< p->getRemote() <<" ("<< buffer.length()<<" octets)"<<endl);
if(buffer.length() > p->getMaxReplyLen()) {
- cerr<<"Weird, trying to send a message that needs truncation, "<< buffer.length()<<" > "<<p->getMaxReplyLen()<<endl;
+ L<<Logger::Error<<"Weird, trying to send a message that needs truncation, "<< buffer.length()<<" > "<<p->getMaxReplyLen()<<endl;
}
if(sendmsg(p->getSocket(), &msgh, 0) < 0)
L<<Logger::Error<<"Error sending reply with sendmsg (socket="<<p->getSocket()<<"): "<<strerror(errno)<<endl;
--- /dev/null
+#include "responsestats.hh"
+#include <limits>
+#include "namespaces.hh"
+
+ResponseStats::ResponseStats()
+{
+ d_qtypecounters.resize(std::numeric_limits<uint16_t>::max());
+ d_sizecounters.push_back(make_pair(20,0));
+ d_sizecounters.push_back(make_pair(40,0));
+ d_sizecounters.push_back(make_pair(60,0));
+ d_sizecounters.push_back(make_pair(80,0));
+ d_sizecounters.push_back(make_pair(100,0));
+ d_sizecounters.push_back(make_pair(150,0));
+ for(int n=200; n < 65000 ; n+=200)
+ d_sizecounters.push_back(make_pair(n,0));
+ d_sizecounters.push_back(make_pair(std::numeric_limits<uint16_t>::max(),0));
+}
+
+static bool pcomp(const pair<uint16_t, uint64_t>&a , const pair<uint16_t, uint64_t>&b)
+{
+ return a.first < b.first;
+}
+
+void ResponseStats::submitResponse(uint16_t qtype, uint16_t respsize, bool udpOrTCP)
+{
+ d_qtypecounters[qtype]++;
+ pair<uint16_t, uint64_t> s(respsize, 0);
+ sizecounters_t::iterator iter = std::upper_bound(d_sizecounters.begin(), d_sizecounters.end(), s, pcomp);
+ if(iter!= d_sizecounters.begin())
+ --iter;
+ iter->second++;
+}
+
+map<uint16_t, uint64_t> ResponseStats::getQTypeResponseCounts()
+{
+ map<uint16_t, uint64_t> ret;
+ uint64_t count;
+ for(int i = 0 ; i < d_qtypecounters.size() ; ++i) {
+ count= d_qtypecounters[i];
+ if(count)
+ ret[i]=count;
+ }
+ return ret;
+}
--- /dev/null
+#ifndef PDNS_RESPONSESTATS_HH
+#define PDNS_RESPONSESTATS_HH
+#include "misc.hh"
+
+class ResponseStats
+{
+public:
+ ResponseStats();
+
+ void submitResponse(uint16_t qtype, uint16_t respsize, bool udpOrTCP);
+ map<uint16_t, uint64_t> getQTypeResponseCounts();
+ map<uint16_t, uint64_t> getSizeResponseCounts();
+
+private:
+ vector<AtomicCounter> d_qtypecounters;
+ typedef vector<pair<uint16_t, uint64_t> > sizecounters_t;
+ sizecounters_t d_sizecounters;
+};
+
+#endif