2 * Copyright (C) 2004-2009 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.
18 /* $Id: stats.h,v 1.13.128.7 2009/01/29 23:47:13 tbox Exp $ */
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,
68 * Zone statistics counters.
70 dns_zonestatscounter_notifyoutv4
= 0,
71 dns_zonestatscounter_notifyoutv6
= 1,
72 dns_zonestatscounter_notifyinv4
= 2,
73 dns_zonestatscounter_notifyinv6
= 3,
74 dns_zonestatscounter_notifyrej
= 4,
75 dns_zonestatscounter_soaoutv4
= 5,
76 dns_zonestatscounter_soaoutv6
= 6,
77 dns_zonestatscounter_axfrreqv4
= 7,
78 dns_zonestatscounter_axfrreqv6
= 8,
79 dns_zonestatscounter_ixfrreqv4
= 9,
80 dns_zonestatscounter_ixfrreqv6
= 10,
81 dns_zonestatscounter_xfrsuccess
= 11,
82 dns_zonestatscounter_xfrfail
= 12,
84 dns_zonestatscounter_max
= 13,
87 * Query statistics counters (obsolete).
89 dns_statscounter_success
= 0, /*%< Successful lookup */
90 dns_statscounter_referral
= 1, /*%< Referral result */
91 dns_statscounter_nxrrset
= 2, /*%< NXRRSET result */
92 dns_statscounter_nxdomain
= 3, /*%< NXDOMAIN result */
93 dns_statscounter_recursion
= 4, /*%< Recursion was used */
94 dns_statscounter_failure
= 5, /*%< Some other failure */
95 dns_statscounter_duplicate
= 6, /*%< Duplicate query */
96 dns_statscounter_dropped
= 7 /*%< Duplicate query (dropped) */
99 #define DNS_STATS_NCOUNTERS 8
103 * Flag(s) for dns_xxxstats_dump(). DNS_STATSDUMP_VERBOSE is obsolete.
104 * ISC_STATSDUMP_VERBOSE should be used instead. These two values are
105 * intentionally defined to be the same value to ensure binary compatibility.
107 #define DNS_STATSDUMP_VERBOSE 0x00000001 /*%< dump 0-value counters */
113 LIBDNS_EXTERNAL_DATA
extern const char *dns_statscounter_names
[];
116 * Attributes for statistics counters of RRset and Rdatatype types.
119 * The rdata type is not explicitly supported and the corresponding counter
120 * is counted for other such types, too. When this attribute is set,
121 * the base type is of no use.
124 * RRset type counters only. Indicates the RRset is non existent.
127 * RRset type counters only. Indicates a non existent name. When this
128 * attribute is set, the base type is of no use.
130 #define DNS_RDATASTATSTYPE_ATTR_OTHERTYPE 0x0001
131 #define DNS_RDATASTATSTYPE_ATTR_NXRRSET 0x0002
132 #define DNS_RDATASTATSTYPE_ATTR_NXDOMAIN 0x0004
135 * Conversion macros among dns_rdatatype_t, attributes and isc_statscounter_t.
137 #define DNS_RDATASTATSTYPE_BASE(type) ((dns_rdatatype_t)((type) & 0xFFFF))
138 #define DNS_RDATASTATSTYPE_ATTR(type) ((type) >> 16)
139 #define DNS_RDATASTATSTYPE_VALUE(b, a) (((a) << 16) | (b))
142 * Types of dump callbacks.
144 typedef void (*dns_generalstats_dumper_t
)(isc_statscounter_t
, isc_uint64_t
,
146 typedef void (*dns_rdatatypestats_dumper_t
)(dns_rdatastatstype_t
, isc_uint64_t
,
148 typedef void (*dns_opcodestats_dumper_t
)(dns_opcode_t
, isc_uint64_t
, void *);
151 dns_generalstats_create(isc_mem_t
*mctx
, dns_stats_t
**statsp
, int ncounters
);
153 * Create a statistics counter structure of general type. It counts a general
154 * set of counters indexed by an ID between 0 and ncounters -1.
155 * This function is obsolete. A more general function, isc_stats_create(),
159 *\li 'mctx' must be a valid memory context.
161 *\li 'statsp' != NULL && '*statsp' == NULL.
164 *\li ISC_R_SUCCESS -- all ok
166 *\li anything else -- failure
170 dns_rdatatypestats_create(isc_mem_t
*mctx
, dns_stats_t
**statsp
);
172 * Create a statistics counter structure per rdatatype.
175 *\li 'mctx' must be a valid memory context.
177 *\li 'statsp' != NULL && '*statsp' == NULL.
180 *\li ISC_R_SUCCESS -- all ok
182 *\li anything else -- failure
186 dns_rdatasetstats_create(isc_mem_t
*mctx
, dns_stats_t
**statsp
);
188 * Create a statistics counter structure per RRset.
191 *\li 'mctx' must be a valid memory context.
193 *\li 'statsp' != NULL && '*statsp' == NULL.
196 *\li ISC_R_SUCCESS -- all ok
198 *\li anything else -- failure
202 dns_opcodestats_create(isc_mem_t
*mctx
, dns_stats_t
**statsp
);
204 * Create a statistics counter structure per opcode.
207 *\li 'mctx' must be a valid memory context.
209 *\li 'statsp' != NULL && '*statsp' == NULL.
212 *\li ISC_R_SUCCESS -- all ok
214 *\li anything else -- failure
218 dns_stats_attach(dns_stats_t
*stats
, dns_stats_t
**statsp
);
220 * Attach to a statistics set.
223 *\li 'stats' is a valid dns_stats_t.
225 *\li 'statsp' != NULL && '*statsp' == NULL
229 dns_stats_detach(dns_stats_t
**statsp
);
231 * Detaches from the statistics set.
234 *\li 'statsp' != NULL and '*statsp' is a valid dns_stats_t.
238 dns_generalstats_increment(dns_stats_t
*stats
, isc_statscounter_t counter
);
240 * Increment the counter-th counter of stats. This function is obsolete.
241 * A more general function, isc_stats_increment(), should be used.
244 *\li 'stats' is a valid dns_stats_t created by dns_generalstats_create().
246 *\li counter is less than the maximum available ID for the stats specified
251 dns_rdatatypestats_increment(dns_stats_t
*stats
, dns_rdatatype_t type
);
253 * Increment the statistics counter for 'type'.
256 *\li 'stats' is a valid dns_stats_t created by dns_rdatatypestats_create().
260 dns_rdatasetstats_increment(dns_stats_t
*stats
, dns_rdatastatstype_t rrsettype
);
262 * Increment the statistics counter for 'rrsettype'.
265 *\li 'stats' is a valid dns_stats_t created by dns_rdatasetstats_create().
269 dns_rdatasetstats_decrement(dns_stats_t
*stats
, dns_rdatastatstype_t rrsettype
);
271 * Decrement the statistics counter for 'rrsettype'.
274 *\li 'stats' is a valid dns_stats_t created by dns_rdatasetstats_create().
278 dns_opcodestats_increment(dns_stats_t
*stats
, dns_opcode_t code
);
280 * Increment the statistics counter for 'code'.
283 *\li 'stats' is a valid dns_stats_t created by dns_opcodestats_create().
287 dns_generalstats_dump(dns_stats_t
*stats
, dns_generalstats_dumper_t dump_fn
,
288 void *arg
, unsigned int options
);
290 * Dump the current statistics counters in a specified way. For each counter
291 * in stats, dump_fn is called with its current value and the given argument
292 * arg. By default counters that have a value of 0 is skipped; if options has
293 * the ISC_STATSDUMP_VERBOSE flag, even such counters are dumped.
295 * This function is obsolete. A more general function, isc_stats_dump(),
299 *\li 'stats' is a valid dns_stats_t created by dns_generalstats_create().
303 dns_rdatatypestats_dump(dns_stats_t
*stats
, dns_rdatatypestats_dumper_t dump_fn
,
304 void *arg
, unsigned int options
);
306 * Dump the current statistics counters in a specified way. For each counter
307 * in stats, dump_fn is called with the corresponding type in the form of
308 * dns_rdatastatstype_t, the current counter value and the given argument
309 * arg. By default counters that have a value of 0 is skipped; if options has
310 * the ISC_STATSDUMP_VERBOSE flag, even such counters are dumped.
313 *\li 'stats' is a valid dns_stats_t created by dns_generalstats_create().
317 dns_rdatasetstats_dump(dns_stats_t
*stats
, dns_rdatatypestats_dumper_t dump_fn
,
318 void *arg
, unsigned int options
);
320 * Dump the current statistics counters in a specified way. For each counter
321 * in stats, dump_fn is called with the corresponding type in the form of
322 * dns_rdatastatstype_t, the current counter value and the given argument
323 * arg. By default counters that have a value of 0 is skipped; if options has
324 * the ISC_STATSDUMP_VERBOSE flag, even such counters are dumped.
327 *\li 'stats' is a valid dns_stats_t created by dns_generalstats_create().
331 dns_opcodestats_dump(dns_stats_t
*stats
, dns_opcodestats_dumper_t dump_fn
,
332 void *arg
, unsigned int options
);
334 * Dump the current statistics counters in a specified way. For each counter
335 * in stats, dump_fn is called with the corresponding opcode, the current
336 * counter value and the given argument arg. By default counters that have a
337 * value of 0 is skipped; if options has the ISC_STATSDUMP_VERBOSE flag, even
338 * such counters are dumped.
341 *\li 'stats' is a valid dns_stats_t created by dns_generalstats_create().
345 dns_stats_alloccounters(isc_mem_t
*mctx
, isc_uint64_t
**ctrp
);
347 * Allocate an array of query statistics counters from the memory
350 * This function is obsoleted. Use dns_xxxstats_create() instead.
354 dns_stats_freecounters(isc_mem_t
*mctx
, isc_uint64_t
**ctrp
);
356 * Free an array of query statistics counters allocated from the memory
359 * This function is obsoleted. Use dns_stats_destroy() instead.
364 #endif /* DNS_STATS_H */