gnupg 1.2.2: IPv6 support

Jun-ichiro itojun Hagino itojun@iijlab.net
Fri Aug 22 11:14:02 2003


	the following diff should add IPv6 support (keyserver access)
	to gnupg 1.2.2.
	config.h.in should be automatically generated, however, i'm not too
	familiar with automake so i hand-patched it.  please consider
	integrating it into future distribution.

itojun


Index: config.h.in
===================================================================
RCS file: /cvsroot/apps/gnupg/config.h.in,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- config.h.in	15 Aug 2003 05:12:06 -0000	1.1.1.1
+++ config.h.in	15 Aug 2003 06:44:46 -0000	1.2
@@ -537,3 +537,4 @@
 
 #include "g10defs.h"
 
+#undef HAVE_GETADDRINFO
Index: configure
===================================================================
RCS file: /cvsroot/apps/gnupg/configure,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- configure	15 Aug 2003 05:12:08 -0000	1.1.1.1
+++ configure	15 Aug 2003 06:47:49 -0000	1.2
@@ -13111,7 +13111,7 @@
 
 
 
-for ac_func in waitpid wait4 sigaction sigprocmask rand pipe stat
+for ac_func in waitpid wait4 sigaction sigprocmask rand pipe stat getaddrinfo
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
 echo "$as_me:$LINENO: checking for $ac_func" >&5
Index: configure.ac
===================================================================
RCS file: /cvsroot/apps/gnupg/configure.ac,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
--- configure.ac	15 Aug 2003 05:12:08 -0000	1.1.1.1
+++ configure.ac	15 Aug 2003 06:47:49 -0000	1.3
@@ -586,7 +586,7 @@
 AC_CHECK_FUNCS(strcasecmp strncasecmp ctermid)
 AC_CHECK_FUNCS(memmove gettimeofday getrusage setrlimit clock_gettime)
 AC_CHECK_FUNCS(atexit raise getpagesize strftime nl_langinfo setlocale)
-AC_CHECK_FUNCS(waitpid wait4 sigaction sigprocmask rand pipe stat)
+AC_CHECK_FUNCS(waitpid wait4 sigaction sigprocmask rand pipe stat getaddrinfo)
 AC_REPLACE_FUNCS(mkdtemp)
 
 #
Index: util/http.c
===================================================================
RCS file: /cvsroot/apps/gnupg/util/http.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- util/http.c	15 Aug 2003 05:12:28 -0000	1.1.1.1
+++ util/http.c	15 Aug 2003 06:44:46 -0000	1.2
@@ -753,6 +753,28 @@
         sock_close (sd);
         return -1;
     }
+#elif defined(HAVE_GETADDRINFO)
+    struct addrinfo hints, *res0, *res;
+    char portstr[20];
+
+    memset(&hints, 0, sizeof(hints));
+    hints.ai_socktype = SOCK_STREAM;
+    snprintf(portstr, sizeof(portstr), "%u", port);
+    if (getaddrinfo(server, portstr, &hints, &res0) != 0)
+	return -1;
+    for (res = res0; res; res = res->ai_next) {
+	sd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+	if (sd < 0)
+	    continue;
+	if (connect(sd, res->ai_addr, res->ai_addrlen) < 0) {
+	    close(sd);
+	    sd = -1;
+	    continue;
+	}
+	break;
+    }
+    freeaddrinfo(res0);
+    return sd;
 #else
     struct sockaddr_in addr;
     struct hostent *host;