示例#1
0
int nslookup_main(int argc, char **argv)
{
	/* 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 (!argv[1] || argv[1][0] == '-' || argc > 3)
		bb_show_usage();

	/* initialize DNS structure _res used in printing the default
	 * name server and in the explicit name server option feature. */
	res_init();
	/* rfc2133 says this enables IPv6 lookups */
	/* (but it also says "may be enabled in /etc/resolv.conf") */
	/*_res.options |= RES_USE_INET6;*/

		set_default_dns(argv[2]);

	server_print();

	/* getaddrinfo and friends are free to request a resolver
	 * reinitialization. Just in case, set_default_dns() again
	 * after getaddrinfo (in server_print). This reportedly helps
	 * with bug 675 "nslookup does not properly use second argument"
	 * at least on Debian Wheezy and Openwrt AA (eglibc based).
	 */
	set_default_dns(argv[2]);

	return print_host(argv[1], "Name:");
}
示例#2
0
/* ________________________________________________________________________ */
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;
}
示例#3
0
int nslookup_main(int argc, char **argv)
{
    /* 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 (!argv[1] || argv[1][0] == '-' || argc > 3)
        bb_show_usage();

#ifndef __UC_LIBC__
    /* initialize DNS structure _res used in printing the default
     * name server and in the explicit name server option feature. */
    res_init();
#endif

    /* rfc2133 says this enables IPv6 lookups */
    /* (but it also says "may be enabled in /etc/resolv.conf") */
    /*_res.options |= RES_USE_INET6;*/

    if (argv[2])
        set_default_dns(argv[2]);

    server_print();
    return print_host(argv[1], "Name:");
}