1 /* 2 * Copyright (C) 2004-2009, 2012, 2015 Internet Systems Consortium, Inc. ("ISC") 3 * Copyright (C) 2000, 2001 Internet Software Consortium. 4 * 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. 8 * 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. 16 */ 17 18 /* $Id$ */ 19 20 #ifndef DNS_STATS_H 21 #define DNS_STATS_H 1 22 23 /*! \file dns/stats.h */ 24 25 #include <dns/types.h> 26 27 /*% 28 * Statistics counters. Used as isc_statscounter_t values. 29 */ 30 enum { 31 /*% 32 * Resolver statistics counters. 33 */ 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, 64 dns_resstatscounter_zonequota = 30, 65 dns_resstatscounter_serverquota = 31, 66 67 dns_resstatscounter_max = 32, 68 69 /* 70 * DNSSEC stats. 71 */ 72 dns_dnssecstats_asis = 0, 73 dns_dnssecstats_downcase = 1, 74 dns_dnssecstats_wildcard = 2, 75 dns_dnssecstats_fail = 3, 76 77 dns_dnssecstats_max = 4, 78 79 /*% 80 * Zone statistics counters. 81 */ 82 dns_zonestatscounter_notifyoutv4 = 0, 83 dns_zonestatscounter_notifyoutv6 = 1, 84 dns_zonestatscounter_notifyinv4 = 2, 85 dns_zonestatscounter_notifyinv6 = 3, 86 dns_zonestatscounter_notifyrej = 4, 87 dns_zonestatscounter_soaoutv4 = 5, 88 dns_zonestatscounter_soaoutv6 = 6, 89 dns_zonestatscounter_axfrreqv4 = 7, 90 dns_zonestatscounter_axfrreqv6 = 8, 91 dns_zonestatscounter_ixfrreqv4 = 9, 92 dns_zonestatscounter_ixfrreqv6 = 10, 93 dns_zonestatscounter_xfrsuccess = 11, 94 dns_zonestatscounter_xfrfail = 12, 95 96 dns_zonestatscounter_max = 13, 97 98 /*% 99 * Query statistics counters (obsolete). 100 */ 101 dns_statscounter_success = 0, /*%< Successful lookup */ 102 dns_statscounter_referral = 1, /*%< Referral result */ 103 dns_statscounter_nxrrset = 2, /*%< NXRRSET result */ 104 dns_statscounter_nxdomain = 3, /*%< NXDOMAIN result */ 105 dns_statscounter_recursion = 4, /*%< Recursion was used */ 106 dns_statscounter_failure = 5, /*%< Some other failure */ 107 dns_statscounter_duplicate = 6, /*%< Duplicate query */ 108 dns_statscounter_dropped = 7 /*%< Duplicate query (dropped) */ 109 }; 110 111 #define DNS_STATS_NCOUNTERS 8 112 113 #if 0 114 /*%< 115 * Flag(s) for dns_xxxstats_dump(). DNS_STATSDUMP_VERBOSE is obsolete. 116 * ISC_STATSDUMP_VERBOSE should be used instead. These two values are 117 * intentionally defined to be the same value to ensure binary compatibility. 118 */ 119 #define DNS_STATSDUMP_VERBOSE 0x00000001 /*%< dump 0-value counters */ 120 #endif 121 122 /*%< 123 * (Obsoleted) 124 */ 125 LIBDNS_EXTERNAL_DATA extern const char *dns_statscounter_names[]; 126 127 /*% 128 * Attributes for statistics counters of RRset and Rdatatype types. 129 * 130 * _OTHERTYPE 131 * The rdata type is not explicitly supported and the corresponding counter 132 * is counted for other such types, too. When this attribute is set, 133 * the base type is of no use. 134 * 135 * _NXRRSET 136 * RRset type counters only. Indicates the RRset is non existent. 137 * 138 * _NXDOMAIN 139 * RRset type counters only. Indicates a non existent name. When this 140 * attribute is set, the base type is of no use. 141 */ 142 #define DNS_RDATASTATSTYPE_ATTR_OTHERTYPE 0x0001 143 #define DNS_RDATASTATSTYPE_ATTR_NXRRSET 0x0002 144 #define DNS_RDATASTATSTYPE_ATTR_NXDOMAIN 0x0004 145 146 /*%< 147 * Conversion macros among dns_rdatatype_t, attributes and isc_statscounter_t. 148 */ 149 #define DNS_RDATASTATSTYPE_BASE(type) ((dns_rdatatype_t)((type) & 0xFFFF)) 150 #define DNS_RDATASTATSTYPE_ATTR(type) ((type) >> 16) 151 #define DNS_RDATASTATSTYPE_VALUE(b, a) (((a) << 16) | (b)) 152 153 /*%< 154 * Types of dump callbacks. 155 */ 156 typedef void (*dns_generalstats_dumper_t)(isc_statscounter_t, isc_uint64_t, 157 void *); 158 typedef void (*dns_rdatatypestats_dumper_t)(dns_rdatastatstype_t, isc_uint64_t, 159 void *); 160 typedef void (*dns_opcodestats_dumper_t)(dns_opcode_t, isc_uint64_t, void *); 161 162 ISC_LANG_BEGINDECLS 163 164 isc_result_t 165 dns_generalstats_create(isc_mem_t *mctx, dns_stats_t **statsp, int ncounters); 166 /*%< 167 * Create a statistics counter structure of general type. It counts a general 168 * set of counters indexed by an ID between 0 and ncounters -1. 169 * This function is obsolete. A more general function, isc_stats_create(), 170 * should be used. 171 * 172 * Requires: 173 *\li 'mctx' must be a valid memory context. 174 * 175 *\li 'statsp' != NULL && '*statsp' == NULL. 176 * 177 * Returns: 178 *\li ISC_R_SUCCESS -- all ok 179 * 180 *\li anything else -- failure 181 */ 182 183 isc_result_t 184 dns_rdatatypestats_create(isc_mem_t *mctx, dns_stats_t **statsp); 185 /*%< 186 * Create a statistics counter structure per rdatatype. 187 * 188 * Requires: 189 *\li 'mctx' must be a valid memory context. 190 * 191 *\li 'statsp' != NULL && '*statsp' == NULL. 192 * 193 * Returns: 194 *\li ISC_R_SUCCESS -- all ok 195 * 196 *\li anything else -- failure 197 */ 198 199 isc_result_t 200 dns_rdatasetstats_create(isc_mem_t *mctx, dns_stats_t **statsp); 201 /*%< 202 * Create a statistics counter structure per RRset. 203 * 204 * Requires: 205 *\li 'mctx' must be a valid memory context. 206 * 207 *\li 'statsp' != NULL && '*statsp' == NULL. 208 * 209 * Returns: 210 *\li ISC_R_SUCCESS -- all ok 211 * 212 *\li anything else -- failure 213 */ 214 215 isc_result_t 216 dns_opcodestats_create(isc_mem_t *mctx, dns_stats_t **statsp); 217 /*%< 218 * Create a statistics counter structure per opcode. 219 * 220 * Requires: 221 *\li 'mctx' must be a valid memory context. 222 * 223 *\li 'statsp' != NULL && '*statsp' == NULL. 224 * 225 * Returns: 226 *\li ISC_R_SUCCESS -- all ok 227 * 228 *\li anything else -- failure 229 */ 230 231 void 232 dns_stats_attach(dns_stats_t *stats, dns_stats_t **statsp); 233 /*%< 234 * Attach to a statistics set. 235 * 236 * Requires: 237 *\li 'stats' is a valid dns_stats_t. 238 * 239 *\li 'statsp' != NULL && '*statsp' == NULL 240 */ 241 242 void 243 dns_stats_detach(dns_stats_t **statsp); 244 /*%< 245 * Detaches from the statistics set. 246 * 247 * Requires: 248 *\li 'statsp' != NULL and '*statsp' is a valid dns_stats_t. 249 */ 250 251 void 252 dns_generalstats_increment(dns_stats_t *stats, isc_statscounter_t counter); 253 /*%< 254 * Increment the counter-th counter of stats. This function is obsolete. 255 * A more general function, isc_stats_increment(), should be used. 256 * 257 * Requires: 258 *\li 'stats' is a valid dns_stats_t created by dns_generalstats_create(). 259 * 260 *\li counter is less than the maximum available ID for the stats specified 261 * on creation. 262 */ 263 264 void 265 dns_rdatatypestats_increment(dns_stats_t *stats, dns_rdatatype_t type); 266 /*%< 267 * Increment the statistics counter for 'type'. 268 * 269 * Requires: 270 *\li 'stats' is a valid dns_stats_t created by dns_rdatatypestats_create(). 271 */ 272 273 void 274 dns_rdatasetstats_increment(dns_stats_t *stats, dns_rdatastatstype_t rrsettype); 275 /*%< 276 * Increment the statistics counter for 'rrsettype'. 277 * 278 * Requires: 279 *\li 'stats' is a valid dns_stats_t created by dns_rdatasetstats_create(). 280 */ 281 282 void 283 dns_rdatasetstats_decrement(dns_stats_t *stats, dns_rdatastatstype_t rrsettype); 284 /*%< 285 * Decrement the statistics counter for 'rrsettype'. 286 * 287 * Requires: 288 *\li 'stats' is a valid dns_stats_t created by dns_rdatasetstats_create(). 289 */ 290 291 void 292 dns_opcodestats_increment(dns_stats_t *stats, dns_opcode_t code); 293 /*%< 294 * Increment the statistics counter for 'code'. 295 * 296 * Requires: 297 *\li 'stats' is a valid dns_stats_t created by dns_opcodestats_create(). 298 */ 299 300 void 301 dns_generalstats_dump(dns_stats_t *stats, dns_generalstats_dumper_t dump_fn, 302 void *arg, unsigned int options); 303 /*%< 304 * Dump the current statistics counters in a specified way. For each counter 305 * in stats, dump_fn is called with its current value and the given argument 306 * arg. By default counters that have a value of 0 is skipped; if options has 307 * the ISC_STATSDUMP_VERBOSE flag, even such counters are dumped. 308 * 309 * This function is obsolete. A more general function, isc_stats_dump(), 310 * should be used. 311 * 312 * Requires: 313 *\li 'stats' is a valid dns_stats_t created by dns_generalstats_create(). 314 */ 315 316 void 317 dns_rdatatypestats_dump(dns_stats_t *stats, dns_rdatatypestats_dumper_t dump_fn, 318 void *arg, unsigned int options); 319 /*%< 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. 325 * 326 * Requires: 327 *\li 'stats' is a valid dns_stats_t created by dns_generalstats_create(). 328 */ 329 330 void 331 dns_rdatasetstats_dump(dns_stats_t *stats, dns_rdatatypestats_dumper_t dump_fn, 332 void *arg, unsigned int options); 333 /*%< 334 * Dump the current statistics counters in a specified way. For each counter 335 * in stats, dump_fn is called with the corresponding type in the form of 336 * dns_rdatastatstype_t, the current counter value and the given argument 337 * arg. By default counters that have a value of 0 is skipped; if options has 338 * the ISC_STATSDUMP_VERBOSE flag, even such counters are dumped. 339 * 340 * Requires: 341 *\li 'stats' is a valid dns_stats_t created by dns_generalstats_create(). 342 */ 343 344 void 345 dns_opcodestats_dump(dns_stats_t *stats, dns_opcodestats_dumper_t dump_fn, 346 void *arg, unsigned int options); 347 /*%< 348 * Dump the current statistics counters in a specified way. For each counter 349 * in stats, dump_fn is called with the corresponding opcode, the current 350 * counter value and the given argument arg. By default counters that have a 351 * value of 0 is skipped; if options has the ISC_STATSDUMP_VERBOSE flag, even 352 * such counters are dumped. 353 * 354 * Requires: 355 *\li 'stats' is a valid dns_stats_t created by dns_generalstats_create(). 356 */ 357 358 isc_result_t 359 dns_stats_alloccounters(isc_mem_t *mctx, isc_uint64_t **ctrp); 360 /*%< 361 * Allocate an array of query statistics counters from the memory 362 * context 'mctx'. 363 * 364 * This function is obsoleted. Use dns_xxxstats_create() instead. 365 */ 366 367 void 368 dns_stats_freecounters(isc_mem_t *mctx, isc_uint64_t **ctrp); 369 /*%< 370 * Free an array of query statistics counters allocated from the memory 371 * context 'mctx'. 372 * 373 * This function is obsoleted. Use dns_stats_destroy() instead. 374 */ 375 376 ISC_LANG_ENDDECLS 377 378 #endif /* DNS_STATS_H */ 379