mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-02 07:35:26 +00:00
add "dig +qid" option to set QID to desired value
This commit is contained in:
@@ -1489,6 +1489,24 @@ plus_option(char *option, bool is_batchfile, dig_lookup_t *lookup) {
|
|||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
switch (cmd[1]) {
|
switch (cmd[1]) {
|
||||||
|
case 'i': /* qid */
|
||||||
|
FULLCHECK("qid");
|
||||||
|
if (!state) {
|
||||||
|
lookup->setqid = false;
|
||||||
|
lookup->qid = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (value == NULL) {
|
||||||
|
goto need_value;
|
||||||
|
}
|
||||||
|
result = parse_uint(&num, value, MAXQID, "qid");
|
||||||
|
if (result != ISC_R_SUCCESS) {
|
||||||
|
warn("Couldn't parse qid");
|
||||||
|
goto exit_or_usage;
|
||||||
|
}
|
||||||
|
lookup->setqid = true;
|
||||||
|
lookup->qid = num;
|
||||||
|
break;
|
||||||
case 'r': /* qr */
|
case 'r': /* qr */
|
||||||
FULLCHECK("qr");
|
FULLCHECK("qr");
|
||||||
lookup->qr = state;
|
lookup->qr = state;
|
||||||
|
@@ -426,6 +426,10 @@ abbreviation is unambiguous; for example, ``+cd`` is equivalent to
|
|||||||
mandatory. Responses to padded queries may also be padded, but only
|
mandatory. Responses to padded queries may also be padded, but only
|
||||||
if the query uses TCP or DNS COOKIE.
|
if the query uses TCP or DNS COOKIE.
|
||||||
|
|
||||||
|
``+qid=value``
|
||||||
|
|
||||||
|
Specify the query ID to use when sending queries.
|
||||||
|
|
||||||
``+[no]qr``
|
``+[no]qr``
|
||||||
Toggles the display of the query message as it is sent. By default, the query
|
Toggles the display of the query message as it is sent. By default, the query
|
||||||
is not printed.
|
is not printed.
|
||||||
|
@@ -677,6 +677,8 @@ make_empty_lookup(void) {
|
|||||||
looknew->tcflag = false;
|
looknew->tcflag = false;
|
||||||
looknew->print_unknown_format = false;
|
looknew->print_unknown_format = false;
|
||||||
looknew->zflag = false;
|
looknew->zflag = false;
|
||||||
|
looknew->setqid = false;
|
||||||
|
looknew->qid = 0;
|
||||||
looknew->ns_search_only = false;
|
looknew->ns_search_only = false;
|
||||||
looknew->origin = NULL;
|
looknew->origin = NULL;
|
||||||
looknew->tsigctx = NULL;
|
looknew->tsigctx = NULL;
|
||||||
@@ -820,6 +822,8 @@ clone_lookup(dig_lookup_t *lookold, bool servers) {
|
|||||||
looknew->tcflag = lookold->tcflag;
|
looknew->tcflag = lookold->tcflag;
|
||||||
looknew->print_unknown_format = lookold->print_unknown_format;
|
looknew->print_unknown_format = lookold->print_unknown_format;
|
||||||
looknew->zflag = lookold->zflag;
|
looknew->zflag = lookold->zflag;
|
||||||
|
looknew->setqid = lookold->setqid;
|
||||||
|
looknew->qid = lookold->qid;
|
||||||
looknew->ns_search_only = lookold->ns_search_only;
|
looknew->ns_search_only = lookold->ns_search_only;
|
||||||
looknew->tcp_mode = lookold->tcp_mode;
|
looknew->tcp_mode = lookold->tcp_mode;
|
||||||
looknew->tcp_mode_set = lookold->tcp_mode_set;
|
looknew->tcp_mode_set = lookold->tcp_mode_set;
|
||||||
@@ -2298,6 +2302,11 @@ setup_lookup(dig_lookup_t *lookup) {
|
|||||||
lookup->sendmsg->flags |= 0x0040U;
|
lookup->sendmsg->flags |= 0x0040U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lookup->setqid) {
|
||||||
|
debug("set QID");
|
||||||
|
lookup->sendmsg->id = lookup->qid;
|
||||||
|
}
|
||||||
|
|
||||||
dns_message_addname(lookup->sendmsg, lookup->name,
|
dns_message_addname(lookup->sendmsg, lookup->name,
|
||||||
DNS_SECTION_QUESTION);
|
DNS_SECTION_QUESTION);
|
||||||
|
|
||||||
|
@@ -60,6 +60,8 @@
|
|||||||
#define MAXPORT 0xffff
|
#define MAXPORT 0xffff
|
||||||
/*% Max serial number */
|
/*% Max serial number */
|
||||||
#define MAXSERIAL 0xffffffff
|
#define MAXSERIAL 0xffffffff
|
||||||
|
/*% Max query ID */
|
||||||
|
#define MAXQID 0xffff
|
||||||
|
|
||||||
/*% Default TCP Timeout */
|
/*% Default TCP Timeout */
|
||||||
#define TCP_TIMEOUT 10
|
#define TCP_TIMEOUT 10
|
||||||
@@ -108,9 +110,10 @@ struct dig_lookup {
|
|||||||
tcp_keepalive, header_only, ednsneg, mapped,
|
tcp_keepalive, header_only, ednsneg, mapped,
|
||||||
print_unknown_format, multiline, nottl, noclass, onesoa,
|
print_unknown_format, multiline, nottl, noclass, onesoa,
|
||||||
use_usec, nocrypto, ttlunits, idnin, idnout, expandaaaa, qr,
|
use_usec, nocrypto, ttlunits, idnin, idnout, expandaaaa, qr,
|
||||||
accept_reply_unexpected_src; /*% print replies from
|
accept_reply_unexpected_src, /*% print replies from
|
||||||
* unexpected
|
* unexpected
|
||||||
* sources. */
|
* sources. */
|
||||||
|
setqid; /*% use a speciied query ID */
|
||||||
char textname[MXNAME]; /*% Name we're going to be
|
char textname[MXNAME]; /*% Name we're going to be
|
||||||
* looking up */
|
* looking up */
|
||||||
char cmdline[MXNAME];
|
char cmdline[MXNAME];
|
||||||
@@ -157,6 +160,7 @@ struct dig_lookup {
|
|||||||
dns_opcode_t opcode;
|
dns_opcode_t opcode;
|
||||||
int rrcomments;
|
int rrcomments;
|
||||||
unsigned int eoferr;
|
unsigned int eoferr;
|
||||||
|
uint16_t qid;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*% The dig_query structure */
|
/*% The dig_query structure */
|
||||||
|
@@ -788,6 +788,8 @@ addlookup(char *opt) {
|
|||||||
lookup->aaonly = aaonly;
|
lookup->aaonly = aaonly;
|
||||||
lookup->retries = tries;
|
lookup->retries = tries;
|
||||||
lookup->udpsize = 0;
|
lookup->udpsize = 0;
|
||||||
|
lookup->setqid = false;
|
||||||
|
lookup->qid = 0;
|
||||||
lookup->comments = comments;
|
lookup->comments = comments;
|
||||||
if (lookup->rdtype == dns_rdatatype_any && !tcpmode_set) {
|
if (lookup->rdtype == dns_rdatatype_any && !tcpmode_set) {
|
||||||
lookup->tcp_mode = true;
|
lookup->tcp_mode = true;
|
||||||
|
Reference in New Issue
Block a user