]>
Commit | Line | Data |
---|---|---|
b552d7b1 PL |
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"); | |
50dbdbeb PL |
16 | static AtomicCounter &udpbytesanswered4=*S.getPointer("udp4-answers-bytes"); |
17 | static AtomicCounter &udpbytesanswered6=*S.getPointer("udp6-answers-bytes"); | |
b552d7b1 PL |
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"); | |
50dbdbeb PL |
22 | static AtomicCounter &tcpbytesanswered4=*S.getPointer("tcp4-answers-bytes"); |
23 | static AtomicCounter &tcpbytesanswered6=*S.getPointer("tcp6-answers-bytes"); | |
b552d7b1 PL |
24 | |
25 | if(p.d.aa) { | |
26 | if (p.d.rcode==RCode::NXDomain) | |
eb029b8e | 27 | S.ringAccount("nxdomain-queries", p.qdomain, p.qtype); |
abfec582 | 28 | } else if (p.d.rcode == RCode::Refused) { |
eb029b8e | 29 | S.ringAccount("unauth-queries", p.qdomain, p.qtype); |
b552d7b1 PL |
30 | S.ringAccount("remotes-unauth",p.d_remote); |
31 | } | |
32 | ||
33 | if (udpOrTCP) { // udp | |
34 | udpnumanswered++; | |
35 | udpbytesanswered+=buf.length(); | |
50dbdbeb | 36 | if(p.d_remote.sin4.sin_family==AF_INET) { |
b552d7b1 | 37 | udpnumanswered4++; |
50dbdbeb PL |
38 | udpbytesanswered4+=buf.length(); |
39 | } else { | |
b552d7b1 | 40 | udpnumanswered6++; |
50dbdbeb PL |
41 | udpbytesanswered6+=buf.length(); |
42 | } | |
b552d7b1 PL |
43 | } else { //tcp |
44 | tcpnumanswered++; | |
45 | tcpbytesanswered+=buf.length(); | |
50dbdbeb | 46 | if(p.d_remote.sin4.sin_family==AF_INET) { |
b552d7b1 | 47 | tcpnumanswered4++; |
50dbdbeb PL |
48 | tcpbytesanswered4+=buf.length(); |
49 | } else { | |
b552d7b1 | 50 | tcpnumanswered6++; |
50dbdbeb PL |
51 | tcpbytesanswered6+=buf.length(); |
52 | } | |
b552d7b1 PL |
53 | } |
54 | ||
87798d5e | 55 | submitResponse(p.qtype.getCode(), buf.length(), p.d.rcode, udpOrTCP); |
b552d7b1 | 56 | } |