[wiki] [sites] ii: readd ipv6 patch || Nico Golde

From: <hg_AT_suckless.org>
Date: Mon, 27 Feb 2012 16:43:07 +0100 (CET)

changeset: 866:017a59285113
tag: tip
user: Nico Golde <nico_AT_ngolde.de>
date: Mon Feb 27 16:43:00 2012 +0100
files: tools.suckless.org/ii/patches/ii-ipv6.diff tools.suckless.org/ii/patches/ipv6.md
description:
ii: readd ipv6 patch


diff -r ba214d5ab200 -r 017a59285113 tools.suckless.org/ii/patches/ii-ipv6.diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools.suckless.org/ii/patches/ii-ipv6.diff Mon Feb 27 16:43:00 2012 +0100
_AT_@ -0,0 +1,62 @@
+--- ii.c.orig 2007-07-22 11:54:29.061710701 +0100
++++ ii.c 2007-07-22 14:08:42.833057387 +0100
+_AT_@ -153,25 +153,45 @@
+
+ static int tcpopen(unsigned short port) {
+ int fd;
+- struct sockaddr_in sin;
+- struct hostent *hp = gethostbyname(host);
+-
+- memset(&sin, 0, sizeof(struct sockaddr_in));
+- if(!hp) {
+- perror("ii: cannot retrieve host information");
++ struct addrinfo req, *res, *orig_res;
++ char service[6];
++ char errmsg[512];
++
++ snprintf(service, 6, "%u", port);
++ memset(&req, 0, sizeof(req));
++ req.ai_flags = AI_NUMERICSERV;
++ req.ai_socktype = SOCK_STREAM;
++ int e = getaddrinfo(host, service, &req, &res);
++ if(e) {
++ fprintf(stderr, "ii: getaddrinfo() failed : %s\n", gai_strerror(e));
+ exit(EXIT_FAILURE);
+ }
+- sin.sin_family = AF_INET;
+- memcpy(&sin.sin_addr, hp->h_addr, hp->h_length);
+- sin.sin_port = htons(port);
+- if((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
+- perror("ii: cannot create socket");
+- exit(EXIT_FAILURE);
++
++ orig_res = res;
++ for (; res; res = res->ai_next ) {
++ fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
++
++ if(fd < 0) {
++ snprintf(errmsg, sizeof(errmsg), "ii: socket() failed : %s", strerror(fd));
++ continue;
++ }
++
++ if(connect(fd, res->ai_addr, res->ai_addrlen) != 0) {
++ snprintf(errmsg, sizeof(errmsg), "ii: connect() failed : %s", strerror(errno));
++ fd = -1;
++ continue;
++ }
++
++ /* sucessful connection */
++ break;
+ }
+- if(connect(fd, (const struct sockaddr *) &sin, sizeof(sin)) < 0) {
+- perror("ii: cannot connect to host");
++ freeaddrinfo(orig_res);
++
++ if(fd < 0) {
++ fprintf(stderr, "%s\n", errmsg);
+ exit(EXIT_FAILURE);
+ }
++
+ return fd;
+ }
+
diff -r ba214d5ab200 -r 017a59285113 tools.suckless.org/ii/patches/ipv6.md
--- a/tools.suckless.org/ii/patches/ipv6.md Mon Feb 27 15:24:33 2012 +0100
+++ b/tools.suckless.org/ii/patches/ipv6.md Mon Feb 27 16:43:00 2012 +0100
_AT_@ -9,7 +9,7 @@
 Download
 --------
 
-* [ii-ipv6.patch](http://suckless.org/~nion/ii-ipv6.patch) (seems to have gone missing)
+* [ii-ipv6.diff](ii-ipv6.diff) (seems to have gone missing)
 
 Author
 ------
Received on Mon Feb 27 2012 - 16:43:07 CET

This archive was generated by hypermail 2.3.0 : Thu Sep 13 2012 - 19:32:07 CEST