/***
*** DNS Query Performance Testing Tool (queryperf.c)
***
- *** Version $Id: queryperf.c,v 1.4 2002/04/30 00:11:55 marka Exp $
+ *** Version $Id: queryperf.c,v 1.5 2002/07/22 02:47:24 marka Exp $
***
*** Stephen Jacob <sj@nominum.com>
***/
28, 252, 253, 254, 255, 255 \
}
+#define RCODE_STRINGS { \
+ "NOERROR", "FORMERR", "SERVFAIL", "NXDOMAIN", \
+ "NOTIMP", "REFUSED", "YXDOMAIN", "YXRRSET", \
+ "NXRRSET", "NOTAUTH", "NOTZONE", "rcode11", \
+ "rcode12", "rcode13", "rcode14", "rcode15" \
+}
+
/*
* Data type definitions
*/
int serverset = FALSE, portset = FALSE;
int queriesset = FALSE, timeoutset = FALSE;
int edns = FALSE, dnssec = FALSE;
+int countrcodes = FALSE;
+int rcodecounts[16] = {0};
int verbose = FALSE;
int query_socket; /* init 0 */
struct sockaddr_in qaddr;
+static char *rcode_strings[] = RCODE_STRINGS;
+
/*
* get_uint16:
* Get an unsigned short integer from a buffer (in network order)
show_startup_info(void) {
printf("\n"
"DNS Query Performance Testing Tool\n"
-"Version: $Id: queryperf.c,v 1.4 2002/04/30 00:11:55 marka Exp $\n"
+"Version: $Id: queryperf.c,v 1.5 2002/07/22 02:47:24 marka Exp $\n"
"\n");
}
" -b set input/output buffer size in kilobytes (default: %d k)\n"
" -e enable EDNS 0\n"
" -D set the DNSSEC OK bit (implies EDNS)\n"
+" -c print the number of packets with each rcode\n"
" -v verbose: report the RCODE of each response on stdout\n"
"\n",
DEF_SERVER_TO_QUERY, DEF_SERVER_PORT,
int c;
unsigned int uint_arg_val;
- while ((c = getopt(argc, argv, "q:t:nd:s:p:1l:b:eDv")) != -1) {
+ while ((c = getopt(argc, argv, "q:t:nd:s:p:1l:b:eDcv")) != -1) {
switch (c) {
case 'q':
if (is_uint(optarg, &uint_arg_val) == TRUE) {
dnssec = TRUE;
edns = TRUE;
break;
+ case 'c':
+ countrcodes = TRUE;
+ break;
case 'v':
verbose = 1;
break;
num_queries_outstanding--;
found = TRUE;
if (status[ct].desc) {
- printf("> %d %s\n", rcode, status[ct].desc);
+ printf("> %s %s\n", rcode_strings[rcode],
+ status[ct].desc);
free(status[ct].desc);
}
+ if (countrcodes)
+ rcodecounts[rcode]++;
}
}
printf("\n");
+ if (countrcodes) {
+ unsigned int i;
+
+ for (i = 0; i < 16; i++) {
+ if (rcodecounts[i] == 0)
+ continue;
+ printf(" Returned %8s: %u queries\n",
+ rcode_strings[i], rcodecounts[i]);
+ }
+ printf("\n");
+ }
+
printf(" Percentage completed: %6.2lf%%\n", per_completed);
printf(" Percentage lost: %6.2lf%%\n", per_lost);