]>
Commit | Line | Data |
---|---|---|
861ce85b RG |
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 | */ | |
22 | ||
23 | #include "dnsdist.hh" | |
24 | #include "dnsdist-dynblocks.hh" | |
25 | ||
3dec2251 | 26 | #ifndef DISABLE_DYNBLOCKS |
861ce85b RG |
27 | uint64_t dnsdist_ffi_stat_node_get_queries_count(const dnsdist_ffi_stat_node_t* node) |
28 | { | |
29 | return node->self.queries; | |
30 | } | |
31 | ||
32 | uint64_t dnsdist_ffi_stat_node_get_noerrors_count(const dnsdist_ffi_stat_node_t* node) | |
33 | { | |
34 | return node->self.noerrors; | |
35 | } | |
36 | ||
37 | uint64_t dnsdist_ffi_stat_node_get_nxdomains_count(const dnsdist_ffi_stat_node_t* node) | |
38 | { | |
39 | return node->self.nxdomains; | |
40 | } | |
41 | ||
42 | uint64_t dnsdist_ffi_stat_node_get_servfails_count(const dnsdist_ffi_stat_node_t* node) | |
43 | { | |
44 | return node->self.servfails; | |
45 | } | |
46 | ||
47 | uint64_t dnsdist_ffi_stat_node_get_drops_count(const dnsdist_ffi_stat_node_t* node) | |
48 | { | |
49 | return node->self.drops; | |
50 | } | |
51 | ||
92375564 RG |
52 | uint64_t dnsdist_ffi_stat_node_get_bytes(const dnsdist_ffi_stat_node_t* node) |
53 | { | |
54 | return node->self.bytes; | |
55 | } | |
56 | ||
6ecfaee2 RG |
57 | uint64_t dnsdist_ffi_stat_node_get_hits(const dnsdist_ffi_stat_node_t* node) |
58 | { | |
59 | return node->self.hits; | |
60 | } | |
61 | ||
861ce85b RG |
62 | unsigned int dnsdist_ffi_stat_node_get_labels_count(const dnsdist_ffi_stat_node_t* node) |
63 | { | |
64 | return node->node.labelsCount; | |
65 | } | |
66 | ||
67 | void dnsdist_ffi_stat_node_get_full_name_raw(const dnsdist_ffi_stat_node_t* node, const char** name, size_t* nameSize) | |
68 | { | |
69 | const auto& storage = node->node.fullname; | |
70 | *name = storage.c_str(); | |
71 | *nameSize = storage.size(); | |
72 | } | |
73 | ||
74 | unsigned int dnsdist_ffi_stat_node_get_children_count(const dnsdist_ffi_stat_node_t* node) | |
75 | { | |
76 | return node->node.children.size(); | |
77 | } | |
78 | ||
79 | uint64_t dnsdist_ffi_stat_node_get_children_queries_count(const dnsdist_ffi_stat_node_t* node) | |
80 | { | |
81 | return node->children.queries; | |
82 | } | |
83 | ||
84 | uint64_t dnsdist_ffi_stat_node_get_children_noerrors_count(const dnsdist_ffi_stat_node_t* node) | |
85 | { | |
86 | return node->children.noerrors; | |
87 | } | |
88 | ||
89 | uint64_t dnsdist_ffi_stat_node_get_children_nxdomains_count(const dnsdist_ffi_stat_node_t* node) | |
90 | { | |
91 | return node->children.nxdomains; | |
92 | } | |
93 | ||
94 | uint64_t dnsdist_ffi_stat_node_get_children_servfails_count(const dnsdist_ffi_stat_node_t* node) | |
95 | { | |
96 | return node->children.servfails; | |
97 | } | |
98 | ||
99 | uint64_t dnsdist_ffi_stat_node_get_children_drops_count(const dnsdist_ffi_stat_node_t* node) | |
100 | { | |
101 | return node->children.drops; | |
102 | } | |
92375564 RG |
103 | |
104 | uint64_t dnsdist_ffi_stat_node_get_children_bytes_count(const dnsdist_ffi_stat_node_t* node) | |
105 | { | |
106 | return node->children.bytes; | |
107 | } | |
7179dab0 | 108 | |
6ecfaee2 RG |
109 | uint64_t dnsdist_ffi_stat_node_get_children_hits(const dnsdist_ffi_stat_node_t* node) |
110 | { | |
111 | return node->children.hits; | |
112 | } | |
113 | ||
7179dab0 RG |
114 | void dnsdist_ffi_state_node_set_reason(dnsdist_ffi_stat_node_t* node, const char* reason, size_t reasonSize) |
115 | { | |
1cd18a7c RG |
116 | node->d_blockParameters.d_reason = std::string(reason, reasonSize); |
117 | } | |
118 | ||
119 | void dnsdist_ffi_state_node_set_action(dnsdist_ffi_stat_node_t* node, int blockAction) | |
120 | { | |
121 | node->d_blockParameters.d_action = static_cast<DNSAction::Action>(blockAction); | |
7179dab0 | 122 | } |
3dec2251 | 123 | #endif /* DISABLE_DYNBLOCKS */ |