[prev in list] [next in list] [prev in thread] [next in thread]
List: winpcap-users
Subject: Re: [Winpcap-users] Patch - Problems compiling Winpcap 4.0.1 with
From: "Gianluca Varenni" <gianluca.varenni () cacetech ! com>
Date: 2007-09-19 16:22:28
Message-ID: 464501c7fad9$46e0e6e0$6600a8c0 () NELSON2
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
I've committed the patch on our sources.
Actually such source file is part of the libpcap official sources, you can see the \
commit here
http://cvs.tcpdump.org/cgi-bin/cvsweb/libpcap/Win32/Src/gai_strerror.c
Thanks for the bug report!
Have a nice day
GV
----- Original Message -----
From: kha
To: winpcap-bugs@winpcap.org
Cc: winpcap-users@winpcap.org
Sent: Tuesday, September 18, 2007 2:32 PM
Subject: [Winpcap-users] Patch - Problems compiling Winpcap 4.0.1 with MinGW
Hi,
I am trying to compile some libraries (Winpcap 4.0.1/ libnet and others) under \
MinGW (not the one included in Cygwin, but the one at http://www.mingw.org/).
Here is my environment:
a.. Windows XP pro, 32bits
b.. gcc-core-3.4.5-20060117-1.tar.gz
c.. gcc-g++-3.4.5-20060117-1.tar.gz
d.. gcc-objc-3.4.5-20060117-1.tar.gz
e.. mingw-runtime-3.13.tar.gz
f.. mingw32-make-3.81-2.tar.gz
g.. w32api-3.10.tar.gz
I get the following error:
mcarbou@BOX /d/data/download/winpcap/wpcap/PRJ
$ make
gcc -I ../libpcap -I ../libpcap/bpf -I ../libpcap/lbl -I ../libpcap/Win32/Include \
-I../libpcap/Win32/Include/ipv6kit -I ../../common -I ../Win32-Extensions -I \
../../../Airpcap_DevPack/include -DLIBPCAP_EXPORTS -DYY_NEVER_INTERACTIVE \
-Dyylval=pcap_lval -DHAVE_STRERROR -DNEED_ADDRINFO_H -DINET6 -DWIN3 2 -DSIZEOF_CHAR=1 \
-DSIZEOF_SHORT=2 -DSIZEOF_INT=4 -DSIZEOF_LONG_LONG=8 -DWPCAP -D'_U_=' -DHAVE_SNPRINTF \
-DHAVE_VSNPRINTF -DSIZEOF_LONG_LONG=8 -DHAVE_REMOTE -DHAVE_AIRPCAP_API -mno-cygwin \
-shared -O -o ../libpcap/Win32/Src/gai_strerror.o -c \
../libpcap/Win32/Src/gai_strerror.c
../libpcap/Win32/Src/gai_strerror.c:72: error: conflicting types for 'gai_strerrorA'
c:/programs/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/ws2tcpip.h:309: \
error: previous definition of 'gai_strerrorA' was here
make: *** [../libpcap/Win32/Src/gai_strerror.o] Error 1
Searching in the mailing list archives, i have found the possible cause of this \
issue:
http://www.winpcap.org/pipermail/winpcap-users/2005-December/000575.html
A patch seems to be applied to add the gai_strerrorA function that was missing. But \
in my environment, i have this function already defined in ws2tcpip.h. See the \
attachment. So simply adding a #ifndef gai_strerror seems to solve the issue.
Here is the patch:
--- /d/data/download/gai_strerror.c Sun Jan 22 15:14:18 2006
+++ ../libpcap/Win32/Src/gai_strerror.c Tue Sep 18 21:29:11 2007
@@ -67,6 +67,7 @@
#define EAI_MAX (sizeof(ai_errlist)/sizeof(ai_errlist[0]))
#endif
+#ifndef gai_strerror
char *
WSAAPI gai_strerrorA(int ecode)
{
@@ -74,4 +75,4 @@
return ai_errlist[ecode];
return "Unknown error";
}
-
+#endif
--
Mathieu Carbou
IT Consultant,
Sun Certified Java Programmer
Mail: mathieu.carbou@gmail.com
Website: http://mathieu.carbou.free.fr/
------------------------------------------------------------------------------
/*
* ws2tcpip.h : TCP/IP specific extensions in Windows Sockets 2
*
* Portions Copyright (c) 1980, 1983, 1988, 1993
* The Regents of the University of California. All rights reserved.
*
*/
#ifndef _WS2TCPIP_H
#define _WS2TCPIP_H
#if __GNUC__ >=3
#pragma GCC system_header
#endif
#if (defined _WINSOCK_H && !defined _WINSOCK2_H)
#error "ws2tcpip.h is not compatible with winsock.h. Include winsock2.h instead."
#endif
#include <winsock2.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* The IP_* macros are also defined in winsock.h, but some values are different \
there.
* The values defined in winsock.h for 1.1 and used in wsock32.dll are consistent
* with the original values Steve Deering defined in his document "IP Multicast \
Extensions
* for 4.3BSD UNIX related systems (MULTICAST 1.2 Release)." However, these \
conflicted with
* the definitions for some IPPROTO_IP level socket options already assigned by \
BSD,
* so Berkeley changed all the values by adding 7. WinSock2 (ws2_32.dll) uses
* the BSD 4.4 compatible values defined here.
*
* See also: msdn kb article Q257460
* http://support.microsoft.com/support/kb/articles/Q257/4/60.asp
*/
/* This is also defined in winsock.h; value hasn't changed */
#define IP_OPTIONS 1
#define IP_HDRINCL 2
/*
* These are also be defined in winsock.h,
* but values have changed for WinSock2 interface
*/
#define IP_TOS 3 /* old (winsock 1.1) value 8 */
#define IP_TTL 4 /* old value 7 */
#define IP_MULTICAST_IF 9 /* old value 2 */
#define IP_MULTICAST_TTL 10 /* old value 3 */
#define IP_MULTICAST_LOOP 11 /* old value 4 */
#define IP_ADD_MEMBERSHIP 12 /* old value 5 */
#define IP_DROP_MEMBERSHIP 13 /* old value 6 */
#define IP_DONTFRAGMENT 14 /* old value 9 */
#define IP_ADD_SOURCE_MEMBERSHIP 15
#define IP_DROP_SOURCE_MEMBERSHIP 16
#define IP_BLOCK_SOURCE 17
#define IP_UNBLOCK_SOURCE 18
#define IP_PKTINFO 19
/*
* As with BSD implementation, IPPROTO_IPV6 level socket options have
* same values as IPv4 counterparts.
*/
#define IPV6_UNICAST_HOPS 4
#define IPV6_MULTICAST_IF 9
#define IPV6_MULTICAST_HOPS 10
#define IPV6_MULTICAST_LOOP 11
#define IPV6_ADD_MEMBERSHIP 12
#define IPV6_DROP_MEMBERSHIP 13
#define IPV6_JOIN_GROUP IPV6_ADD_MEMBERSHIP
#define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP
#define IPV6_PKTINFO 19
#define IP_DEFAULT_MULTICAST_TTL 1
#define IP_DEFAULT_MULTICAST_LOOP 1
#define IP_MAX_MEMBERSHIPS 20
#define TCP_EXPEDITED_1122 2
#define UDP_NOCHECKSUM 1
/* INTERFACE_INFO iiFlags */
#define IFF_UP 1
#define IFF_BROADCAST 2
#define IFF_LOOPBACK 4
#define IFF_POINTTOPOINT 8
#define IFF_MULTICAST 16
#define SIO_GET_INTERFACE_LIST _IOR('t', 127, u_long)
#define INET_ADDRSTRLEN 16
#define INET6_ADDRSTRLEN 46
/* getnameinfo constants */
#define NI_MAXHOST 1025
#define NI_MAXSERV 32
#define NI_NOFQDN 0x01
#define NI_NUMERICHOST 0x02
#define NI_NAMEREQD 0x04
#define NI_NUMERICSERV 0x08
#define NI_DGRAM 0x10
/* getaddrinfo constants */
#define AI_PASSIVE 1
#define AI_CANONNAME 2
#define AI_NUMERICHOST 4
/* getaddrinfo error codes */
#define EAI_AGAIN WSATRY_AGAIN
#define EAI_BADFLAGS WSAEINVAL
#define EAI_FAIL WSANO_RECOVERY
#define EAI_FAMILY WSAEAFNOSUPPORT
#define EAI_MEMORY WSA_NOT_ENOUGH_MEMORY
#define EAI_NODATA WSANO_DATA
#define EAI_NONAME WSAHOST_NOT_FOUND
#define EAI_SERVICE WSATYPE_NOT_FOUND
#define EAI_SOCKTYPE WSAESOCKTNOSUPPORT
/*
* ip_mreq also in winsock.h for WinSock1.1,
* but online msdn docs say it is defined here for WinSock2.
*/
struct ip_mreq {
struct in_addr imr_multiaddr;
struct in_addr imr_interface;
};
struct ip_mreq_source {
struct in_addr imr_multiaddr;
struct in_addr imr_sourceaddr;
struct in_addr imr_interface;
};
struct ip_msfilter {
struct in_addr imsf_multiaddr;
struct in_addr imsf_interface;
u_long imsf_fmode;
u_long imsf_numsrc;
struct in_addr imsf_slist[1];
};
#define IP_MSFILTER_SIZE(numsrc) \
(sizeof(struct ip_msfilter) - sizeof(struct in_addr) \
+ (numsrc) * sizeof(struct in_addr))
struct in_pktinfo {
IN_ADDR ipi_addr;
UINT ipi_ifindex;
};
typedef struct in_pktinfo IN_PKTINFO;
/* ipv6 */
/* These require XP or .NET Server or use of add-on IPv6 stacks on NT 4
or higher */
/* This is based on the example given in RFC 2553 with stdint types
changed to BSD types. For now, use these field names until there
is some consistency in MS docs. In this file, we only use the
in6_addr structure start address, with casts to get the right offsets
when testing addresses */
struct in6_addr {
union {
u_char _S6_u8[16];
u_short _S6_u16[8];
u_long _S6_u32[4];
} _S6_un;
};
/* s6_addr is the standard name */
#define s6_addr _S6_un._S6_u8
/* These are GLIBC names */
#define s6_addr16 _S6_un._S6_u16
#define s6_addr32 _S6_un._S6_u32
/* These are used in some MS code */
#define in_addr6 in6_addr
#define _s6_bytes _S6_un._S6_u8
#define _s6_words _S6_un._S6_u16
typedef struct in6_addr IN6_ADDR, *PIN6_ADDR, *LPIN6_ADDR;
struct sockaddr_in6 {
short sin6_family; /* AF_INET6 */
u_short sin6_port; /* transport layer port # */
u_long sin6_flowinfo; /* IPv6 traffic class & flow info */
struct in6_addr sin6_addr; /* IPv6 address */
u_long sin6_scope_id; /* set of interfaces for a scope */
};
typedef struct sockaddr_in6 SOCKADDR_IN6, *PSOCKADDR_IN6, *LPSOCKADDR_IN6;
extern const struct in6_addr in6addr_any;
extern const struct in6_addr in6addr_loopback;
/* the above can get initialised using: */
#define IN6ADDR_ANY_INIT { 0 }
#define IN6ADDR_LOOPBACK_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }
/* Described in RFC 2292, but not in 2553 */
/* int IN6_ARE_ADDR_EQUAL(const struct in6_addr * a, const struct in6_addr * b) */
#define IN6_ARE_ADDR_EQUAL(a, b) \
(memcmp ((void*)(a), (void*)(b), sizeof (struct in6_addr)) == 0)
/* Address Testing Macros
These macro functions all take const struct in6_addr* as arg.
Static inlines would allow type checking, but RFC 2553 says they
macros.
NB: These are written specifically for little endian host */
#define IN6_IS_ADDR_UNSPECIFIED(_addr) \
( (((const u_long *)(_addr))[0] == 0) \
&& (((const u_long *)(_addr))[1] == 0) \
&& (((const u_long *)(_addr))[2] == 0) \
&& (((const u_long *)(_addr))[3] == 0))
#define IN6_IS_ADDR_LOOPBACK(_addr) \
( (((const u_long *)(_addr))[0] == 0) \
&& (((const u_long *)(_addr))[1] == 0) \
&& (((const u_long *)(_addr))[2] == 0) \
&& (((const u_long *)(_addr))[3] == 0x01000000)) /* Note byte order reversed */
/* (((const u_long *)(_addr))[3] == ntohl(1)) */
#define IN6_IS_ADDR_MULTICAST(_addr) (((const u_char *) (_addr))[0] == 0xff)
#define IN6_IS_ADDR_LINKLOCAL(_addr) \
( (((const u_char *)(_addr))[0] == 0xfe) \
&& ((((const u_char *)(_addr))[1] & 0xc0) == 0x80))
#define IN6_IS_ADDR_SITELOCAL(_addr) \
( (((const u_char *)(_addr))[0] == 0xfe) \
&& ((((const u_char *)(_addr))[1] & 0xc0) == 0xc0))
#define IN6_IS_ADDR_V4MAPPED(_addr) \
( (((const u_long *)(_addr))[0] == 0) \
&& (((const u_long *)(_addr))[1] == 0) \
&& (((const u_long *)(_addr))[2] == 0xffff0000)) /* Note byte order reversed */
/* (((const u_long *)(_addr))[2] == ntohl(0x0000ffff))) */
#define IN6_IS_ADDR_V4COMPAT(_addr) \
( (((const u_long *)(_addr))[0] == 0) \
&& (((const u_long *)(_addr))[1] == 0) \
&& (((const u_long *)(_addr))[2] == 0) \
&& (((const u_long *)(_addr))[3] != 0) \
&& (((const u_long *)(_addr))[3] != 0x01000000)) /* Note byte order reversed */
/* (ntohl (((const u_long *)(_addr))[3]) > 1 ) */
#define IN6_IS_ADDR_MC_NODELOCAL(_addr) \
( IN6_IS_ADDR_MULTICAST(_addr) \
&& ((((const u_char *)(_addr))[1] & 0xf) == 0x1))
#define IN6_IS_ADDR_MC_LINKLOCAL(_addr) \
( IN6_IS_ADDR_MULTICAST (_addr) \
&& ((((const u_char *)(_addr))[1] & 0xf) == 0x2))
#define IN6_IS_ADDR_MC_SITELOCAL(_addr) \
( IN6_IS_ADDR_MULTICAST(_addr) \
&& ((((const u_char *)(_addr))[1] & 0xf) == 0x5))
#define IN6_IS_ADDR_MC_ORGLOCAL(_addr) \
( IN6_IS_ADDR_MULTICAST(_addr) \
&& ((((const u_char *)(_addr))[1] & 0xf) == 0x8))
#define IN6_IS_ADDR_MC_GLOBAL(_addr) \
( IN6_IS_ADDR_MULTICAST(_addr) \
&& ((((const u_char *)(_addr))[1] & 0xf) == 0xe))
typedef int socklen_t;
struct ipv6_mreq {
struct in6_addr ipv6mr_multiaddr;
unsigned int ipv6mr_interface;
};
typedef struct ipv6_mreq IPV6_MREG;
struct in6_pktinfo {
IN6_ADDR ipi6_addr;
UINT ipi6_ifindex;
};
typedef struct in6_pktinfo IN6_PKTINFO;
struct addrinfo {
int ai_flags;
int ai_family;
int ai_socktype;
int ai_protocol;
size_t ai_addrlen;
char *ai_canonname;
struct sockaddr *ai_addr;
struct addrinfo *ai_next;
};
#if (_WIN32_WINNT >= 0x0501)
void WSAAPI freeaddrinfo (struct addrinfo*);
int WSAAPI getaddrinfo (const char*,const char*,const struct addrinfo*,
struct addrinfo**);
int WSAAPI getnameinfo(const struct sockaddr*,socklen_t,char*,DWORD,
char*,DWORD,int);
#else
/* FIXME: Need WS protocol-independent API helpers. */
#endif
static __inline char*
gai_strerrorA(int ecode)
{
static char message[1024+1];
DWORD dwFlags = FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_IGNORE_INSERTS
| FORMAT_MESSAGE_MAX_WIDTH_MASK;
DWORD dwLanguageId = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);
FormatMessageA(dwFlags, NULL, ecode, dwLanguageId, (LPSTR)message, 1024, NULL);
return message;
}
static __inline WCHAR*
gai_strerrorW(int ecode)
{
static WCHAR message[1024+1];
DWORD dwFlags = FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_IGNORE_INSERTS
| FORMAT_MESSAGE_MAX_WIDTH_MASK;
DWORD dwLanguageId = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);
FormatMessageW(dwFlags, NULL, ecode, dwLanguageId, (LPWSTR)message, 1024, NULL);
return message;
}
#ifdef UNICODE
#define gai_strerror gai_strerrorW
#else
#define gai_strerror gai_strerrorA
#endif
/* Some older IPv4/IPv6 compatibility stuff */
/* This struct lacks sin6_scope_id; retained for use in sockaddr_gen */
struct sockaddr_in6_old {
short sin6_family;
u_short sin6_port;
u_long sin6_flowinfo;
struct in6_addr sin6_addr;
};
typedef union sockaddr_gen{
struct sockaddr Address;
struct sockaddr_in AddressIn;
struct sockaddr_in6_old AddressIn6;
} sockaddr_gen;
typedef struct _INTERFACE_INFO {
u_long iiFlags;
sockaddr_gen iiAddress;
sockaddr_gen iiBroadcastAddress;
sockaddr_gen iiNetmask;
} INTERFACE_INFO, *LPINTERFACE_INFO;
/*
The definition above can cause problems on NT4,prior to sp4.
To workaround, include the following struct and typedef and
#define INTERFACE_INFO OLD_INTERFACE_INFO
See: FIX: WSAIoctl SIO_GET_INTERFACE_LIST Option Problem
(Q181520) in MSDN KB.
The old definition causes problems on newer NT and on XP.
typedef struct _OLD_INTERFACE_INFO {
u_long iiFlags;
struct sockaddr iiAddress;
struct sockaddr iiBroadcastAddress;
struct sockaddr iiNetmask;
} OLD_INTERFACE_INFO;
*/
#ifdef __cplusplus
}
#endif
#endif
------------------------------------------------------------------------------
_______________________________________________
Winpcap-users mailing list
Winpcap-users@winpcap.org
https://www.winpcap.org/mailman/listinfo/winpcap-users
[Attachment #5 (text/html)]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16525" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=#000000 bgColor=#ffffff>
<DIV><FONT size=2>I've committed the patch on our sources.</FONT></DIV>
<DIV><FONT size=2>Actually such source file is part of the libpcap official
sources, you can see the commit here</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2><A
href="http://cvs.tcpdump.org/cgi-bin/cvsweb/libpcap/Win32/Src/gai_strerror.c">http://cvs.tcpdump.org/cgi-bin/cvsweb/libpcap/Win32/Src/gai_strerror.c</A></FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>Thanks for the bug report!</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>Have a nice day</FONT></DIV>
<DIV><FONT size=2>GV</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2></FONT> </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 \
2px solid; MARGIN-RIGHT: 0px"> <DIV style="FONT: 10pt arial">----- Original Message \
----- </DIV> <DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=kha.kha@laposte.net href="mailto:kha.kha@laposte.net">kha</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=winpcap-bugs@winpcap.org
href="mailto:winpcap-bugs@winpcap.org">winpcap-bugs@winpcap.org</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Cc:</B> <A title=winpcap-users@winpcap.org
href="mailto:winpcap-users@winpcap.org">winpcap-users@winpcap.org</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Tuesday, September 18, 2007 2:32
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [Winpcap-users] Patch - Problems
compiling Winpcap 4.0.1 with MinGW</DIV>
<DIV><BR></DIV>Hi,<BR><BR>I am trying to compile some libraries (Winpcap
4.0.1/ libnet and others) under MinGW (not the one included in Cygwin, but the
one at <A href="http://www.mingw.org/">http://www.mingw.org/</A>).<BR><BR>Here
is <A
href="http://mathieu.carbou.free.fr/wiki/index.php?title=Setup_and_configure_MinGW">my \
environment</A>:<BR>
<UL>
<LI>Windows XP pro, 32bits<BR>
<LI>gcc-core-3.4.5-20060117-1.tar.gz
<LI>gcc-g++-3.4.5-20060117-1.tar.gz
<LI>gcc-objc-3.4.5-20060117-1.tar.gz
<LI>mingw-runtime-3.13.tar.gz
<LI>mingw32-make-3.81-2.tar.gz
<LI>w32api-3.10.tar.gz<BR></LI></UL>I get the following error:<BR><PRE><A \
href="mailto:mcarbou@BOX">mcarbou@BOX</A> /d/data/download/winpcap/wpcap/PRJ $ make
gcc -I ../libpcap -I ../libpcap/bpf -I ../libpcap/lbl -I ../libpcap/Win32/Include \
-I../libpcap/Win32/Include/ipv6kit -I ../../common -I ../Win32-Extensions -I \
../../../Airpcap_DevPack/include -DLIBPCAP_EXPORTS -DYY_NEVER_INTERACTIVE \
-Dyylval=pcap_lval -DHAVE_STRERROR -DNEED_ADDRINFO_H -DINET6 -DWIN3 2 -DSIZEOF_CHAR=1 \
-DSIZEOF_SHORT=2 -DSIZEOF_INT=4 -DSIZEOF_LONG_LONG=8 -DWPCAP -D'_U_=' -DHAVE_SNPRINTF \
-DHAVE_VSNPRINTF -DSIZEOF_LONG_LONG=8 -DHAVE_REMOTE -DHAVE_AIRPCAP_API -mno-cygwin \
-shared -O -o ../libpcap/Win32/Src/gai_strerror.o -c \
../libpcap/Win32/Src/gai_strerror.c
../libpcap/Win32/Src/gai_strerror.c:72: <B>error: conflicting types for \
'gai_strerrorA'</B> c:/programs/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/ws2tcpip.h:309: \
<B>error: previous definition of 'gai_strerrorA' was here</B>
make: *** [../libpcap/Win32/Src/gai_strerror.o] Error 1
</PRE>Searching in the mailing list archives, i have found the possible cause
of this issue:<BR><BR><A
href="http://www.winpcap.org/pipermail/winpcap-users/2005-December/000575.html">http \
://www.winpcap.org/pipermail/winpcap-users/2005-December/000575.html</A><BR><BR>A \
patch seems to be applied to add the gai_strerrorA function that was missing. But \
in my environment, i have this function already defined in ws2tcpip.h. See the \
attachment. So simply adding a #ifndef gai_strerror seems to solve the \
issue.<BR><BR>Here is the patch:<BR><PRE>--- /d/data/download/gai_strerror.c Sun \
Jan 22 15:14:18 2006
+++ ../libpcap/Win32/Src/gai_strerror.c Tue Sep 18 21:29:11 2007
@@ -67,6 +67,7 @@
#define EAI_MAX (sizeof(ai_errlist)/sizeof(ai_errlist[0]))
#endif
+#ifndef gai_strerror
char *
WSAAPI gai_strerrorA(int ecode)
{
@@ -74,4 +75,4 @@
return ai_errlist[ecode];
return "Unknown error";
}
-
+#endif
</PRE><BR>
<DIV class=moz-signature>-- <BR>
<TABLE
style="BORDER-RIGHT: rgb(0,0,0) 2px outset; PADDING-RIGHT: 3px; BORDER-TOP: \
rgb(0,0,0) 2px outset; PADDING-LEFT: 3px; FONT-SIZE: 11px; PADDING-BOTTOM: 1px; \
BORDER-LEFT: rgb(0,0,0) 2px outset; COLOR: rgb(0,0,0); PADDING-TOP: 1px; \
BORDER-BOTTOM: rgb(0,0,0) 2px outset; FONT-FAMILY: monospace; BACKGROUND-COLOR: \
rgb(240,240,255)" cellSpacing=0>
<TBODY>
<TR>
<TD colSpan=2><SPAN style="FONT-SIZE: larger"><B>Mathieu
Carbou</B></SPAN><BR>IT Consultant,<BR>Sun Certified Java Programmer
</TD></TR>
<TR>
<TD><B>Mail:</B></TD>
<TD><A
href="mailto:mathieu.carbou@gmail.com">mathieu.carbou@gmail.com</A></TD></TR>
<TR>
<TD><B>Website:</B></TD>
<TD><A
href="http://mathieu.carbou.free.fr/">http://mathieu.carbou.free.fr/</A></TD></TR></TBODY></TABLE></DIV><BR>
<P>
<HR>
<P></P>/*<BR> * ws2tcpip.h : TCP/IP specific extensions in Windows
Sockets 2<BR> *<BR> * Portions Copyright (c) 1980, 1983, 1988,
1993<BR> * The Regents of the University of California. All rights
reserved.<BR> *<BR> */<BR><BR>#ifndef _WS2TCPIP_H<BR>#define
_WS2TCPIP_H<BR>#if __GNUC__ >=3<BR>#pragma GCC
system_header<BR>#endif<BR><BR>#if (defined _WINSOCK_H && !defined
_WINSOCK2_H)<BR>#error "ws2tcpip.h is not compatible with winsock.h. Include
winsock2.h instead."<BR>#endif<BR><BR>#include
<winsock2.h><BR>#ifdef __cplusplus<BR>extern "C"
{<BR>#endif<BR><BR>/* <BR> * The IP_* macros are also defined in
winsock.h, but some values are different there.<BR> * The values defined
in winsock.h for 1.1 and used in wsock32.dll are consistent<BR> * with
the original values Steve Deering defined in his document "IP Multicast
Extensions<BR> * for 4.3BSD UNIX related systems (MULTICAST 1.2
Release)." However, these conflicted with<BR> * the definitions for some
IPPROTO_IP level socket options already assigned by BSD,<BR> * so
Berkeley changed all the values by adding 7. WinSock2 (ws2_32.dll)
uses<BR> * the BSD 4.4 compatible values defined
here.<BR> *<BR> * See also: msdn kb article Q257460<BR> *
http://support.microsoft.com/support/kb/articles/Q257/4/60.asp<BR> */<BR><BR>/* \
This is also defined in winsock.h; value hasn't changed */<BR>#define
IP_OPTIONS 1<BR><BR>#define IP_HDRINCL 2<BR>/*<BR> * These
are also be defined in winsock.h,<BR> * but values have changed for
WinSock2 interface<BR> */<BR>#define IP_TOS 3 /* old (winsock
1.1) value 8 */<BR>#define IP_TTL 4 /* old value 7 */<BR>#define
IP_MULTICAST_IF 9 /* old value 2 */<BR>#define IP_MULTICAST_TTL
10 /* old value 3 */<BR>#define IP_MULTICAST_LOOP 11 /* old value
4 */<BR>#define IP_ADD_MEMBERSHIP 12 /* old value 5 */<BR>#define
IP_DROP_MEMBERSHIP 13 /* old value 6 */<BR>#define IP_DONTFRAGMENT
14 /* old value 9 */<BR>#define IP_ADD_SOURCE_MEMBERSHIP 15<BR>#define
IP_DROP_SOURCE_MEMBERSHIP 16<BR>#define IP_BLOCK_SOURCE 17<BR>#define
IP_UNBLOCK_SOURCE 18<BR>#define IP_PKTINFO 19<BR><BR>/*<BR> * As with BSD
implementation, IPPROTO_IPV6 level socket options have<BR> * same values
as IPv4 counterparts.<BR> */<BR>#define IPV6_UNICAST_HOPS 4<BR>#define
IPV6_MULTICAST_IF 9<BR>#define IPV6_MULTICAST_HOPS 10<BR>#define
IPV6_MULTICAST_LOOP 11<BR>#define IPV6_ADD_MEMBERSHIP 12<BR>#define
IPV6_DROP_MEMBERSHIP 13<BR>#define IPV6_JOIN_GROUP
IPV6_ADD_MEMBERSHIP<BR>#define IPV6_LEAVE_GROUP
IPV6_DROP_MEMBERSHIP<BR>#define IPV6_PKTINFO 19<BR><BR>#define
IP_DEFAULT_MULTICAST_TTL 1 <BR>#define IP_DEFAULT_MULTICAST_LOOP 1 <BR>#define
IP_MAX_MEMBERSHIPS 20 <BR><BR>#define TCP_EXPEDITED_1122
2<BR><BR>#define UDP_NOCHECKSUM 1<BR><BR>/* INTERFACE_INFO iiFlags
*/<BR>#define IFF_UP 1<BR>#define IFF_BROADCAST 2<BR>#define
IFF_LOOPBACK 4<BR>#define IFF_POINTTOPOINT
8<BR>#define IFF_MULTICAST 16<BR><BR>#define
SIO_GET_INTERFACE_LIST _IOR('t', 127, u_long)<BR><BR>#define
INET_ADDRSTRLEN 16<BR>#define INET6_ADDRSTRLEN 46<BR><BR>/* getnameinfo
constants */ <BR>#define NI_MAXHOST 1025<BR>#define NI_MAXSERV
32<BR><BR>#define NI_NOFQDN 0x01<BR>#define NI_NUMERICHOST 0x02<BR>#define
NI_NAMEREQD 0x04<BR>#define NI_NUMERICSERV 0x08<BR>#define NI_DGRAM
0x10<BR><BR>/* getaddrinfo constants */<BR>#define AI_PASSIVE 1<BR>#define
AI_CANONNAME 2<BR>#define AI_NUMERICHOST 4<BR><BR>/* getaddrinfo error codes
*/<BR>#define EAI_AGAIN WSATRY_AGAIN<BR>#define EAI_BADFLAGS
WSAEINVAL<BR>#define EAI_FAIL WSANO_RECOVERY<BR>#define EAI_FAMILY
WSAEAFNOSUPPORT<BR>#define EAI_MEMORY WSA_NOT_ENOUGH_MEMORY<BR>#define
EAI_NODATA WSANO_DATA<BR>#define EAI_NONAME WSAHOST_NOT_FOUND<BR>#define
EAI_SERVICE WSATYPE_NOT_FOUND<BR>#define EAI_SOCKTYPE
WSAESOCKTNOSUPPORT<BR><BR>/*<BR> * ip_mreq also in winsock.h
for WinSock1.1,<BR> * but online msdn docs say it is defined
here for WinSock2.<BR> */ <BR><BR>struct ip_mreq {<BR>struct in_addr
imr_multiaddr;<BR>struct in_addr imr_interface;<BR>};<BR><BR>struct
ip_mreq_source {<BR>struct in_addr imr_multiaddr;<BR>struct in_addr
imr_sourceaddr;<BR>struct in_addr imr_interface;<BR>};<BR><BR>struct
ip_msfilter {<BR>struct in_addr imsf_multiaddr;<BR>struct in_addr
imsf_interface;<BR>u_long imsf_fmode;<BR>u_long imsf_numsrc;<BR>struct in_addr
imsf_slist[1];<BR>};<BR><BR>#define IP_MSFILTER_SIZE(numsrc) \<BR>
(sizeof(struct ip_msfilter) - sizeof(struct in_addr) \<BR> +
(numsrc) * sizeof(struct in_addr))<BR><BR>struct in_pktinfo {<BR>IN_ADDR
ipi_addr;<BR>UINT ipi_ifindex;<BR>};<BR>typedef struct
in_pktinfo IN_PKTINFO;<BR><BR><BR>/* ipv6 */ <BR>/* These require XP or .NET
Server or use of add-on IPv6 stacks on NT 4<BR> or higher */<BR><BR>/*
This is based on the example given in RFC 2553 with stdint
types<BR> changed to BSD types. For now, use these
field names until there<BR> is some consistency in MS docs. In
this file, we only use the<BR> in6_addr structure start address,
with casts to get the right offsets<BR> when testing addresses
*/<BR> <BR>struct in6_addr {<BR> union
{<BR> u_char
_S6_u8[16];<BR> u_short
_S6_u16[8];<BR> u_long
_S6_u32[4];<BR> }
_S6_un;<BR>};<BR>/* s6_addr is the standard name */<BR>#define s6_addr
_S6_un._S6_u8<BR><BR>/* These are GLIBC names */ <BR>#define s6_addr16
_S6_un._S6_u16<BR>#define s6_addr32 _S6_un._S6_u32<BR><BR>/* These are used in
some MS code */<BR>#define in_addr6 in6_addr<BR>#define _s6_bytes
_S6_un._S6_u8<BR>#define _s6_words _S6_un._S6_u16<BR><BR>typedef struct
in6_addr IN6_ADDR, *PIN6_ADDR, *LPIN6_ADDR;<BR><BR>struct sockaddr_in6
{<BR>short sin6_family; /* AF_INET6 */<BR>u_short sin6_port; /* transport
layer port # */<BR>u_long sin6_flowinfo; /* IPv6 traffic class & flow info
*/<BR>struct in6_addr sin6_addr; /* IPv6 address */<BR>u_long
sin6_scope_id; /* set of interfaces for a scope */<BR>};<BR>typedef struct
sockaddr_in6 SOCKADDR_IN6, *PSOCKADDR_IN6, *LPSOCKADDR_IN6;<BR><BR>extern
const struct in6_addr in6addr_any;<BR>extern const struct in6_addr
in6addr_loopback;<BR>/* the above can get initialised using: */ <BR>#define
IN6ADDR_ANY_INIT { 0 }<BR>#define
IN6ADDR_LOOPBACK_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
}<BR><BR>/* Described in RFC 2292, but not in 2553 */<BR>/* int
IN6_ARE_ADDR_EQUAL(const struct in6_addr * a, const struct in6_addr * b)
*/<BR>#define IN6_ARE_ADDR_EQUAL(a, b) \<BR> (memcmp
((void*)(a), (void*)(b), sizeof (struct in6_addr)) == 0)<BR><BR><BR>/* Address
Testing Macros <BR><BR> These macro functions all take const struct
in6_addr* as arg.<BR> Static inlines would allow type checking, but RFC
2553 says they<BR> macros. <BR> NB: These are written specifically
for little endian host */<BR><BR>#define IN6_IS_ADDR_UNSPECIFIED(_addr)
\<BR>( (((const u_long *)(_addr))[0] == 0) \<BR>&&
(((const u_long *)(_addr))[1] == 0) \<BR>&& (((const u_long
*)(_addr))[2] == 0) \<BR>&& (((const u_long *)(_addr))[3] ==
0))<BR><BR>#define IN6_IS_ADDR_LOOPBACK(_addr) \<BR>( (((const
u_long *)(_addr))[0] == 0) \<BR>&& (((const u_long *)(_addr))[1] == 0)
\<BR>&& (((const u_long *)(_addr))[2] == 0) \<BR>&& (((const
u_long *)(_addr))[3] == 0x01000000)) /* Note byte order reversed */<BR>/*
(((const u_long *)(_addr))[3] == ntohl(1))
*/<BR><BR>#define IN6_IS_ADDR_MULTICAST(_addr) (((const u_char *) (_addr))[0]
== 0xff)<BR><BR>#define IN6_IS_ADDR_LINKLOCAL(_addr) \<BR>(
(((const u_char *)(_addr))[0] == 0xfe) \<BR>&& ((((const u_char
*)(_addr))[1] & 0xc0) == 0x80))<BR><BR>#define
IN6_IS_ADDR_SITELOCAL(_addr) \<BR>( (((const u_char *)(_addr))[0]
== 0xfe) \<BR>&& ((((const u_char *)(_addr))[1] & 0xc0) ==
0xc0))<BR><BR>#define IN6_IS_ADDR_V4MAPPED(_addr) \<BR>( (((const
u_long *)(_addr))[0] == 0) \<BR>&& (((const u_long *)(_addr))[1] == 0)
\<BR>&& (((const u_long *)(_addr))[2] == 0xffff0000)) /* Note byte
order reversed */<BR>/* (((const u_long *)(_addr))[2] ==
ntohl(0x0000ffff))) */<BR><BR>#define IN6_IS_ADDR_V4COMPAT(_addr)
\<BR>( (((const u_long *)(_addr))[0] == 0) \<BR>&&
(((const u_long *)(_addr))[1] == 0) \<BR>&& (((const u_long
*)(_addr))[2] == 0) \<BR>&& (((const u_long *)(_addr))[3] != 0)
\<BR>&& (((const u_long *)(_addr))[3] != 0x01000000)) /* Note byte
order reversed
*/<BR>/* (ntohl
(((const u_long *)(_addr))[3]) > 1 ) */<BR><BR><BR>#define
IN6_IS_ADDR_MC_NODELOCAL(_addr) \<BR>(
IN6_IS_ADDR_MULTICAST(_addr) \<BR>&& ((((const u_char *)(_addr))[1]
& 0xf) == 0x1)) <BR><BR>#define IN6_IS_ADDR_MC_LINKLOCAL(_addr)
\<BR>( IN6_IS_ADDR_MULTICAST (_addr) \<BR>&& ((((const
u_char *)(_addr))[1] & 0xf) == 0x2))<BR><BR>#define
IN6_IS_ADDR_MC_SITELOCAL(_addr) \<BR>(
IN6_IS_ADDR_MULTICAST(_addr) \<BR>&& ((((const u_char *)(_addr))[1]
& 0xf) == 0x5))<BR><BR>#define IN6_IS_ADDR_MC_ORGLOCAL(_addr)
\<BR>( IN6_IS_ADDR_MULTICAST(_addr) \<BR>&& ((((const
u_char *)(_addr))[1] & 0xf) == 0x8))<BR><BR>#define
IN6_IS_ADDR_MC_GLOBAL(_addr) \<BR>( IN6_IS_ADDR_MULTICAST(_addr)
\<BR>&& ((((const u_char *)(_addr))[1] & 0xf) ==
0xe))<BR><BR><BR>typedef int socklen_t;<BR><BR>struct ipv6_mreq {<BR>struct
in6_addr ipv6mr_multiaddr;<BR>unsigned int
ipv6mr_interface;<BR>};<BR>typedef struct ipv6_mreq IPV6_MREG;<BR><BR>struct
in6_pktinfo {<BR>IN6_ADDR ipi6_addr;<BR>UINT
ipi6_ifindex;<BR>};<BR>typedef struct in6_pktinfo
IN6_PKTINFO;<BR><BR>struct addrinfo {<BR>int
ai_flags;<BR>int
ai_family;<BR>int
ai_socktype;<BR>int ai_protocol;<BR>size_t
ai_addrlen;<BR>char *ai_canonname;<BR>struct sockaddr
*ai_addr;<BR>struct addrinfo *ai_next;<BR>};<BR><BR>#if (_WIN32_WINNT
>= 0x0501)<BR>void WSAAPI freeaddrinfo (struct addrinfo*);<BR>int WSAAPI
getaddrinfo (const char*,const char*,const struct
addrinfo*,<BR> struct
addrinfo**);<BR>int WSAAPI getnameinfo(const struct
sockaddr*,socklen_t,char*,DWORD,<BR>
char*,DWORD,int);<BR>#else<BR>/* FIXME: Need WS protocol-independent API
helpers. */<BR>#endif<BR><BR>static __inline char*<BR>gai_strerrorA(int
ecode)<BR>{<BR>static char message[1024+1];<BR>DWORD dwFlags =
FORMAT_MESSAGE_FROM_SYSTEM<BR> \
| FORMAT_MESSAGE_IGNORE_INSERTS<BR> |
FORMAT_MESSAGE_MAX_WIDTH_MASK;<BR>DWORD dwLanguageId =
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);<BR> FormatMessageA(dwFlags,
NULL, ecode, dwLanguageId, (LPSTR)message, 1024, NULL);<BR>return
message;<BR>}<BR>static __inline WCHAR*<BR>gai_strerrorW(int
ecode)<BR>{<BR>static WCHAR message[1024+1];<BR>DWORD dwFlags =
FORMAT_MESSAGE_FROM_SYSTEM<BR> \
| FORMAT_MESSAGE_IGNORE_INSERTS<BR> |
FORMAT_MESSAGE_MAX_WIDTH_MASK;<BR>DWORD dwLanguageId =
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);<BR> FormatMessageW(dwFlags,
NULL, ecode, dwLanguageId, (LPWSTR)message, 1024, NULL);<BR>return
message;<BR>}<BR>#ifdef UNICODE<BR>#define gai_strerror
gai_strerrorW<BR>#else<BR>#define gai_strerror
gai_strerrorA<BR>#endif<BR><BR>/* Some older IPv4/IPv6 compatibility stuff
*/<BR><BR>/* This struct lacks sin6_scope_id; retained for use in sockaddr_gen
*/<BR>struct sockaddr_in6_old {<BR>short sin6_family;<BR>u_short
sin6_port;<BR>u_long sin6_flowinfo;<BR>struct in6_addr
sin6_addr;<BR>};<BR><BR>typedef union sockaddr_gen{<BR>struct sockaddr
Address;<BR>struct sockaddr_in AddressIn;<BR>struct sockaddr_in6_old
AddressIn6;<BR>} sockaddr_gen;<BR><BR><BR>typedef struct _INTERFACE_INFO
{<BR>u_long iiFlags;<BR>sockaddr_gen iiAddress;<BR>sockaddr_gen
iiBroadcastAddress;<BR>sockaddr_gen iiNetmask;<BR>} INTERFACE_INFO,
*LPINTERFACE_INFO;<BR><BR>/*<BR> The definition above can cause
problems on NT4,prior to sp4.<BR> To workaround, include the
following struct and typedef and<BR> #define INTERFACE_INFO
OLD_INTERFACE_INFO<BR> See: FIX: WSAIoctl SIO_GET_INTERFACE_LIST
Option Problem<BR> (Q181520) in MSDN KB.<BR><BR> The
old definition causes problems on newer NT and on XP.<BR><BR>typedef struct
_OLD_INTERFACE_INFO {<BR>u_long iiFlags;<BR>struct sockaddr
iiAddress;<BR> struct sockaddr iiBroadcastAddress;<BR> struct
sockaddr iiNetmask;<BR>} OLD_INTERFACE_INFO;<BR>*/<BR><BR>#ifdef
__cplusplus<BR>}<BR>#endif<BR>#endif<BR>
<P>
<HR>
<P></P>_______________________________________________<BR>Winpcap-users
mailing
list<BR>Winpcap-users@winpcap.org<BR>https://www.winpcap.org/mailman/listinfo/winpcap-users<BR></BLOCKQUOTE></BODY></HTML>
_______________________________________________
Winpcap-users mailing list
Winpcap-users@winpcap.org
https://www.winpcap.org/mailman/listinfo/winpcap-users
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic