]>
Commit | Line | Data |
---|---|---|
12471842 PL |
1 | /* |
2 | * This file is part of PowerDNS or dnsdist. | |
3 | * Copyright -- PowerDNS.COM B.V. and its contributors | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of version 2 of the GNU General Public License as | |
7 | * published by the Free Software Foundation. | |
8 | * | |
9 | * In addition, for the avoidance of any doubt, permission is granted to | |
10 | * link this program with OpenSSL and to (re)distribute the binaries | |
11 | * produced as the result of such linking. | |
12 | * | |
13 | * This program is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with this program; if not, write to the Free Software | |
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
21 | */ | |
6264512b | 22 | #pragma once |
23 | #include "dnsname.hh" | |
24 | #include <deque> | |
25 | #include <map> | |
26 | #include "iputils.hh" | |
27 | ||
28 | class StatNode | |
29 | { | |
30 | public: | |
6264512b | 31 | |
aec222df | 32 | struct Stat |
6264512b | 33 | { |
34 | Stat() : queries(0), noerrors(0), nxdomains(0), servfails(0), drops(0){} | |
35 | int queries, noerrors, nxdomains, servfails, drops; | |
36 | ||
37 | Stat& operator+=(const Stat& rhs) { | |
38 | queries+=rhs.queries; | |
39 | noerrors+=rhs.noerrors; | |
40 | nxdomains+=rhs.nxdomains; | |
41 | servfails+=rhs.servfails; | |
42 | drops+=rhs.drops; | |
43 | ||
aec222df RG |
44 | //for(const remotes_t::value_type& rem : rhs.remotes) { |
45 | // remotes[rem.first]+=rem.second; | |
46 | //} | |
6264512b | 47 | return *this; |
48 | } | |
aec222df RG |
49 | //typedef std::map<ComboAddress,int,ComboAddress::addressOnlyLessThan> remotes_t; |
50 | //remotes_t remotes; | |
6264512b | 51 | }; |
52 | ||
53 | Stat s; | |
431c4359 RG |
54 | std::string name; |
55 | std::string fullname; | |
56 | unsigned int labelsCount{0}; | |
57 | ||
58 | void submit(const DNSName& domain, int rcode, const ComboAddress& remote); | |
431c4359 RG |
59 | |
60 | Stat print(unsigned int depth=0, Stat newstat=Stat(), bool silent=false) const; | |
6264512b | 61 | typedef boost::function<void(const StatNode*, const Stat& selfstat, const Stat& childstat)> visitor_t; |
431c4359 | 62 | void visit(visitor_t visitor, Stat& newstat, unsigned int depth=0) const; |
6264512b | 63 | typedef std::map<std::string,StatNode, CIStringCompare> children_t; |
64 | children_t children; | |
aec222df RG |
65 | |
66 | private: | |
1b7c449b | 67 | void submit(std::vector<string>::const_iterator end, std::vector<string>::const_iterator begin, const std::string& domain, int rcode, const ComboAddress& remote, unsigned int count); |
6264512b | 68 | }; |