* SOFTWARE.
*/
-/* $Id: dig.c,v 1.51.2.7 2000/09/12 23:07:03 explorer Exp $ */
+/* $Id: dig.c,v 1.51.2.8 2000/09/15 22:56:11 gson Exp $ */
#include <config.h>
#include <stdlib.h>
extern isc_boolean_t have_ipv6, show_details, specified_source,
- usesearch, qr;
+ usesearch, qr, ignore;
extern in_port_t port;
extern unsigned int timeout;
extern isc_mem_t *mctx;
" +[no]search (Set whether to use searchlist)\n"
" +[no]defname (Set whether to use default domaon)\n"
" +[no]recursive (Recursive mode)\n"
+" +[no]ignore (Don't revert to TCP for TC responses.)"
+"\n"
" +[no]aaonly (Set AA flag in query)\n"
" +[no]adflag (Set AD flag in query)\n"
" +[no]cdflag (Set CD flag in query)\n"
}
} else if (strncmp(rv[0], "+nosho", 6) == 0) {
short_form = ISC_FALSE;
+ } else if (strncmp(rv[0], "+i", 2) == 0) {
+ ignore = ISC_TRUE;
+ } else if (strncmp(rv[0], "+noi", 4) == 0) {
+ ignore = ISC_FALSE;
} else if (strncmp(rv[0], "+id", 3) == 0) {
if (have_host)
lookup->identify = ISC_TRUE;
* SOFTWARE.
*/
-/* $Id: dighost.c,v 1.58.2.10 2000/08/18 20:00:11 gson Exp $ */
+/* $Id: dighost.c,v 1.58.2.11 2000/09/15 22:56:12 gson Exp $ */
/*
* Notice to programmers: Do not use this code as an example of how to
show_details = ISC_FALSE,
usesearch = ISC_FALSE,
qr = ISC_FALSE,
- is_dst_up = ISC_FALSE;
+ is_dst_up = ISC_FALSE,
+ ignore = ISC_FALSE;
in_port_t port = 53;
unsigned int timeout = 0;
query->waiting_connect = ISC_FALSE;
+ if (sevent->result == ISC_R_CANCELED) {
+ debug("in cancel handler");
+ query->working = ISC_FALSE;
+ query->waiting_connect = ISC_FALSE;
+ isc_event_free(&event);
+ check_next_lookup(query->lookup);
+ return;
+ }
if (sevent->result != ISC_R_SUCCESS) {
debug("buffer allocate connect_timeout");
result = isc_buffer_allocate(mctx, &b, 256);
hex_dump(b);
query->working = ISC_FALSE;
query->waiting_connect = ISC_FALSE;
- if (!query->lookup->tcp_mode) {
- printf(";; Retrying in TCP mode.\n");
- n = requeue_lookup(query->lookup, ISC_TRUE);
- n->tcp_mode = ISC_TRUE;
- }
dns_message_destroy(&msg);
isc_event_free(&event);
- result_bool = cancel_lookup(query->lookup);
+ cancel_lookup(query->lookup);
return;
}
+ if (((msg->flags & DNS_MESSAGEFLAG_TC) != 0)
+ && !query->lookup->tcp_mode && !ignore) {
+ printf(";; Truncated, retrying in TCP mode.\n");
+ n = requeue_lookup(query->lookup, ISC_TRUE);
+ n->tcp_mode = ISC_TRUE;
+ query->working = ISC_FALSE;
+ query->waiting_connect = ISC_FALSE;
+ dns_message_destroy(&msg);
+ isc_event_free(&event);
+ cancel_lookup(query->lookup);
+ return;
+ }
if (key != NULL) {
debug("querysig 2 is %p", query->lookup->querysig);
debug("before verify");
* SOFTWARE.
*/
-/* $Id: host.c,v 1.29.2.5 2000/08/22 17:42:45 bwelling Exp $ */
+/* $Id: host.c,v 1.29.2.6 2000/09/15 22:56:14 gson Exp $ */
#include <config.h>
#include <stdlib.h>
short_form = ISC_TRUE,
filter = ISC_FALSE,
showallsoa = ISC_FALSE,
- tcpmode = ISC_FALSE;
+ tcpmode = ISC_FALSE,
+ listed_server = ISC_FALSE;
static const char *opcodetext[] = {
"QUERY",
ISC_TF(!short_form), query);
if (result != ISC_R_SUCCESS)
return (result);
+ } else {
+ if ((short_form) && (listed_server)) {
+ printf("Using domain server:\n");
+ printf("Name: %s\n", query->servname);
+ result = isc_buffer_allocate(mctx, &b, MXNAME);
+ check_result(result, "isc_buffer_allocate");
+ result = isc_sockaddr_totext(&query->sockaddr, b);
+ check_result(result, "isc_sockaddr_totext");
+ printf("Address: %.*s\n",
+ (int)isc_buffer_usedlength(b),
+ (char*)isc_buffer_base(b));
+ isc_buffer_free(&b);
+ printf("Aliases: \n\n");
+ }
}
if (! ISC_LIST_EMPTY(msg->sections[DNS_SECTION_AUTHORITY]) &&
!short_form) {
argv[isc_commandline_index+1], MXNAME-1);
debug("server is %s", srv->servername);
ISC_LIST_APPEND(server_list, srv, link);
+ listed_server = ISC_TRUE;
}
lookup = isc_mem_allocate(mctx, sizeof(struct dig_lookup));
* SOFTWARE.
*/
-/* $Id: nslookup.c,v 1.20.2.7 2000/09/05 21:58:09 gson Exp $ */
+/* $Id: nslookup.c,v 1.20.2.8 2000/09/15 22:56:15 gson Exp $ */
#include <config.h>
#include <dns/rdata.h>
#include <dns/rdataset.h>
#include <dns/rdatatype.h>
+#include <dns/rdataclass.h>
#include <isc/app.h>
#include <isc/buffer.h>
#include <isc/commandline.h>
debug ("printmessage()");
+ debug ("continuing on with rcode != 0");
+ result = isc_buffer_allocate(mctx, &b, MXNAME);
+ check_result(result, "isc_buffer_allocate");
+ printf("Server:\t\t%s\n", query->servname);
+ result = isc_sockaddr_totext(&query->sockaddr, b);
+ check_result(result, "isc_sockaddr_totext");
+ printf("Address:\t%.*s\n", (int)isc_buffer_usedlength(b),
+ (char*)isc_buffer_base(b));
+ isc_buffer_free(&b);
+ puts("");
if (msg->rcode != 0) {
result = isc_buffer_allocate(mctx, &b, MXNAME);
check_result(result, "isc_buffer_allocate");
debug ("returning with rcode == 0");
return (ISC_R_SUCCESS);
}
- debug ("continuing on with rcode != 0");
- result = isc_buffer_allocate(mctx, &b, MXNAME);
- check_result(result, "isc_buffer_allocate");
- printf("Server:\t\t%s\n", query->servname);
- result = isc_sockaddr_totext(&query->sockaddr, b);
- check_result(result, "isc_sockaddr_totext");
- printf("Address:\t%.*s\n", (int)isc_buffer_usedlength(b),
- (char*)isc_buffer_base(b));
- isc_buffer_free(&b);
- puts("");
if (!short_form){
puts ("------------");
/* detailheader(query, msg);*/
}
+static isc_boolean_t
+testtype(char *typetext) {
+ isc_result_t result;
+ isc_textregion_t tr;
+ dns_rdatatype_t rdtype;
+
+ tr.base = typetext;
+ tr.length = strlen(typetext);
+ result = dns_rdatatype_fromtext(&rdtype, &tr);
+ if (result == ISC_R_SUCCESS)
+ return (ISC_TRUE);
+ else {
+ printf("unknown query type: %s\n", typetext);
+ return (ISC_FALSE);
+ }
+}
+
+static isc_boolean_t
+testclass(char *typetext) {
+ isc_result_t result;
+ isc_textregion_t tr;
+ dns_rdataclass_t rdclass;
+
+ tr.base = typetext;
+ tr.length = strlen(typetext);
+ result = dns_rdataclass_fromtext(&rdclass, &tr);
+ if (result == ISC_R_SUCCESS)
+ return (ISC_TRUE);
+ else {
+ printf("unknown query class: %s\n", typetext);
+ return (ISC_FALSE);
+ }
+}
+
+
static void
setoption(char *opt) {
dig_server_t *srv;
if (strncasecmp(opt,"all",4) == 0) {
show_settings(ISC_TRUE);
} else if (strncasecmp(opt, "class=", 6) == 0) {
- strncpy(defclass, &opt[6], MXRD);
+ if (testclass(&opt[6]))
+ strncpy(defclass, &opt[6], MXRD);
} else if (strncasecmp(opt, "cl=", 3) == 0) {
- strncpy(defclass, &opt[3], MXRD);
+ if (testclass(&opt[3]))
+ strncpy(defclass, &opt[3], MXRD);
} else if (strncasecmp(opt, "type=", 5) == 0) {
- strncpy(deftype, &opt[5], MXRD);
+ if (testtype(&opt[5]))
+ strncpy(deftype, &opt[5], MXRD);
} else if (strncasecmp(opt, "ty=", 3) == 0) {
- strncpy(deftype, &opt[3], MXRD);
+ if (testtype(&opt[3]))
+ strncpy(deftype, &opt[3], MXRD);
} else if (strncasecmp(opt, "querytype=", 10) == 0) {
- strncpy(deftype, &opt[10], MXRD);
+ if (testtype(&opt[10]))
+ strncpy(deftype, &opt[10], MXRD);
} else if (strncasecmp(opt, "query=", 6) == 0) {
- strncpy(deftype, &opt[6], MXRD);
+ if (testtype(&opt[6]))
+ strncpy(deftype, &opt[6], MXRD);
} else if (strncasecmp(opt, "qu=", 3) == 0) {
- strncpy(deftype, &opt[3], MXRD);
+ if (testtype(&opt[3]))
+ strncpy(deftype, &opt[3], MXRD);
#if 0
/* XXXMWS domain= doesn't work now. */
} else if (strncasecmp(opt, "domain=", 7) == 0) {
fatal("Memory allocation failure.");
lookup->pending = ISC_FALSE;
strncpy(lookup->textname, opt, MXNAME-1);
- strncpy (lookup->rttext, deftype, MXNAME);
- strncpy (lookup->rctext, defclass, MXNAME);
+ if (istype(deftype))
+ strncpy(lookup->rttext, deftype, MXNAME);
+ else {
+ strcpy(lookup->rttext, "a");
+ printf ("unknown query type: %s\n",deftype);
+ }
+ if (isclass(defclass))
+ strncpy(lookup->rctext, defclass, MXNAME);
+ else {
+ strcpy(lookup->rctext, "in");
+ printf ("unknown query class: %s\n",defclass);
+ }
lookup->namespace[0]=0;
lookup->sendspace = NULL;
lookup->sendmsg=NULL;