1 /*	$NetBSD: stats.h,v 1.7 2022/09/23 12:15:30 christos Exp $	*/
2 
3 /*
4  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
5  *
6  * SPDX-License-Identifier: MPL-2.0
7  *
8  * This Source Code Form is subject to the terms of the Mozilla Public
9  * License, v. 2.0. If a copy of the MPL was not distributed with this
10  * file, you can obtain one at https://mozilla.org/MPL/2.0/.
11  *
12  * See the COPYRIGHT file distributed with this work for additional
13  * information regarding copyright ownership.
14  */
15 
16 #ifndef DNS_STATS_H
17 #define DNS_STATS_H 1
18 
19 /*! \file dns/stats.h */
20 
21 #include <inttypes.h>
22 
23 #include <dns/types.h>
24 
25 /*%
26  * Statistics counters.  Used as isc_statscounter_t values.
27  */
28 enum {
29 	/*%
30 	 * Resolver statistics counters.
31 	 */
32 	dns_resstatscounter_queryv4 = 0,
33 	dns_resstatscounter_queryv6 = 1,
34 	dns_resstatscounter_responsev4 = 2,
35 	dns_resstatscounter_responsev6 = 3,
36 	dns_resstatscounter_nxdomain = 4,
37 	dns_resstatscounter_servfail = 5,
38 	dns_resstatscounter_formerr = 6,
39 	dns_resstatscounter_othererror = 7,
40 	dns_resstatscounter_edns0fail = 8,
41 	dns_resstatscounter_mismatch = 9,
42 	dns_resstatscounter_truncated = 10,
43 	dns_resstatscounter_lame = 11,
44 	dns_resstatscounter_retry = 12,
45 	dns_resstatscounter_gluefetchv4 = 13,
46 	dns_resstatscounter_gluefetchv6 = 14,
47 	dns_resstatscounter_gluefetchv4fail = 15,
48 	dns_resstatscounter_gluefetchv6fail = 16,
49 	dns_resstatscounter_val = 17,
50 	dns_resstatscounter_valsuccess = 18,
51 	dns_resstatscounter_valnegsuccess = 19,
52 	dns_resstatscounter_valfail = 20,
53 	dns_resstatscounter_dispabort = 21,
54 	dns_resstatscounter_dispsockfail = 22,
55 	dns_resstatscounter_querytimeout = 23,
56 	dns_resstatscounter_queryrtt0 = 24,
57 	dns_resstatscounter_queryrtt1 = 25,
58 	dns_resstatscounter_queryrtt2 = 26,
59 	dns_resstatscounter_queryrtt3 = 27,
60 	dns_resstatscounter_queryrtt4 = 28,
61 	dns_resstatscounter_queryrtt5 = 29,
62 	dns_resstatscounter_nfetch = 30,
63 	dns_resstatscounter_disprequdp = 31,
64 	dns_resstatscounter_dispreqtcp = 32,
65 	dns_resstatscounter_buckets = 33,
66 	dns_resstatscounter_refused = 34,
67 	dns_resstatscounter_cookienew = 35,
68 	dns_resstatscounter_cookieout = 36,
69 	dns_resstatscounter_cookiein = 37,
70 	dns_resstatscounter_cookieok = 38,
71 	dns_resstatscounter_badvers = 39,
72 	dns_resstatscounter_badcookie = 40,
73 	dns_resstatscounter_zonequota = 41,
74 	dns_resstatscounter_serverquota = 42,
75 	dns_resstatscounter_nextitem = 43,
76 	dns_resstatscounter_priming = 44,
77 	dns_resstatscounter_max = 45,
78 
79 	/*
80 	 * DNSSEC stats.
81 	 */
82 	dns_dnssecstats_asis = 0,
83 	dns_dnssecstats_downcase = 1,
84 	dns_dnssecstats_wildcard = 2,
85 	dns_dnssecstats_fail = 3,
86 
87 	dns_dnssecstats_max = 4,
88 
89 	/*%
90 	 * Zone statistics counters.
91 	 */
92 	dns_zonestatscounter_notifyoutv4 = 0,
93 	dns_zonestatscounter_notifyoutv6 = 1,
94 	dns_zonestatscounter_notifyinv4 = 2,
95 	dns_zonestatscounter_notifyinv6 = 3,
96 	dns_zonestatscounter_notifyrej = 4,
97 	dns_zonestatscounter_soaoutv4 = 5,
98 	dns_zonestatscounter_soaoutv6 = 6,
99 	dns_zonestatscounter_axfrreqv4 = 7,
100 	dns_zonestatscounter_axfrreqv6 = 8,
101 	dns_zonestatscounter_ixfrreqv4 = 9,
102 	dns_zonestatscounter_ixfrreqv6 = 10,
103 	dns_zonestatscounter_xfrsuccess = 11,
104 	dns_zonestatscounter_xfrfail = 12,
105 
106 	dns_zonestatscounter_max = 13,
107 
108 	/*
109 	 * Adb statistics values.
110 	 */
111 	dns_adbstats_nentries = 0,
112 	dns_adbstats_entriescnt = 1,
113 	dns_adbstats_nnames = 2,
114 	dns_adbstats_namescnt = 3,
115 
116 	dns_adbstats_max = 4,
117 
118 	/*
119 	 * Cache statistics values.
120 	 */
121 	dns_cachestatscounter_hits = 1,
122 	dns_cachestatscounter_misses = 2,
123 	dns_cachestatscounter_queryhits = 3,
124 	dns_cachestatscounter_querymisses = 4,
125 	dns_cachestatscounter_deletelru = 5,
126 	dns_cachestatscounter_deletettl = 6,
127 
128 	dns_cachestatscounter_max = 7,
129 
130 	/*%
131 	 * Query statistics counters (obsolete).
132 	 */
133 	dns_statscounter_success = 0,	/*%< Successful lookup */
134 	dns_statscounter_referral = 1,	/*%< Referral result */
135 	dns_statscounter_nxrrset = 2,	/*%< NXRRSET result */
136 	dns_statscounter_nxdomain = 3,	/*%< NXDOMAIN result */
137 	dns_statscounter_recursion = 4, /*%< Recursion was used */
138 	dns_statscounter_failure = 5,	/*%< Some other failure */
139 	dns_statscounter_duplicate = 6, /*%< Duplicate query */
140 	dns_statscounter_dropped = 7,	/*%< Duplicate query (dropped) */
141 
142 	/*%
143 	 * DNSTAP statistics counters.
144 	 */
145 	dns_dnstapcounter_success = 0,
146 	dns_dnstapcounter_drop = 1,
147 	dns_dnstapcounter_max = 2,
148 
149 	/*
150 	 * Glue cache statistics counters.
151 	 */
152 	dns_gluecachestatscounter_hits_present = 0,
153 	dns_gluecachestatscounter_hits_absent = 1,
154 	dns_gluecachestatscounter_inserts_present = 2,
155 	dns_gluecachestatscounter_inserts_absent = 3,
156 
157 	dns_gluecachestatscounter_max = 4,
158 };
159 
160 /*%
161  * Traffic size statistics counters. Used as isc_statscounter_t values.
162  */
163 enum {
164 	dns_sizecounter_in_0 = 0,
165 	dns_sizecounter_in_16 = 1,
166 	dns_sizecounter_in_32 = 2,
167 	dns_sizecounter_in_48 = 3,
168 	dns_sizecounter_in_64 = 4,
169 	dns_sizecounter_in_80 = 5,
170 	dns_sizecounter_in_96 = 6,
171 	dns_sizecounter_in_112 = 7,
172 	dns_sizecounter_in_128 = 8,
173 	dns_sizecounter_in_144 = 9,
174 	dns_sizecounter_in_160 = 10,
175 	dns_sizecounter_in_176 = 11,
176 	dns_sizecounter_in_192 = 12,
177 	dns_sizecounter_in_208 = 13,
178 	dns_sizecounter_in_224 = 14,
179 	dns_sizecounter_in_240 = 15,
180 	dns_sizecounter_in_256 = 16,
181 	dns_sizecounter_in_272 = 17,
182 	dns_sizecounter_in_288 = 18,
183 
184 	dns_sizecounter_in_max = 19,
185 };
186 
187 enum {
188 	dns_sizecounter_out_0 = 0,
189 	dns_sizecounter_out_16 = 1,
190 	dns_sizecounter_out_32 = 2,
191 	dns_sizecounter_out_48 = 3,
192 	dns_sizecounter_out_64 = 4,
193 	dns_sizecounter_out_80 = 5,
194 	dns_sizecounter_out_96 = 6,
195 	dns_sizecounter_out_112 = 7,
196 	dns_sizecounter_out_128 = 8,
197 	dns_sizecounter_out_144 = 9,
198 	dns_sizecounter_out_160 = 10,
199 	dns_sizecounter_out_176 = 11,
200 	dns_sizecounter_out_192 = 12,
201 	dns_sizecounter_out_208 = 13,
202 	dns_sizecounter_out_224 = 14,
203 	dns_sizecounter_out_240 = 15,
204 	dns_sizecounter_out_256 = 16,
205 	dns_sizecounter_out_272 = 17,
206 	dns_sizecounter_out_288 = 18,
207 	dns_sizecounter_out_304 = 19,
208 	dns_sizecounter_out_320 = 20,
209 	dns_sizecounter_out_336 = 21,
210 	dns_sizecounter_out_352 = 22,
211 	dns_sizecounter_out_368 = 23,
212 	dns_sizecounter_out_384 = 24,
213 	dns_sizecounter_out_400 = 25,
214 	dns_sizecounter_out_416 = 26,
215 	dns_sizecounter_out_432 = 27,
216 	dns_sizecounter_out_448 = 28,
217 	dns_sizecounter_out_464 = 29,
218 	dns_sizecounter_out_480 = 30,
219 	dns_sizecounter_out_496 = 31,
220 	dns_sizecounter_out_512 = 32,
221 	dns_sizecounter_out_528 = 33,
222 	dns_sizecounter_out_544 = 34,
223 	dns_sizecounter_out_560 = 35,
224 	dns_sizecounter_out_576 = 36,
225 	dns_sizecounter_out_592 = 37,
226 	dns_sizecounter_out_608 = 38,
227 	dns_sizecounter_out_624 = 39,
228 	dns_sizecounter_out_640 = 40,
229 	dns_sizecounter_out_656 = 41,
230 	dns_sizecounter_out_672 = 42,
231 	dns_sizecounter_out_688 = 43,
232 	dns_sizecounter_out_704 = 44,
233 	dns_sizecounter_out_720 = 45,
234 	dns_sizecounter_out_736 = 46,
235 	dns_sizecounter_out_752 = 47,
236 	dns_sizecounter_out_768 = 48,
237 	dns_sizecounter_out_784 = 49,
238 	dns_sizecounter_out_800 = 50,
239 	dns_sizecounter_out_816 = 51,
240 	dns_sizecounter_out_832 = 52,
241 	dns_sizecounter_out_848 = 53,
242 	dns_sizecounter_out_864 = 54,
243 	dns_sizecounter_out_880 = 55,
244 	dns_sizecounter_out_896 = 56,
245 	dns_sizecounter_out_912 = 57,
246 	dns_sizecounter_out_928 = 58,
247 	dns_sizecounter_out_944 = 59,
248 	dns_sizecounter_out_960 = 60,
249 	dns_sizecounter_out_976 = 61,
250 	dns_sizecounter_out_992 = 62,
251 	dns_sizecounter_out_1008 = 63,
252 	dns_sizecounter_out_1024 = 64,
253 	dns_sizecounter_out_1040 = 65,
254 	dns_sizecounter_out_1056 = 66,
255 	dns_sizecounter_out_1072 = 67,
256 	dns_sizecounter_out_1088 = 68,
257 	dns_sizecounter_out_1104 = 69,
258 	dns_sizecounter_out_1120 = 70,
259 	dns_sizecounter_out_1136 = 71,
260 	dns_sizecounter_out_1152 = 72,
261 	dns_sizecounter_out_1168 = 73,
262 	dns_sizecounter_out_1184 = 74,
263 	dns_sizecounter_out_1200 = 75,
264 	dns_sizecounter_out_1216 = 76,
265 	dns_sizecounter_out_1232 = 77,
266 	dns_sizecounter_out_1248 = 78,
267 	dns_sizecounter_out_1264 = 79,
268 	dns_sizecounter_out_1280 = 80,
269 	dns_sizecounter_out_1296 = 81,
270 	dns_sizecounter_out_1312 = 82,
271 	dns_sizecounter_out_1328 = 83,
272 	dns_sizecounter_out_1344 = 84,
273 	dns_sizecounter_out_1360 = 85,
274 	dns_sizecounter_out_1376 = 86,
275 	dns_sizecounter_out_1392 = 87,
276 	dns_sizecounter_out_1408 = 88,
277 	dns_sizecounter_out_1424 = 89,
278 	dns_sizecounter_out_1440 = 90,
279 	dns_sizecounter_out_1456 = 91,
280 	dns_sizecounter_out_1472 = 92,
281 	dns_sizecounter_out_1488 = 93,
282 	dns_sizecounter_out_1504 = 94,
283 	dns_sizecounter_out_1520 = 95,
284 	dns_sizecounter_out_1536 = 96,
285 	dns_sizecounter_out_1552 = 97,
286 	dns_sizecounter_out_1568 = 98,
287 	dns_sizecounter_out_1584 = 99,
288 	dns_sizecounter_out_1600 = 100,
289 	dns_sizecounter_out_1616 = 101,
290 	dns_sizecounter_out_1632 = 102,
291 	dns_sizecounter_out_1648 = 103,
292 	dns_sizecounter_out_1664 = 104,
293 	dns_sizecounter_out_1680 = 105,
294 	dns_sizecounter_out_1696 = 106,
295 	dns_sizecounter_out_1712 = 107,
296 	dns_sizecounter_out_1728 = 108,
297 	dns_sizecounter_out_1744 = 109,
298 	dns_sizecounter_out_1760 = 110,
299 	dns_sizecounter_out_1776 = 111,
300 	dns_sizecounter_out_1792 = 112,
301 	dns_sizecounter_out_1808 = 113,
302 	dns_sizecounter_out_1824 = 114,
303 	dns_sizecounter_out_1840 = 115,
304 	dns_sizecounter_out_1856 = 116,
305 	dns_sizecounter_out_1872 = 117,
306 	dns_sizecounter_out_1888 = 118,
307 	dns_sizecounter_out_1904 = 119,
308 	dns_sizecounter_out_1920 = 120,
309 	dns_sizecounter_out_1936 = 121,
310 	dns_sizecounter_out_1952 = 122,
311 	dns_sizecounter_out_1968 = 123,
312 	dns_sizecounter_out_1984 = 124,
313 	dns_sizecounter_out_2000 = 125,
314 	dns_sizecounter_out_2016 = 126,
315 	dns_sizecounter_out_2032 = 127,
316 	dns_sizecounter_out_2048 = 128,
317 	dns_sizecounter_out_2064 = 129,
318 	dns_sizecounter_out_2080 = 130,
319 	dns_sizecounter_out_2096 = 131,
320 	dns_sizecounter_out_2112 = 132,
321 	dns_sizecounter_out_2128 = 133,
322 	dns_sizecounter_out_2144 = 134,
323 	dns_sizecounter_out_2160 = 135,
324 	dns_sizecounter_out_2176 = 136,
325 	dns_sizecounter_out_2192 = 137,
326 	dns_sizecounter_out_2208 = 138,
327 	dns_sizecounter_out_2224 = 139,
328 	dns_sizecounter_out_2240 = 140,
329 	dns_sizecounter_out_2256 = 141,
330 	dns_sizecounter_out_2272 = 142,
331 	dns_sizecounter_out_2288 = 143,
332 	dns_sizecounter_out_2304 = 144,
333 	dns_sizecounter_out_2320 = 145,
334 	dns_sizecounter_out_2336 = 146,
335 	dns_sizecounter_out_2352 = 147,
336 	dns_sizecounter_out_2368 = 148,
337 	dns_sizecounter_out_2384 = 149,
338 	dns_sizecounter_out_2400 = 150,
339 	dns_sizecounter_out_2416 = 151,
340 	dns_sizecounter_out_2432 = 152,
341 	dns_sizecounter_out_2448 = 153,
342 	dns_sizecounter_out_2464 = 154,
343 	dns_sizecounter_out_2480 = 155,
344 	dns_sizecounter_out_2496 = 156,
345 	dns_sizecounter_out_2512 = 157,
346 	dns_sizecounter_out_2528 = 158,
347 	dns_sizecounter_out_2544 = 159,
348 	dns_sizecounter_out_2560 = 160,
349 	dns_sizecounter_out_2576 = 161,
350 	dns_sizecounter_out_2592 = 162,
351 	dns_sizecounter_out_2608 = 163,
352 	dns_sizecounter_out_2624 = 164,
353 	dns_sizecounter_out_2640 = 165,
354 	dns_sizecounter_out_2656 = 166,
355 	dns_sizecounter_out_2672 = 167,
356 	dns_sizecounter_out_2688 = 168,
357 	dns_sizecounter_out_2704 = 169,
358 	dns_sizecounter_out_2720 = 170,
359 	dns_sizecounter_out_2736 = 171,
360 	dns_sizecounter_out_2752 = 172,
361 	dns_sizecounter_out_2768 = 173,
362 	dns_sizecounter_out_2784 = 174,
363 	dns_sizecounter_out_2800 = 175,
364 	dns_sizecounter_out_2816 = 176,
365 	dns_sizecounter_out_2832 = 177,
366 	dns_sizecounter_out_2848 = 178,
367 	dns_sizecounter_out_2864 = 179,
368 	dns_sizecounter_out_2880 = 180,
369 	dns_sizecounter_out_2896 = 181,
370 	dns_sizecounter_out_2912 = 182,
371 	dns_sizecounter_out_2928 = 183,
372 	dns_sizecounter_out_2944 = 184,
373 	dns_sizecounter_out_2960 = 185,
374 	dns_sizecounter_out_2976 = 186,
375 	dns_sizecounter_out_2992 = 187,
376 	dns_sizecounter_out_3008 = 188,
377 	dns_sizecounter_out_3024 = 189,
378 	dns_sizecounter_out_3040 = 190,
379 	dns_sizecounter_out_3056 = 191,
380 	dns_sizecounter_out_3072 = 192,
381 	dns_sizecounter_out_3088 = 193,
382 	dns_sizecounter_out_3104 = 194,
383 	dns_sizecounter_out_3120 = 195,
384 	dns_sizecounter_out_3136 = 196,
385 	dns_sizecounter_out_3152 = 197,
386 	dns_sizecounter_out_3168 = 198,
387 	dns_sizecounter_out_3184 = 199,
388 	dns_sizecounter_out_3200 = 200,
389 	dns_sizecounter_out_3216 = 201,
390 	dns_sizecounter_out_3232 = 202,
391 	dns_sizecounter_out_3248 = 203,
392 	dns_sizecounter_out_3264 = 204,
393 	dns_sizecounter_out_3280 = 205,
394 	dns_sizecounter_out_3296 = 206,
395 	dns_sizecounter_out_3312 = 207,
396 	dns_sizecounter_out_3328 = 208,
397 	dns_sizecounter_out_3344 = 209,
398 	dns_sizecounter_out_3360 = 210,
399 	dns_sizecounter_out_3376 = 211,
400 	dns_sizecounter_out_3392 = 212,
401 	dns_sizecounter_out_3408 = 213,
402 	dns_sizecounter_out_3424 = 214,
403 	dns_sizecounter_out_3440 = 215,
404 	dns_sizecounter_out_3456 = 216,
405 	dns_sizecounter_out_3472 = 217,
406 	dns_sizecounter_out_3488 = 218,
407 	dns_sizecounter_out_3504 = 219,
408 	dns_sizecounter_out_3520 = 220,
409 	dns_sizecounter_out_3536 = 221,
410 	dns_sizecounter_out_3552 = 222,
411 	dns_sizecounter_out_3568 = 223,
412 	dns_sizecounter_out_3584 = 224,
413 	dns_sizecounter_out_3600 = 225,
414 	dns_sizecounter_out_3616 = 226,
415 	dns_sizecounter_out_3632 = 227,
416 	dns_sizecounter_out_3648 = 228,
417 	dns_sizecounter_out_3664 = 229,
418 	dns_sizecounter_out_3680 = 230,
419 	dns_sizecounter_out_3696 = 231,
420 	dns_sizecounter_out_3712 = 232,
421 	dns_sizecounter_out_3728 = 233,
422 	dns_sizecounter_out_3744 = 234,
423 	dns_sizecounter_out_3760 = 235,
424 	dns_sizecounter_out_3776 = 236,
425 	dns_sizecounter_out_3792 = 237,
426 	dns_sizecounter_out_3808 = 238,
427 	dns_sizecounter_out_3824 = 239,
428 	dns_sizecounter_out_3840 = 240,
429 	dns_sizecounter_out_3856 = 241,
430 	dns_sizecounter_out_3872 = 242,
431 	dns_sizecounter_out_3888 = 243,
432 	dns_sizecounter_out_3904 = 244,
433 	dns_sizecounter_out_3920 = 245,
434 	dns_sizecounter_out_3936 = 246,
435 	dns_sizecounter_out_3952 = 247,
436 	dns_sizecounter_out_3968 = 248,
437 	dns_sizecounter_out_3984 = 249,
438 	dns_sizecounter_out_4000 = 250,
439 	dns_sizecounter_out_4016 = 251,
440 	dns_sizecounter_out_4032 = 252,
441 	dns_sizecounter_out_4048 = 253,
442 	dns_sizecounter_out_4064 = 254,
443 	dns_sizecounter_out_4080 = 255,
444 	dns_sizecounter_out_4096 = 256,
445 
446 	dns_sizecounter_out_max = 257
447 };
448 
449 #define DNS_STATS_NCOUNTERS 8
450 
451 #if 0
452 /*%<
453  * Flag(s) for dns_xxxstats_dump().  DNS_STATSDUMP_VERBOSE is obsolete.
454  * ISC_STATSDUMP_VERBOSE should be used instead.  These two values are
455  * intentionally defined to be the same value to ensure binary compatibility.
456  */
457 #define DNS_STATSDUMP_VERBOSE 0x00000001 /*%< dump 0-value counters */
458 #endif					 /* if 0 */
459 
460 /*%<
461  * (Obsoleted)
462  */
463 LIBDNS_EXTERNAL_DATA extern const char *dns_statscounter_names[];
464 
465 /*%
466  * Attributes for statistics counters of RRset and Rdatatype types.
467  *
468  * _OTHERTYPE
469  *	The rdata type is not explicitly supported and the corresponding counter
470  *	is counted for other such types, too.  When this attribute is set,
471  *	the base type is of no use.
472  *
473  * _NXRRSET
474  * 	RRset type counters only.  Indicates the RRset is non existent.
475  *
476  * _NXDOMAIN
477  *	RRset type counters only.  Indicates a non existent name.  When this
478  *	attribute is set, the base type is of no use.
479  *
480  * _STALE
481  *	RRset type counters only.  This indicates a record that is stale
482  *	but may still be served.
483  *
484  * _ANCIENT
485  *	RRset type counters only.  This indicates a record that is marked for
486  *	removal.
487  */
488 #define DNS_RDATASTATSTYPE_ATTR_OTHERTYPE 0x0001
489 #define DNS_RDATASTATSTYPE_ATTR_NXRRSET	  0x0002
490 #define DNS_RDATASTATSTYPE_ATTR_NXDOMAIN  0x0004
491 #define DNS_RDATASTATSTYPE_ATTR_STALE	  0x0008
492 #define DNS_RDATASTATSTYPE_ATTR_ANCIENT	  0x0010
493 
494 /*%<
495  * Conversion macros among dns_rdatatype_t, attributes and isc_statscounter_t.
496  */
497 #define DNS_RDATASTATSTYPE_BASE(type)  ((dns_rdatatype_t)((type)&0xFFFF))
498 #define DNS_RDATASTATSTYPE_ATTR(type)  ((type) >> 16)
499 #define DNS_RDATASTATSTYPE_VALUE(b, a) (((a) << 16) | (b))
500 
501 /*%
502  * Types of DNSSEC sign statistics operations.
503  */
504 typedef enum {
505 	dns_dnssecsignstats_sign = 1,
506 	dns_dnssecsignstats_refresh = 2
507 } dnssecsignstats_type_t;
508 
509 /*%<
510  * Types of dump callbacks.
511  */
512 typedef void (*dns_generalstats_dumper_t)(isc_statscounter_t, uint64_t, void *);
513 typedef void (*dns_rdatatypestats_dumper_t)(dns_rdatastatstype_t, uint64_t,
514 					    void *);
515 typedef void (*dns_dnssecsignstats_dumper_t)(dns_keytag_t, uint64_t, void *);
516 typedef void (*dns_opcodestats_dumper_t)(dns_opcode_t, uint64_t, void *);
517 typedef void (*dns_rcodestats_dumper_t)(dns_rcode_t, uint64_t, void *);
518 
519 ISC_LANG_BEGINDECLS
520 
521 isc_result_t
522 dns_generalstats_create(isc_mem_t *mctx, dns_stats_t **statsp, int ncounters);
523 /*%<
524  * Create a statistics counter structure of general type.  It counts a general
525  * set of counters indexed by an ID between 0 and ncounters -1.
526  * This function is obsolete.  A more general function, isc_stats_create(),
527  * should be used.
528  *
529  * Requires:
530  *\li	'mctx' must be a valid memory context.
531  *
532  *\li	'statsp' != NULL && '*statsp' == NULL.
533  *
534  * Returns:
535  *\li	ISC_R_SUCCESS	-- all ok
536  *
537  *\li	anything else	-- failure
538  */
539 
540 isc_result_t
541 dns_rdatatypestats_create(isc_mem_t *mctx, dns_stats_t **statsp);
542 /*%<
543  * Create a statistics counter structure per rdatatype.
544  *
545  * Requires:
546  *\li	'mctx' must be a valid memory context.
547  *
548  *\li	'statsp' != NULL && '*statsp' == NULL.
549  *
550  * Returns:
551  *\li	ISC_R_SUCCESS	-- all ok
552  *
553  *\li	anything else	-- failure
554  */
555 
556 isc_result_t
557 dns_rdatasetstats_create(isc_mem_t *mctx, dns_stats_t **statsp);
558 /*%<
559  * Create a statistics counter structure per RRset.
560  *
561  * Requires:
562  *\li	'mctx' must be a valid memory context.
563  *
564  *\li	'statsp' != NULL && '*statsp' == NULL.
565  *
566  * Returns:
567  *\li	ISC_R_SUCCESS	-- all ok
568  *
569  *\li	anything else	-- failure
570  */
571 
572 isc_result_t
573 dns_opcodestats_create(isc_mem_t *mctx, dns_stats_t **statsp);
574 /*%<
575  * Create a statistics counter structure per opcode.
576  *
577  * Requires:
578  *\li	'mctx' must be a valid memory context.
579  *
580  *\li	'statsp' != NULL && '*statsp' == NULL.
581  *
582  * Returns:
583  *\li	ISC_R_SUCCESS	-- all ok
584  *
585  *\li	anything else	-- failure
586  */
587 
588 isc_result_t
589 dns_rcodestats_create(isc_mem_t *mctx, dns_stats_t **statsp);
590 /*%<
591  * Create a statistics counter structure per assigned rcode.
592  *
593  * Requires:
594  *\li	'mctx' must be a valid memory context.
595  *
596  *\li	'statsp' != NULL && '*statsp' == NULL.
597  *
598  * Returns:
599  *\li	ISC_R_SUCCESS	-- all ok
600  *
601  *\li	anything else	-- failure
602  */
603 
604 isc_result_t
605 dns_dnssecsignstats_create(isc_mem_t *mctx, dns_stats_t **statsp);
606 /*%<
607  * Create a statistics counter structure per assigned DNSKEY id.
608  *
609  * Requires:
610  *\li	'mctx' must be a valid memory context.
611  *
612  *\li	'statsp' != NULL && '*statsp' == NULL.
613  *
614  * Returns:
615  *\li	ISC_R_SUCCESS	-- all ok
616  *
617  *\li	anything else	-- failure
618  */
619 
620 void
621 dns_stats_attach(dns_stats_t *stats, dns_stats_t **statsp);
622 /*%<
623  * Attach to a statistics set.
624  *
625  * Requires:
626  *\li	'stats' is a valid dns_stats_t.
627  *
628  *\li	'statsp' != NULL && '*statsp' == NULL
629  */
630 
631 void
632 dns_stats_detach(dns_stats_t **statsp);
633 /*%<
634  * Detaches from the statistics set.
635  *
636  * Requires:
637  *\li	'statsp' != NULL and '*statsp' is a valid dns_stats_t.
638  */
639 
640 void
641 dns_generalstats_increment(dns_stats_t *stats, isc_statscounter_t counter);
642 /*%<
643  * Increment the counter-th counter of stats.  This function is obsolete.
644  * A more general function, isc_stats_increment(), should be used.
645  *
646  * Requires:
647  *\li	'stats' is a valid dns_stats_t created by dns_generalstats_create().
648  *
649  *\li	counter is less than the maximum available ID for the stats specified
650  *	on creation.
651  */
652 
653 void
654 dns_rdatatypestats_increment(dns_stats_t *stats, dns_rdatatype_t type);
655 /*%<
656  * Increment the statistics counter for 'type'.
657  *
658  * Requires:
659  *\li	'stats' is a valid dns_stats_t created by dns_rdatatypestats_create().
660  */
661 
662 void
663 dns_rdatasetstats_increment(dns_stats_t *stats, dns_rdatastatstype_t rrsettype);
664 /*%<
665  * Increment the statistics counter for 'rrsettype'.
666  *
667  * Note: if 'rrsettype' has the _STALE attribute set the corresponding
668  * non-stale counter will be decremented.
669  *
670  * Requires:
671  *\li	'stats' is a valid dns_stats_t created by dns_rdatasetstats_create().
672  */
673 
674 void
675 dns_rdatasetstats_decrement(dns_stats_t *stats, dns_rdatastatstype_t rrsettype);
676 /*%<
677  * Decrement the statistics counter for 'rrsettype'.
678  *
679  * Requires:
680  *\li	'stats' is a valid dns_stats_t created by dns_rdatasetstats_create().
681  */
682 
683 void
684 dns_opcodestats_increment(dns_stats_t *stats, dns_opcode_t code);
685 /*%<
686  * Increment the statistics counter for 'code'.
687  *
688  * Requires:
689  *\li	'stats' is a valid dns_stats_t created by dns_opcodestats_create().
690  */
691 
692 void
693 dns_rcodestats_increment(dns_stats_t *stats, dns_opcode_t code);
694 /*%<
695  * Increment the statistics counter for 'code'.
696  *
697  * Requires:
698  *\li	'stats' is a valid dns_stats_t created by dns_rcodestats_create().
699  */
700 
701 void
702 dns_dnssecsignstats_increment(dns_stats_t *stats, dns_keytag_t id, uint8_t alg,
703 			      dnssecsignstats_type_t operation);
704 /*%<
705  * Increment the statistics counter for the DNSKEY 'id' with algorithm 'alg'.
706  * The 'operation' determines what counter is incremented.
707  *
708  * Requires:
709  *\li	'stats' is a valid dns_stats_t created by dns_dnssecsignstats_create().
710  */
711 
712 void
713 dns_dnssecsignstats_clear(dns_stats_t *stats, dns_keytag_t id, uint8_t alg);
714 /*%<
715  * Clear the statistics counter for the DNSKEY 'id' with algorithm 'alg'.
716  *
717  * Requires:
718  *\li	'stats' is a valid dns_stats_t created by dns_dnssecsignstats_create().
719  */
720 
721 void
722 dns_generalstats_dump(dns_stats_t *stats, dns_generalstats_dumper_t dump_fn,
723 		      void *arg, unsigned int options);
724 /*%<
725  * Dump the current statistics counters in a specified way.  For each counter
726  * in stats, dump_fn is called with its current value and the given argument
727  * arg.  By default counters that have a value of 0 is skipped; if options has
728  * the ISC_STATSDUMP_VERBOSE flag, even such counters are dumped.
729  *
730  * This function is obsolete.  A more general function, isc_stats_dump(),
731  * should be used.
732  *
733  * Requires:
734  *\li	'stats' is a valid dns_stats_t created by dns_generalstats_create().
735  */
736 
737 void
738 dns_rdatatypestats_dump(dns_stats_t *stats, dns_rdatatypestats_dumper_t dump_fn,
739 			void *arg, unsigned int options);
740 /*%<
741  * Dump the current statistics counters in a specified way.  For each counter
742  * in stats, dump_fn is called with the corresponding type in the form of
743  * dns_rdatastatstype_t, the current counter value and the given argument
744  * arg.  By default counters that have a value of 0 is skipped; if options has
745  * the ISC_STATSDUMP_VERBOSE flag, even such counters are dumped.
746  *
747  * Requires:
748  *\li	'stats' is a valid dns_stats_t created by dns_generalstats_create().
749  */
750 
751 void
752 dns_rdatasetstats_dump(dns_stats_t *stats, dns_rdatatypestats_dumper_t dump_fn,
753 		       void *arg, unsigned int options);
754 /*%<
755  * Dump the current statistics counters in a specified way.  For each counter
756  * in stats, dump_fn is called with the corresponding type in the form of
757  * dns_rdatastatstype_t, the current counter value and the given argument
758  * arg.  By default counters that have a value of 0 is skipped; if options has
759  * the ISC_STATSDUMP_VERBOSE flag, even such counters are dumped.
760  *
761  * Requires:
762  *\li	'stats' is a valid dns_stats_t created by dns_generalstats_create().
763  */
764 
765 void
766 dns_dnssecsignstats_dump(dns_stats_t *stats, dnssecsignstats_type_t operation,
767 			 dns_dnssecsignstats_dumper_t dump_fn, void *arg,
768 			 unsigned int options);
769 /*%<
770  * Dump the current statistics counters in a specified way.  For each counter
771  * in stats, dump_fn is called with the corresponding type in the form of
772  * dns_rdatastatstype_t, the current counter value and the given argument
773  * arg.  By default counters that have a value of 0 is skipped; if options has
774  * the ISC_STATSDUMP_VERBOSE flag, even such counters are dumped.
775  *
776  * Requires:
777  *\li	'stats' is a valid dns_stats_t created by dns_generalstats_create().
778  */
779 
780 void
781 dns_opcodestats_dump(dns_stats_t *stats, dns_opcodestats_dumper_t dump_fn,
782 		     void *arg, unsigned int options);
783 /*%<
784  * Dump the current statistics counters in a specified way.  For each counter
785  * in stats, dump_fn is called with the corresponding opcode, the current
786  * counter value and the given argument arg.  By default counters that have a
787  * value of 0 is skipped; if options has the ISC_STATSDUMP_VERBOSE flag, even
788  * such counters are dumped.
789  *
790  * Requires:
791  *\li	'stats' is a valid dns_stats_t created by dns_generalstats_create().
792  */
793 
794 void
795 dns_rcodestats_dump(dns_stats_t *stats, dns_rcodestats_dumper_t dump_fn,
796 		    void *arg, unsigned int options);
797 /*%<
798  * Dump the current statistics counters in a specified way.  For each counter
799  * in stats, dump_fn is called with the corresponding rcode, the current
800  * counter value and the given argument arg.  By default counters that have a
801  * value of 0 is skipped; if options has the ISC_STATSDUMP_VERBOSE flag, even
802  * such counters are dumped.
803  *
804  * Requires:
805  *\li	'stats' is a valid dns_stats_t created by dns_generalstats_create().
806  */
807 
808 isc_result_t
809 dns_stats_alloccounters(isc_mem_t *mctx, uint64_t **ctrp);
810 /*%<
811  * Allocate an array of query statistics counters from the memory
812  * context 'mctx'.
813  *
814  * This function is obsoleted.  Use dns_xxxstats_create() instead.
815  */
816 
817 void
818 dns_stats_freecounters(isc_mem_t *mctx, uint64_t **ctrp);
819 /*%<
820  * Free an array of query statistics counters allocated from the memory
821  * context 'mctx'.
822  *
823  * This function is obsoleted.  Use dns_stats_destroy() instead.
824  */
825 
826 ISC_LANG_ENDDECLS
827 
828 #endif /* DNS_STATS_H */
829