2000-02-01 01:39:23 +00:00
|
|
|
/*
|
2007-06-19 23:47:24 +00:00
|
|
|
* Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
|
2001-01-09 22:01:04 +00:00
|
|
|
* Copyright (C) 2000, 2001 Internet Software Consortium.
|
2000-08-01 01:33:37 +00:00
|
|
|
*
|
2007-06-18 23:47:57 +00:00
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
2000-02-01 01:39:23 +00:00
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
2000-08-01 01:33:37 +00:00
|
|
|
*
|
2004-03-05 05:14:21 +00:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
|
|
|
|
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
|
|
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
|
|
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
|
|
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
|
|
|
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
2000-02-01 01:39:23 +00:00
|
|
|
*/
|
2000-06-09 21:08:19 +00:00
|
|
|
|
2007-06-19 23:47:24 +00:00
|
|
|
/* $Id: gxba_test.c,v 1.13 2007/06/19 23:46:59 tbox Exp $ */
|
2000-06-22 22:00:42 +00:00
|
|
|
|
2005-04-27 04:57:32 +00:00
|
|
|
/*! \file */
|
2000-05-08 14:38:29 +00:00
|
|
|
#include <config.h>
|
2000-02-01 01:39:23 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <isc/net.h>
|
|
|
|
|
|
|
|
#include <lwres/netdb.h>
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_he(struct hostent *he, int error, const char *fun, const char *name) {
|
|
|
|
char **c;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (he != NULL) {
|
|
|
|
printf("%s(%s):\n", fun, name);
|
|
|
|
printf("\tname = %s\n", he->h_name);
|
|
|
|
printf("\taddrtype = %d\n", he->h_addrtype);
|
|
|
|
printf("\tlength = %d\n", he->h_length);
|
|
|
|
c = he->h_aliases;
|
|
|
|
i = 1;
|
|
|
|
while (*c != NULL) {
|
|
|
|
printf("\talias[%d] = %s\n", i, *c);
|
|
|
|
i++;
|
|
|
|
c++;
|
|
|
|
}
|
|
|
|
c = he->h_addr_list;
|
|
|
|
i = 1;
|
|
|
|
while (*c != NULL) {
|
|
|
|
char buf[128];
|
2001-11-27 01:56:32 +00:00
|
|
|
inet_ntop(he->h_addrtype, *c, buf, sizeof(buf));
|
2000-02-01 01:39:23 +00:00
|
|
|
printf("\taddress[%d] = %s\n", i, buf);
|
|
|
|
c++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
printf("%s(%s): error = %d (%s)\n", fun, name, error,
|
|
|
|
hstrerror(error));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char **argv) {
|
|
|
|
struct hostent *he;
|
|
|
|
int error;
|
|
|
|
struct in_addr in_addr;
|
|
|
|
struct in6_addr in6_addr;
|
|
|
|
void *addr;
|
|
|
|
int af;
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
(void)argc;
|
|
|
|
|
|
|
|
while (argv[1] != NULL) {
|
|
|
|
if (inet_pton(AF_INET, argv[1], &in_addr) == 1) {
|
|
|
|
af = AF_INET;
|
|
|
|
addr = &in_addr;
|
|
|
|
len = sizeof(in_addr);
|
|
|
|
} else if (inet_pton(AF_INET6, argv[1], &in6_addr) == 1) {
|
|
|
|
af = AF_INET6;
|
|
|
|
addr = &in6_addr;
|
|
|
|
len = sizeof(in6_addr);
|
|
|
|
} else {
|
|
|
|
printf("unable to convert \"%s\" to an address\n",
|
|
|
|
argv[1]);
|
|
|
|
argv++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
he = gethostbyaddr(addr, len, af);
|
|
|
|
print_he(he, h_errno, "gethostbyaddr", argv[1]);
|
|
|
|
|
|
|
|
he = getipnodebyaddr(addr, len, af, &error);
|
|
|
|
print_he(he, error, "getipnodebyaddr", argv[1]);
|
|
|
|
if (he != NULL)
|
|
|
|
freehostent(he);
|
|
|
|
argv++;
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|