Blame SOURCES/netkit-ftp.usagi-ipv6.patch

09d58c
diff -uNr netkit-ftp-0.17/CVS/Entries netkit-ftp/CVS/Entries
09d58c
diff -uNr netkit-ftp-0.17/ChangeLog netkit-ftp/ChangeLog
09d58c
--- netkit-ftp-0.17/ChangeLog	Sun Jul 23 04:38:08 2000
09d58c
+++ netkit-ftp/ChangeLog	Tue Nov 28 03:50:10 2000
09d58c
@@ -1,3 +1,6 @@
09d58c
+28-Nov-2000:
09d58c
+	IPv6 support. (Hiroyuki YAMAMORI <h-yamamo@db3.so-net.ne.jp>)
09d58c
+
09d58c
 8-Jul-2000:
09d58c
 	Fix misused printf-function call (not %n-exploitable though).
09d58c
 
09d58c
diff -uNr netkit-ftp-0.17/configure netkit-ftp/configure
09d58c
--- netkit-ftp-0.17/configure	Sat Jul 29 21:00:28 2000
09d58c
+++ netkit-ftp/configure	Sat Jan 27 06:14:54 2001
09d58c
@@ -24,6 +24,7 @@
09d58c
     --binmode=mode        Mode for binaries [755]
09d58c
     --manmode=mode        Mode for manual pages [644]
09d58c
     --with-c-compiler=cc  Program for compiling C source [guessed]
09d58c
+    --enable-ipv6         Enable IPv6 support
09d58c
 EOF
09d58c
 	exit 0;;
09d58c
 	--verbose) ;;
09d58c
@@ -39,6 +40,11 @@
09d58c
 	--manmode=*) MANMODE=`echo $1 | sed 's/^[^=]*=//'` ;;
09d58c
 	--with-c-compiler=*) CC=`echo $1 | sed 's/^[^=]*=//'` ;;
09d58c
 	--without-readline|--disable-readline) WITHOUT_READLINE=1;;
09d58c
+
09d58c
+	--disable-ipv6) ENABLE_IPV6=no;;
09d58c
+	--enable-ipv6=*) ENABLE_IPV6=`echo $1 | sed 's/^[^=]*=//'`;;
09d58c
+	--enable-ipv6) ENABLE_IPV6=yes;;
09d58c
+
09d58c
 	*) echo "Unrecognized option: $1"; exit 1;;
09d58c
 esac 
09d58c
 shift
09d58c
@@ -142,6 +148,42 @@
09d58c
 
09d58c
 LDFLAGS=
09d58c
 LIBS=
09d58c
+
09d58c
+rm -f __conftest*
09d58c
+
09d58c
+##################################################
09d58c
+## Enable IPv6
09d58c
+echo -n "Whether to enable IPv6 support... "
09d58c
+if [ x"$ENABLE_IPV6" = x"yes" ]; then
09d58c
+    echo yes
09d58c
+    CFLAGS="$CFLAGS -DINET6"
09d58c
+else
09d58c
+    echo no
09d58c
+fi
09d58c
+
09d58c
+rm -f __conftest*
09d58c
+
09d58c
+## Search IPv6 Library / Headers
09d58c
+if [ x"$ENABLE_IPV6" = x"yes" ]; then
09d58c
+    echo -n "Search for IPv6 library... "
09d58c
+    inet6libdirs="/usr/local/v6/lib /usr/local/lib /usr /usr/inet6/lib"
09d58c
+    inet6libs="inet6"
09d58c
+    inet6found=no
09d58c
+    for inet6libdir in $inet6libdirs; do
09d58c
+        for inet6lib in $inet6libs; do
09d58c
+            if [ -d $inet6libdir ] && [ -f $inet6libdir/lib$inet6lib.a ]; then
09d58c
+                inet6found=yes
09d58c
+                break 2
09d58c
+            fi
09d58c
+        done
09d58c
+    done
09d58c
+    if [ x"$inet6found" = x"yes" ]; then
09d58c
+        echo "$inet6libdir/lib$inet6lib.a"
09d58c
+        LIBS="$LIBS -L$inet6libdir -l$inet6lib"
09d58c
+    else
09d58c
+        echo "not found"
09d58c
+    fi
09d58c
+fi
09d58c
 
09d58c
 rm -f __conftest*
09d58c
 
09d58c
diff -uNr netkit-ftp-0.17/ftp/CVS/Entries netkit-ftp/ftp/CVS/Entries
09d58c
--- netkit-ftp-0.17/ftp/CVS/Entries	Thu Jan  1 02:00:00 1970
09d58c
+++ netkit-ftp/ftp/CVS/Entries	Mon Feb 19 06:50:49 2001
09d58c
@@ -0,0 +1,16 @@
09d58c
+/.cvsignore/1.1.1.1/Fri Nov  3 19:18:15 2000//
09d58c
+/Makefile/1.4/Sat Jan 27 05:57:08 2001//
09d58c
+/cmds.c/1.3/Fri Jan 12 21:36:27 2001//
09d58c
+/cmds.h/1.1.1.1/Fri Nov  3 19:18:15 2000//
09d58c
+/cmdtab.c/1.1.1.1/Fri Nov  3 19:18:15 2000//
09d58c
+/domacro.c/1.1.1.1/Fri Nov  3 19:18:15 2000//
09d58c
+/ftp.1/1.1.1.1/Fri Nov  3 19:18:15 2000//
09d58c
+/ftp.c/1.11/Sun Feb 11 12:26:59 2001//
09d58c
+/ftp_var.h/1.3/Fri Jan 12 21:36:27 2001//
09d58c
+/glob.c/1.1.1.1/Fri Nov  3 19:18:15 2000//
09d58c
+/glob.h/1.1.1.1/Fri Nov  3 19:18:15 2000//
09d58c
+/main.c/1.1.1.1/Fri Nov  3 19:18:15 2000//
09d58c
+/netrc.5/1.1.1.1/Fri Nov  3 19:18:15 2000//
09d58c
+/pathnames.h/1.1.1.1/Fri Nov  3 19:18:15 2000//
09d58c
+/ruserpass.c/1.1.1.1/Fri Nov  3 19:18:15 2000//
09d58c
+D
09d58c
diff -uNr netkit-ftp-0.17/ftp/CVS/Repository netkit-ftp/ftp/CVS/Repository
09d58c
--- netkit-ftp-0.17/ftp/CVS/Repository	Thu Jan  1 02:00:00 1970
09d58c
+++ netkit-ftp/ftp/CVS/Repository	Mon Feb 19 06:50:49 2001
09d58c
@@ -0,0 +1 @@
09d58c
+usagi/src/netkit-ftp/ftp
09d58c
diff -uNr netkit-ftp-0.17/ftp/CVS/Root netkit-ftp/ftp/CVS/Root
09d58c
--- netkit-ftp-0.17/ftp/CVS/Root	Thu Jan  1 02:00:00 1970
09d58c
+++ netkit-ftp/ftp/CVS/Root	Mon Feb 19 06:50:49 2001
09d58c
@@ -0,0 +1 @@
09d58c
+:pserver:anoncvs@anoncvs.linux-ipv6.org:/cvsroot/usagi
09d58c
diff -uNr netkit-ftp-0.17/ftp/Makefile netkit-ftp/ftp/Makefile
09d58c
--- netkit-ftp-0.17/ftp/Makefile	Sun Aug  1 09:00:12 1999
09d58c
+++ netkit-ftp/ftp/Makefile	Sat Jan 27 07:57:08 2001
09d58c
@@ -16,10 +16,13 @@
09d58c
 cmds.o glob.o: glob.h
09d58c
 
09d58c
 install: ftp
09d58c
+	install -d $(INSTALLROOT)$(BINDIR)
09d58c
 	install -s -m$(BINMODE) ftp $(INSTALLROOT)$(BINDIR)
09d58c
 	ln -sf ftp $(INSTALLROOT)$(BINDIR)/pftp
09d58c
+	install -d $(INSTALLROOT)$(MANDIR)/man1
09d58c
 	install -m$(MANMODE) ftp.1 $(INSTALLROOT)$(MANDIR)/man1
09d58c
 	ln -sf ftp.1 $(INSTALLROOT)$(MANDIR)/man1/pftp.1
09d58c
+	install -d $(INSTALLROOT)$(MANDIR)/man5
09d58c
 	install -m$(MANMODE) netrc.5 $(INSTALLROOT)$(MANDIR)/man5
09d58c
 
09d58c
 clean:
09d58c
diff -uNr netkit-ftp-0.17/ftp/cmds.c netkit-ftp/ftp/cmds.c
09d58c
--- netkit-ftp-0.17/ftp/cmds.c	Sun Jul 23 04:36:59 2000
09d58c
+++ netkit-ftp/ftp/cmds.c	Fri Jan 12 23:36:27 2001
09d58c
@@ -1,3 +1,5 @@
09d58c
+/* $USAGI$ */
09d58c
+
09d58c
 /*
09d58c
  * Copyright (c) 1985, 1989 Regents of the University of California.
09d58c
  * All rights reserved.
09d58c
@@ -35,7 +37,7 @@
09d58c
  * from: @(#)cmds.c	5.26 (Berkeley) 3/5/91
09d58c
  */
09d58c
 char cmds_rcsid[] = 
09d58c
-   "$Id: cmds.c,v 1.33 2000/07/23 01:36:59 dholland Exp $";
09d58c
+   "$Id: cmds.c,v 1.3 2001/01/12 21:36:27 sekiya Exp $";
09d58c
 
09d58c
 /*
09d58c
  * FTP User Program -- Command Routines.
09d58c
@@ -190,7 +192,7 @@
09d58c
 setpeer(int argc, char *argv[])
09d58c
 {
09d58c
 	char *host;
09d58c
-	unsigned short port;
09d58c
+	char *port;
09d58c
 
09d58c
 	if (connected) {
09d58c
 		printf("Already connected to %s, use close first.\n",
09d58c
@@ -205,22 +207,17 @@
09d58c
 		code = -1;
09d58c
 		return;
09d58c
 	}
09d58c
-	port = ftp_port;
09d58c
+	port = NULL;
09d58c
 	if (argc > 2) {
09d58c
-		port = atoi(argv[2]);
09d58c
-		if (port < 1) {
09d58c
-			printf("%s: bad port number-- %s\n", argv[1], argv[2]);
09d58c
-			printf ("usage: %s host-name [port]\n", argv[0]);
09d58c
-			code = -1;
09d58c
-			return;
09d58c
-		}
09d58c
-		port = htons(port);
09d58c
+		port = argv[2];
09d58c
 	}
09d58c
 	host = hookup(argv[1], port);
09d58c
 	if (host) {
09d58c
 		int overbose;
09d58c
 
09d58c
 		connected = 1;
09d58c
+		try_epsv = 1;
09d58c
+		try_eprt = 1;
09d58c
 		/*
09d58c
 		 * Set up defaults for FTP.
09d58c
 		 */
09d58c
diff -uNr netkit-ftp-0.17/ftp/cmdtab.c netkit-ftp/ftp/cmdtab.c
09d58c
--- netkit-ftp-0.17/ftp/cmdtab.c	Tue Sep 28 18:36:05 1999
09d58c
+++ netkit-ftp/ftp/cmdtab.c	Fri Nov  3 21:18:15 2000
09d58c
@@ -35,7 +35,7 @@
09d58c
  * from: @(#)cmdtab.c	5.10 (Berkeley) 6/1/90
09d58c
  */
09d58c
 char cmdtab_rcsid[] = 
09d58c
-  "$Id: cmdtab.c,v 1.8 1999/09/28 15:36:05 dholland Exp $";
09d58c
+  "$Id: cmdtab.c,v 1.1.1.1 2000/11/03 19:18:15 mk Exp $";
09d58c
 
09d58c
 #include <string.h>   /* for NULL */
09d58c
 #include "ftp_var.h"
09d58c
diff -uNr netkit-ftp-0.17/ftp/domacro.c netkit-ftp/ftp/domacro.c
09d58c
--- netkit-ftp-0.17/ftp/domacro.c	Thu Aug 15 02:27:28 1996
09d58c
+++ netkit-ftp/ftp/domacro.c	Fri Nov  3 21:18:15 2000
09d58c
@@ -35,7 +35,7 @@
09d58c
  * from: @(#)domacro.c	1.8 (Berkeley) 9/28/90
09d58c
  */
09d58c
 char domacro_rcsid[] = 
09d58c
-  "$Id: domacro.c,v 1.4 1996/08/14 23:27:28 dholland Exp $";
09d58c
+  "$Id: domacro.c,v 1.1.1.1 2000/11/03 19:18:15 mk Exp $";
09d58c
 
09d58c
 #include <errno.h>
09d58c
 #include <ctype.h>
09d58c
diff -uNr netkit-ftp-0.17/ftp/ftp.1 netkit-ftp/ftp/ftp.1
09d58c
--- netkit-ftp-0.17/ftp/ftp.1	Mon Jul 31 02:56:59 2000
09d58c
+++ netkit-ftp/ftp/ftp.1	Fri Nov  3 21:18:15 2000
09d58c
@@ -30,7 +30,7 @@
09d58c
 .\" SUCH DAMAGE.
09d58c
 .\"
09d58c
 .\"	from: @(#)ftp.1	6.18 (Berkeley) 7/30/91
09d58c
-.\"	$Id: ftp.1,v 1.14 2000/07/30 23:56:59 dholland Exp $
09d58c
+.\"	$Id: ftp.1,v 1.1.1.1 2000/11/03 19:18:15 mk Exp $
09d58c
 .\"
09d58c
 .Dd August 15, 1999
09d58c
 .Dt FTP 1
09d58c
diff -uNr netkit-ftp-0.17/ftp/ftp.c netkit-ftp/ftp/ftp.c
09d58c
--- netkit-ftp-0.17/ftp/ftp.c	Mon Dec 13 22:33:20 1999
09d58c
+++ netkit-ftp/ftp/ftp.c	Sun Feb 11 14:26:59 2001
09d58c
@@ -1,3 +1,34 @@
09d58c
+/* $USAGI$ */
09d58c
+
09d58c
+/*
09d58c
+ * Copyright (C) 1997 and 1998 WIDE Project.
09d58c
+ * All rights reserved.
09d58c
+ * 
09d58c
+ * Redistribution and use in source and binary forms, with or without
09d58c
+ * modification, are permitted provided that the following conditions
09d58c
+ * are met:
09d58c
+ * 1. Redistributions of source code must retain the above copyright
09d58c
+ *    notice, this list of conditions and the following disclaimer.
09d58c
+ * 2. Redistributions in binary form must reproduce the above copyright
09d58c
+ *    notice, this list of conditions and the following disclaimer in the
09d58c
+ *    documentation and/or other materials provided with the distribution.
09d58c
+ * 3. Neither the name of the project nor the names of its contributors
09d58c
+ *    may be used to endorse or promote products derived from this software
09d58c
+ *    without specific prior written permission.
09d58c
+ * 
09d58c
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
09d58c
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
09d58c
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
09d58c
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
09d58c
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
09d58c
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
09d58c
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
09d58c
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
09d58c
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
09d58c
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
09d58c
+ * SUCH DAMAGE.
09d58c
+ */
09d58c
+
09d58c
 /*
09d58c
  * Copyright (c) 1985, 1989 Regents of the University of California.
09d58c
  * All rights reserved.
09d58c
@@ -35,7 +66,7 @@
09d58c
  * From: @(#)ftp.c	5.38 (Berkeley) 4/22/91
09d58c
  */
09d58c
 char ftp_rcsid[] = 
09d58c
-  "$Id: ftp.c,v 1.25 1999/12/13 20:33:20 dholland Exp $";
09d58c
+  "$Id: ftp.c,v 1.11 2001/02/11 12:26:59 yoshfuji Exp $";
09d58c
 
09d58c
 #include <sys/param.h>
09d58c
 #include <sys/stat.h>
09d58c
@@ -63,14 +94,38 @@
09d58c
 #include "ftp_var.h"
09d58c
 #include "cmds.h"
09d58c
 
09d58c
+#ifdef _USAGI
09d58c
+#include "version.h"
09d58c
+#else
09d58c
 #include "../version.h"
09d58c
+#endif
09d58c
+
09d58c
+union sockunion {
09d58c
+	struct sockinet {
09d58c
+		u_short	si_family;
09d58c
+		u_short	si_port;
09d58c
+	} su_si;
09d58c
+	struct	sockaddr		su_sa;
09d58c
+	struct	sockaddr_in  		su_sin;
09d58c
+#ifdef INET6
09d58c
+	struct	sockaddr_in6 		su_sin6;
09d58c
+#endif
09d58c
+};
09d58c
+#define	su_family	su_sa.sa_family
09d58c
+#define	su_port		su_si.si_port
09d58c
+
09d58c
+#ifdef INET6
09d58c
+#define ex_af2prot(a) (a == AF_INET ? 1 : (a == AF_INET6 ? 2 : 0))
09d58c
+#else
09d58c
+#define ex_af2prot(a) (a == AF_INET ? 1 : 0)
09d58c
+#endif
09d58c
 
09d58c
 int data = -1;
09d58c
 off_t restart_point = 0;
09d58c
 
09d58c
-static struct sockaddr_in hisctladdr;
09d58c
-static struct sockaddr_in data_addr;
09d58c
-static struct sockaddr_in myctladdr;
09d58c
+static union sockunion hisctladdr;
09d58c
+static union sockunion data_addr;
09d58c
+static union sockunion myctladdr;
09d58c
 static int ptflag = 0;
09d58c
 static sigjmp_buf recvabort;
09d58c
 static sigjmp_buf sendabort;
09d58c
@@ -96,79 +151,119 @@
09d58c
 static FILE *dataconn(const char *);
09d58c
 
09d58c
 char *
09d58c
-hookup(char *host, int port)
09d58c
+hookup(const char *host, const char *port)
09d58c
 {
09d58c
-	register struct hostent *hp = 0;
09d58c
-	int s, tos;
09d58c
+	int s, tos, error;
09d58c
 	socklen_t len;
09d58c
 	static char hostnamebuf[256];
09d58c
-
09d58c
+	struct addrinfo hints, *res, *res0;
09d58c
+	char hbuf[MAXHOSTNAMELEN], pbuf[NI_MAXSERV];
09d58c
+	char *cause = "ftp: unknown";
09d58c
+
09d58c
+	if (port) {
09d58c
+		strncpy(pbuf, port, sizeof(pbuf) - 1);
09d58c
+		pbuf[sizeof(pbuf) - 1] = '\0';
09d58c
+	} else {
09d58c
+		sprintf(pbuf, "%d", ntohs(ftp_port));
09d58c
+	}
09d58c
 	memset(&hisctladdr, 0, sizeof(hisctladdr));
09d58c
-	if (inet_aton(host, &hisctladdr.sin_addr)) {
09d58c
-		hisctladdr.sin_family = AF_INET;
09d58c
-		strncpy(hostnamebuf, host, sizeof(hostnamebuf));
09d58c
-		hostnamebuf[sizeof(hostnamebuf)-1]=0;
09d58c
-	} 
09d58c
-	else {
09d58c
-		hp = gethostbyname(host);
09d58c
-		if (hp == NULL) {
09d58c
-			fprintf(stderr, "ftp: %s: ", host);
09d58c
-			herror((char *)NULL);
09d58c
-			code = -1;
09d58c
-			return((char *) 0);
09d58c
+	memset(&hints, 0, sizeof(hints));
09d58c
+	hints.ai_flags = AI_CANONNAME;
09d58c
+	hints.ai_socktype = SOCK_STREAM;
09d58c
+	error = getaddrinfo(host, pbuf, &hints, &res0);
09d58c
+	if (error) {
09d58c
+		if (port) {
09d58c
+			strcpy(hbuf, " ");
09d58c
+		} else {
09d58c
+			hbuf[0] = '\0';
09d58c
+			pbuf[0] = '\0';
09d58c
 		}
09d58c
-		hisctladdr.sin_family = hp->h_addrtype;
09d58c
-		if (hp->h_length > (int)sizeof(hisctladdr.sin_addr)) {
09d58c
-			hp->h_length = sizeof(hisctladdr.sin_addr);
09d58c
-		}
09d58c
-		memcpy(&hisctladdr.sin_addr, hp->h_addr_list[0], hp->h_length);
09d58c
-		(void) strncpy(hostnamebuf, hp->h_name, sizeof(hostnamebuf));
09d58c
-		hostnamebuf[sizeof(hostnamebuf)-1] = 0;
09d58c
-	}
09d58c
-	hostname = hostnamebuf;
09d58c
-	s = socket(hisctladdr.sin_family, SOCK_STREAM, 0);
09d58c
-	if (s < 0) {
09d58c
-		perror("ftp: socket");
09d58c
+		fprintf(stderr, "ftp: %s%s%s: %s\n", host, hbuf, pbuf,
09d58c
+						gai_strerror(error));
09d58c
 		code = -1;
09d58c
 		return (0);
09d58c
 	}
09d58c
-	hisctladdr.sin_port = port;
09d58c
-	while (connect(s, (struct sockaddr *)&hisctladdr, sizeof (hisctladdr)) < 0) {
09d58c
-		if (hp && hp->h_addr_list[1]) {
09d58c
-			int oerrno = errno;
09d58c
-
09d58c
-			fprintf(stderr, "ftp: connect to address %s: ",
09d58c
-				inet_ntoa(hisctladdr.sin_addr));
09d58c
-			errno = oerrno;
09d58c
-			perror((char *) 0);
09d58c
-			hp->h_addr_list++;
09d58c
-			memcpy(&hisctladdr.sin_addr, hp->h_addr_list[0], 
09d58c
-			       hp->h_length);
09d58c
-			fprintf(stdout, "Trying %s...\n",
09d58c
-				inet_ntoa(hisctladdr.sin_addr));
09d58c
-			(void) close(s);
09d58c
-			s = socket(hisctladdr.sin_family, SOCK_STREAM, 0);
09d58c
-			if (s < 0) {
09d58c
-				perror("ftp: socket");
09d58c
-				code = -1;
09d58c
-				return (0);
09d58c
+
09d58c
+	if (res0->ai_canonname) {
09d58c
+		struct addrinfo h, *a;
09d58c
+		memset(&h, 0, sizeof(h));
09d58c
+		h.ai_family = PF_UNSPEC;
09d58c
+		h.ai_socktype = SOCK_STREAM;
09d58c
+		h.ai_flags = AI_NUMERICHOST;
09d58c
+		if (!getaddrinfo(res0->ai_canonname, NULL, &h, &a)) {
09d58c
+			strncpy(hostnamebuf, res0->ai_canonname, sizeof(hostnamebuf));
09d58c
+			freeaddrinfo(a);
09d58c
+		} else
09d58c
+			strncpy(hostnamebuf, host, sizeof(hostnamebuf));
09d58c
+	}
09d58c
+	else
09d58c
+		strncpy(hostnamebuf, host, sizeof(hostnamebuf));
09d58c
+	hostnamebuf[sizeof(hostnamebuf) - 1] = '\0';
09d58c
+	hostname = hostnamebuf;
09d58c
+	
09d58c
+	s = -1;
09d58c
+	for (res = res0; res; res = res->ai_next) {
09d58c
+		if (!ex_af2prot(res->ai_family)) {
09d58c
+			cause = "ftp: mismatch address family";
09d58c
+			errno = EPROTONOSUPPORT;
09d58c
+			continue;
09d58c
+		}
09d58c
+		if ((size_t)res->ai_addrlen > sizeof(hisctladdr)) {
09d58c
+			cause = "ftp: mismatch struct sockaddr size";
09d58c
+			errno = EPROTO;
09d58c
+			continue;
09d58c
+		}
09d58c
+		if (getnameinfo(res->ai_addr, res->ai_addrlen,
09d58c
+				hbuf, sizeof(hbuf), NULL, 0,
09d58c
+				NI_NUMERICHOST))
09d58c
+			strcpy(hbuf, "???");
09d58c
+		if (res0->ai_next)	/* if we have multiple possibilities */
09d58c
+			fprintf(stdout, "Trying %s...\n", hbuf);
09d58c
+		s = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
09d58c
+		if (s < 0) {
09d58c
+			cause = "ftp: socket";
09d58c
+			continue;
09d58c
+		}
09d58c
+		while ((error = connect(s, res->ai_addr, res->ai_addrlen)) < 0
09d58c
+				&& errno == EINTR) {
09d58c
+			;
09d58c
+		}
09d58c
+		if (error) {
09d58c
+			/* this "if" clause is to prevent print warning twice */
09d58c
+			if (res->ai_next) {
09d58c
+				fprintf(stderr,
09d58c
+					"ftp: connect to address %s", hbuf);
09d58c
+				perror("");
09d58c
 			}
09d58c
+			cause = "ftp: connect";
09d58c
+			close(s);
09d58c
+			s = -1;
09d58c
 			continue;
09d58c
 		}
09d58c
-		perror("ftp: connect");
09d58c
+		/* finally we got one */
09d58c
+		break;
09d58c
+	}
09d58c
+	if (s < 0) {
09d58c
+		perror(cause);
09d58c
 		code = -1;
09d58c
-		goto bad;
09d58c
+		freeaddrinfo(res0);
09d58c
+		return NULL;
09d58c
 	}
09d58c
-	len = sizeof (myctladdr);
09d58c
+	len = res->ai_addrlen;
09d58c
+	memcpy(&hisctladdr, res->ai_addr, len);
09d58c
+	freeaddrinfo(res0);
09d58c
 	if (getsockname(s, (struct sockaddr *)&myctladdr, &len) < 0) {
09d58c
 		perror("ftp: getsockname");
09d58c
 		code = -1;
09d58c
 		goto bad;
09d58c
 	}
09d58c
 #ifdef IP_TOS
09d58c
+	if (hisctladdr.su_family == AF_INET)
09d58c
+	{
09d58c
 	tos = IPTOS_LOWDELAY;
09d58c
 	if (setsockopt(s, IPPROTO_IP, IP_TOS, (char *)&tos, sizeof(int)) < 0)
09d58c
 		perror("ftp: setsockopt TOS (ignored)");
09d58c
+	}
09d58c
 #endif
09d58c
 	cin = fdopen(s, "r");
09d58c
 	cout = fdopen(s, "w");
09d58c
@@ -182,7 +277,7 @@
09d58c
 		goto bad;
09d58c
 	}
09d58c
 	if (verbose)
09d58c
-		printf("Connected to %s.\n", hostname);
09d58c
+		printf("Connected to %s (%s).\n", hostname, hbuf);
09d58c
 	if (getreply(0) > 2) { 	/* read startup message from server */
09d58c
 		if (cin)
09d58c
 			(void) fclose(cin);
09d58c
@@ -392,8 +487,10 @@
09d58c
 			}
09d58c
 			if (dig < 4 && isdigit(c))
09d58c
 				code = code * 10 + (c - '0');
09d58c
-			if (!pflag && code == 227)
09d58c
+			if (!pflag && (code == 227 || code == 228))
09d58c
 				pflag = 1;
09d58c
+			else if (!pflag && code == 229)
09d58c
+				pflag = 100;
09d58c
 			if (dig > 4 && pflag == 1 && isdigit(c))
09d58c
 				pflag = 2;
09d58c
 			if (pflag == 2) {
09d58c
@@ -405,6 +502,8 @@
09d58c
 					pflag = 3;
09d58c
 				}
09d58c
 			}
09d58c
+			if (pflag == 100 && c == '(')
09d58c
+				pflag = 2;
09d58c
 			if (dig == 4 && c == '-') {
09d58c
 				if (continuation)
09d58c
 					code = 0;
09d58c
@@ -1083,15 +1182,25 @@
09d58c
 static int
09d58c
 initconn(void)
09d58c
 {
09d58c
-	register char *p, *a;
09d58c
+	u_char *p, *a;
09d58c
 	int result, tmpno = 0;
09d58c
 	socklen_t len;
09d58c
 	int on = 1;
09d58c
-	int tos;
09d58c
-	u_long a1,a2,a3,a4,p1,p2;
09d58c
-
09d58c
+	int tos, error = 0;
09d58c
+	u_int ad[16], po[2], af, alen, plen;
09d58c
+	char *pasvcmd = NULL;
09d58c
+	char hbuf[MAXHOSTNAMELEN], pbuf[NI_MAXSERV];
09d58c
+
09d58c
+#ifdef INET6
09d58c
+	if (myctladdr.su_family == AF_INET6
09d58c
+	 && (IN6_IS_ADDR_LINKLOCAL(&myctladdr.su_sin6.sin6_addr)
09d58c
+	  || IN6_IS_ADDR_SITELOCAL(&myctladdr.su_sin6.sin6_addr))) {
09d58c
+		fprintf(stderr, "use of scoped address can be troublesome\n");
09d58c
+	}
09d58c
+#endif
09d58c
 	if (passivemode) {
09d58c
-		data = socket(AF_INET, SOCK_STREAM, 0);
09d58c
+		data_addr = hisctladdr;
09d58c
+		data = socket(data_addr.su_family, SOCK_STREAM, 0);
09d58c
 		if (data < 0) {
09d58c
 			perror("ftp: socket");
09d58c
 			return(1);
09d58c
@@ -1100,52 +1209,203 @@
09d58c
 		    setsockopt(data, SOL_SOCKET, SO_DEBUG, (char *)&on,
09d58c
 			       sizeof (on)) < 0)
09d58c
 			perror("ftp: setsockopt (ignored)");
09d58c
-		if (command("PASV") != COMPLETE) {
09d58c
+		switch (data_addr.su_family) {
09d58c
+		case AF_INET:
09d58c
+#if 0
09d58c
+			if (try_epsv) {
09d58c
+				result = command(pasvcmd = "EPSV 1");
09d58c
+				if (code / 10 == 22 && code != 229) {
09d58c
+					fprintf(stderr,
09d58c
+				  "wrong server: return code must be 229\n");
09d58c
+					result = COMPLETE + 1;
09d58c
+				}
09d58c
+			} else {
09d58c
+#endif
09d58c
+			result = COMPLETE + 1;
09d58c
+
09d58c
+			if (result != COMPLETE) {
09d58c
+				try_epsv = 0;
09d58c
+				result = command(pasvcmd = "PASV");
09d58c
+			}
09d58c
+			break;
09d58c
+#ifdef INET6
09d58c
+		case AF_INET6:
09d58c
+			if (try_epsv) {
09d58c
+				result = command(pasvcmd = "EPSV 2");
09d58c
+				if (code / 10 == 22 && code != 229) {
09d58c
+					fprintf(stderr,
09d58c
+				  "wrong server: return code must be 229\n");
09d58c
+					result = COMPLETE + 1;
09d58c
+				}
09d58c
+			} else {
09d58c
+				result = COMPLETE + 1;
09d58c
+			}
09d58c
+			if (result != COMPLETE) {
09d58c
+				try_epsv = 0;
09d58c
+				result = command(pasvcmd = "LPSV");
09d58c
+			}
09d58c
+			break;
09d58c
+#endif
09d58c
+		default:
09d58c
+			result = COMPLETE + 1;
09d58c
+			break;
09d58c
+		}
09d58c
+		if (result != COMPLETE) {
09d58c
 			printf("Passive mode refused.\n");
09d58c
-			return(1);
09d58c
+			goto bad;
09d58c
 		}
09d58c
 
09d58c
+#define pack2(var) \
09d58c
+	(((var[0] & 0xff) << 8) | ((var[1] & 0xff) << 0))
09d58c
+#define pack4(var) \
09d58c
+	((((var)[0] & 0xff) << 24) | (((var)[1] & 0xff) << 16) | \
09d58c
+	 (((var)[2] & 0xff) << 8) | (((var)[3] & 0xff) << 0))
09d58c
+
09d58c
 		/*
09d58c
 		 * What we've got at this point is a string of comma separated
09d58c
 		 * one-byte unsigned integer values, separated by commas.
09d58c
-		 * The first four are the an IP address. The fifth is the MSB
09d58c
-		 * of the port number, the sixth is the LSB. From that we'll
09d58c
-		 * prepare a sockaddr_in.
09d58c
 		 */
09d58c
-
09d58c
-		if (sscanf(pasv,"%ld,%ld,%ld,%ld,%ld,%ld",
09d58c
-			   &a1,&a2,&a3,&a4,&p1,&p2)
09d58c
-		    != 6) 
09d58c
-		{
09d58c
-			printf("Passive mode address scan failure. Shouldn't happen!\n");
09d58c
-			return(1);
09d58c
+		error = 0;
09d58c
+		if (strcmp(pasvcmd, "PASV") == 0) {
09d58c
+			if (data_addr.su_family != AF_INET) {
09d58c
+				error = 2;
09d58c
+				goto psv_done;
09d58c
+			}
09d58c
+			if (code / 10 == 22 && code != 227) {
09d58c
+				error = 227;
09d58c
+				goto psv_done;
09d58c
+			}
09d58c
+			if (sscanf(pasv, "%u,%u,%u,%u,%u,%u",
09d58c
+					&ad[0], &ad[1], &ad[2], &ad[3],
09d58c
+					&po[0], &po[1]) != 6) {
09d58c
+				error = 1;
09d58c
+				goto psv_done;
09d58c
+			}
09d58c
+			data_addr.su_sin.sin_addr.s_addr = htonl(pack4(ad));
09d58c
+			data_addr.su_port = htons(pack2(po));
09d58c
+		} else
09d58c
+		    if (strcmp(pasvcmd, "LPSV") == 0) {
09d58c
+			if (code / 10 == 22 && code != 228) {
09d58c
+				error = 228;
09d58c
+				goto psv_done;
09d58c
+			}
09d58c
+			switch (data_addr.su_family) {
09d58c
+			case AF_INET:
09d58c
+				if (sscanf(pasv, "%u,%u,%u,%u,%u,%u,%u,%u,%u",
09d58c
+						&af, &alen,
09d58c
+						&ad[0], &ad[1], &ad[2], &ad[3],
09d58c
+						&plen, &po[0], &po[1]) != 9) {
09d58c
+					error = 1;
09d58c
+					goto psv_done;
09d58c
+				}
09d58c
+				if (af != 4 || alen != 4 || plen != 2) {
09d58c
+					error = 2;
09d58c
+					goto psv_done;
09d58c
+				}
09d58c
+				data_addr.su_sin.sin_addr.s_addr =
09d58c
+							htonl(pack4(ad));
09d58c
+				data_addr.su_port = htons(pack2(po));
09d58c
+				break;
09d58c
+#ifdef INET6
09d58c
+			case AF_INET6:
09d58c
+				if (sscanf(pasv,
09d58c
+	"%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u",
09d58c
+				  &af, &alen,
09d58c
+				  &ad[0], &ad[1], &ad[2], &ad[3],
09d58c
+				  &ad[4], &ad[5], &ad[6], &ad[7],
09d58c
+				  &ad[8], &ad[9], &ad[10], &ad[11],
09d58c
+				  &ad[12], &ad[13], &ad[14], &ad[15],
09d58c
+				  &plen, &po[0], &po[1]) != 21) {
09d58c
+					error = 1;
09d58c
+					goto psv_done;
09d58c
+				}
09d58c
+				if (af != 6 || alen != 16 || plen != 2) {
09d58c
+					error = 2;
09d58c
+					goto psv_done;
09d58c
+				}
09d58c
+				data_addr.su_sin6.sin6_addr.s6_addr32[0] =
09d58c
+							htonl(pack4(ad));
09d58c
+				data_addr.su_sin6.sin6_addr.s6_addr32[1] =
09d58c
+							htonl(pack4(ad+4));
09d58c
+				data_addr.su_sin6.sin6_addr.s6_addr32[2] =
09d58c
+							htonl(pack4(ad+8));
09d58c
+				data_addr.su_sin6.sin6_addr.s6_addr32[3] =
09d58c
+							htonl(pack4(ad+12));
09d58c
+				data_addr.su_port = htons(pack2(po));
09d58c
+				break;
09d58c
+#endif
09d58c
+			default:
09d58c
+				error = 1;
09d58c
+			}
09d58c
+		} else if (strncmp(pasvcmd, "EPSV", 4) == 0) {
09d58c
+			char delim[4];
09d58c
+			u_int epsvpo;
09d58c
+
09d58c
+			if (code / 10 == 22 && code != 229) {
09d58c
+				error = 229;
09d58c
+				goto psv_done;
09d58c
+			}
09d58c
+			if (sscanf(pasv, "%c%c%c%u%c", &delim[0], &delim[1],
09d58c
+					&delim[2], &epsvpo, &delim[3]) != 5) {
09d58c
+				error = 1;
09d58c
+				goto psv_done;
09d58c
+			}
09d58c
+			if (delim[0] != delim[1] || delim[0] != delim[2]
09d58c
+			 || delim[0] != delim[3]) {
09d58c
+				error = 1;
09d58c
+				goto psv_done;
09d58c
+			}
09d58c
+			data_addr.su_port = htons(epsvpo);
09d58c
+		} else {
09d58c
+			error = 1;
09d58c
+		}
09d58c
+psv_done:
09d58c
+		switch (error) {
09d58c
+		case 0:
09d58c
+			break;
09d58c
+		case 1:
09d58c
+			fprintf(stderr,
09d58c
+		  "Passive mode address scan failure. Shouldn't happen!\n");
09d58c
+			goto bad;
09d58c
+		case 2:
09d58c
+			fprintf(stderr,
09d58c
+			  "Passive mode AF mismatch. Shouldn't happen!\n");
09d58c
+			goto bad;
09d58c
+		case 227:
09d58c
+		case 228:
09d58c
+		case 229:
09d58c
+			fprintf(stderr,
09d58c
+			  "wrong server: return code must be %d\n", error);
09d58c
+			goto bad;
09d58c
+		default:
09d58c
+			fprintf(stderr, "Bug\n");
09d58c
 		}
09d58c
 
09d58c
-		data_addr.sin_family = AF_INET;
09d58c
-		data_addr.sin_addr.s_addr = htonl((a1 << 24) | (a2 << 16) |
09d58c
-						  (a3 << 8) | a4);
09d58c
-		data_addr.sin_port = htons((p1 << 8) | p2);
09d58c
-
09d58c
 		if (connect(data, (struct sockaddr *) &data_addr,
09d58c
-		    sizeof(data_addr))<0) {
09d58c
+			    (data_addr.su_family == AF_INET ?
09d58c
+			     sizeof(data_addr.su_sin) :
09d58c
+			     sizeof(data_addr.su_sin6)))<0) {
09d58c
 			perror("ftp: connect");
09d58c
 			return(1);
09d58c
 		}
09d58c
 #ifdef IP_TOS
09d58c
+		if (data_addr.su_family == AF_INET)
09d58c
+		{
09d58c
 		tos = IPTOS_THROUGHPUT;
09d58c
 		if (setsockopt(data, IPPROTO_IP, IP_TOS, (char *)&tos,
09d58c
 		    sizeof(tos)) < 0)
09d58c
 			perror("ftp: setsockopt TOS (ignored)");
09d58c
+		}
09d58c
 #endif
09d58c
 		return(0);
09d58c
 	}
09d58c
 noport:
09d58c
 	data_addr = myctladdr;
09d58c
 	if (sendport)
09d58c
-		data_addr.sin_port = 0;	/* let system pick one */ 
09d58c
+		data_addr.su_port = 0;	/* let system pick one */ 
09d58c
 	if (data != -1)
09d58c
 		(void) close(data);
09d58c
-	data = socket(AF_INET, SOCK_STREAM, 0);
09d58c
+	data = socket(data_addr.su_family, SOCK_STREAM, 0);
09d58c
 	if (data < 0) {
09d58c
 		perror("ftp: socket");
09d58c
 		if (tmpno)
09d58c
@@ -1172,13 +1432,47 @@
09d58c
 	if (listen(data, 1) < 0)
09d58c
 		perror("ftp: listen");
09d58c
 	if (sendport) {
09d58c
-		a = (char *)&data_addr.sin_addr;
09d58c
-		p = (char *)&data_addr.sin_port;
09d58c
-#define	UC(b)	(((int)b)&0xff)
09d58c
-		result =
09d58c
-		    command("PORT %d,%d,%d,%d,%d,%d",
09d58c
-		      UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]),
09d58c
-		      UC(p[0]), UC(p[1]));
09d58c
+		af = ex_af2prot(data_addr.su_family);
09d58c
+		if (try_eprt && af > 1) {      /* only IPv6 */
09d58c
+			if (getnameinfo((struct sockaddr *)&data_addr, len,
09d58c
+					hbuf, sizeof(hbuf), pbuf, sizeof(pbuf),
09d58c
+					NI_NUMERICHOST | NI_NUMERICSERV) == 0) {
09d58c
+				result = command("EPRT |%d|%s|%s|",
09d58c
+							af, hbuf, pbuf);
09d58c
+				if (result != COMPLETE) {
09d58c
+					try_eprt = 0;
09d58c
+				}
09d58c
+			} else {
09d58c
+				result = ERROR;
09d58c
+			}
09d58c
+		} else {
09d58c
+			result = COMPLETE + 1;
09d58c
+		}
09d58c
+		if (result == COMPLETE)
09d58c
+			goto prt_done;
09d58c
+
09d58c
+		p = (u_char *)&data_addr.su_port;
09d58c
+		switch (data_addr.su_family) {
09d58c
+		case AF_INET:
09d58c
+			a = (u_char *)&data_addr.su_sin.sin_addr;
09d58c
+			result = command("PORT %u,%u,%u,%u,%u,%u",
09d58c
+				a[0], a[1], a[2], a[3], p[0], p[1]);
09d58c
+			break;
09d58c
+#ifdef INET6
09d58c
+		case AF_INET6:
09d58c
+			a = (u_char *)&data_addr.su_sin6.sin6_addr;
09d58c
+			result = command(
09d58c
+	"LPRT 6,16,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,2,%d,%d",
09d58c
+				a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7],
09d58c
+				a[8], a[9],a[10],a[11],a[12],a[13],a[14],a[15],
09d58c
+				p[0], p[1]);
09d58c
+			break;
09d58c
+#endif
09d58c
+		default:
09d58c
+			result = COMPLETE + 1; /* xxx */
09d58c
+		}
09d58c
+
09d58c
+	prt_done:
09d58c
 		if (result == ERROR && sendport == -1) {
09d58c
 			sendport = 0;
09d58c
 			tmpno = 1;
09d58c
@@ -1189,9 +1483,12 @@
09d58c
 	if (tmpno)
09d58c
 		sendport = 1;
09d58c
 #ifdef IP_TOS
09d58c
+	if (data_addr.su_family == AF_INET)
09d58c
+	{
09d58c
 	on = IPTOS_THROUGHPUT;
09d58c
 	if (setsockopt(data, IPPROTO_IP, IP_TOS, (char *)&on, sizeof(int)) < 0)
09d58c
 		perror("ftp: setsockopt TOS (ignored)");
09d58c
+	}
09d58c
 #endif
09d58c
 	return (0);
09d58c
 bad:
09d58c
@@ -1204,7 +1501,7 @@
09d58c
 static FILE *
09d58c
 dataconn(const char *lmode)
09d58c
 {
09d58c
-	struct sockaddr_in from;
09d58c
+	union sockunion from;
09d58c
 	int s, tos;
09d58c
 	socklen_t fromlen = sizeof(from);
09d58c
 
09d58c
@@ -1220,9 +1517,12 @@
09d58c
 	(void) close(data);
09d58c
 	data = s;
09d58c
 #ifdef IP_TOS
09d58c
+	if (from.su_family == AF_INET)
09d58c
+	{
09d58c
 	tos = IPTOS_THROUGHPUT;
09d58c
 	if (setsockopt(s, IPPROTO_IP, IP_TOS, (char *)&tos, sizeof(int)) < 0)
09d58c
 		perror("ftp: setsockopt TOS (ignored)");
09d58c
+	}
09d58c
 #endif
09d58c
 	return (fdopen(data, lmode));
09d58c
 }
09d58c
@@ -1284,8 +1584,8 @@
09d58c
 	static struct comvars {
09d58c
 		int connect;
09d58c
 		char name[MAXHOSTNAMELEN];
09d58c
-		struct sockaddr_in mctl;
09d58c
-		struct sockaddr_in hctl;
09d58c
+		union sockunion mctl;
09d58c
+		union sockunion hctl;
09d58c
 		FILE *in;
09d58c
 		FILE *out;
09d58c
 		int tpe;
09d58c
@@ -1323,7 +1623,7 @@
09d58c
 	connected = op->connect;
09d58c
 	if (hostname) {
09d58c
 		(void) strncpy(ip->name, hostname, sizeof(ip->name) - 1);
09d58c
-		ip->name[strlen(ip->name)] = '\0';
09d58c
+		ip->name[sizeof(ip->name) - 1] = '\0';
09d58c
 	} 
09d58c
 	else {
09d58c
 		ip->name[0] = 0;
09d58c
@@ -1352,18 +1652,18 @@
09d58c
 	ip->ntflg = ntflag;
09d58c
 	ntflag = op->ntflg;
09d58c
 	(void) strncpy(ip->nti, ntin, 16);
09d58c
-	(ip->nti)[strlen(ip->nti)] = '\0';
09d58c
+	(ip->nti)[16] = '\0';		/* shouldn't use strlen */
09d58c
 	(void) strcpy(ntin, op->nti);
09d58c
 	(void) strncpy(ip->nto, ntout, 16);
09d58c
-	(ip->nto)[strlen(ip->nto)] = '\0';
09d58c
+	(ip->nto)[16] = '\0';
09d58c
 	(void) strcpy(ntout, op->nto);
09d58c
 	ip->mapflg = mapflag;
09d58c
 	mapflag = op->mapflg;
09d58c
 	(void) strncpy(ip->mi, mapin, MAXPATHLEN - 1);
09d58c
-	(ip->mi)[strlen(ip->mi)] = '\0';
09d58c
+	(ip->mi)[MAXPATHLEN - 1] = '\0';
09d58c
 	(void) strcpy(mapin, op->mi);
09d58c
 	(void) strncpy(ip->mo, mapout, MAXPATHLEN - 1);
09d58c
-	(ip->mo)[strlen(ip->mo)] = '\0';
09d58c
+	(ip->mo)[MAXPATHLEN - 1] = '\0';
09d58c
 	(void) strcpy(mapout, op->mo);
09d58c
 	(void) signal(SIGINT, oldintr);
09d58c
 	if (abrtflag) {
09d58c
diff -uNr netkit-ftp-0.17/ftp/ftp_var.h netkit-ftp/ftp/ftp_var.h
09d58c
--- netkit-ftp-0.17/ftp/ftp_var.h	Sat Oct  2 21:39:17 1999
09d58c
+++ netkit-ftp/ftp/ftp_var.h	Fri Jan 12 23:36:27 2001
09d58c
@@ -1,3 +1,5 @@
09d58c
+/* $USAGI$ */
09d58c
+
09d58c
 /*
09d58c
  * Copyright (c) 1985, 1989 Regents of the University of California.
09d58c
  * All rights reserved.
09d58c
@@ -31,7 +33,7 @@
09d58c
  * SUCH DAMAGE.
09d58c
  *
09d58c
  *	from: @(#)ftp_var.h	5.9 (Berkeley) 6/1/90
09d58c
- *	$Id: ftp_var.h,v 1.12 1999/10/02 18:39:17 dholland Exp $
09d58c
+ *	$Id: ftp_var.h,v 1.3 2001/01/12 21:36:27 sekiya Exp $
09d58c
  */
09d58c
 
09d58c
 /*
09d58c
@@ -112,6 +114,8 @@
09d58c
 Extern int	mflag;		/* flag: if != 0, then active multi command */
09d58c
 
09d58c
 Extern int	options;	/* used during socket creation */
09d58c
+Extern int	try_epsv;	/* try EPSV for this session */
09d58c
+Extern int	try_eprt;	/* try EPRT for this session */
09d58c
 
09d58c
 /*
09d58c
  * Format of command table.
09d58c
@@ -140,7 +144,7 @@
09d58c
 Extern char macbuf[4096];
09d58c
 #define MACBUF_SIZE 4096
09d58c
 
09d58c
-char *hookup(char *host, int port);
09d58c
+char *hookup(const char *host, const char *port);
09d58c
 struct cmd *getcmd(const char *);
09d58c
 char **makeargv(int *pargc, char **parg);
09d58c
 int dologin(const char *host);