[Pkg-wmaker-commits] [wmbiff] 01/84: IPv6 support using getaddrinfo from Jun-ichiro itojun Hagino <itojun at iijlab.net>
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Thu Aug 20 03:01:44 UTC 2015
This is an automated email from the git hooks/post-receive script.
dtorrance-guest pushed a commit to tag wmbiff_0_4_10
in repository wmbiff.
commit ac4776aadf54e6f5c4d0262c7d30d4f0467c9cff
Author: bluehal <bluehal>
Date: Sat Jun 1 05:42:38 2002 +0000
IPv6 support using getaddrinfo from Jun-ichiro itojun Hagino <itojun at iijlab.net>
---
configure.in | 3 +++
wmbiff/socket.c | 42 +++++++++++++++++++++++++++++++++++++++++-
2 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/configure.in b/configure.in
index 03f2386..0af1047 100644
--- a/configure.in
+++ b/configure.in
@@ -26,6 +26,9 @@ fi
dnl a no-op to force autoconf to seek out the preprocessor now.
AC_CHECK_HEADERS(stdio.h)
+dnl for IPv6 support
+AC_CHECK_FUNCS(getaddrinfo)
+
dnl Pre-gnutls.
gnutls="ok"
AC_CHECK_LIB(z, gzopen, [], [gnutls="nope"]) dnl GNUTLS seems to need libz; fail here if it's missing.
diff --git a/wmbiff/socket.c b/wmbiff/socket.c
index c70a603..0269655 100644
--- a/wmbiff/socket.c
+++ b/wmbiff/socket.c
@@ -1,4 +1,4 @@
-/* $Id: socket.c,v 1.4 2002/04/12 05:54:36 bluehal Exp $ */
+/* $Id: socket.c,v 1.5 2002/06/01 05:42:38 bluehal Exp $ */
/* Copyright (C) 1998 Trent Piepho <xyzzy at u.washington.edu>
* (C) 1999 Trent Piepho <xyzzy at speakeasy.org>
*
@@ -34,9 +34,48 @@
/* nspring/blueHal, 10 Apr 2002; added some extra error
printing, in line with the debug-messages-to-stdout
philosophy of the rest of the wmbiff code */
+/* 29 May 2002; incorporated IPv6 support by
+ Jun-ichiro itojun Hagino <itojun at iijlab.net>, thanks! */
+
int sock_connect(const char *hostname, int port)
{
+#ifdef HAVE_GETADDRINFO
+ struct addrinfo hints, *res, *res0;
+ int fd;
+ char pbuf[NI_MAXSERV];
+ int error;
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_socktype = SOCK_STREAM;
+ snprintf(pbuf, sizeof(pbuf), "%d", port);
+ error = getaddrinfo(hostname, pbuf, &hints, &res0);
+ if (error) {
+ printf("%s: %s\n", hostname, gai_strerror(error));
+ return -1;
+ }
+
+ fd = -1;
+ for (res = res0; res; res = res->ai_next) {
+ fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+ if (fd < 0)
+ continue;
+ if (connect(fd, res->ai_addr, res->ai_addrlen) < 0) {
+ close(fd);
+ fd = -1;
+ continue;
+ }
+ break;
+ }
+ freeaddrinfo(res0);
+ if (fd < 0) {
+ perror("Error connecting");
+ printf("socket/connect to %s failed: %s\n", hostname,
+ strerror(errno));
+ return -1;
+ }
+ return fd;
+#else
struct hostent *host;
struct sockaddr_in addr;
int fd, i;
@@ -67,6 +106,7 @@ int sock_connect(const char *hostname, int port)
return (-1);
};
return (fd);
+#endif
}
/* vim:set ts=4: */
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmbiff.git
More information about the Pkg-wmaker-commits
mailing list