Re: compile failed with 'HAVE_IPv6' opened under Mingw32/Win7

honglei jiang <[email protected]>
Newsgroups gmane.comp.web.polipo.user
Message-ID <CAKLLBfA-bsgGCfR6M+7VdS5vL+BR+0vFStictDwPnVQE_TbO2A@mail.gmail.com>
Hi,
      I've pasted the diff as an  attached files. I compiled it under
Mingw/Win7 SP1
        Mingw Version: http://nuwen.net/files/mingw/mingw-7.2.exe
    Now runing it directly without any arguments as an http proxy, i
can visit both ipv6-only sites and ipv4 sites.  The following error
will appear.

DNS: couldn't open /etc/resolv.conf: No such file or director
Disabling disk cache: path ./polipo/ is not absolute.
Disabling local tree: path is not absolute.
Established listening socket on port 8123.
DNS: recv failed: No error
Falling back to using system resolver.
DNS: recv failed: Unknown error
DNS: recv failed: No error
Falling back to using system resolver.
DNS: recv failed: Unknown error
DNS: recv failed: No error
Falling back to using system resolver.
DNS: recv failed: Unknown error
Falling back to using system resolver.
DNS: recv failed: Unknown error
Falling back to using system resolver.
DNS: recv failed: Unknown error
Falling back to using system resolver.
DNS: recv failed: Unknown error
Falling back to using system resolver.
DNS: recv failed: Unknown error
DNS: recv failed: Unknown error
DNS: recv failed: Unknown error
DNS: recv failed: Unknown error
DNS: recv failed: Unknown error
DNS: recv failed: No error
Falling back to using system resolver.
DNS: recv failed: Unknown error
DNS: recv failed: Unknown error
Falling back to using system resolver.
DNS: recv failed: Unknown error
DNS: recv failed: No error
Falling back to using system resolver.
DNS: recv failed: Unknown error
Couldn't read from server: Unknown error
Couldn't read from server: Unknown error
Couldn't write to server: Unknown error
DNS: recv failed: No error
Falling back to using system resolver.
DNS: recv failed: Unknown error
DNS: recv failed: No error
Falling back to using system resolver.
DNS: recv failed: Unknown error
Couldn't read from server: Unknown error
Couldn't write to server: Unknown error
Couldn't read from server: Unknown error
Couldn't write to server: Unknown error
DNS: recv failed: Unknown error
Falling back to using system resolver.
DNS: recv failed: Unknown error
Read from server failed: Unknown error
Read from server failed: Unknown error
-----------------
just visit site is OK,but i cann't send this email by polipo, it met
the following errors:

Read from server failed: Unknown error
Read from server failed: Unknown error
Couldn't write to server: Unknown error
Couldn't read from server: Unknown error
Couldn't read from client: Unknown error
Couldn't read from client: Unknown error



On Tue, Sep 6, 2011 at 7:48 PM, honglei jiang <[email protected]> wrote:
> Dear everyone:
>      I met the following error when add 'EXTRA_DEFINES = -DWIN32
> -DHAVE_IPv6' to Makefile.
> F:\Python\LibEvent\Proxy\polipo>make
> cc  -Os -g -Wall -fno-strict-aliasing -DLOCAL_ROOT=\"./www/\"
> -DDISK_CACHE_ROOT=\"./polipo/\"  -DWIN32 -DHAVE_IPv6   -c -o util.o
> util.c
> cc  -Os -g -Wall -fno-strict-aliasing -DLOCAL_ROOT=\"./www/\"
> -DDISK_CACHE_ROOT=\"./polipo/\"  -DWIN32 -DHAVE_IPv6   -c -o event.o
> event.c
> cc  -Os -g -Wall -fno-strict-aliasing -DLOCAL_ROOT=\"./www/\"
> -DDISK_CACHE_ROOT=\"./polipo/\"  -DWIN32 -DHAVE_IPv6   -c -o io.o io.c
> io.c: In function 'do_scheduled_connect':
> io.c:517:25: error: storage size of 'servaddr6' isn't known
> io.c:582:58: error: invalid application of 'sizeof' to incomplete type 'struct i
> n6_addr'
> io.c:517:25: warning: unused variable 'servaddr6' [-Wunused-variable]
> io.c: In function 'do_scheduled_accept':
> io.c:674:10: warning: pointer targets in passing argument 3 of 'win32_accept' di
> ffer in signedness [-Wpointer-sign]
> mingw.h:109:9: note: expected 'socklen_t *' but argument is of type 'unsigned in
> t *'
> io.c: In function 'create_listener':
> io.c:694:25: error: storage size of 'addr6' isn't known
> io.c:737:9: warning: implicit declaration of function 'inet_pton' [-Wimplicit-fu
> nction-declaration]
> io.c:694:25: warning: unused variable 'addr6' [-Wunused-variable]
> io.c: In function 'parseNetAddress':
> io.c:955:21: error: storage size of 'ina6' isn't known
> io.c:955:21: warning: unused variable 'ina6' [-Wunused-variable]
> io.c: In function 'netAddressMatch':
> io.c:1103:25: error: storage size of 'sain6' isn't known
> io.c:1107:10: warning: pointer targets in passing argument 3 of 'win32_getpeerna
> me' differ in signedness [-Wpointer-sign]
> mingw.h:111:9: note: expected 'socklen_t *' but argument is of type 'unsigned in
> t *'
> io.c:1118:14: warning: pointer targets in passing argument 3 of 'win32_getpeerna
> me' differ in signedness [-Wpointer-sign]
> mingw.h:111:9: note: expected 'socklen_t *' but argument is of type 'unsigned in
> t *'
> io.c:1103:25: warning: unused variable 'sain6' [-Wunused-variable]
> make: *** [io.o] Error 1
>

------------------------------------------------------------------------------
Using storage to extend the benefits of virtualization and iSCSI
Virtualization increases hardware utilization and delivers a new level of
agility. Learn what those decisions are and how to modernize your storage 
and backup environments for virtualization.
http://www.accelacomm.com/jaw/sfnl/114/51434361/

_______________________________________________
Polipo-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/polipo-users
ipv6_mingw.diff (application/octet-stream, 5.4 KB)
Author: Honglei Jiang<[email protected]>  2011-09-07 09:17:21
Committer: Honglei Jiang<[email protected]>  2011-09-07 09:17:21
Parent: fa77e60bef02ba624fb573723ef95aa183ba8926 (Tweak INSTALL.)
Branch: master
Follows: polipo-20091115
Precedes: 

    add support for IPv6 under Mingw.
    
    Signed-off-by: Honglei <[email protected]>

---------------------------------- .gitignore ----------------------------------
index d0d22d9..bf0f488 100644
@@ -1,3 +1,6 @@
 polipo
 core
 *.o
+*.exe
+.cproject
+.project

----------------------------------- Makefile -----------------------------------
index 17b9fdb..a6c84fe 100644
@@ -1,9 +1,9 @@
-PREFIX = /usr/local
+PREFIX = .
 BINDIR = $(PREFIX)/bin
 MANDIR = $(PREFIX)/man
 INFODIR = $(PREFIX)/info
-LOCAL_ROOT = /usr/share/polipo/www
-DISK_CACHE_ROOT = /var/cache/polipo
+LOCAL_ROOT = ./www
+DISK_CACHE_ROOT = ./polipo
 
 # To compile with Unix CC:
 
@@ -35,8 +35,9 @@ CDEBUGFLAGS = -Os -g -Wall -fno-strict-aliasing
 
 # On mingw, you need
 
-# EXE=.exe
-# LDLIBS = -lwsock32
+EXE=.exe
+EXTRA_DEFINES = -DWIN32 -DHAVE_IPv6 -DWINVER=0x0601
+LDLIBS = -lws2_32 -lwsock32
 
 FILE_DEFINES = -DLOCAL_ROOT=\"$(LOCAL_ROOT)/\" \
                -DDISK_CACHE_ROOT=\"$(DISK_CACHE_ROOT)/\"
@@ -60,6 +61,8 @@ FILE_DEFINES = -DLOCAL_ROOT=\"$(LOCAL_ROOT)/\" \
 
 DEFINES = $(FILE_DEFINES) $(PLATFORM_DEFINES)
 
+
+
 CFLAGS = $(MD5INCLUDES) $(CDEBUGFLAGS) $(DEFINES) $(EXTRA_DEFINES)
 
 SRCS = util.c event.c io.c chunk.c atom.c object.c log.c diskcache.c main.c \

------------------------------------ dns.c ------------------------------------
index 06103e0..6cbca79 100644
@@ -194,7 +194,7 @@ preinitDns()
             do_log_error(L_WARN, errno, "DNS: couldn't create socket");
         }
     } else {
-        close(fd);
+        CLOSE(fd);
     }
 #endif
 
@@ -532,16 +532,20 @@ really_do_gethostbyname(AtomPtr name, ObjectPtr object)
 #ifdef EAI_NONAME
     case EAI_NONAME:
 #endif
+#ifndef WIN32:
 #ifdef EAI_NODATA
     case EAI_NODATA:
 #endif
+#endif
         error = EDNS_NO_ADDRESS; break;
     case EAI_FAIL: error = EDNS_NO_RECOVERY; break;
     case EAI_AGAIN: error = EDNS_TRY_AGAIN; break;
 #ifdef EAI_MEMORY
     case EAI_MEMORY: error = ENOMEM; break;
 #endif
+#ifndef WIN32:
     case EAI_SYSTEM: error = errno; break;
+#endif
     default: error = EUNKNOWN;
     }
 

----------------------------------- mingw.h -----------------------------------
index 4b2ec77..8e1403a 100644
@@ -40,14 +40,16 @@ THE SOFTWARE.
 /* At time of writing, a fair bit of stuff doesn't work under Mingw.
  * Hopefully they will be fixed later (especially the disk-cache).
  */
-#define NO_IPv6 1
+/*#define NO_IPv6 1 */
 
 #include <io.h>
 
 #define S_IROTH S_IREAD
 
 /* Pull in winsock.h for (almost) berkeley sockets. */
-#include <winsock.h>
+#include <winsock2.h>
+#include <ws2tcpip.h>
+/*#include <Wspiapi.h>*/
 #define ENOTCONN        WSAENOTCONN
 #define EWOULDBLOCK     WSAEWOULDBLOCK
 #define ENOBUFS         WSAENOBUFS
@@ -63,19 +65,50 @@ THE SOFTWARE.
  * are copied from linux man pages. A poll() macro is defined to
  * call the version in mingw.c.
  */
+#ifdef __MINGW32__
 #define POLLIN      0x0001    /* There is data to read */
 #define POLLPRI     0x0002    /* There is urgent data to read */
 #define POLLOUT     0x0004    /* Writing now will not block */
 #define POLLERR     0x0008    /* Error condition */
 #define POLLHUP     0x0010    /* Hung up */
 #define POLLNVAL    0x0020    /* Invalid request: fd not open */
+
 struct pollfd {
-    SOCKET fd;        /* file descriptor */
-    short events;     /* requested events */
-    short revents;    /* returned events */
+	SOCKET fd;        /* file descriptor */
+	short events;     /* requested events */
+	short revents;    /* returned events */
 };
+#endif
 #define poll(x, y, z)        win32_poll(x, y, z)
 
+#ifdef __MINGW32__
+
+typedef USHORT ADDRESS_FAMILY;
+static int
+inet_pton( int family, const char * addr, void * dst )
+	{
+	struct sockaddr_storage ss;
+	int sslen = sizeof( ss );
+
+	ZeroMemory( &ss, sizeof( ss ) );
+	ss.ss_family = (ADDRESS_FAMILY)family;
+
+	if ( WSAStringToAddressA( (LPSTR)addr, family, NULL, ( struct sockaddr* ) &ss, &sslen ) == 0 )
+		{
+		if ( family == AF_INET ) { memcpy( dst, &( ( struct sockaddr_in* ) &ss)->sin_addr, sizeof( IN_ADDR ) ); return 1; }
+		else if ( family == AF_INET6 ) { memcpy( dst, &( ( struct sockaddr_in6* ) &ss)->sin6_addr, sizeof( IN6_ADDR ) ); return 1; }
+		else return 0;
+		}
+	else return 0;
+	}
+
+#endif
+
+
+
+struct in6_addr sin6;
+
+
 /* These wrappers do nothing special except set the global errno variable if
  * an error occurs (winsock doesn't do this by default). They set errno
  * to unix-like values (i.e. WSAEWOULDBLOCK is mapped to EAGAIN), so code

----------------------------------- tunnel.c -----------------------------------
index ddb9edf..38a9240 100644
@@ -170,7 +170,7 @@ do_tunnel(int fd, char *buf, int offset, int len, AtomPtr url)
         return;
     }
     tunnel->port = port;
-    
+#ifndef NO_FORBIDDEN
     if (tunnelIsMatched(url->string, url->length, 
 			tunnel->hostname->string, tunnel->hostname->length)) {
         releaseAtom(url);
@@ -178,6 +178,7 @@ do_tunnel(int fd, char *buf, int offset, int len, AtomPtr url)
 	logTunnel(tunnel,1);
         return;
     }
+#endif
     
     logTunnel(tunnel,0);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.