diff -urN lynx-2.8.1.orig/README.ipv6 lynx-2.8.1.ip6/README.ipv6 --- lynx-2.8.1.orig/README.ipv6 Wed Dec 31 21:00:00 1969 +++ lynx-2.8.1.ip6/README.ipv6 Wed Mar 31 07:15:27 1999 @@ -0,0 +1,19 @@ +IPv6 Support Patch for lynx-2.8.1 +================================= + + This program has been modified to support IPv6. It's my first port +to IPv6 so you'll probably find lots of bugs. (for example, ftp is +not working) + + I'm submitting this patch to the lynx developers (it's probably not +going to be accepted, as it's so buggy) and to Craig Metz to be included +in the inner.net colection, but, for now, the "oficial" url is +http://www2.compendium.com.ar/~horape/lynx-ipv6.patch + + Horacio J. Peña (n.) + address@hidden + +History +======= + +1 Initial release. diff -urN lynx-2.8.1.orig/WWW/Library/Implementation/HTTCP.c lynx-2.8.1.ip6/WWW/Library/Implementation/HTTCP.c --- lynx-2.8.1.orig/WWW/Library/Implementation/HTTCP.c Sat Oct 24 13:49:07 1998 +++ lynx-2.8.1.ip6/WWW/Library/Implementation/HTTCP.c Wed Mar 31 06:09:04 1999 @@ -299,6 +299,9 @@ PUBLIC CONST char * HTInetString ARGS1( SockA*, soc_in) { +#ifdef INET6 + return "Some IPv6 address"; +#else static char string[16]; sprintf(string, "%d.%d.%d.%d", (int)*((unsigned char *)(&soc_in->sin_addr)+0), @@ -306,6 +309,7 @@ (int)*((unsigned char *)(&soc_in->sin_addr)+2), (int)*((unsigned char *)(&soc_in->sin_addr)+3)); return string; +#endif } #endif /* !DECNET */ @@ -334,16 +338,29 @@ ** *soc_in is filled in. If no port is specified in str, that ** field is left unchanged in *soc_in. */ -PUBLIC int HTParseInet ARGS2( +#ifdef INET6 +PUBLIC int HTParseInet ARGS3( + SockA **, soc_in, + CONST char *, str, + int, def_port) +#else +PUBLIC int HTParseInet ARGS3( SockA *, soc_in, - CONST char *, str) + CONST char *, str, + int, def_port) +#endif { char *port; int dotcount_ip = 0; /* for dotted decimal IP addr */ #ifndef _WINDOWS_NSL char *host = NULL; #endif /* _WINDOWS_NSL */ +#ifdef INET6 + char dport[6]; + snprintf(dport,6,"%d",def_port); +#endif + if (!str) { CTRACE(tfp, "HTParseInet: Can't parse `NULL'.\n"); return -1; @@ -361,9 +378,13 @@ /* ** Parse port number if present. */ +#ifndef INET6 + soc_in->sin_port = htons(def_port); +#endif /* !INET6 */ if ((port = strchr(host, ':')) != NULL) { *port++ = 0; /* Chop off port */ if (port[0] >= '0' && port[0] <= '9') { +#ifndef INET6 #ifdef unix soc_in->sin_port = htons(atol(port)); #else /* VMS: */ @@ -382,8 +403,16 @@ CTRACE(tfp, "TCP: Unknown service %s\n", port); } #endif /* SUPPRESS */ - } - } +#else /* !INET6 */ + } else { + port = NULL; +#endif /* !INET6 */ + } + } +#ifdef INET6 +if (port == NULL) + port = dport; +#endif #ifdef DECNET /* @@ -396,6 +425,7 @@ soc_in->sdn_objnum, host); #else /* parse Internet host: */ +#ifndef INET6 if (*host >= '0' && *host <= '9') { /* Test for numeric node address: */ char *strptr = host; while (*strptr) { @@ -432,12 +462,15 @@ #ifndef _WINDOWS_NSL FREE(host); #endif /* _WINDOWS_NSL */ - } else { /* Alphanumeric node name: */ + } else +#endif /* !INET6 */ + { /* Alphanumeric node name: */ #ifdef MVS /* Outstanding problem with crash in MVS gethostbyname */ CTRACE(tfp, "HTParseInet: Calling gethostbyname(%s)\n", host); #endif /* MVS */ #ifdef NSL_FORK +#error "NSL_FORK doesn't work with IPv6 yet" /* ** Start block for fork-based gethostbyname() with ** checks for interrupts. - Tom Zerucha (address@hidden) & FM @@ -680,6 +713,16 @@ memcpy((void *)&soc_in->sin_addr, phost->h_addr, phost->h_length); #else /* !NSL_FORK, !DJGPP, !_WINDOWS_NSL: */ { +#ifdef INET6 + SockA hints; + + bzero(&hints, sizeof(SockA)); + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + + if(getaddrinfo(host, port, &hints, soc_in) !=0) goto failed; + +#else /* INET6 */ struct hostent *phost; phost = gethostbyname(host); /* See netdb.h */ #ifdef MVS @@ -699,6 +742,7 @@ #else memcpy((void *)&soc_in->sin_addr, phost->h_addr, phost->h_length); #endif /* VMS && CMU_TCP */ +#endif /* INET6 */ } #endif /* !NSL_FORK, !DJGPP, !_WINDOWS_NSL */ #endif /* !NSL_FORK, !DJGPP */ @@ -709,12 +753,14 @@ } +#ifndef INET6 CTRACE(tfp, "HTParseInet: Parsed address as port %d, IP address %d.%d.%d.%d\n", (int)ntohs(soc_in->sin_port), (int)*((unsigned char *)(&soc_in->sin_addr)+0), (int)*((unsigned char *)(&soc_in->sin_addr)+1), (int)*((unsigned char *)(&soc_in->sin_addr)+2), (int)*((unsigned char *)(&soc_in->sin_addr)+3)); +#endif /* INET6 */ #endif /* Internet vs. Decnet */ return 0; /* OK */ @@ -810,8 +856,13 @@ int, default_port, int *, s) { +#ifdef INET6 + SockA *res, *ressave; +#else struct sockaddr_in soc_address; struct sockaddr_in *soc_in = &soc_address; +#endif + int status; char *line = NULL; char *p1 = NULL; @@ -821,9 +872,10 @@ /* ** Set up defaults. */ +#ifndef INET6 memset(soc_in, 0, sizeof(*soc_in)); soc_in->sin_family = AF_INET; - soc_in->sin_port = htons(default_port); +#endif /* ** Get node name and optional port number. @@ -844,7 +896,12 @@ outofmem(__FILE__, "HTDoConnect"); sprintf (line, "Looking up %s.", host); _HTProgress (line); - status = HTParseInet(soc_in, host); +#ifdef INET6 + status = HTParseInet(&res, host, default_port); + ressave = res; +#else + status = HTParseInet(soc_in, host, default_port); +#endif if (status) { if (status != HT_INTERRUPTED) { sprintf (line, "Unable to locate remote host %s.", host); @@ -860,14 +917,26 @@ _HTProgress (line); FREE(host); +/* INET6: Aquí tiene que empezar el for... el #if llega hasta el fin de + la función. */ +#ifdef INET6 +do { +#endif /* ** Now, let's get a socket set up from the server for the data. */ +#ifdef INET6 + *s = socket(res->ai_family, res->ai_socktype, + res->ai_protocol); + if (*s < 0) { + continue; +#else *s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (*s == -1) { HTAlert("socket failed."); FREE(line); return HT_NO_DATA; +#endif /* INET6 */ } #ifndef DOSPATH @@ -905,7 +974,13 @@ socks_bind_remoteAddr = soc_address.sin_addr.s_addr; } else #endif /* SOCKS */ + +#ifdef INET6 + status = connect(*s, res->ai_addr, res->ai_addrlen); +#else status = connect(*s, (struct sockaddr*)&soc_address, sizeof(soc_address)); +#endif + #ifndef DJGPP /* ** According to the Sun man page for connect: @@ -939,9 +1014,13 @@ ** Protect against an infinite loop. */ if (tries++ >= 180000) { +#ifdef INET6 + break; +#else HTAlert("Connection failed for 180,000 tries."); FREE(line); return HT_NO_DATA; +#endif /* INET6 */ } #ifdef _WINDOWS_NSL @@ -991,8 +1070,13 @@ status = 0; } else { #endif /* SOCKS */ +#ifdef INET6 + status = connect(*s, res->ai_addr, res->ai_addrlen); +#else status = connect(*s, (struct sockaddr*)&soc_address, - sizeof(soc_address)); + sizeof(soc_address)); +#endif + #ifdef UCX /* ** A UCX feature: Instead of returning EISCONN @@ -1034,8 +1118,12 @@ ** For some reason, UCX pre 3 apparently returns ** errno = 18242 instead the EALREADY or EISCONN. */ +#ifdef INET6 + status = connect(*s, res->ai_addr, res->ai_addrlen); +#else status = connect(*s, (struct sockaddr*)&soc_address, - sizeof(soc_address)); + sizeof(soc_address)); +#endif if ((status < 0) && (SOCKET_ERRNO != EALREADY && SOCKET_ERRNO != EAGAIN) && #ifdef UCX @@ -1060,6 +1148,9 @@ ** so close up the socket. */ NETCLOSE(*s); +#ifdef INET6 + continue; +#endif } #ifndef DOSPATH #if !defined(NO_IOCTL) || defined(USE_FCNTL) @@ -1075,9 +1166,15 @@ #endif /* USE_FCNTL */ if (ret == -1) _HTProgress("Could not restore socket to blocking."); +#ifdef INET6 + break; +#endif /* INET6 */ } #endif /* !NO_IOCTL || USE_FCNTL */ #endif /* !DOSPATH */ +#ifdef INET6 + } while ( res = res->ai_next ); +#endif /* ! INET6 */ FREE(line); return status; diff -urN lynx-2.8.1.orig/WWW/Library/Implementation/HTTCP.h lynx-2.8.1.ip6/WWW/Library/Implementation/HTTCP.h --- lynx-2.8.1.orig/WWW/Library/Implementation/HTTCP.h Thu Aug 6 09:28:22 1998 +++ lynx-2.8.1.ip6/WWW/Library/Implementation/HTTCP.h Wed Mar 31 05:13:04 1999 @@ -25,7 +25,7 @@ */ #ifndef _WINDOWS #ifdef __STDC__ - extern const char * HTInetString(struct sockaddr_in* mysin); + extern const char * HTInetString(SockA *mysin); #else extern char * HTInetString(); #endif @@ -87,8 +87,13 @@ ** field is left unchanged in *sin. */ #ifdef __STDC__ - extern int HTParseInet(struct sockaddr_in * mysin, CONST char * str); +#ifdef INET6 + extern int HTParseInet(SockA ** mysin, CONST char * str, int port); /*!! had to change this to get it to compile. CTB */ +#else + extern int HTParseInet(SockA * mysin, CONST char * str, int port); + /*!! had to change this to get it to compile. CTB */ +#endif #else extern int HTParseInet(); #endif diff -urN lynx-2.8.1.orig/WWW/Library/Implementation/tcp.h lynx-2.8.1.ip6/WWW/Library/Implementation/tcp.h --- lynx-2.8.1.orig/WWW/Library/Implementation/tcp.h Sat Oct 24 13:49:07 1998 +++ lynx-2.8.1.ip6/WWW/Library/Implementation/tcp.h Wed Mar 31 03:19:05 1999 @@ -53,7 +53,11 @@ #define GOT_PIPE #endif /* unix */ +#ifdef INET6 +typedef struct addrinfo SockA; +#else typedef struct sockaddr_in SockA; /* See netinet/in.h */ +#endif #ifndef VMS #include diff -urN lynx-2.8.1.orig/src/LYMain.c lynx-2.8.1.ip6/src/LYMain.c --- lynx-2.8.1.orig/src/LYMain.c Sat Oct 24 13:49:07 1998 +++ lynx-2.8.1.ip6/src/LYMain.c Wed Mar 31 06:22:41 1999 @@ -690,6 +690,9 @@ StrAllocCat(LYUserAgent, HTLibraryVersion); } StrAllocCopy(LYUserAgentDefault, LYUserAgent); +#ifdef INET6 + StrAllocCat(LYUserAgent, " +IPv6/1"); +#endif #ifdef VMS Define_VMSLogical("LYNX_VERSION", LYNX_VERSION); #else diff -urN lynx-2.8.1.orig/src/LYUtils.c lynx-2.8.1.ip6/src/LYUtils.c --- lynx-2.8.1.orig/src/LYUtils.c Sat Oct 24 13:49:07 1998 +++ lynx-2.8.1.ip6/src/LYUtils.c Wed Mar 31 04:39:36 1999 @@ -4223,8 +4223,7 @@ fprintf(stdout, "Looking up '%s' first.\n", host); } #ifndef DJGPP - sock.sin_port = htons(80); - if ((hoststat = HTParseInet(&sock, host)) == 0) + if ((hoststat = HTParseInet(&sock, host, 80)) == 0) #else if (resolve(host) != 0) #endif /* DJGPP */ @@ -4345,8 +4344,7 @@ fprintf(stdout, "Looking up '%s', guessing...\n", host); } #ifndef DJGPP - sock.sin_port = htons(80); - GotHost = ((hoststat = HTParseInet(&sock, host)) == 0); + GotHost = ((hoststat = HTParseInet(&sock, host, 80)) == 0); #else GotHost = (resolve(host) != 0); #endif /* DJGPP */