0a49863
--- netkit-ftp-0.17/ftp/ftp.c.multiipv6	2006-08-02 15:03:26.000000000 +0200
0a49863
+++ netkit-ftp-0.17/ftp/ftp.c	2006-08-02 15:06:19.000000000 +0200
0a49863
@@ -78,9 +78,7 @@
0a49863
 #include <netinet/in.h>
0a49863
 #include <netinet/ip.h>
0a49863
 #include <arpa/ftp.h>
0a49863
-#include <arpa/inet.h>
0a49863
 #include <arpa/telnet.h>
0a49863
-
0a49863
 #include <stdio.h>
0a49863
 #include <signal.h>
0a49863
 #include <string.h>
0a49863
@@ -132,7 +130,7 @@
0a49863
 static sigjmp_buf ptabort;
0a49863
 static int ptabflg = 0;
0a49863
 static int abrtflag = 0;
0a49863
-struct sockaddr_in source;
0a49863
+struct sockaddr_storage source;
0a49863
 
0a49863
 void lostpeer(int);
0a49863
 extern int connected;
0a49863
@@ -154,8 +152,8 @@
0a49863
 char *
0a49863
 hookup(const char *host, const char *port)
0a49863
 {
0a49863
-	int s, tos, error, alen;
0a49863
-	socklen_t len;
0a49863
+	int s, tos, error;
0a49863
+	socklen_t len, alen;
0a49863
 	static char hostnamebuf[256];
0a49863
 	struct addrinfo hints, *res, *res0;
0a49863
 	char hbuf[MAXHOSTNAMELEN], pbuf[NI_MAXSERV];
0a49863
@@ -281,7 +279,15 @@
0a49863
 		printf("Connected to %s (%s).\n", hostname, hbuf);
0a49863
 	alen = sizeof(source);
0a49863
 	getsockname(s,(struct sockaddr*)&source, &alen;;
0a49863
-	source.sin_port = 0;    /* We just want the addr, not the port */
0a49863
+	switch (source.ss_family) {
0a49863
+	    /* We just want the addr, not the port */
0a49863
+	    case AF_INET:
0a49863
+		((struct sockaddr_in *) &source)->sin_port = 0;
0a49863
+	        break;
0a49863
+	    case AF_INET6:
0a49863
+		((struct sockaddr_in6 *) &source)->sin6_port = 0;
0a49863
+	        break;
0a49863
+	}
0a49863
 
0a49863
 	if (getreply(0) > 2) { 	/* read startup message from server    */
0a49863
 		if (cin)
0a49863
@@ -1260,11 +1266,11 @@
0a49863
 			return(1);
0a49863
 		}
0a49863
 		if((multihome) &&
0a49863
-			bind(data, (struct sockaddr*)&source, sizeof(source)) == -1) {
0a49863
-			close(data);
0a49863
-			data = -1;
0a49863
-			perror("ftp multihome bind");
0a49863
-			return(1);
0a49863
+                       bind(data, (struct sockaddr *)&source, sizeof(source)) == -1) {
0a49863
+                       close(data);
0a49863
+                       data = -1;
0a49863
+                       perror("ftp multihome bind");
0a49863
+                       return(1);
0a49863
                 }
0a49863
 		if (options & SO_DEBUG &&
0a49863
 		    setsockopt(data, SOL_SOCKET, SO_DEBUG, (char *)&on,