]>
git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/responsestats-auth.cc
1 #include "responsestats.hh"
2 #include "dnspacket.hh"
7 * Function that creates all the stats
8 * when udpOrTCP is true, it is udp
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");
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
);
33 if (udpOrTCP
) { // udp
35 udpbytesanswered
+=buf
.length();
36 if(p
.d_remote
.sin4
.sin_family
==AF_INET
) {
38 udpbytesanswered4
+=buf
.length();
41 udpbytesanswered6
+=buf
.length();
45 tcpbytesanswered
+=buf
.length();
46 if(p
.d_remote
.sin4
.sin_family
==AF_INET
) {
48 tcpbytesanswered4
+=buf
.length();
51 tcpbytesanswered6
+=buf
.length();
55 submitResponse(p
.qtype
.getCode(), buf
.length(), udpOrTCP
);