mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-04 12:52:15 +00:00
Make it more convenient to query NICs other than InterNIC. Explain in the
man page what each database contains.
This commit is contained in:
parent
f5c7505126
commit
a00fe97d5a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=33626
@ -29,28 +29,54 @@
|
|||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.\" @(#)whois.1 8.1 (Berkeley) 6/6/93
|
.\" From: @(#)whois.1 8.1 (Berkeley) 6/6/93
|
||||||
|
.\" $Id$
|
||||||
.\"
|
.\"
|
||||||
.Dd June 6, 1993
|
.Dd February 19, 1998
|
||||||
.Dt WHOIS 1
|
.Dt WHOIS 1
|
||||||
.Os BSD 4.3
|
.Os BSD 4.3
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm whois
|
.Nm whois
|
||||||
.Nd Internet user name directory service
|
.Nd Internet domain name and network number directory service
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm whois
|
.Nm whois
|
||||||
.Op Fl h Ar hostname
|
.Op Fl adpr
|
||||||
|
.Op Fl h Ar host
|
||||||
.Ar name ...
|
.Ar name ...
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
.Nm Whois
|
.Nm Whois
|
||||||
looks up records in the Network Information Center
|
looks up records in the databases maintained by several
|
||||||
.Pq Tn NIC
|
Network Information Centers
|
||||||
database.
|
.Pq Tn NICs .
|
||||||
.Pp
|
.Pp
|
||||||
The options are as follows:
|
The options are as follows:
|
||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
.It Fl h
|
.It Fl a
|
||||||
Use the specified host instead of the default NIC (whois.internic.net).
|
Use the American Registry for Internet Numbers
|
||||||
|
.Pq Tn ARIN
|
||||||
|
database. It contains network numbers used in those parts of the world
|
||||||
|
covered neither by
|
||||||
|
.Tn APNIC nor by
|
||||||
|
.Tn RIPE .
|
||||||
|
.It Fl d
|
||||||
|
Use the (US Military) Defense Data Network
|
||||||
|
.Pq Tn DDN
|
||||||
|
database. It contains points of contact for subdomains of
|
||||||
|
.Tn \&.MIL .
|
||||||
|
.It Fl h Ar host
|
||||||
|
Use the specified host instead of the default NIC
|
||||||
|
(whois.internic.net).
|
||||||
|
Either a host name or an IP address may be specified.
|
||||||
|
.It Fl p
|
||||||
|
Use the Asia/Pacific Network Information Center
|
||||||
|
.Pq Tn APNIC
|
||||||
|
database. It contains network numbers used in East Asia, Australia,
|
||||||
|
New Zealand, and the Pacific islands.
|
||||||
|
.It Fl r
|
||||||
|
Use the R\(aaeseaux IP Europ\(aaeens
|
||||||
|
.Pq Tn RIPE
|
||||||
|
database. It contains network numbers and domain contact information
|
||||||
|
for Europe.
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
The operands specified to
|
The operands specified to
|
||||||
|
@ -42,7 +42,7 @@ static const char copyright[] =
|
|||||||
static char sccsid[] = "@(#)whois.c 8.1 (Berkeley) 6/6/93";
|
static char sccsid[] = "@(#)whois.c 8.1 (Berkeley) 6/6/93";
|
||||||
#endif
|
#endif
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"$Id$";
|
"$Id: whois.c,v 1.4 1997/08/26 11:16:08 charnier Exp $";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -52,9 +52,15 @@ static const char rcsid[] =
|
|||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sysexits.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#define NICHOST "whois.internic.net"
|
#define NICHOST "whois.internic.net"
|
||||||
|
#define DNICHOST "nic.ddn.mil"
|
||||||
|
#define ANICHOST "whois.arin.net"
|
||||||
|
#define RNICHOST "whois.ripe.net"
|
||||||
|
#define PNICHOST "whois.apnic.net"
|
||||||
|
#define WHOIS_PORT 43
|
||||||
|
|
||||||
static void usage __P((void));
|
static void usage __P((void));
|
||||||
|
|
||||||
@ -76,11 +82,23 @@ main(argc, argv)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
host = NICHOST;
|
host = NICHOST;
|
||||||
while ((ch = getopt(argc, argv, "h:")) != -1)
|
while ((ch = getopt(argc, argv, "adh:pr")) != -1)
|
||||||
switch((char)ch) {
|
switch((char)ch) {
|
||||||
|
case 'a':
|
||||||
|
host = ANICHOST;
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
host = DNICHOST;
|
||||||
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
host = optarg;
|
host = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'p':
|
||||||
|
host = PNICHOST;
|
||||||
|
break;
|
||||||
|
case 'r':
|
||||||
|
host = RNICHOST;
|
||||||
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
@ -91,32 +109,35 @@ main(argc, argv)
|
|||||||
if (!argc)
|
if (!argc)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
hp = gethostbyname(host);
|
s = socket(PF_INET, SOCK_STREAM, 0);
|
||||||
if (hp == NULL) {
|
|
||||||
(void)fprintf(stderr, "whois: %s: ", host);
|
|
||||||
herror((char *)NULL);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
host = hp->h_name;
|
|
||||||
s = socket(hp->h_addrtype, SOCK_STREAM, 0);
|
|
||||||
if (s < 0)
|
if (s < 0)
|
||||||
err(1, "socket");
|
err(EX_OSERR, "socket");
|
||||||
bzero((caddr_t)&sin, sizeof (sin));
|
|
||||||
sin.sin_family = hp->h_addrtype;
|
memset(&sin, 0, sizeof sin);
|
||||||
bcopy(hp->h_addr, (char *)&sin.sin_addr, hp->h_length);
|
sin.sin_len = sizeof sin;
|
||||||
|
sin.sin_family = AF_INET;
|
||||||
|
|
||||||
|
if (inet_aton(host, &sin.sin_addr) == 0) {
|
||||||
|
hp = gethostbyname2(host, AF_INET);
|
||||||
|
if (hp == NULL)
|
||||||
|
errx(EX_NOHOST, "%s: %s", host, hstrerror(h_errno));
|
||||||
|
host = hp->h_name;
|
||||||
|
sin.sin_addr = *(struct in_addr *)hp->h_addr_list[0];
|
||||||
|
}
|
||||||
|
|
||||||
sp = getservbyname("whois", "tcp");
|
sp = getservbyname("whois", "tcp");
|
||||||
if (sp == NULL)
|
if (sp == NULL)
|
||||||
errx(1, "whois/tcp: unknown service");
|
sin.sin_port = htons(WHOIS_PORT);
|
||||||
sin.sin_port = sp->s_port;
|
else
|
||||||
|
sin.sin_port = sp->s_port;
|
||||||
|
|
||||||
if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0)
|
if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0)
|
||||||
err(1, "connect");
|
err(EX_OSERR, "connect");
|
||||||
|
|
||||||
sfi = fdopen(s, "r");
|
sfi = fdopen(s, "r");
|
||||||
sfo = fdopen(s, "w");
|
sfo = fdopen(s, "w");
|
||||||
if (sfi == NULL || sfo == NULL) {
|
if (sfi == NULL || sfo == NULL)
|
||||||
warn("fdopen");
|
err(EX_OSERR, "fdopen");
|
||||||
(void)close(s);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
while (argc-- > 1)
|
while (argc-- > 1)
|
||||||
(void)fprintf(sfo, "%s ", *argv++);
|
(void)fprintf(sfo, "%s ", *argv++);
|
||||||
(void)fprintf(sfo, "%s\r\n", *argv);
|
(void)fprintf(sfo, "%s\r\n", *argv);
|
||||||
@ -129,6 +150,6 @@ main(argc, argv)
|
|||||||
static void
|
static void
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
(void)fprintf(stderr, "usage: whois [-h hostname] name ...\n");
|
(void)fprintf(stderr, "usage: whois [-adpr] [-h hostname] name ...\n");
|
||||||
exit(1);
|
exit(EX_USAGE);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user