~kernevil/ubuntu/trusty/bind9/sdlz-hmac-keys

« back to all changes in this revision

Viewing changes to contrib/queryperf/queryperf.c

  • Committer: Package Import Robot
  • Author(s): LaMont Jones, Matthew Grant, LaMont Jones
  • Date: 2012-10-29 08:37:49 UTC
  • mfrom: (1.9.2)
  • Revision ID: package-import@ubuntu.com-20121029083749-r9inpzl0yuj9xdlu
Tags: 1:9.8.4.dfsg-1
[Matthew Grant]

* Turn off dlopen as it was causing test compile failures.
* Add missing library .postrm files for debhelper

[LaMont Jones]

* New upstream version
* soname fixup
* Ack NMUs

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
/***
19
19
 ***    DNS Query Performance Testing Tool  (queryperf.c)
20
20
 ***
21
 
 ***    Version $Id: queryperf.c,v 1.12 2007-09-05 07:36:04 marka Exp $
 
21
 ***    Version $Id: queryperf.c,v 1.12 2007/09/05 07:36:04 marka Exp $
22
22
 ***
23
23
 ***    Stephen Jacob <sj@nominum.com>
24
24
 ***/
25
25
 
 
26
#define BIND_8_COMPAT   /* Pull in <arpa/nameser_compat.h> */
 
27
 
26
28
#include <sys/time.h>
27
29
#include <sys/types.h>
28
30
#include <sys/socket.h>
118
120
};
119
121
 
120
122
/*
 
123
 * Forward declarations.
 
124
 */
 
125
int is_uint(char *test_int, unsigned int *result);
 
126
 
 
127
/*
121
128
 * Configuration options (global)
122
129
 */
123
130
 
148
155
int rcodecounts[16] = {0};
149
156
 
150
157
int verbose = FALSE;
 
158
int recurse = 1;
151
159
 
152
160
/*
153
161
 * Other global stuff
220
228
show_startup_info(void) {
221
229
        printf("\n"
222
230
"DNS Query Performance Testing Tool\n"
223
 
"Version: $Id: queryperf.c,v 1.12 2007-09-05 07:36:04 marka Exp $\n"
 
231
"Version: $Id: queryperf.c,v 1.12 2007/09/05 07:36:04 marka Exp $\n"
224
232
"\n");
225
233
}
226
234
 
235
243
"Usage: queryperf [-d datafile] [-s server_addr] [-p port] [-q num_queries]\n"
236
244
"                 [-b bufsize] [-t timeout] [-n] [-l limit] [-f family] [-1]\n"
237
245
"                 [-i interval] [-r arraysize] [-u unit] [-H histfile]\n"
238
 
"                 [-T qps] [-e] [-D] [-c] [-v] [-h]\n"
 
246
"                 [-T qps] [-e] [-D] [-R] [-c] [-v] [-h]\n"
239
247
"  -d specifies the input data file (default: stdin)\n"
240
248
"  -s sets the server to query (default: %s)\n"
241
249
"  -p sets the port on which to query the server (default: %s)\n"
253
261
"  -T specify the target qps (default: 0=unspecified)\n"
254
262
"  -e enable EDNS 0\n"
255
263
"  -D set the DNSSEC OK bit (implies EDNS)\n"
 
264
"  -R disable recursion\n"
256
265
"  -c print the number of packets with each rcode\n"
257
266
"  -v verbose: report the RCODE of each response on stdout\n"
258
267
"  -h print this usage\n"
462
471
        struct query_status *temp_stat;
463
472
        unsigned int count;
464
473
 
465
 
        if (new_max < 0) {
466
 
                fprintf(stderr, "Unable to change max outstanding queries: "
467
 
                        "must be positive and non-zero: %u\n", new_max);
468
 
                return (-1);
469
 
        }
470
 
 
471
474
        if (new_max > query_status_allocated) {
472
475
                temp_stat = realloc(status, new_max * size_qs);
473
476
 
514
517
        unsigned int uint_arg_val;
515
518
 
516
519
        while ((c = getopt(argc, argv,
517
 
                           "f:q:t:i:nd:s:p:1l:b:eDcvr:T::u:H:h")) != -1) {
 
520
                           "f:q:t:i:nd:s:p:1l:b:eDcvr:RT::u:H:h")) != -1) {
518
521
                switch (c) {
519
522
                case 'f':
520
523
                        if (strcmp(optarg, "inet") == 0)
638
641
                                return (-1);
639
642
                        }
640
643
                        break;
 
644
                case 'R':
 
645
                        recurse = 0;
 
646
                        break;
641
647
                case 'r':
642
648
                        if (is_uint(optarg, &uint_arg_val) == TRUE)
643
649
                                rttarray_size = uint_arg_val;
1367
1373
int
1368
1374
dispatch_query(unsigned short int id, char *dom, int qt) {
1369
1375
        static u_char packet_buffer[PACKETSZ + 1];
1370
 
        static socklen_t sockaddrlen = sizeof(struct sockaddr);
1371
1376
        int buffer_len = PACKETSZ;
1372
1377
        int bytes_sent;
1373
1378
        unsigned short int net_id = htons(id);
1374
1379
        char *id_ptr = (char *)&net_id;
 
1380
        HEADER *hp = (HEADER *)packet_buffer;
1375
1381
 
1376
1382
        buffer_len = res_mkquery(QUERY, dom, C_IN, qt, NULL, 0,
1377
1383
                                 NULL, packet_buffer, PACKETSZ);
1380
1386
                        dom, qt);
1381
1387
                return (-1);
1382
1388
        }
 
1389
        hp->rd = recurse;
1383
1390
        if (edns) {
1384
1391
                unsigned char *p;
1385
1392
                if (buffer_len + EDNSLEN >= PACKETSZ) {
1599
1606
        struct sockaddr_storage from_addr_ss;
1600
1607
        struct sockaddr *from_addr;
1601
1608
        static unsigned char in_buf[MAX_BUFFER_LEN];
1602
 
        int numbytes, addr_len, resp_id;
 
1609
        int numbytes, resp_id;
 
1610
        socklen_t addr_len;
1603
1611
        int flags;
1604
1612
 
1605
1613
        memset(&from_addr_ss, 0, sizeof(from_addr_ss));