2 * Copyright (C) 2004-2009, 2012 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 2000, 2001 Internet Software Consortium.
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
23 /*! \file dns/stats.h */
25 #include <dns/types.h>
28 * Statistics counters. Used as isc_statscounter_t values.
32 * Resolver statistics counters.
34 dns_resstatscounter_queryv4 = 0,
35 dns_resstatscounter_queryv6 = 1,
36 dns_resstatscounter_responsev4 = 2,
37 dns_resstatscounter_responsev6 = 3,
38 dns_resstatscounter_nxdomain = 4,
39 dns_resstatscounter_servfail = 5,
40 dns_resstatscounter_formerr = 6,
41 dns_resstatscounter_othererror = 7,
42 dns_resstatscounter_edns0fail = 8,
43 dns_resstatscounter_mismatch = 9,
44 dns_resstatscounter_truncated = 10,
45 dns_resstatscounter_lame = 11,
46 dns_resstatscounter_retry = 12,
47 dns_resstatscounter_gluefetchv4 = 13,
48 dns_resstatscounter_gluefetchv6 = 14,
49 dns_resstatscounter_gluefetchv4fail = 15,
50 dns_resstatscounter_gluefetchv6fail = 16,
51 dns_resstatscounter_val = 17,
52 dns_resstatscounter_valsuccess = 18,
53 dns_resstatscounter_valnegsuccess = 19,
54 dns_resstatscounter_valfail = 20,
55 dns_resstatscounter_dispabort = 21,
56 dns_resstatscounter_dispsockfail = 22,
57 dns_resstatscounter_querytimeout = 23,
58 dns_resstatscounter_queryrtt0 = 24,
59 dns_resstatscounter_queryrtt1 = 25,
60 dns_resstatscounter_queryrtt2 = 26,
61 dns_resstatscounter_queryrtt3 = 27,
62 dns_resstatscounter_queryrtt4 = 28,
63 dns_resstatscounter_queryrtt5 = 29,
65 dns_resstatscounter_max = 30,
70 dns_dnssecstats_asis = 0,
71 dns_dnssecstats_downcase = 1,
72 dns_dnssecstats_wildcard = 2,
73 dns_dnssecstats_fail = 3,
75 dns_dnssecstats_max = 4,
78 * Zone statistics counters.
80 dns_zonestatscounter_notifyoutv4 = 0,
81 dns_zonestatscounter_notifyoutv6 = 1,
82 dns_zonestatscounter_notifyinv4 = 2,
83 dns_zonestatscounter_notifyinv6 = 3,
84 dns_zonestatscounter_notifyrej = 4,
85 dns_zonestatscounter_soaoutv4 = 5,
86 dns_zonestatscounter_soaoutv6 = 6,
87 dns_zonestatscounter_axfrreqv4 = 7,
88 dns_zonestatscounter_axfrreqv6 = 8,
89 dns_zonestatscounter_ixfrreqv4 = 9,
90 dns_zonestatscounter_ixfrreqv6 = 10,
91 dns_zonestatscounter_xfrsuccess = 11,
92 dns_zonestatscounter_xfrfail = 12,
94 dns_zonestatscounter_max = 13,
97 * Query statistics counters (obsolete).
99 dns_statscounter_success = 0, /*%< Successful lookup */
100 dns_statscounter_referral = 1, /*%< Referral result */
101 dns_statscounter_nxrrset = 2, /*%< NXRRSET result */
102 dns_statscounter_nxdomain = 3, /*%< NXDOMAIN result */
103 dns_statscounter_recursion = 4, /*%< Recursion was used */
104 dns_statscounter_failure = 5, /*%< Some other failure */
105 dns_statscounter_duplicate = 6, /*%< Duplicate query */
106 dns_statscounter_dropped = 7 /*%< Duplicate query (dropped) */
109 #define DNS_STATS_NCOUNTERS 8
113 * Flag(s) for dns_xxxstats_dump(). DNS_STATSDUMP_VERBOSE is obsolete.
114 * ISC_STATSDUMP_VERBOSE should be used instead. These two values are
115 * intentionally defined to be the same value to ensure binary compatibility.
117 #define DNS_STATSDUMP_VERBOSE 0x00000001 /*%< dump 0-value counters */
123 LIBDNS_EXTERNAL_DATA extern const char *dns_statscounter_names[];
126 * Attributes for statistics counters of RRset and Rdatatype types.
129 * The rdata type is not explicitly supported and the corresponding counter
130 * is counted for other such types, too. When this attribute is set,
131 * the base type is of no use.
134 * RRset type counters only. Indicates the RRset is non existent.
137 * RRset type counters only. Indicates a non existent name. When this
138 * attribute is set, the base type is of no use.
140 #define DNS_RDATASTATSTYPE_ATTR_OTHERTYPE 0x0001
141 #define DNS_RDATASTATSTYPE_ATTR_NXRRSET 0x0002
142 #define DNS_RDATASTATSTYPE_ATTR_NXDOMAIN 0x0004
145 * Conversion macros among dns_rdatatype_t, attributes and isc_statscounter_t.
147 #define DNS_RDATASTATSTYPE_BASE(type) ((dns_rdatatype_t)((type) & 0xFFFF))
148 #define DNS_RDATASTATSTYPE_ATTR(type) ((type) >> 16)
149 #define DNS_RDATASTATSTYPE_VALUE(b, a) (((a) << 16) | (b))
152 * Types of dump callbacks.
154 typedef void (*dns_generalstats_dumper_t)(isc_statscounter_t, isc_uint64_t,
156 typedef void (*dns_rdatatypestats_dumper_t)(dns_rdatastatstype_t, isc_uint64_t,
158 typedef void (*dns_opcodestats_dumper_t)(dns_opcode_t, isc_uint64_t, void *);
163 dns_generalstats_create(isc_mem_t *mctx, dns_stats_t **statsp, int ncounters);
165 * Create a statistics counter structure of general type. It counts a general
166 * set of counters indexed by an ID between 0 and ncounters -1.
167 * This function is obsolete. A more general function, isc_stats_create(),
171 *\li 'mctx' must be a valid memory context.
173 *\li 'statsp' != NULL && '*statsp' == NULL.
176 *\li ISC_R_SUCCESS -- all ok
178 *\li anything else -- failure
182 dns_rdatatypestats_create(isc_mem_t *mctx, dns_stats_t **statsp);
184 * Create a statistics counter structure per rdatatype.
187 *\li 'mctx' must be a valid memory context.
189 *\li 'statsp' != NULL && '*statsp' == NULL.
192 *\li ISC_R_SUCCESS -- all ok
194 *\li anything else -- failure
198 dns_rdatasetstats_create(isc_mem_t *mctx, dns_stats_t **statsp);
200 * Create a statistics counter structure per RRset.
203 *\li 'mctx' must be a valid memory context.
205 *\li 'statsp' != NULL && '*statsp' == NULL.
208 *\li ISC_R_SUCCESS -- all ok
210 *\li anything else -- failure
214 dns_opcodestats_create(isc_mem_t *mctx, dns_stats_t **statsp);
216 * Create a statistics counter structure per opcode.
219 *\li 'mctx' must be a valid memory context.
221 *\li 'statsp' != NULL && '*statsp' == NULL.
224 *\li ISC_R_SUCCESS -- all ok
226 *\li anything else -- failure
230 dns_stats_attach(dns_stats_t *stats, dns_stats_t **statsp);
232 * Attach to a statistics set.
235 *\li 'stats' is a valid dns_stats_t.
237 *\li 'statsp' != NULL && '*statsp' == NULL
241 dns_stats_detach(dns_stats_t **statsp);
243 * Detaches from the statistics set.
246 *\li 'statsp' != NULL and '*statsp' is a valid dns_stats_t.
250 dns_generalstats_increment(dns_stats_t *stats, isc_statscounter_t counter);
252 * Increment the counter-th counter of stats. This function is obsolete.
253 * A more general function, isc_stats_increment(), should be used.
256 *\li 'stats' is a valid dns_stats_t created by dns_generalstats_create().
258 *\li counter is less than the maximum available ID for the stats specified
263 dns_rdatatypestats_increment(dns_stats_t *stats, dns_rdatatype_t type);
265 * Increment the statistics counter for 'type'.
268 *\li 'stats' is a valid dns_stats_t created by dns_rdatatypestats_create().
272 dns_rdatasetstats_increment(dns_stats_t *stats, dns_rdatastatstype_t rrsettype);
274 * Increment the statistics counter for 'rrsettype'.
277 *\li 'stats' is a valid dns_stats_t created by dns_rdatasetstats_create().
281 dns_rdatasetstats_decrement(dns_stats_t *stats, dns_rdatastatstype_t rrsettype);
283 * Decrement the statistics counter for 'rrsettype'.
286 *\li 'stats' is a valid dns_stats_t created by dns_rdatasetstats_create().
290 dns_opcodestats_increment(dns_stats_t *stats, dns_opcode_t code);
292 * Increment the statistics counter for 'code'.
295 *\li 'stats' is a valid dns_stats_t created by dns_opcodestats_create().
299 dns_generalstats_dump(dns_stats_t *stats, dns_generalstats_dumper_t dump_fn,
300 void *arg, unsigned int options);
302 * Dump the current statistics counters in a specified way. For each counter
303 * in stats, dump_fn is called with its current value and the given argument
304 * arg. By default counters that have a value of 0 is skipped; if options has
305 * the ISC_STATSDUMP_VERBOSE flag, even such counters are dumped.
307 * This function is obsolete. A more general function, isc_stats_dump(),
311 *\li 'stats' is a valid dns_stats_t created by dns_generalstats_create().
315 dns_rdatatypestats_dump(dns_stats_t *stats, dns_rdatatypestats_dumper_t dump_fn,
316 void *arg, unsigned int options);
318 * Dump the current statistics counters in a specified way. For each counter
319 * in stats, dump_fn is called with the corresponding type in the form of
320 * dns_rdatastatstype_t, the current counter value and the given argument
321 * arg. By default counters that have a value of 0 is skipped; if options has
322 * the ISC_STATSDUMP_VERBOSE flag, even such counters are dumped.
325 *\li 'stats' is a valid dns_stats_t created by dns_generalstats_create().
329 dns_rdatasetstats_dump(dns_stats_t *stats, dns_rdatatypestats_dumper_t dump_fn,
330 void *arg, unsigned int options);
332 * Dump the current statistics counters in a specified way. For each counter
333 * in stats, dump_fn is called with the corresponding type in the form of
334 * dns_rdatastatstype_t, the current counter value and the given argument
335 * arg. By default counters that have a value of 0 is skipped; if options has
336 * the ISC_STATSDUMP_VERBOSE flag, even such counters are dumped.
339 *\li 'stats' is a valid dns_stats_t created by dns_generalstats_create().
343 dns_opcodestats_dump(dns_stats_t *stats, dns_opcodestats_dumper_t dump_fn,
344 void *arg, unsigned int options);
346 * Dump the current statistics counters in a specified way. For each counter
347 * in stats, dump_fn is called with the corresponding opcode, the current
348 * counter value and the given argument arg. By default counters that have a
349 * value of 0 is skipped; if options has the ISC_STATSDUMP_VERBOSE flag, even
350 * such counters are dumped.
353 *\li 'stats' is a valid dns_stats_t created by dns_generalstats_create().
357 dns_stats_alloccounters(isc_mem_t *mctx, isc_uint64_t **ctrp);
359 * Allocate an array of query statistics counters from the memory
362 * This function is obsoleted. Use dns_xxxstats_create() instead.
366 dns_stats_freecounters(isc_mem_t *mctx, isc_uint64_t **ctrp);
368 * Free an array of query statistics counters allocated from the memory
371 * This function is obsoleted. Use dns_stats_destroy() instead.
376 #endif /* DNS_STATS_H */