nslookup.c revision da5d1cf1b1aa29ae53a0427be49291b04bd60549
c1aef54e14bb92518b1c062ba8c0292a7cb949cbAutomatic Updater * Copyright (C) 2000, 2001 Internet Software Consortium.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * Permission to use, copy, modify, and distribute this software for any
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater * purpose with or without fee is hereby granted, provided that the above
99e207809793732e3e47da3a1cab6925b6eee8e9William King * copyright notice and this permission notice appear in all copies.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
8bd2b6923c282eee7d957bda830e74a0e5285f8fMark Andrews/* $Id: nslookup.c,v 1.95 2001/12/19 12:16:42 marka Exp $ */
99e207809793732e3e47da3a1cab6925b6eee8e9William Kingextern unsigned int timeout;
1b6d529cb5ee0ad44f8518e1b8c2cbca54bbdf18David Lawrence tcpmode = ISC_FALSE, deprecation_msg = ISC_TRUE,
99e207809793732e3e47da3a1cab6925b6eee8e9William King comments = ISC_TRUE, section_question = ISC_TRUE,
99e207809793732e3e47da3a1cab6925b6eee8e9William King section_answer = ISC_TRUE, section_authority = ISC_TRUE,
76c8294c81fb48b1da6e1fc5b83322a4cedb8e58Andreas Gustafsson section_additional = ISC_TRUE, recurse = ISC_TRUE,
76c8294c81fb48b1da6e1fc5b83322a4cedb8e58Andreas Gustafssonstatic const char *rcodetext[] = {
99e207809793732e3e47da3a1cab6925b6eee8e9William King "RESERVED11",
99e207809793732e3e47da3a1cab6925b6eee8e9William King "RESERVED12",
99e207809793732e3e47da3a1cab6925b6eee8e9William King "RESERVED13",
99e207809793732e3e47da3a1cab6925b6eee8e9William King "RESERVED14",
99e207809793732e3e47da3a1cab6925b6eee8e9William King "RESERVED15",
1b6d529cb5ee0ad44f8518e1b8c2cbca54bbdf18David Lawrencestatic const char *rtypetext[] = {
99e207809793732e3e47da3a1cab6925b6eee8e9William King#define N_KNOWN_RRTYPES (sizeof(rtypetext) / sizeof(rtypetext[0]))
99e207809793732e3e47da3a1cab6925b6eee8e9William Kingstatic void flush_lookup_list(void);
99e207809793732e3e47da3a1cab6925b6eee8e9William Kingstatic void getinput(isc_task_t *task, isc_event_t *event);
99e207809793732e3e47da3a1cab6925b6eee8e9William King result = dns_rdata_tostruct(rdata, &soa, NULL);
99e207809793732e3e47da3a1cab6925b6eee8e9William King dns_name_format(&soa.origin, namebuf, sizeof(namebuf));
99e207809793732e3e47da3a1cab6925b6eee8e9William King dns_name_format(&soa.contact, namebuf, sizeof(namebuf));
99e207809793732e3e47da3a1cab6925b6eee8e9William King printf("Address: %.*s\n", (int)isc_buffer_usedlength(&b),
99e207809793732e3e47da3a1cab6925b6eee8e9William King printf("%.*s\n", (int)isc_buffer_usedlength(b),
99e207809793732e3e47da3a1cab6925b6eee8e9William Kingprintsection(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers,
91cd0f93ad34d23e8b09dca337120f64fbe8f0a1Andreas Gustafsson result = dns_message_firstname(msg, section);
91cd0f93ad34d23e8b09dca337120f64fbe8f0a1Andreas Gustafsson for (rdataset = ISC_LIST_HEAD(name->list);
99e207809793732e3e47da3a1cab6925b6eee8e9William Kingdetailsection(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers,
99e207809793732e3e47da3a1cab6925b6eee8e9William Kingreceived(int bytes, isc_sockaddr_t *from, dig_query_t *query)
e1bb80ea30482d37abf16cd9621045f873c57e74William Kingprintmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
99e207809793732e3e47da3a1cab6925b6eee8e9William King isc_sockaddr_format(&query->sockaddr, servtext, sizeof(servtext));
99e207809793732e3e47da3a1cab6925b6eee8e9William King /* detailheader(query, msg);*/
99e207809793732e3e47da3a1cab6925b6eee8e9William King detailsection(query, msg, headers, DNS_SECTION_QUESTION);
99e207809793732e3e47da3a1cab6925b6eee8e9William King detailsection(query, msg, headers, DNS_SECTION_ANSWER);
56e85a97bb913177a1459d8447281a9893e90037Mark Andrews detailsection(query, msg, headers, DNS_SECTION_AUTHORITY);
99e207809793732e3e47da3a1cab6925b6eee8e9William King detailsection(query, msg, headers, DNS_SECTION_ADDITIONAL);
99e207809793732e3e47da3a1cab6925b6eee8e9William King printf("** server can't find %s: %s\n", nametext,
99e207809793732e3e47da3a1cab6925b6eee8e9William King if (!ISC_LIST_EMPTY(msg->sections[DNS_SECTION_ANSWER]))
99e207809793732e3e47da3a1cab6925b6eee8e9William King printsection(query, msg, headers, DNS_SECTION_ANSWER);
99e207809793732e3e47da3a1cab6925b6eee8e9William King if (((msg->flags & DNS_MESSAGEFLAG_AA) == 0) &&
99e207809793732e3e47da3a1cab6925b6eee8e9William King puts("\nAuthoritative answers can be found from:");
99e207809793732e3e47da3a1cab6925b6eee8e9William Kingshow_settings(isc_boolean_t full, isc_boolean_t serv_only) {
99e207809793732e3e47da3a1cab6925b6eee8e9William King isc_sockaddr_format(&sockaddr, sockstr, sizeof(sockstr));
99e207809793732e3e47da3a1cab6925b6eee8e9William King printf(" timeout = %d\t\tretry = %d\tport = %d\n",
99e207809793732e3e47da3a1cab6925b6eee8e9William King printf(" querytype = %-8s\tclass = %s\n", deftype, defclass);
99e207809793732e3e47da3a1cab6925b6eee8e9William King result = dns_rdataclass_fromtext(&rdclass, &tr);
99e207809793732e3e47da3a1cab6925b6eee8e9William Kingparse_uint(isc_uint32_t *uip, const char *value, isc_uint32_t max, const char *desc) {
99e207809793732e3e47da3a1cab6925b6eee8e9William King isc_result_t result = isc_parse_uint32(&n, value, 10);
99e207809793732e3e47da3a1cab6925b6eee8e9William King isc_result_t result = parse_uint(&n, value, 65535, "port");
99e207809793732e3e47da3a1cab6925b6eee8e9William King isc_result_t result = parse_uint(&n, value, UINT_MAX, "timeout");
99e207809793732e3e47da3a1cab6925b6eee8e9William King isc_result_t result = parse_uint(&n, value, INT_MAX, "tries");
99e207809793732e3e47da3a1cab6925b6eee8e9William King } else if (strncasecmp(opt, "class=", 6) == 0) {
99e207809793732e3e47da3a1cab6925b6eee8e9William King } else if (strncasecmp(opt, "type=", 5) == 0) {
9f44e95160bae777bcebe9cf216107de628bb1c0David Lawrence } else if (strncasecmp(opt, "querytype=", 10) == 0) {
95799c090cc4aae52c57feaba43fbf2d62586a76David Lawrence } else if (strncasecmp(opt, "query=", 6) == 0) {
95799c090cc4aae52c57feaba43fbf2d62586a76David Lawrence } else if (strncasecmp(opt, "qu=", 3) == 0) {
99e207809793732e3e47da3a1cab6925b6eee8e9William King } else if (strncasecmp(opt, "domain=", 7) == 0) {
99e207809793732e3e47da3a1cab6925b6eee8e9William King safecpy(domainopt, &opt[7], sizeof(domainopt));
99e207809793732e3e47da3a1cab6925b6eee8e9William King safecpy(domainopt, &opt[3], sizeof(domainopt));
99e207809793732e3e47da3a1cab6925b6eee8e9William King } else if (strncasecmp(opt, "port=", 5) == 0) {
99e207809793732e3e47da3a1cab6925b6eee8e9William King } else if (strncasecmp(opt, "timeout=", 8) == 0) {
99e207809793732e3e47da3a1cab6925b6eee8e9William King } else if (strncasecmp(opt, "norec", 5) == 0) {
99e207809793732e3e47da3a1cab6925b6eee8e9William King } else if (strncasecmp(opt, "retry=", 6) == 0) {
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence } else if (strncasecmp(opt, "ret=", 4) == 0) {
99e207809793732e3e47da3a1cab6925b6eee8e9William King } else if (strncasecmp(opt, "nodef", 5) == 0) {
99e207809793732e3e47da3a1cab6925b6eee8e9William King } else if (strncasecmp(opt, "nodeb", 5) == 0) {
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence } else if (strncasecmp(opt, "search", 3) == 0) {
99e207809793732e3e47da3a1cab6925b6eee8e9William King } else if (strncasecmp(opt, "nosearch", 5) == 0) {
99e207809793732e3e47da3a1cab6925b6eee8e9William King result = dns_rdataclass_fromtext(&rdclass, &tr);
99e207809793732e3e47da3a1cab6925b6eee8e9William King if (get_reverse(store, opt, lookup->nibble, ISC_TRUE)
99e207809793732e3e47da3a1cab6925b6eee8e9William King safecpy(lookup->textname, store, sizeof(lookup->textname));
99e207809793732e3e47da3a1cab6925b6eee8e9William King safecpy(lookup->textname, opt, sizeof(lookup->textname));
99e207809793732e3e47da3a1cab6925b6eee8e9William King lookup->section_additional = section_additional;
99e207809793732e3e47da3a1cab6925b6eee8e9William King while (s != NULL) {
99e207809793732e3e47da3a1cab6925b6eee8e9William King * This works on the global server list, instead of on a per-lookup
99e207809793732e3e47da3a1cab6925b6eee8e9William King * server list, since the change is persistent.
99e207809793732e3e47da3a1cab6925b6eee8e9William King srv = isc_mem_allocate(mctx, sizeof(struct dig_server));
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence safecpy(srv->servername, opt, sizeof(srv->servername));
99e207809793732e3e47da3a1cab6925b6eee8e9William King ISC_LIST_INITANDAPPEND(server_list, srv, link);
cbf59e5887d69fca6fe86a1ee5fcc82dded14babMark Andrews printf("The '%s' command is not yet implemented.\n", ptr);
271d5bfc5ca8d746b535d1522f2aa9389ece2a7eBob Halley printf("The '%s' command is not implemented.\n", ptr);
99e207809793732e3e47da3a1cab6925b6eee8e9William King for (argc--, argv++; argc > 0; argc--, argv++) {
99e207809793732e3e47da3a1cab6925b6eee8e9William King while (l != NULL) {
99e207809793732e3e47da3a1cab6925b6eee8e9William King while (q != NULL) {
99e207809793732e3e47da3a1cab6925b6eee8e9William King while (s != NULL) {
99e207809793732e3e47da3a1cab6925b6eee8e9William Kinggetinput(isc_task_t *task, isc_event_t *event) {
99e207809793732e3e47da3a1cab6925b6eee8e9William King"Note: nslookup is deprecated and may be removed from future releases.\n"
99e207809793732e3e47da3a1cab6925b6eee8e9William King"Consider using the `dig' or `host' programs instead. Run nslookup with\n"
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence"the `-sil[ent]' option to prevent this message from appearing.\n", stderr);
99e207809793732e3e47da3a1cab6925b6eee8e9William King result = isc_app_onrun(mctx, global_task, onrun_callback,