]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
1276. [contrib] 'queryperf' now has EDNS (-e) + DNSSEC DO (-D) support.
authorMark Andrews <marka@isc.org>
Tue, 30 Apr 2002 00:11:55 +0000 (00:11 +0000)
committerMark Andrews <marka@isc.org>
Tue, 30 Apr 2002 00:11:55 +0000 (00:11 +0000)
CHANGES
contrib/queryperf/queryperf.c

diff --git a/CHANGES b/CHANGES
index ae2eaa6919ebc6a510e83ea4ea6972331f7178d2..2e9c10653162e2b261afea16ebed60875ddac10d 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,5 @@
+1276.  [contrib]       'queryperf' now has EDNS (-e) + DNSSEC DO (-D) support.
+
 1275.  [bug]           When verifying that an NXT proves nonexistence, check
                        the rcode of the message and only do the matching NXT
                        check.  That is, for NXDOMAIN responses, check that
index 0920219d9279d291f7cce802fb92970a302b1358..8f4e46c0022f3ccf2a4ef5ce7bb1dfc3dce0293b 100644 (file)
@@ -18,7 +18,7 @@
 /***
  ***   DNS Query Performance Testing Tool  (queryperf.c)
  ***
- ***   Version $Id: queryperf.c,v 1.3 2002/03/11 19:00:01 gson Exp $
+ ***   Version $Id: queryperf.c,v 1.4 2002/04/30 00:11:55 marka Exp $
  ***
  ***   Stephen Jacob <sj@nominum.com>
  ***/
@@ -61,6 +61,7 @@
 #define MAX_BUFFER_LEN                 8192            /* in bytes */
 #define HARD_TIMEOUT_EXTRA             5               /* in seconds */
 #define RESPONSE_BLOCKING_WAIT_TIME    0.1             /* in seconds */
+#define EDNSLEN                                11
 
 #define FALSE                          0
 #define TRUE                           1
@@ -120,6 +121,7 @@ unsigned int run_timelimit;                         /* init 0 */
 
 int serverset = FALSE, portset = FALSE;
 int queriesset = FALSE, timeoutset = FALSE;
+int edns = FALSE, dnssec = FALSE;
 
 int verbose = FALSE;
 
@@ -167,7 +169,7 @@ void
 show_startup_info(void) {
        printf("\n"
 "DNS Query Performance Testing Tool\n"
-"Version: $Id: queryperf.c,v 1.3 2002/03/11 19:00:01 gson Exp $\n"
+"Version: $Id: queryperf.c,v 1.4 2002/04/30 00:11:55 marka Exp $\n"
 "\n");
 }
 
@@ -190,6 +192,8 @@ show_usage(void) {
 "  -l specifies how a limit for how long to run tests in seconds (no default)\n"
 "  -1 run through input only once (default: multiple iff limit given)\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"
 "  -v verbose: report the RCODE of each response on stdout\n"
 "\n",
                DEF_SERVER_TO_QUERY, DEF_SERVER_PORT,
@@ -407,7 +411,7 @@ parse_args(int argc, char **argv) {
        int c;
        unsigned int uint_arg_val;
 
-       while ((c = getopt(argc, argv, "q:t:nd:s:p:1l:b:v")) != -1) {
+       while ((c = getopt(argc, argv, "q:t:nd:s:p:1l:b:eDv")) != -1) {
                switch (c) {
                case 'q':
                        if (is_uint(optarg, &uint_arg_val) == TRUE) {
@@ -494,6 +498,13 @@ parse_args(int argc, char **argv) {
                                return (-1);
                        }
                        break;
+               case 'e':
+                       edns = TRUE;
+                       break;
+               case 'D':
+                       dnssec = TRUE;
+                       edns = TRUE;
+                       break;
                case 'v':
                        verbose = 1;
                        break;
@@ -991,7 +1002,7 @@ parse_query(char *input, char *qname, int qnlen, int *qtype) {
        type_str = strtok(NULL, WHITESPACE);
 
        if ((domain_str == NULL) || (type_str == NULL)) {
-               fprintf(stderr, "Invalid query input format: %s", input);
+               fprintf(stderr, "Invalid query input format: %s\n", input);
                return (-1);
        }
 
@@ -1001,7 +1012,7 @@ parse_query(char *input, char *qname, int qnlen, int *qtype) {
        }
 
        for (index = 0; (index < num_types) && (found == FALSE); index++) {
-               if (strcmp(type_str, qtype_strings[index]) == 0) {
+               if (strcasecmp(type_str, qtype_strings[index]) == 0) {
                        *qtype = qtype_codes[index];
                        found = TRUE;
                }
@@ -1040,6 +1051,30 @@ dispatch_query(unsigned short int id, char *dom, int qt) {
                        dom, qt);
                return (-1);
        }
+       if (edns) {
+               unsigned char *p;
+               if (buffer_len + EDNSLEN >= PACKETSZ) {
+                       fprintf(stderr, "Failed to add OPT to query packet\n");
+                       return (-1);
+               }
+               packet_buffer[11] = 1;
+               p = &packet_buffer[buffer_len];
+               *p++ = 0;       /* root name */
+               *p++ = 0;
+               *p++ = 41;      /* OPT */
+               *p++ = 16;      
+               *p++ = 0;       /* UDP payload size (4K) */
+               *p++ = 0;       /* extended rcode */
+               *p++ = 0;       /* version */
+               if (dnssec)
+                       *p++ = 0x80;    /* upper flag bits - DO set */
+               else
+                       *p++ = 0;       /* upper flag bits */
+               *p++ = 0;       /* lower flag bit */
+               *p++ = 0;
+               *p++ = 0;       /* rdlen == 0 */
+               buffer_len += EDNSLEN;
+       }
 
        packet_buffer[0] = id_ptr[0];
        packet_buffer[1] = id_ptr[1];