Blame SOURCES/netkit-ftp-0.17-multiipv6.patch

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