/* ________________________________________________________________________ */ int main(int argc, char **argv) { struct hostent *host = NULL; #if 0 res_init(); server_print(); #endif host = gethostbyaddr_wrapper(argv[1]); if (host) { printf("Server :::::::::>> %s\n", host->h_name); /* addr_list_fprint(host->h_addr_list); */ } else printf("Server :::::::::>> Host not found\n"); return EXIT_SUCCESS; #if 0 if (is_ip_address(argv[1])) { host = gethostbyaddr_wrapper(argv[1]); } else { host = gethostbyname(argv[1]); } hostent_fprint(host, 0); return EXIT_SUCCESS; #endif }
/* ________________________________________________________________________ */ int nslookup_main(int argc, char **argv) { struct hostent *host; /* * initialize DNS structure _res used in printing the default * name server and in the explicit name server option feature. */ res_init(); /* * We allow 1 or 2 arguments. * The first is the name to be looked up and the second is an * optional DNS server with which to do the lookup. * More than 3 arguments is an error to follow the pattern of the * standard nslookup */ if (argc < 2 || *argv[1]=='-' || argc > 3) bb_show_usage(); else if(argc == 3) set_default_dns(argv[2]); server_print(); if (is_ip_address(argv[1])) { host = gethostbyaddr_wrapper(argv[1]); } else { host = xgethostbyname(argv[1]); } hostent_fprint(host, "Name: "); return EXIT_SUCCESS; }
/* lookup the default nameserver and display it */ static inline void server_print(void) { struct sockaddr_in def = _res.nsaddr_list[0]; char *ip = inet_ntoa(def.sin_addr); hostent_fprint(gethostbyaddr_wrapper(ip), 1); printf("\n"); }
/* ________________________________________________________________________ */ int nslookup_main(int argc, char **argv) { struct hostent *host; if (argc < 2 || *argv[1]=='-') { show_usage(); } res_init(); server_print(); if (is_ip_address(argv[1])) { host = gethostbyaddr_wrapper(argv[1]); } else { host = gethostbyname(argv[1]); } hostent_fprint(host, 0); return EXIT_SUCCESS; }