NetBSD Problem Report #8281
Received: (qmail 14217 invoked from network); 27 Aug 1999 07:02:51 -0000
Message-Id: <199908270702.QAA00987@laysner.grid.iri.co.jp>
Date: Fri, 27 Aug 1999 16:02:28 +0900 (JST)
From: seirios@matrix.iri.co.jp
Reply-To: seirios@matrix.iri.co.jp
To: gnats-bugs@gnats.netbsd.org
Subject: whois IPv6 patch
X-Send-Pr-Version: 3.95
>Number: 8281
>Category: misc
>Synopsis: Support IPv6 connection for whois
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: itojun
>State: closed
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Fri Aug 27 00:05:01 +0000 1999
>Closed-Date: Sun Sep 05 15:34:50 +0000 1999
>Last-Modified: Sun Sep 05 15:35:04 +0000 1999
>Originator: HEO SeonMeyong
>Release: NetBSD-current 1999, 27 Aug.
>Organization:
Internet Research Institute, Inc.
>Environment:
System: NetBSD laysner.grid.iri.co.jp 1.4K NetBSD 1.4K (LAYSNER.v6) #1: Mon Aug 23 01:14:27 JST 1999 root@laysner.grid.iri.co.jp:/usr/src/sys/arch/i386/compile/LAYSNER.v6 i386
>Description:
whois(1) supports both IPv6 connection and IPv4 connection.
If whois server has IPv6 address, whois(1) will try to connect IPv6 protocol first.
And if cannot connect to server on IPv6, try to connect IPv4.
If whois server has no IPv6 address, whois(1) will try to connect IPv4 connection without IPv6 coonnection.
>How-To-Repeat:
>Fix:
apply attached patch.
>Release-Note:
>Audit-Trail:
From: HEO SeonMeyong <seirios@Matrix.IRI.Co.Jp>
To: gnats-bugs@gnats.netbsd.org, misc-bug-people@netbsd.org
Cc: seirios@Matrix.iri.co.jp
Subject: Re: misc/8281: whois IPv6 patch
Date: Fri, 27 Aug 1999 16:47:21 +0900
----Next_Part(Fri_Aug_27_16:47:18_1999_229)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi, This is HEO SeonMeyong writing
> >Category: misc
> >Responsible: misc-bug-people
> >Synopsis: Support IPv6 connection for whois
> >Arrival-Date: Fri Aug 27 00:05:01 1999
I'm verry sorry for my mistake.
patch will attach this mail.
HEO
----Next_Part(Fri_Aug_27_16:47:18_1999_229)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="whois.diff"
diff -ru whois.orig/whois.1 whois/whois.1
--- whois.orig/whois.1 Wed May 19 07:36:36 1999
+++ whois/whois.1 Fri Aug 27 04:05:22 1999
@@ -41,7 +41,7 @@
.Nd TCP/IP Internet directory service, RIPE version
.Sh SYNOPSIS
.Nm ""
-.Op Fl aFSrR
+.Op Fl 46aFSrR
.Op Fl h Ar host
.Op Fl p Ar port
.Op Fl i Ar attributes
@@ -133,6 +133,12 @@
.B \-T types
types is a comma separated list of object types.
requests the server to only send back objects that match one of the "types".
+By default, whois connect to whois server both IPv6 and IPv4. If you want
+to connect IPv4 only, you use
+.B \-4
+option, and if you want to connect IPv6 only, you use
+.B \-6
+option.
.TP 8
.Lp
.Sh EXAMPLES
@@ -205,9 +211,17 @@
to <ncc@ripe.net>. For more information about the RIPE database please also
refer to <ncc@ripe.net>.
.Lp
+.Sh IPv6 supported
+This whois support the IPv6(IP version 6) whois connections.
+This whois is get the all of host's Information from nameserver, and
+connect order is (if exist) IPv6 addresses of server at first and IPv4
+address is later.
+.Lp
.Sh BUGS
Most of the extra flags are ONLY supported by the RIPE whois server,
or copies of the same version of the software. Usage of these flags
may cause errors on other whois servers.
+This whois depends on getaddrinfo(3) functions and search order depends on
+that function.
.\".Sh SEE ALSO
.\"RFC 812: NICNAME/WHOIS
diff -ru whois.orig/whois.c whois/whois.c
--- whois.orig/whois.c Wed May 19 07:36:36 1999
+++ whois/whois.c Fri Aug 27 15:14:07 1999
@@ -167,16 +167,18 @@
{
#ifdef RIPE
#ifdef NETWORKUPDATE
- (void)fprintf(stderr, "\nUsage: networkupdate [-h hostname] [-p port]");
+ (void)fprintf(stderr, "\nUsage: networkupdate [-46] [-h hostname] [-p port]");
#else
- (void)fprintf(stderr, "\nUsage: whois [-aFLmMrSvR] [-h hostname] [-s sources] [-T types] [-i attr] keys\n");
+ (void)fprintf(stderr, "\nUsage: whois [-46aFLmMrSvR] [-h hostname] [-s sources] [-T types] [-i attr] keys\n");
(void)fprintf(stderr, " whois -t type");
(void)fprintf(stderr, " whois -v type");
#endif
#else
- (void)fprintf(stderr, "\nUsage: whois [-h hostname] [-p port] name ...");
+ (void)fprintf(stderr, "\nUsage: whois [-46] [-h hostname] [-p port] name ...");
#endif
(void)fprintf(stderr, "\n\nWhere:\n\n");
+ (void)fprintf(stderr, "-4 Use IPv4 Only\n");
+ (void)fprintf(stderr, "-6 Use IPv6 Only\n");
#ifdef RIPE
#ifndef NETWORKUPDATE
(void)fprintf(stderr, "-a search all databases\n");
@@ -266,13 +268,19 @@
FILE *sfi;
FILE *sfo;
int ch;
- struct sockaddr_in sin;
- struct hostent *hp;
- struct servent *sp;
+ struct addrinfo *dst, hints;
+ int socktype=PF_UNSPEC;
+ int error;
char *host, *whoishost;
- int optp=0, optport=0;
+ int optp=0;
+ char *optport="whois";
+#ifdef DEBUG
+ int verb=1;
+#else /*DEBUG */
+ int verb=0;
+#endif
#ifdef RIPE
- int verb=0, opthost=0;
+ int opthost=0;
#ifndef NETWORKUPDATE
/* normal whois client */
char *string;
@@ -304,20 +312,26 @@
#ifdef RIPE
#ifdef NETWORKUPDATE
- while ((ch = getopt(argc, argv, "h:p:")) != EOF)
+ while ((ch = getopt(argc, argv, "46h:p:")) != EOF)
#else
- while ((ch = getopt(argc, argv, "acFg:h:i:LmMp:rs:SRt:T:v:")) != EOF)
+ while ((ch = getopt(argc, argv, "46acFg:h:i:LmMp:rs:SRt:T:v:")) != EOF)
#endif
#else
- while ((ch = getopt(argc, argv, "h:p:")) != EOF)
+ while ((ch = getopt(argc, argv, "46h:p:")) != EOF)
#endif
switch((char)ch) {
+ case '4':
+ socktype = PF_INET;
+ break;
+ case '6':
+ socktype = PF_INET6;
+ break;
case 'h':
host = optarg;
opthost = 1;
break;
case 'p':
- optport=htons((u_short)atoi(optarg));
+ optport=optarg;
optp =1;
break;
#ifdef RIPE
@@ -423,23 +437,32 @@
if (verb) fprintf(stderr, "Clever guess: %s\n", whoishost);
}
}
- hp = gethostbyname(whoishost);
- if ((hp == NULL) && (verb))
- fprintf(stderr,"No such host: %s\n", whoishost);
- if (hp==NULL) {
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_flags = AI_CANONNAME;
+ hints.ai_family = socktype;
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_protocol = 0;
+ error = getaddrinfo(host, optport, &hints, &dst);
+ if ((error) && (verb))
+ fprintf(stderr,"No such host: %s\n", whoishost);
+ if (error) {
#endif
whoishost=NICHOST;
if (verb) fprintf(stderr, "Default host: %s\n\n", whoishost);
- hp = gethostbyname(whoishost);
-
- if (hp == NULL) {
+ memset( &hints, 0, sizeof(hints) );
+ hints.ai_flags = AI_CANONNAME;
+ hints.ai_family = socktype;
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_protocol = 0;
+ error = getaddrinfo(host, optport , &hints, &dst);
+ if (error) {
fprintf(stderr,"No such host: %s\n", whoishost);
if (verb) fprintf(stderr, "Now I give up ...\n");
perror("Unknown host");
- exit(1);
+ exit(1);
}
#ifdef CLEVER
@@ -448,50 +471,34 @@
}
else {
if (verb) fprintf(stderr, "Trying: %s\n\n", host);
- hp = gethostbyname(host);
- if (hp == NULL) {
+ memset( &hints, 0, sizeof(hints) );
+ hints.ai_flags = AI_CANONNAME;
+ hints.ai_family = socktype;
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_protocol = 0;
+ error = getaddrinfo(host, optport, &hints, &dst);
+ if (error) {
(void)fprintf(stderr, "whois: %s: ", host);
perror("Unknown host");
exit(1);
}
}
- host = hp->h_name;
- s = socket(hp->h_addrtype, SOCK_STREAM, 0);
- if (s < 0) {
- perror("whois: socket");
- exit(1);
- }
- bzero((caddr_t)&sin, sizeof (sin));
- sin.sin_family = hp->h_addrtype;
- if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
- perror("whois: bind");
- exit(1);
- }
- bcopy(hp->h_addr, (char *)&sin.sin_addr, hp->h_length);
-
- if (optp) {
- sin.sin_port=optport;
- }
- else {
-
- sp=getservbyname("whois", "tcp");
-
- if (sp == NULL) {
- (void)fprintf(stderr, "whois: whois/tcp: unknown service\n");
- exit(1);
- }
-
- sin.sin_port = sp->s_port;
-
- }
-
- /* printf("%i\n", sin.sin_port); */
-
- if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
- perror("whois: connect");
- exit(1);
+ while (1) {
+ s = socket(dst->ai_family, dst->ai_socktype, dst->ai_protocol);
+ if (connect(s, dst->ai_addr, dst->ai_addrlen) < 0) {
+ if (verb) (void)fprintf(stderr, "whois: connect miss\n");
+ if (dst->ai_next == NULL) {
+ perror("whois: connect");
+ exit(1);
+ } else {
+ dst = dst->ai_next;
+ }
+ continue;
+ }
+ break;
}
+ if (verb) (void)fprintf(stderr, "whois: connect success\n");
#ifndef NETWORKUPDATE
sfi = fdopen(s, "r");
Only in whois: whois.cat1
----Next_Part(Fri_Aug_27_16:47:18_1999_229)----
From: itojun@iijlab.net
To: seirios@matrix.iri.co.jp
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: misc/8281: whois IPv6 patch
Date: Fri, 27 Aug 1999 23:38:12 +0900
>>Synopsis: Support IPv6 connection for whois
>>Fix:
> apply attached patch.
patch is not there :-P
itojun
From: HEO SeonMeyong <seirios@Matrix.IRI.Co.Jp>
To: itojun@iijlab.net
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: misc/8281: whois IPv6 patch
Date: Sat, 28 Aug 1999 04:27:23 +0900
----Next_Part(Sat_Aug_28_04:27:12_1999_229)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi Mr. itojun.
> > apply attached patch.
> patch is not there :-P
Ouch.....
Now I attach patch file. sorry.
HEO
----Next_Part(Sat_Aug_28_04:27:12_1999_229)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="whois.diff"
diff -ru whois.orig/whois.1 whois/whois.1
--- whois.orig/whois.1 Wed May 19 07:36:36 1999
+++ whois/whois.1 Fri Aug 27 04:05:22 1999
@@ -41,7 +41,7 @@
.Nd TCP/IP Internet directory service, RIPE version
.Sh SYNOPSIS
.Nm ""
-.Op Fl aFSrR
+.Op Fl 46aFSrR
.Op Fl h Ar host
.Op Fl p Ar port
.Op Fl i Ar attributes
@@ -133,6 +133,12 @@
.B \-T types
types is a comma separated list of object types.
requests the server to only send back objects that match one of the "types".
+By default, whois connect to whois server both IPv6 and IPv4. If you want
+to connect IPv4 only, you use
+.B \-4
+option, and if you want to connect IPv6 only, you use
+.B \-6
+option.
.TP 8
.Lp
.Sh EXAMPLES
@@ -205,9 +211,17 @@
to <ncc@ripe.net>. For more information about the RIPE database please also
refer to <ncc@ripe.net>.
.Lp
+.Sh IPv6 supported
+This whois support the IPv6(IP version 6) whois connections.
+This whois is get the all of host's Information from nameserver, and
+connect order is (if exist) IPv6 addresses of server at first and IPv4
+address is later.
+.Lp
.Sh BUGS
Most of the extra flags are ONLY supported by the RIPE whois server,
or copies of the same version of the software. Usage of these flags
may cause errors on other whois servers.
+This whois depends on getaddrinfo(3) functions and search order depends on
+that function.
.\".Sh SEE ALSO
.\"RFC 812: NICNAME/WHOIS
diff -ru whois.orig/whois.c whois/whois.c
--- whois.orig/whois.c Wed May 19 07:36:36 1999
+++ whois/whois.c Fri Aug 27 15:14:07 1999
@@ -167,16 +167,18 @@
{
#ifdef RIPE
#ifdef NETWORKUPDATE
- (void)fprintf(stderr, "\nUsage: networkupdate [-h hostname] [-p port]");
+ (void)fprintf(stderr, "\nUsage: networkupdate [-46] [-h hostname] [-p port]");
#else
- (void)fprintf(stderr, "\nUsage: whois [-aFLmMrSvR] [-h hostname] [-s sources] [-T types] [-i attr] keys\n");
+ (void)fprintf(stderr, "\nUsage: whois [-46aFLmMrSvR] [-h hostname] [-s sources] [-T types] [-i attr] keys\n");
(void)fprintf(stderr, " whois -t type");
(void)fprintf(stderr, " whois -v type");
#endif
#else
- (void)fprintf(stderr, "\nUsage: whois [-h hostname] [-p port] name ...");
+ (void)fprintf(stderr, "\nUsage: whois [-46] [-h hostname] [-p port] name ...");
#endif
(void)fprintf(stderr, "\n\nWhere:\n\n");
+ (void)fprintf(stderr, "-4 Use IPv4 Only\n");
+ (void)fprintf(stderr, "-6 Use IPv6 Only\n");
#ifdef RIPE
#ifndef NETWORKUPDATE
(void)fprintf(stderr, "-a search all databases\n");
@@ -266,13 +268,19 @@
FILE *sfi;
FILE *sfo;
int ch;
- struct sockaddr_in sin;
- struct hostent *hp;
- struct servent *sp;
+ struct addrinfo *dst, hints;
+ int socktype=PF_UNSPEC;
+ int error;
char *host, *whoishost;
- int optp=0, optport=0;
+ int optp=0;
+ char *optport="whois";
+#ifdef DEBUG
+ int verb=1;
+#else /*DEBUG */
+ int verb=0;
+#endif
#ifdef RIPE
- int verb=0, opthost=0;
+ int opthost=0;
#ifndef NETWORKUPDATE
/* normal whois client */
char *string;
@@ -304,20 +312,26 @@
#ifdef RIPE
#ifdef NETWORKUPDATE
- while ((ch = getopt(argc, argv, "h:p:")) != EOF)
+ while ((ch = getopt(argc, argv, "46h:p:")) != EOF)
#else
- while ((ch = getopt(argc, argv, "acFg:h:i:LmMp:rs:SRt:T:v:")) != EOF)
+ while ((ch = getopt(argc, argv, "46acFg:h:i:LmMp:rs:SRt:T:v:")) != EOF)
#endif
#else
- while ((ch = getopt(argc, argv, "h:p:")) != EOF)
+ while ((ch = getopt(argc, argv, "46h:p:")) != EOF)
#endif
switch((char)ch) {
+ case '4':
+ socktype = PF_INET;
+ break;
+ case '6':
+ socktype = PF_INET6;
+ break;
case 'h':
host = optarg;
opthost = 1;
break;
case 'p':
- optport=htons((u_short)atoi(optarg));
+ optport=optarg;
optp =1;
break;
#ifdef RIPE
@@ -423,23 +437,32 @@
if (verb) fprintf(stderr, "Clever guess: %s\n", whoishost);
}
}
- hp = gethostbyname(whoishost);
- if ((hp == NULL) && (verb))
- fprintf(stderr,"No such host: %s\n", whoishost);
- if (hp==NULL) {
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_flags = AI_CANONNAME;
+ hints.ai_family = socktype;
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_protocol = 0;
+ error = getaddrinfo(host, optport, &hints, &dst);
+ if ((error) && (verb))
+ fprintf(stderr,"No such host: %s\n", whoishost);
+ if (error) {
#endif
whoishost=NICHOST;
if (verb) fprintf(stderr, "Default host: %s\n\n", whoishost);
- hp = gethostbyname(whoishost);
-
- if (hp == NULL) {
+ memset( &hints, 0, sizeof(hints) );
+ hints.ai_flags = AI_CANONNAME;
+ hints.ai_family = socktype;
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_protocol = 0;
+ error = getaddrinfo(host, optport , &hints, &dst);
+ if (error) {
fprintf(stderr,"No such host: %s\n", whoishost);
if (verb) fprintf(stderr, "Now I give up ...\n");
perror("Unknown host");
- exit(1);
+ exit(1);
}
#ifdef CLEVER
@@ -448,50 +471,34 @@
}
else {
if (verb) fprintf(stderr, "Trying: %s\n\n", host);
- hp = gethostbyname(host);
- if (hp == NULL) {
+ memset( &hints, 0, sizeof(hints) );
+ hints.ai_flags = AI_CANONNAME;
+ hints.ai_family = socktype;
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_protocol = 0;
+ error = getaddrinfo(host, optport, &hints, &dst);
+ if (error) {
(void)fprintf(stderr, "whois: %s: ", host);
perror("Unknown host");
exit(1);
}
}
- host = hp->h_name;
- s = socket(hp->h_addrtype, SOCK_STREAM, 0);
- if (s < 0) {
- perror("whois: socket");
- exit(1);
- }
- bzero((caddr_t)&sin, sizeof (sin));
- sin.sin_family = hp->h_addrtype;
- if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
- perror("whois: bind");
- exit(1);
- }
- bcopy(hp->h_addr, (char *)&sin.sin_addr, hp->h_length);
-
- if (optp) {
- sin.sin_port=optport;
- }
- else {
-
- sp=getservbyname("whois", "tcp");
-
- if (sp == NULL) {
- (void)fprintf(stderr, "whois: whois/tcp: unknown service\n");
- exit(1);
- }
-
- sin.sin_port = sp->s_port;
-
- }
-
- /* printf("%i\n", sin.sin_port); */
-
- if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
- perror("whois: connect");
- exit(1);
+ while (1) {
+ s = socket(dst->ai_family, dst->ai_socktype, dst->ai_protocol);
+ if (connect(s, dst->ai_addr, dst->ai_addrlen) < 0) {
+ if (verb) (void)fprintf(stderr, "whois: connect miss\n");
+ if (dst->ai_next == NULL) {
+ perror("whois: connect");
+ exit(1);
+ } else {
+ dst = dst->ai_next;
+ }
+ continue;
+ }
+ break;
}
+ if (verb) (void)fprintf(stderr, "whois: connect success\n");
#ifndef NETWORKUPDATE
sfi = fdopen(s, "r");
Only in whois: whois.cat1
----Next_Part(Sat_Aug_28_04:27:12_1999_229)----
State-Changed-From-To: open->feedback
State-Changed-By: itojun
State-Changed-When: Fri Sep 3 06:51:35 PDT 1999
State-Changed-Why:
committed
Responsible-Changed-From-To: misc-bug-people->itojun
Responsible-Changed-By: itojun
Responsible-Changed-When: Fri Sep 3 06:51:35 PDT 1999
Responsible-Changed-Why:
i will handle it (as it is ipv6 issue!)
State-Changed-From-To: feedback->closed
State-Changed-By: itojun
State-Changed-When: Sun Sep 5 08:34:50 PDT 1999
State-Changed-Why:
submitter confirmed
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.49 2026/05/14 01:52:41 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.