View | Details | Raw Unified | Return to bug 28790
Collapse All | Expand All

(-)whois/whois.1 (-3 / +10 lines)
Lines 40-47 Link Here
40
.Nd Internet domain name and network number directory service
40
.Nd Internet domain name and network number directory service
41
.Sh SYNOPSIS
41
.Sh SYNOPSIS
42
.Nm
42
.Nm
43
.Op Fl adgimpQrR6
43
.Op Fl adgimpQrRu6
44
.Op Fl h Ar host
44
.Op Fl h Ar host
45
.Op Fl P Ar port
45
.Ar name ...
46
.Ar name ...
46
.Sh DESCRIPTION
47
.Sh DESCRIPTION
47
.Nm Whois
48
.Nm Whois
Lines 114-124 Link Here
114
database.
115
database.
115
It contains route policy specifications for a large
116
It contains route policy specifications for a large
116
number of operators' networks.
117
number of operators' networks.
118
.It Fl P Ar port
119
Specify a port to query.  The default is 43
117
.It Fl p
120
.It Fl p
118
Use the Asia/Pacific Network Information Center
121
Use the Asia/Pacific Network Information Center
119
.Pq Tn APNIC
122
.Pq Tn APNIC
120
database.  It contains network numbers used in East Asia, Australia,
123
database.  It contains network numbers used in East Asia, New Zealand,
121
New Zealand, and the Pacific islands.
124
and the Pacific islands.
122
.It Fl Q
125
.It Fl Q
123
Do a quick lookup.  This means that
126
Do a quick lookup.  This means that
124
.Nm
127
.Nm
Lines 136-141 Link Here
136
database.  It contains network numbers and domain contact information
139
database.  It contains network numbers and domain contact information
137
for subdomains of
140
for subdomains of
138
.Tn \&.RU .
141
.Tn \&.RU .
142
.It Fl u
143
Use the Australia Network Information Center
144
.Pq Tn AUNIC
145
database.  It contains network numbers used in Australia
139
.It Fl 6
146
.It Fl 6
140
Use the IPv6 Resource Center
147
Use the IPv6 Resource Center
141
.Pq Tn 6bone
148
.Pq Tn 6bone
(-)whois/whois.c (-9 / +44 lines)
Lines 56-67 Link Here
56
#include <string.h>
56
#include <string.h>
57
#include <sysexits.h>
57
#include <sysexits.h>
58
#include <unistd.h>
58
#include <unistd.h>
59
#include <ctype.h>
59
60
60
#define	NICHOST		"whois.crsnic.net"
61
#define	NICHOST		"whois.crsnic.net"
61
#define	INICHOST	"whois.networksolutions.com"
62
#define	INICHOST	"whois.networksolutions.com"
62
#define	DNICHOST	"whois.nic.mil"
63
#define	DNICHOST	"whois.nic.mil"
63
#define	GNICHOST	"whois.nic.gov"
64
#define	GNICHOST	"whois.nic.gov"
64
#define	ANICHOST	"whois.arin.net"
65
#define	ANICHOST	"whois.arin.net"
66
#define	AUNICHOST	"whois.aunic.net"
65
#define	RNICHOST	"whois.ripe.net"
67
#define	RNICHOST	"whois.ripe.net"
66
#define	PNICHOST	"whois.apnic.net"
68
#define	PNICHOST	"whois.apnic.net"
67
#define	RUNICHOST	"whois.ripn.net"
69
#define	RUNICHOST	"whois.ripn.net"
Lines 75-81 Link Here
75
#define WHOIS_QUICK		0x04
77
#define WHOIS_QUICK		0x04
76
78
77
static void usage __P((void));
79
static void usage __P((void));
78
static void whois __P((char *, struct addrinfo *, int));
80
static void whois __P((char *, struct addrinfo *, char *, int));
79
81
80
int
82
int
81
main(argc, argv)
83
main(argc, argv)
Lines 84-92 Link Here
84
{
86
{
85
	int ch, i, j, error;
87
	int ch, i, j, error;
86
	int use_qnichost, flags;
88
	int use_qnichost, flags;
89
	char *port;
87
	char *host;
90
	char *host;
88
	char *qnichost;
91
	char *qnichost;
89
	struct addrinfo hints, *res;
92
	struct addrinfo hints, *res;
93
	struct servent *se;
90
94
91
#ifdef	SOCKS
95
#ifdef	SOCKS
92
	SOCKSinit(argv[0]);
96
	SOCKSinit(argv[0]);
Lines 96-102 Link Here
96
	qnichost = NULL;
100
	qnichost = NULL;
97
	flags = 0;
101
	flags = 0;
98
	use_qnichost = 0;
102
	use_qnichost = 0;
99
	while ((ch = getopt(argc, argv, "adgh:impQrR6")) != -1) {
103
	port = NULL;
104
	while ((ch = getopt(argc, argv, "adgh:impP:QrRu6")) != -1) {
100
		switch((char)ch) {
105
		switch((char)ch) {
101
		case 'a':
106
		case 'a':
102
			host = ANICHOST;
107
			host = ANICHOST;
Lines 116-121 Link Here
116
		case 'm':
121
		case 'm':
117
			host = MNICHOST;
122
			host = MNICHOST;
118
			break;
123
			break;
124
		case 'P':
125
			port = optarg;
126
			break;
119
		case 'p':
127
		case 'p':
120
			host = PNICHOST;
128
			host = PNICHOST;
121
			break;
129
			break;
Lines 128-133 Link Here
128
		case 'R':
136
		case 'R':
129
			host = RUNICHOST;
137
			host = RUNICHOST;
130
			break;
138
			break;
139
		case 'u':
140
			host = AUNICHOST;
141
			break;
131
		case '6':
142
		case '6':
132
			host = SNICHOST;
143
			host = SNICHOST;
133
			break;
144
			break;
Lines 154-159 Link Here
154
			flags |= WHOIS_INIC_FALLBACK | WHOIS_RECURSE;
165
			flags |= WHOIS_INIC_FALLBACK | WHOIS_RECURSE;
155
		}
166
		}
156
	}
167
	}
168
	if (port != NULL) {
169
		for (i = 0; i < strlen(port); i++) {
170
			if (!isdigit(port[i])) {
171
				port = NULL;
172
				(void)setservent(0);
173
				se = getservbyname("whois", "tcp");
174
				(void)fprintf(stderr,
175
					"Invalid port, defaulting\n");
176
				break;
177
			}
178
		}
179
	}
157
	while (argc--) {
180
	while (argc--) {
158
		if (use_qnichost) {
181
		if (use_qnichost) {
159
			if (qnichost) {
182
			if (qnichost) {
Lines 178-184 Link Here
178
				hints.ai_flags = 0;
201
				hints.ai_flags = 0;
179
				hints.ai_family = AF_UNSPEC;
202
				hints.ai_family = AF_UNSPEC;
180
				hints.ai_socktype = SOCK_STREAM;
203
				hints.ai_socktype = SOCK_STREAM;
181
				error = getaddrinfo(qnichost, "whois",
204
				if (port)
205
					error = getaddrinfo(qnichost, port,
206
						&hints, &res);
207
				else
208
					error = getaddrinfo(qnichost, "whois",
182
						&hints, &res);
209
						&hints, &res);
183
				if (error != 0)
210
				if (error != 0)
184
					errx(EX_NOHOST, "%s: %s", qnichost,
211
					errx(EX_NOHOST, "%s: %s", qnichost,
Lines 190-211 Link Here
190
			hints.ai_flags = 0;
217
			hints.ai_flags = 0;
191
			hints.ai_family = AF_UNSPEC;
218
			hints.ai_family = AF_UNSPEC;
192
			hints.ai_socktype = SOCK_STREAM;
219
			hints.ai_socktype = SOCK_STREAM;
193
			error = getaddrinfo(host, "whois", &hints, &res);
220
			if (port)
221
				error = getaddrinfo(host, port, &hints, &res);
222
			else
223
				error = getaddrinfo(host, "whois", &hints,
224
					&res);
194
			if (error != 0)
225
			if (error != 0)
195
				errx(EX_NOHOST, "%s: %s", host,
226
				errx(EX_NOHOST, "%s: %s", host,
196
					gai_strerror(error));
227
					gai_strerror(error));
197
		}
228
		}
198
229
199
		whois(*argv++, res, flags);
230
		whois(*argv++, res, port, flags);
200
		freeaddrinfo(res);
231
		freeaddrinfo(res);
201
	}
232
	}
202
	exit(0);
233
	exit(0);
203
}
234
}
204
235
205
static void
236
static void
206
whois(name, res, flags)
237
whois(name, res, port, flags)
207
	char *name;
238
	char *name;
208
	struct addrinfo *res;
239
	struct addrinfo *res;
240
	char *port;
209
	int flags;
241
	int flags;
210
{
242
{
211
	FILE *sfi, *sfo;
243
	FILE *sfi, *sfo;
Lines 275-281 Link Here
275
		hints.ai_flags = 0;
307
		hints.ai_flags = 0;
276
		hints.ai_family = AF_UNSPEC;
308
		hints.ai_family = AF_UNSPEC;
277
		hints.ai_socktype = SOCK_STREAM;
309
		hints.ai_socktype = SOCK_STREAM;
278
		error = getaddrinfo(nhost, "whois", &hints, &res2);
310
		if (port)
311
			error = getaddrinfo(nhost, port, &hints, &res2);
312
		else
313
			error = getaddrinfo(nhost, "whois", &hints, &res2);
279
		if (error != 0) {
314
		if (error != 0) {
280
			warnx("%s: %s", nhost, gai_strerror(error));
315
			warnx("%s: %s", nhost, gai_strerror(error));
281
			return;
316
			return;
Lines 283-289 Link Here
283
		if (!nomatch) {
318
		if (!nomatch) {
284
			free(nhost);
319
			free(nhost);
285
		}
320
		}
286
		whois(name, res2, 0);
321
		whois(name, res2, port, 0);
287
		freeaddrinfo(res2);
322
		freeaddrinfo(res2);
288
	}
323
	}
289
}
324
}
Lines 292-297 Link Here
292
usage()
327
usage()
293
{
328
{
294
	(void)fprintf(stderr,
329
	(void)fprintf(stderr,
295
	    "usage: whois [-adgimpQrR6] [-h hostname] name ...\n");
330
	    "usage: whois [-adgimpQrRu6] [-h hostname] [-P port] name ...\n");
296
	exit(EX_USAGE);
331
	exit(EX_USAGE);
297
}
332
}

Return to bug 28790