In terms of network related functionality, rely on Winsock definitions
as much as possible: * dtable.cc: Drop including sys/socket.h. * fhandler_procnet.cc: Change includes accordingly. * fhandler_socket.cc: Ditto. (fhandler_socket::listen): Avoid gcc error message initializing sin6. (LPFN_WSARECVMSG): Only define when building against w32api headers. * net.cc: Change includes accordingly. Define USE_SYS_TYPES_FD_SET and __WSA_ERR_MACROS_DEFINED. Define _INC_NETIOAPI temporarily and explain why. (struct _IP_ADAPTER_UNICAST_ADDRESS_LH): Only define when building against w32api headers. (struct _IP_ADAPTER_ADDRESSES_LH): Ditto. (SIO_GET_INTERFACE_LIST): Ditto. (ws_freeaddrinfo): Rename from freeaddrinfo so as not to collide with Winsock declaration. Change througout. (ws_getaddrinfo): Ditto. (ws_getnameinfo): Ditto. * select.cc: Include netdb.h after defining USE_SYS_TYPES_FD_SET. * syslog.cc: Drop including netinet/in.h. Define USE_SYS_TYPES_FD_SET and include ws2tcpip.h. * include/netdb.h (struct addrinfo): Don't define when building Cygwin. * include/cygwin/if.h: Don't declare if_xxx functions when building Cygwin. * include/cygwin/in.h: Disable most definitions when building Cygwin. * include/cygwin/socket.h: Disable sockaddr and sockaddr_storage definitions when building Cygwin. Same for MCAST_INCLUDE/MCAST_EXCLUDE. * libc/inet_addr.c: Don't define __INSIDE_CYGWIN__ nor __INSIDE_CYGWIN_NET__. * libc/inet_network.c: Ditto. * libc/minires.h: Drop redundant inclusion of netdb.h. Define __INSIDE_CYGWIN_NET__ only before including netdb.h and resolver headers.
This commit is contained in:
		| @@ -1,3 +1,39 @@ | |||||||
|  | 2012-07-06  Corinna Vinschen  <corinna@vinschen.de> | ||||||
|  |  | ||||||
|  | 	In terms of network related functionality, rely on Winsock definitions | ||||||
|  | 	as much as possible: | ||||||
|  | 	* dtable.cc: Drop including sys/socket.h. | ||||||
|  | 	* fhandler_procnet.cc: Change includes accordingly. | ||||||
|  | 	* fhandler_socket.cc: Ditto. | ||||||
|  | 	(fhandler_socket::listen): Avoid gcc error message initializing sin6. | ||||||
|  | 	(LPFN_WSARECVMSG): Only define when building against w32api headers. | ||||||
|  | 	* net.cc: Change includes accordingly.  Define USE_SYS_TYPES_FD_SET | ||||||
|  | 	and __WSA_ERR_MACROS_DEFINED.  Define _INC_NETIOAPI temporarily and | ||||||
|  | 	explain why. | ||||||
|  | 	(struct _IP_ADAPTER_UNICAST_ADDRESS_LH): Only define when building | ||||||
|  | 	against w32api headers. | ||||||
|  | 	(struct _IP_ADAPTER_ADDRESSES_LH): Ditto. | ||||||
|  | 	(SIO_GET_INTERFACE_LIST): Ditto. | ||||||
|  | 	(ws_freeaddrinfo): Rename from freeaddrinfo so as not to collide with | ||||||
|  | 	Winsock declaration.  Change througout. | ||||||
|  | 	(ws_getaddrinfo): Ditto. | ||||||
|  | 	(ws_getnameinfo): Ditto. | ||||||
|  | 	* select.cc: Include netdb.h after defining USE_SYS_TYPES_FD_SET. | ||||||
|  | 	* syslog.cc: Drop including netinet/in.h.  Define USE_SYS_TYPES_FD_SET | ||||||
|  | 	and include ws2tcpip.h. | ||||||
|  | 	* include/netdb.h (struct addrinfo): Don't define when building Cygwin. | ||||||
|  | 	* include/cygwin/if.h: Don't declare if_xxx functions when building | ||||||
|  | 	Cygwin. | ||||||
|  | 	* include/cygwin/in.h: Disable most definitions when building Cygwin. | ||||||
|  | 	* include/cygwin/socket.h: Disable sockaddr and sockaddr_storage | ||||||
|  | 	definitions when building Cygwin.  Same for MCAST_INCLUDE/MCAST_EXCLUDE. | ||||||
|  | 	* libc/inet_addr.c: Don't define __INSIDE_CYGWIN__ nor | ||||||
|  | 	__INSIDE_CYGWIN_NET__. | ||||||
|  | 	* libc/inet_network.c: Ditto. | ||||||
|  | 	* libc/minires.h: Drop redundant inclusion of netdb.h.  Define | ||||||
|  | 	__INSIDE_CYGWIN_NET__ only before including netdb.h and resolver | ||||||
|  | 	headers. | ||||||
|  |  | ||||||
| 2012-07-06  Corinna Vinschen  <corinna@vinschen.de> | 2012-07-06  Corinna Vinschen  <corinna@vinschen.de> | ||||||
|  |  | ||||||
| 	* winbase.h: Throughout use LONG rather than long type to prepare for | 	* winbase.h: Throughout use LONG rather than long type to prepare for | ||||||
|   | |||||||
| @@ -12,7 +12,6 @@ details. */ | |||||||
| #define  __INSIDE_CYGWIN_NET__ | #define  __INSIDE_CYGWIN_NET__ | ||||||
|  |  | ||||||
| #include "winsup.h" | #include "winsup.h" | ||||||
| #include <sys/socket.h> |  | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ Cygwin license.  Please consult the file "CYGWIN_LICENSE" for | |||||||
| details. */ | details. */ | ||||||
|  |  | ||||||
| #define  __INSIDE_CYGWIN_NET__ | #define  __INSIDE_CYGWIN_NET__ | ||||||
|  | #define USE_SYS_TYPES_FD_SET | ||||||
| #include "winsup.h" | #include "winsup.h" | ||||||
| #include "cygerrno.h" | #include "cygerrno.h" | ||||||
| #include "security.h" | #include "security.h" | ||||||
| @@ -18,13 +18,9 @@ details. */ | |||||||
| #include "fhandler_virtual.h" | #include "fhandler_virtual.h" | ||||||
| #include "dtable.h" | #include "dtable.h" | ||||||
| #include "cygheap.h" | #include "cygheap.h" | ||||||
|  | #include <ws2tcpip.h> | ||||||
| #include <netdb.h> |  | ||||||
| #define USE_SYS_TYPES_FD_SET |  | ||||||
| #include <winsock2.h> |  | ||||||
| #include <iphlpapi.h> | #include <iphlpapi.h> | ||||||
| #include <asm/byteorder.h> | #include <asm/byteorder.h> | ||||||
| #include <cygwin/in6.h> |  | ||||||
|  |  | ||||||
| #define _COMPILING_NEWLIB | #define _COMPILING_NEWLIB | ||||||
| #include <dirent.h> | #include <dirent.h> | ||||||
|   | |||||||
| @@ -12,24 +12,21 @@ | |||||||
| /* #define DEBUG_NEST_ON 1 */ | /* #define DEBUG_NEST_ON 1 */ | ||||||
|  |  | ||||||
| #define  __INSIDE_CYGWIN_NET__ | #define  __INSIDE_CYGWIN_NET__ | ||||||
|  | #define USE_SYS_TYPES_FD_SET | ||||||
|  |  | ||||||
| #include "winsup.h" | #include "winsup.h" | ||||||
| #include <sys/un.h> |  | ||||||
| #include <asm/byteorder.h> |  | ||||||
|  |  | ||||||
| #include <stdlib.h> |  | ||||||
| #define USE_SYS_TYPES_FD_SET |  | ||||||
| #include <winsock2.h> |  | ||||||
| #include <mswsock.h> |  | ||||||
| #include <iphlpapi.h> |  | ||||||
| #include "cygerrno.h" | #include "cygerrno.h" | ||||||
| #include "security.h" | #include "security.h" | ||||||
| #include "cygwin/version.h" |  | ||||||
| #include "perprocess.h" |  | ||||||
| #include "path.h" | #include "path.h" | ||||||
| #include "fhandler.h" | #include "fhandler.h" | ||||||
| #include "dtable.h" | #include "dtable.h" | ||||||
| #include "cygheap.h" | #include "cygheap.h" | ||||||
|  | #include <ws2tcpip.h> | ||||||
|  | #include <mswsock.h> | ||||||
|  | #include <iphlpapi.h> | ||||||
|  | #include <asm/byteorder.h> | ||||||
|  | #include "cygwin/version.h" | ||||||
|  | #include "perprocess.h" | ||||||
| #include "shared_info.h" | #include "shared_info.h" | ||||||
| #include "sigproc.h" | #include "sigproc.h" | ||||||
| #include "wininfo.h" | #include "wininfo.h" | ||||||
| @@ -37,7 +34,7 @@ | |||||||
| #include <sys/param.h> | #include <sys/param.h> | ||||||
| #include <sys/acl.h> | #include <sys/acl.h> | ||||||
| #include "cygtls.h" | #include "cygtls.h" | ||||||
| #include "cygwin/in6.h" | #include <sys/un.h> | ||||||
| #include "ntdll.h" | #include "ntdll.h" | ||||||
| #include "miscfuncs.h" | #include "miscfuncs.h" | ||||||
|  |  | ||||||
| @@ -1129,14 +1126,9 @@ fhandler_socket::listen (int backlog) | |||||||
| 	} | 	} | ||||||
|       else if (get_addr_family () == AF_INET6) |       else if (get_addr_family () == AF_INET6) | ||||||
| 	{ | 	{ | ||||||
| 	  struct sockaddr_in6 sin6 = | 	  struct sockaddr_in6 sin6; | ||||||
| 	    { | 	  memset (&sin6, 0, sizeof sin6); | ||||||
| 	      sin6_family: AF_INET6, | 	  sin6.sin6_family = AF_INET6; | ||||||
| 	      sin6_port: 0, |  | ||||||
| 	      sin6_flowinfo: 0, |  | ||||||
| 	      sin6_addr: {{IN6ADDR_ANY_INIT}}, |  | ||||||
| 	      sin6_scope_id: 0 |  | ||||||
| 	    }; |  | ||||||
| 	  if (!::bind (get_socket (), (struct sockaddr *) &sin6, sizeof sin6)) | 	  if (!::bind (get_socket (), (struct sockaddr *) &sin6, sizeof sin6)) | ||||||
| 	    res = ::listen (get_socket (), backlog); | 	    res = ::listen (get_socket (), backlog); | ||||||
| 	} | 	} | ||||||
| @@ -1359,10 +1351,12 @@ fhandler_socket::readv (const struct iovec *const iov, const int iovcnt, | |||||||
| } | } | ||||||
|  |  | ||||||
| extern "C" { | extern "C" { | ||||||
|  | #ifndef __MINGW64_VERSION_MAJOR | ||||||
| #define WSAID_WSARECVMSG \ | #define WSAID_WSARECVMSG \ | ||||||
| 	  {0xf689d7c8,0x6f1f,0x436b,{0x8a,0x53,0xe5,0x4f,0xe3,0x51,0xc3,0x22}}; | 	  {0xf689d7c8,0x6f1f,0x436b,{0x8a,0x53,0xe5,0x4f,0xe3,0x51,0xc3,0x22}}; | ||||||
| typedef int (WSAAPI *LPFN_WSARECVMSG)(SOCKET,LPWSAMSG,LPDWORD,LPWSAOVERLAPPED, | typedef int (WSAAPI *LPFN_WSARECVMSG)(SOCKET,LPWSAMSG,LPDWORD,LPWSAOVERLAPPED, | ||||||
| 				      LPWSAOVERLAPPED_COMPLETION_ROUTINE); | 				      LPWSAOVERLAPPED_COMPLETION_ROUTINE); | ||||||
|  | #endif | ||||||
| int WSAAPI WSASendMsg(SOCKET,LPWSAMSG,DWORD,LPDWORD, LPWSAOVERLAPPED, | int WSAAPI WSASendMsg(SOCKET,LPWSAMSG,DWORD,LPDWORD, LPWSAOVERLAPPED, | ||||||
| 		      LPWSAOVERLAPPED_COMPLETION_ROUTINE); | 		      LPWSAOVERLAPPED_COMPLETION_ROUTINE); | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -111,10 +111,12 @@ struct ifconf | |||||||
| #define ifc_buf ifc_ifcu.ifcu_buf               /* buffer address       */ | #define ifc_buf ifc_ifcu.ifcu_buf               /* buffer address       */ | ||||||
| #define ifc_req ifc_ifcu.ifcu_req               /* array of structures  */ | #define ifc_req ifc_ifcu.ifcu_req               /* array of structures  */ | ||||||
|  |  | ||||||
|  | #ifndef __INSIDE_CYGWIN_NET__ | ||||||
| extern unsigned             if_nametoindex (const char *); | extern unsigned             if_nametoindex (const char *); | ||||||
| extern char                *if_indextoname (unsigned, char *); | extern char                *if_indextoname (unsigned, char *); | ||||||
| extern struct if_nameindex *if_nameindex (void); | extern struct if_nameindex *if_nameindex (void); | ||||||
| extern void                 if_freenameindex (struct if_nameindex *); | extern void                 if_freenameindex (struct if_nameindex *); | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -23,6 +23,8 @@ | |||||||
| typedef uint16_t in_port_t; | typedef uint16_t in_port_t; | ||||||
| typedef uint32_t in_addr_t; | typedef uint32_t in_addr_t; | ||||||
|  |  | ||||||
|  | #ifndef __INSIDE_CYGWIN_NET__ | ||||||
|  |  | ||||||
| /* Standard well-defined IP protocols.  If you ever add one here, don't | /* Standard well-defined IP protocols.  If you ever add one here, don't | ||||||
|    forget to define it below. */ |    forget to define it below. */ | ||||||
| enum | enum | ||||||
| @@ -260,4 +262,6 @@ struct sockaddr_in | |||||||
| #ifdef AF_INET6 | #ifdef AF_INET6 | ||||||
| #include <cygwin/in6.h> | #include <cygwin/in6.h> | ||||||
| #endif | #endif | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #endif	/* _CYGWIN_IN_H */ | #endif	/* _CYGWIN_IN_H */ | ||||||
|   | |||||||
| @@ -26,6 +26,7 @@ typedef int socklen_t; | |||||||
|  |  | ||||||
| typedef uint16_t sa_family_t; | typedef uint16_t sa_family_t; | ||||||
|  |  | ||||||
|  | #ifndef __INSIDE_CYGWIN_NET__ | ||||||
| struct sockaddr { | struct sockaddr { | ||||||
|   sa_family_t		sa_family;	/* address family, AF_xxx	*/ |   sa_family_t		sa_family;	/* address family, AF_xxx	*/ | ||||||
|   char			sa_data[14];	/* 14 bytes of protocol address	*/ |   char			sa_data[14];	/* 14 bytes of protocol address	*/ | ||||||
| @@ -44,6 +45,7 @@ struct sockaddr_storage { | |||||||
|   int64_t		__ss_align; |   int64_t		__ss_align; | ||||||
|   char			_ss_pad2[_SS_PAD2SIZE]; |   char			_ss_pad2[_SS_PAD2SIZE]; | ||||||
| }; | }; | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #include <asm/socket.h>			/* arch-dependent defines	*/ | #include <asm/socket.h>			/* arch-dependent defines	*/ | ||||||
| #include <cygwin/sockios.h>		/* the SIOCxxx I/O controls	*/ | #include <cygwin/sockios.h>		/* the SIOCxxx I/O controls	*/ | ||||||
| @@ -269,8 +271,10 @@ struct OLD_msghdr | |||||||
| #define MCAST_JOIN_SOURCE_GROUP         45 | #define MCAST_JOIN_SOURCE_GROUP         45 | ||||||
| #define MCAST_LEAVE_SOURCE_GROUP        46 | #define MCAST_LEAVE_SOURCE_GROUP        46 | ||||||
|  |  | ||||||
|  | #ifndef __INSIDE_CYGWIN_NET__ | ||||||
| #define MCAST_INCLUDE                    0 | #define MCAST_INCLUDE                    0 | ||||||
| #define MCAST_EXCLUDE                    1 | #define MCAST_EXCLUDE                    1 | ||||||
|  | #endif | ||||||
|  |  | ||||||
| /* Old WinSock1 values, needed internally */ | /* Old WinSock1 values, needed internally */ | ||||||
| #ifdef __INSIDE_CYGWIN__ | #ifdef __INSIDE_CYGWIN__ | ||||||
|   | |||||||
| @@ -117,6 +117,7 @@ struct rpcent { | |||||||
| 	int	r_number;	/* rpc program number */ | 	int	r_number;	/* rpc program number */ | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | #ifndef __INSIDE_CYGWIN_NET__ | ||||||
| struct addrinfo { | struct addrinfo { | ||||||
|   int             ai_flags;		/* input flags */ |   int             ai_flags;		/* input flags */ | ||||||
|   int             ai_family;		/* address family of socket */ |   int             ai_family;		/* address family of socket */ | ||||||
| @@ -127,6 +128,7 @@ struct addrinfo { | |||||||
|   struct sockaddr *ai_addr;		/* socket address of socket */ |   struct sockaddr *ai_addr;		/* socket address of socket */ | ||||||
|   struct addrinfo *ai_next;		/* pointer to next in list */ |   struct addrinfo *ai_next;		/* pointer to next in list */ | ||||||
| }; | }; | ||||||
|  | #endif | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * Error return codes from gethostbyname() and gethostbyaddr() |  * Error return codes from gethostbyname() and gethostbyaddr() | ||||||
|   | |||||||
| @@ -72,8 +72,7 @@ static const char rcsid[] = "$Id$"; | |||||||
| #ifndef __CYGWIN__ | #ifndef __CYGWIN__ | ||||||
| __FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||||
| #else | #else | ||||||
| #define __INSIDE_CYGWIN__ | #include "winsup.h" | ||||||
| #define  __INSIDE_CYGWIN_NET__ |  | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #ifndef __CYGWIN__ | #ifndef __CYGWIN__ | ||||||
|   | |||||||
| @@ -34,8 +34,7 @@ static const char sccsid[] = "@(#)inet_network.c	8.1 (Berkeley) 6/4/93"; | |||||||
| #ifndef __CYGWIN__ | #ifndef __CYGWIN__ | ||||||
| __FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||||
| #else | #else | ||||||
| #define __INSIDE_CYGWIN__ | #include "winsup.h" | ||||||
| #define  __INSIDE_CYGWIN_NET__ |  | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #ifndef __CYGWIN__ | #ifndef __CYGWIN__ | ||||||
|   | |||||||
| @@ -10,13 +10,10 @@ This software is a copyrighted work licensed under the terms of the | |||||||
| Cygwin license.  Please consult the file "CYGWIN_LICENSE" for | Cygwin license.  Please consult the file "CYGWIN_LICENSE" for | ||||||
| details. */ | details. */ | ||||||
|  |  | ||||||
| #define  __INSIDE_CYGWIN_NET__ |  | ||||||
|  |  | ||||||
| #include "winsup.h" | #include "winsup.h" | ||||||
| #include <string.h> | #include <string.h> | ||||||
| #include <malloc.h> | #include <malloc.h> | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| #include <netdb.h> |  | ||||||
| #include <ctype.h> | #include <ctype.h> | ||||||
| #include <sys/time.h> | #include <sys/time.h> | ||||||
| #include <sys/socket.h> | #include <sys/socket.h> | ||||||
| @@ -27,6 +24,7 @@ details. */ | |||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| #include <stdarg.h> | #include <stdarg.h> | ||||||
| #include <sys/unistd.h> | #include <sys/unistd.h> | ||||||
|  | #define  __INSIDE_CYGWIN_NET__ | ||||||
| #include <netdb.h> | #include <netdb.h> | ||||||
| #include <arpa/nameser.h> | #include <arpa/nameser.h> | ||||||
| #include <resolv.h> | #include <resolv.h> | ||||||
|   | |||||||
| @@ -21,9 +21,9 @@ details. */ | |||||||
|  |  | ||||||
| #include <wingdi.h> | #include <wingdi.h> | ||||||
| #include <winuser.h> | #include <winuser.h> | ||||||
| #include <netdb.h> |  | ||||||
| #define USE_SYS_TYPES_FD_SET | #define USE_SYS_TYPES_FD_SET | ||||||
| #include <winsock2.h> | #include <winsock2.h> | ||||||
|  | #include <netdb.h> | ||||||
| #include "cygerrno.h" | #include "cygerrno.h" | ||||||
| #include "security.h" | #include "security.h" | ||||||
| #include "path.h" | #include "path.h" | ||||||
|   | |||||||
| @@ -10,15 +10,15 @@ Cygwin license.  Please consult the file "CYGWIN_LICENSE" for | |||||||
| details. */ | details. */ | ||||||
|  |  | ||||||
| #define  __INSIDE_CYGWIN_NET__ | #define  __INSIDE_CYGWIN_NET__ | ||||||
|  | #define USE_SYS_TYPES_FD_SET | ||||||
| #include "winsup.h" | #include "winsup.h" | ||||||
|  | #include <ws2tcpip.h> | ||||||
|  | #include <iphlpapi.h> | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| #include <syslog.h> | #include <syslog.h> | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
| #include <sys/un.h> | #include <sys/un.h> | ||||||
| #include <netinet/in.h> |  | ||||||
| #include <iphlpapi.h> |  | ||||||
| #include "cygerrno.h" | #include "cygerrno.h" | ||||||
| #include "security.h" | #include "security.h" | ||||||
| #include "path.h" | #include "path.h" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user