]> git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/responsestats-auth.cc
rec: Set ecs-ipv4-cache-bits and ecs-ipv6-cache-bits in the tests
[thirdparty/pdns.git] / pdns / responsestats-auth.cc
1 #include "responsestats.hh"
2 #include "dnspacket.hh"
3 #include "statbag.hh"
4
5 extern StatBag S;
6 /**
7 * Function that creates all the stats
8 * when udpOrTCP is true, it is udp
9 */
10 void ResponseStats::submitResponse(DNSPacket &p, bool udpOrTCP) {
11 const string& buf=p.getString();
12 static AtomicCounter &udpnumanswered=*S.getPointer("udp-answers");
13 static AtomicCounter &udpnumanswered4=*S.getPointer("udp4-answers");
14 static AtomicCounter &udpnumanswered6=*S.getPointer("udp6-answers");
15 static AtomicCounter &udpbytesanswered=*S.getPointer("udp-answers-bytes");
16 static AtomicCounter &udpbytesanswered4=*S.getPointer("udp4-answers-bytes");
17 static AtomicCounter &udpbytesanswered6=*S.getPointer("udp6-answers-bytes");
18 static AtomicCounter &tcpnumanswered=*S.getPointer("tcp-answers");
19 static AtomicCounter &tcpnumanswered4=*S.getPointer("tcp4-answers");
20 static AtomicCounter &tcpnumanswered6=*S.getPointer("tcp6-answers");
21 static AtomicCounter &tcpbytesanswered=*S.getPointer("tcp-answers-bytes");
22 static AtomicCounter &tcpbytesanswered4=*S.getPointer("tcp4-answers-bytes");
23 static AtomicCounter &tcpbytesanswered6=*S.getPointer("tcp6-answers-bytes");
24
25 if(p.d.aa) {
26 if (p.d.rcode==RCode::NXDomain)
27 S.ringAccount("nxdomain-queries",p.qdomain.toLogString()+"/"+p.qtype.getName());
28 } else if (p.isEmpty()) {
29 S.ringAccount("unauth-queries",p.qdomain.toLogString()+"/"+p.qtype.getName());
30 S.ringAccount("remotes-unauth",p.d_remote);
31 }
32
33 if (udpOrTCP) { // udp
34 udpnumanswered++;
35 udpbytesanswered+=buf.length();
36 if(p.d_remote.sin4.sin_family==AF_INET) {
37 udpnumanswered4++;
38 udpbytesanswered4+=buf.length();
39 } else {
40 udpnumanswered6++;
41 udpbytesanswered6+=buf.length();
42 }
43 } else { //tcp
44 tcpnumanswered++;
45 tcpbytesanswered+=buf.length();
46 if(p.d_remote.sin4.sin_family==AF_INET) {
47 tcpnumanswered4++;
48 tcpbytesanswered4+=buf.length();
49 } else {
50 tcpnumanswered6++;
51 tcpbytesanswered6+=buf.length();
52 }
53 }
54
55 submitResponse(p.qtype.getCode(), buf.length(), udpOrTCP);
56 }