A tough critter: Net::Pcap on cygwin

somian on 2005-11-10T07:27:14

A fellow Perler asked me recently if I had ever installed the module Net::Pcap on a cygwinperl system. I had not and decided to look into what might might be going wrong for her.

As an interface to the external pcap library (written in C) the module uses XS and requires compilation. It is a fairly complex build and the authors have gone to a lot of trouble to write a very long Makefile.PL with elaborate "detection" routines. It still seems not to work (and as of this writing, no Net::Pcap release has ever passed on the cygwin platform, according to cpan-testers).

After setting up the WinPcap developers' pack and using the location of its lib and include files as arguments to 'perl Makefile.PL' I saw first errors relating to the detection code (which I'll detail later). After adjusting code in the Makefile.PL to fix them, I got into the test-compilation phase of the Makefile.PL routines and saw a torrent of C compiler errors and warnings flood the console screen. Those errors are thus (filtered through the following pipeline to make them more readable and succinct)

perl Makefile.PL LIBS="-L$W32LIB -lwpcap" INC=-I$W32INCL 2>&1 | perl -naF: -MCwd=realpath -le 'next unless /error/; $pn=$F[0]; $F[1]=~s{/DOCUME~1/SORENS~1/MYDOCU~1/}{/};print "",($pn =~m<^/\w+/> ? realpath(shift @F):join ":"=>splice(@F,0,2)), join(":"=>"",@F)'

ERRORS

 


C:/PROJEC~1/CVS_SR~1/WinPcap/include/pthread.h:271: error: redefinition of `struct timespec'
C:/PROJEC~1/CVS_SR~1/WinPcap/include/pthread.h:503: error: conflicting types for 'pthread_t'
/usr/include/cygwin/types.h:208: error: previous declaration of 'pthread_t' was here
C:/PROJEC~1/CVS_SR~1/WinPcap/include/pthread.h:504: error: conflicting types for 'pthread_attr_t'
/usr/include/cygwin/types.h:212: error: previous declaration of 'pthread_attr_t' was here
C:/PROJEC~1/CVS_SR~1/WinPcap/include/pthread.h:505: error: conflicting types for 'pthread_once_t'
/usr/include/cygwin/types.h:223: error: previous declaration of 'pthread_once_t' was here
C:/PROJEC~1/CVS_SR~1/WinPcap/include/pthread.h:506: error: conflicting types for 'pthread_key_t'
/usr/include/cygwin/types.h:211: error: previous declaration of 'pthread_key_t' was here
C:/PROJEC~1/CVS_SR~1/WinPcap/include/pthread.h:507: error: conflicting types for 'pthread_mutex_t'
/usr/include/cygwin/types.h:209: error: previous declaration of 'pthread_mutex_t' was here
C:/PROJEC~1/CVS_SR~1/WinPcap/include/pthread.h:508: error: conflicting types for 'pthread_mutexattr_t'
/usr/include/cygwin/types.h:213: error: previous declaration of 'pthread_mutexattr_t' was here
C:/PROJEC~1/CVS_SR~1/WinPcap/include/pthread.h:509: error: conflicting types for 'pthread_cond_t'
/usr/include/cygwin/types.h:215: error: previous declaration of 'pthread_cond_t' was here
C:/PROJEC~1/CVS_SR~1/WinPcap/include/pthread.h:510: error: conflicting types for 'pthread_condattr_t'
/usr/include/cygwin/types.h:214: error: previous declaration of 'pthread_condattr_t' was here
C:/PROJEC~1/CVS_SR~1/WinPcap/include/pthread.h:512: error: conflicting types for 'pthread_rwlock_t'
/usr/include/cygwin/types.h:224: error: previous declaration of 'pthread_rwlock_t' was here
C:/PROJEC~1/CVS_SR~1/WinPcap/include/pthread.h:513: error: conflicting types for 'pthread_rwlockattr_t'
/usr/include/cygwin/types.h:225: error: previous declaration of 'pthread_rwlockattr_t' was here
C:/PROJEC~1/CVS_SR~1/WinPcap/include/pthread.h:1082: error: conflicting types for 'pthread_kill'
/usr/include/sys/signal.h:163: error: previous declaration of 'pthread_kill' was here
C:/PROJEC~1/CVS_SR~1/WinPcap/include/pthread.h:1082: error: conflicting types for 'pthread_kill'
/usr/include/sys/signal.h:163: error: previous declaration of 'pthread_kill' was here
/usr/include/w32api/winsock2.h:101: error: redefinition of `struct timeval'
/usr/include/w32api/winsock2.h:112: error: redefinition of `struct hostent'
/usr/include/w32api/winsock2.h:120: error: redefinition of `struct linger'
/usr/include/w32api/winsock2.h:147: error: redefinition of `struct netent'
/usr/include/w32api/winsock2.h:153: error: redefinition of `struct servent'
/usr/include/w32api/winsock2.h:159: error: redefinition of `struct protoent'
/usr/include/w32api/winsock2.h:215: error: redefinition of `struct in_addr'
/usr/include/w32api/winsock2.h:246: error: redefinition of `struct sockaddr_in'
/usr/include/w32api/winsock2.h:327: error: redefinition of `struct sockaddr'
/usr/include/w32api/winsock2.h:515: error: conflicting types for 'accept'
/usr/include/sys/socket.h:29: error: previous declaration of 'accept' was here
/usr/include/w32api/winsock2.h:515: error: conflicting types for 'accept'
/usr/include/sys/socket.h:29: error: previous declaration of 'accept' was here
/usr/include/w32api/winsock2.h:516: error: conflicting types for 'bind'
/usr/include/sys/socket.h:30: error: previous declaration of 'bind' was here
/usr/include/w32api/winsock2.h:516: error: conflicting types for 'bind'
/usr/include/sys/socket.h:30: error: previous declaration of 'bind' was here
/usr/include/w32api/winsock2.h:518: error: conflicting types for 'connect'
/usr/include/sys/socket.h:31: error: previous declaration of 'connect' was here
/usr/include/w32api/winsock2.h:518: error: conflicting types for 'connect'
/usr/include/sys/socket.h:31: error: previous declaration of 'connect' was here
/usr/include/w32api/winsock2.h:520: error: conflicting types for 'getpeername'
/usr/include/sys/socket.h:32: error: previous declaration of 'getpeername' was here
/usr/include/w32api/winsock2.h:520: error: conflicting types for 'getpeername'
/usr/include/sys/socket.h:32: error: previous declaration of 'getpeername' was here
/usr/include/w32api/winsock2.h:521: error: conflicting types for 'getsockname'
/usr/include/sys/socket.h:33: error: previous declaration of 'getsockname' was here
/usr/include/w32api/winsock2.h:521: error: conflicting types for 'getsockname'
/usr/include/sys/socket.h:33: error: previous declaration of 'getsockname' was here
/usr/include/w32api/winsock2.h:522: error: conflicting types for 'getsockopt'
/usr/include/sys/socket.h:44: error: previous declaration of 'getsockopt' was here
/usr/include/w32api/winsock2.h:522: error: conflicting types for 'getsockopt'
/usr/include/sys/socket.h:44: error: previous declaration of 'getsockopt' was here
/usr/include/w32api/winsock2.h:523: error: conflicting types for 'inet_addr'
/usr/include/arpa/inet.h:22: error: previous declaration of 'inet_addr' was here
/usr/include/w32api/winsock2.h:523: error: conflicting types for 'inet_addr'
/usr/include/arpa/inet.h:22: error: previous declaration of 'inet_addr' was here
/usr/include/w32api/winsock2.h:524: error: conflicting types for 'inet_ntoa'
/usr/include/arpa/inet.h:28: error: previous declaration of 'inet_ntoa' was here
/usr/include/w32api/winsock2.h:524: error: conflicting types for 'inet_ntoa'
/usr/include/arpa/inet.h:28: error: previous declaration of 'inet_ntoa' was here
/usr/include/w32api/winsock2.h:525: error: conflicting types for 'listen'
/usr/include/sys/socket.h:34: error: previous declaration of 'listen' was here
/usr/include/w32api/winsock2.h:525: error: conflicting types for 'listen'
/usr/include/sys/socket.h:34: error: previous declaration of 'listen' was here
/usr/include/w32api/winsock2.h:526: error: conflicting types for 'recv'
/usr/include/sys/socket.h:35: error: previous declaration of 'recv' was here
/usr/include/w32api/winsock2.h:526: error: conflicting types for 'recv'
/usr/include/sys/socket.h:35: error: previous declaration of 'recv' was here
/usr/include/w32api/winsock2.h:527: error: conflicting types for 'recvfrom'
/usr/include/sys/socket.h:37: error: previous declaration of 'recvfrom' was here
/usr/include/w32api/winsock2.h:527: error: conflicting types for 'recvfrom'
/usr/include/sys/socket.h:37: error: previous declaration of 'recvfrom' was here
/usr/include/w32api/winsock2.h:528: error: conflicting types for 'send'
/usr/include/sys/socket.h:39: error: previous declaration of 'send' was here
/usr/include/w32api/winsock2.h:528: error: conflicting types for 'send'
/usr/include/sys/socket.h:39: error: previous declaration of 'send' was here
/usr/include/w32api/winsock2.h:529: error: conflicting types for 'sendto'
/usr/include/sys/socket.h:42: error: previous declaration of 'sendto' was here
/usr/include/w32api/winsock2.h:529: error: conflicting types for 'sendto'
/usr/include/sys/socket.h:42: error: previous declaration of 'sendto' was here
/usr/include/w32api/winsock2.h:530: error: conflicting types for 'setsockopt'
/usr/include/sys/socket.h:43: error: previous declaration of 'setsockopt' was here
/usr/include/w32api/winsock2.h:530: error: conflicting types for 'setsockopt'
/usr/include/sys/socket.h:43: error: previous declaration of 'setsockopt' was here
/usr/include/w32api/winsock2.h:531: error: conflicting types for 'shutdown'
/usr/include/sys/socket.h:45: error: previous declaration of 'shutdown' was here
/usr/include/w32api/winsock2.h:531: error: conflicting types for 'shutdown'
/usr/include/sys/socket.h:45: error: previous declaration of 'shutdown' was here
/usr/include/w32api/winsock2.h:532: error: conflicting types for 'socket'
/usr/include/sys/socket.h:46: error: previous declaration of 'socket' was here
/usr/include/w32api/winsock2.h:532: error: conflicting types for 'socket'
/usr/include/sys/socket.h:46: error: previous declaration of 'socket' was here
/usr/include/w32api/winsock2.h:533: error: conflicting types for 'gethostbyaddr'
/usr/include/netdb.h:139: error: previous declaration of 'gethostbyaddr' was here
/usr/include/w32api/winsock2.h:533: error: conflicting types for 'gethostbyaddr'
/usr/include/netdb.h:139: error: previous declaration of 'gethostbyaddr' was here
/usr/include/w32api/winsock2.h:534: error: conflicting types for 'gethostbyname'
/usr/include/netdb.h:140: error: previous declaration of 'gethostbyname' was here
/usr/include/w32api/winsock2.h:534: error: conflicting types for 'gethostbyname'
/usr/include/netdb.h:140: error: previous declaration of 'gethostbyname' was here
/usr/include/w32api/winsock2.h:535: error: conflicting types for 'getservbyport'
/usr/include/netdb.h:149: error: previous declaration of 'getservbyport' was here
/usr/include/w32api/winsock2.h:535: error: conflicting types for 'getservbyport'
/usr/include/netdb.h:149: error: previous declaration of 'getservbyport' was here
/usr/include/w32api/winsock2.h:536: error: conflicting types for 'getservbyname'
/usr/include/netdb.h:148: error: previous declaration of 'getservbyname' was here
/usr/include/w32api/winsock2.h:536: error: conflicting types for 'getservbyname'
/usr/include/netdb.h:148: error: previous declaration of 'getservbyname' was here
/usr/include/w32api/winsock2.h:537: error: conflicting types for 'getprotobynumber'
/usr/include/netdb.h:146: error: previous declaration of 'getprotobynumber' was here
/usr/include/w32api/winsock2.h:537: error: conflicting types for 'getprotobynumber'
/usr/include/netdb.h:146: error: previous declaration of 'getprotobynumber' was here
/usr/include/w32api/winsock2.h:538: error: conflicting types for 'getprotobyname'
/usr/include/netdb.h:145: error: previous declaration of 'getprotobyname' was here
/usr/include/w32api/winsock2.h:538: error: conflicting types for 'getprotobyname'
/usr/include/netdb.h:145: error: previous declaration of 'getprotobyname' was here
/usr/include/w32api/winsock2.h:607: error: parse error before '(' token
/usr/include/w32api/winsock2.h:607: error: parse error before '?' token
/usr/include/w32api/winsock2.h:608: error: parse error before '(' token
/usr/include/w32api/winsock2.h:608: error: parse error before '?' token
/usr/include/w32api/winsock2.h:609: error: parse error before '(' token
/usr/include/w32api/winsock2.h:609: error: parse error before '?' token
/usr/include/w32api/winsock2.h:610: error: parse error before '(' token
/usr/include/w32api/winsock2.h:610: error: parse error before '?' token
/usr/include/w32api/winsock2.h:611: error: conflicting types for 'select'
/usr/include/sys/select.h:31: error: previous declaration of 'select' was here
/usr/include/w32api/winsock2.h:611: error: conflicting types for 'select'
/usr/include/sys/select.h:31: error: previous declaration of 'select' was here
/usr/include/w32api/winsock2.h:614: error: conflicting types for 'gethostname'
/usr/include/sys/unistd.h:206: error: previous declaration of 'gethostname' was here
/usr/include/w32api/winsock2.h:614: error: conflicting types for 'gethostname'
/usr/include/sys/unistd.h:206: error: previous declaration of 'gethostname' was here
C:/PROJEC~1/CVS_SR~1/WinPcap/include/bittypes.h:71: error: conflicting types for 'int32_t'
/usr/include/stdint.h:20: error: previous declaration of 'int32_t' was here
/usr/include/w32api/ws2tcpip.h:124: error: redefinition of `struct ip_mreq'

That's a pretty discouraging output.


Re: A tough critter: Net::Pcap on cygwin

Maddingue on 2005-11-10T11:12:10

Sorry to have broken Cygwin, but I'm not a Win32/Cygwin programmer and therefore rely on Jean-Louis Morel and generaly on user feedback. I may be the one to blame for this release because I didn't ask Jean-Louis to test it on Cygwin and ActivePerl as I didn't change Win32-related code, and therefore assumed it would work. Can you try version 0.09 or 0.08 and tell me if these work for you? Feel free to fill a bug report in Net::Pcap RT queue.

Note that the "elaborate detection routines" are unfortunately needed because the Pcap library didn't provide any version information before 0.8 or something. Part of this detection code comes from XML::LibXML Makefile.PL because it's the one everybody advice to use, and the other part is here to detect the functions actually available in the Pcap library of the host system. Why doing all this? Because the old BSD versions of the Pcap library (the one in FreeBSD and Darwin for example) lack many functions present in the newer versions. And of course, each new version provides new functions, but there are not the same under Unix and Win32, and vary from version to version. Oh, and the Unix version is underdocumented compared to the Win32 version. Hence all this probing stuff.

Re: A tough critter: Net::Pcap on cygwin

Maddingue on 2005-11-10T11:37:59

Oh, just for the records, the version 0.09 should work on ActivePerl, and you can install the PPM from Randy Kobes' repositories. See http://cpan.uwinnipeg.ca/dist/Net-Pcap

(I know, it's ActivePerl, not Cygwin; but Cygwin is a little tough to get right, as it partially relies on Win32 to use WinPcap.)

Re: A tough critter: Net::Pcap on cygwin

somian on 2005-11-11T01:29:00

Hi, thanks for commenting, Sébastien. No, I am afraid there is nothing sufficiently different in v0.09 that it can work under Cygwin. It doesn't. Two things stand out in the overview of WinPcap and Net::Pcap that I've gotten over the last couple of days. One is that nowhere that I have seen is anyone claiming that WinPcap is software that has been ported to Cygwin. The clear claim is that WinPcap "can be built using cygwin", and I've established, by looking hard at the build infrastructure (Makefiles) and readme-s for WinPcap, that this claim is a case of inaccurate terminology. The second standout is that Jean-Louis Morel does not seem to document a case of getting Net::Pcap to work under Cygwin's Perl, nor is there any instance available under extensive Google-ing, of anyone else ever showing or claiming that this has happened.

WinPcap has Makefiles (named GNUmakefile) that use the -mno-cygwin switch to gcc. Even if you are not a Win32 or a Cygwin programmer, I am afraid you need to know about this switch, yes! -- in order to avoid being misled (deliberately or not) by people claiming things that aren't true. This switch causes the cygwin/mingw GCC compiler system to assume the other half of its dual nature: that of a compiler / preprocessor / assembler /linker etc. that only knows about the Microsoft C runtime library and nothing whatsoever about the Cygwin1.dll POSIX emulation C runtime. Specifically when run this way: the headers in /usr/include (the location of a standard system library, same with Cygwin as with any *NIX -- which is part of point of Cygwin, in case you didn't realize that) are not part of the preprocessor search path.

Since the Politecnico di Torino folk are kind of claiming (misleadingly) to have software that "compiles under Cygwin" but does not (it is 100% Win32 software, no Cygwin), someone might have claimed to you that Net::Pcap can run under cygwinperl. It rather looks from the existing RT entries, the files in your module's tree, etc, as well as you own comment above, that the main person who might have been claiming this to you is Jean-Louis Morel. However, even at http://www.bribes.org/perl/wnetpcap.html Jean-Louis does not appear to be claiming that he got Net::Pcap to work under Cygwin. He claims to have gotten it to work with Win32, and these two things are not the same. Cygwin Perl is internally much more like a GNU/Linux or BSD Perl* than it is like Perl for Win32 (by ActiveState or anywhere else).

If my analysis turns out to be correct, I humbly suggest that a fairly important update to Net::Pcap is due, and that update be to make the first documentation that the user sees be a notice that the module will not work with Cygwin's native Perl software, period. The Makefile.PL needs to be changed to not fool around: $^O =~ /cygwin/ and die "Cannot use with Cygwin".

*Cygwin Perl is compiled using the Cygwin/MinGW GCC compiler system in cygwin mode. The definitions of socket, networking symbols in the cygwin headers clash with the winsock or winsock2 definitions. If Jean-Louis Morel is actually claiming (privately to you) to have worked around this fundamental problem, I would be very excited to see him document his procedure publicly so that we can reproduce it.

Finally, I hope that you won't take this recitation of hard, factual information as some sort of attack on yourself, Jean-Louis, or anyone else. I am a volunteer too. This reply is part of an attempt to (perhaps a bit forcefully) impose some clarity and reality on a set of independent, unrelated software projects and the available public documentation of those projects, that seems to be somewhat lacking. That's to benefit users, not to "prove anyone wrong."

Best Regards.

Re: A tough critter: Net::Pcap on cygwin

Maddingue on 2005-11-11T23:53:55

Ok, I took some time and used a Windows system with a Cygwin to test Net::Pcap myself. I have to admit that it's far from being obvious, but all this comes from the fact that Cygwin pretends to be a Unix system (it internally defines itself as a Unix, offers the Unix API, and defines the preprocessor macro _unix). But in fact, it is really bound by the limitations of the Win32 system on which it runs. It usually works in an quite acceptable manner, but in some corner cases can lead to strange behaviour because it can't work exactly like a Unix system, and yet doesn't behave like a Win32 system. A example I recently outlined in Perl5 Porters is the behaviour of unlink(), which is neither like Unix nor Win32.

I usually sum up the Cygwin problem in French by saying that it has "le cul entre deux chaises" (its ass between two chairs).

That said, Jean-Louis Morel assured me that Net::Pcap worked under Cygwin. His web page is not yet out of date as I haven't integrated all the changes he made for the Windows (ActiveState + Cygwin) version of Net::Pcap (the current CPAN version still miss several Windows specific functions).

So let's examine the problem. The WinPcap library is, as you said, a Win32 library, but the developer kit includes several versions. It also includes several headers. Indeed, some of the headers included in the developer kit contains the Win32 definitions of the network API, which directly clashes with the ones defined in Cygwin /usr/include. The clash happens because Cygwin's packet.h tests for and defines a _PACKET_H macro while the WinPcap one tests for and defines a PACKET_H macro.

Ok, so the headers are the problem. So why not just copy the necessary headers to compile Net::Pcap in /usr/include? (I'm saying this from memory, I don't have the Windows machine at hand)

cp Headers/pcap* /usr/include

Now these headers will be in the default search path, and we just have to give the location of the libraries:

perl Makefile.PL LIBS="-L$WIN32LIB -lwpcap"

Et voilà !

I agree this is twisted, but with this, I was able to compile and run a few tests. I couldn't run the whole test suite because lookupdev() returned by default what seems to be the modem device.. which is very unlikely to see any traffic at all as I am connected with an Ethernet interface like any modern workstation. So there's a need here for handling this special case, but at least, I can confirm myself that Net::Pcap compiles and can be run under Cygwin.

And I didn't even ask Jean-Louis for help, so it wasn't that hard ;-)

That said, I agree that Jean-Louis probably overlooked the fact that his system has already been configured to handle this. Maybe he just also copied some of the libs in /usr/lib (I tried that once but it didn't work, but I may have forgot one of them). So I'll update the documentation and the help message to help Cygwin users.

Please try this on you system and confirm that it also works for you. If that's the case, then you owe me a bar of chocolate ;-)

Re: A tough critter: Net::Pcap on cygwin

somian on 2005-11-18T08:16:36

Hello again, Sébastien. No good news, and no bar of chocolate, I'm afraid.

The technique you cited above is unacceptable to me exactly as given, because the contents of /usr/include are managed by the Cygwin package management system. I under no circumstances will manually copy files into that directory as a matter of programmer / sysadmin discipline. The evils that can stem from that act are manifold, and include being unable to reproduce user errors reported by anyone who tries to duplicate any work I document or software I release. It's ok if others disagree, and it's even ok if someone wants to think of this as "anal". I'm the only one who experiences the repercussions to my system, so I don't care much about namecalling or offhand opinions.

The results this run were obtained after doing the following steps. I viewed the contents of include/ in the WinPcap Developers Pack tree and removed anything that did not match the globbing expr "pcap*". I made the INC= argument to perl Makefile.PL point to that location (fully qualified pathname). I re-ran the same command as before and captured the output (see below). Essentially, these are the same errors as before. I am giving up, but before showing the compiler errors yet another time, I'm going to wonder aloud whether (a) you are using the same WinPcap Developer's Pack, and (b) whether you are sure that all header files normally present in the Cygwin system location (under /usr/include) are present on the machine you tested with.

/usr/include/w32api/winsock2.h:101: error: redefinition of `struct timeval'
/usr/include/w32api/winsock2.h:112: error: redefinition of `struct hostent'
/usr/include/w32api/winsock2.h:120: error: redefinition of `struct linger'
/usr/include/w32api/winsock2.h:147: error: redefinition of `struct netent'
/usr/include/w32api/winsock2.h:153: error: redefinition of `struct servent'
/usr/include/w32api/winsock2.h:159: error: redefinition of `struct protoent'
/usr/include/w32api/winsock2.h:215: error: redefinition of `struct in_addr'
/usr/include/w32api/winsock2.h:246: error: redefinition of `struct sockaddr_in'
/usr/include/w32api/winsock2.h:328: error: redefinition of `struct sockaddr'
/usr/include/w32api/winsock2.h:516: error: conflicting types for 'accept'
/usr/include/sys/socket.h:29: error: previous declaration of 'accept' was here
/usr/include/w32api/winsock2.h:516: error: conflicting types for 'accept'
/usr/include/sys/socket.h:29: error: previous declaration of 'accept' was here
/usr/include/w32api/winsock2.h:517: error: conflicting types for 'bind'
/usr/include/sys/socket.h:30: error: previous declaration of 'bind' was here
/usr/include/w32api/winsock2.h:517: error: conflicting types for 'bind'
/usr/include/sys/socket.h:30: error: previous declaration of 'bind' was here
/usr/include/w32api/winsock2.h:519: error: conflicting types for 'connect'
/usr/include/sys/socket.h:31: error: previous declaration of 'connect' was here
/usr/include/w32api/winsock2.h:519: error: conflicting types for 'connect'
/usr/include/sys/socket.h:31: error: previous declaration of 'connect' was here
/usr/include/w32api/winsock2.h:521: error: conflicting types for 'getpeername'
/usr/include/sys/socket.h:32: error: previous declaration of 'getpeername' was here
/usr/include/w32api/winsock2.h:521: error: conflicting types for 'getpeername'
/usr/include/sys/socket.h:32: error: previous declaration of 'getpeername' was here
/usr/include/w32api/winsock2.h:522: error: conflicting types for 'getsockname'
/usr/include/sys/socket.h:33: error: previous declaration of 'getsockname' was here
/usr/include/w32api/winsock2.h:522: error: conflicting types for 'getsockname'
/usr/include/sys/socket.h:33: error: previous declaration of 'getsockname' was here
/usr/include/w32api/winsock2.h:523: error: conflicting types for 'getsockopt'
/usr/include/sys/socket.h:44: error: previous declaration of 'getsockopt' was here
/usr/include/w32api/winsock2.h:523: error: conflicting types for 'getsockopt'
/usr/include/sys/socket.h:44: error: previous declaration of 'getsockopt' was here
/usr/include/w32api/winsock2.h:524: error: conflicting types for 'inet_addr'
/usr/include/arpa/inet.h:22: error: previous declaration of 'inet_addr' was here
/usr/include/w32api/winsock2.h:524: error: conflicting types for 'inet_addr'
/usr/include/arpa/inet.h:22: error: previous declaration of 'inet_addr' was here
/usr/include/w32api/winsock2.h:525: error: conflicting types for 'inet_ntoa'
/usr/include/arpa/inet.h:28: error: previous declaration of 'inet_ntoa' was here
/usr/include/w32api/winsock2.h:525: error: conflicting types for 'inet_ntoa'
/usr/include/arpa/inet.h:28: error: previous declaration of 'inet_ntoa' was here
/usr/include/w32api/winsock2.h:526: error: conflicting types for 'listen'
/usr/include/sys/socket.h:34: error: previous declaration of 'listen' was here
/usr/include/w32api/winsock2.h:526: error: conflicting types for 'listen'
/usr/include/sys/socket.h:34: error: previous declaration of 'listen' was here
/usr/include/w32api/winsock2.h:527: error: conflicting types for 'recv'
/usr/include/sys/socket.h:35: error: previous declaration of 'recv' was here
/usr/include/w32api/winsock2.h:527: error: conflicting types for 'recv'
/usr/include/sys/socket.h:35: error: previous declaration of 'recv' was here
/usr/include/w32api/winsock2.h:528: error: conflicting types for 'recvfrom'
/usr/include/sys/socket.h:37: error: previous declaration of 'recvfrom' was here
/usr/include/w32api/winsock2.h:528: error: conflicting types for 'recvfrom'
/usr/include/sys/socket.h:37: error: previous declaration of 'recvfrom' was here
/usr/include/w32api/winsock2.h:529: error: conflicting types for 'send'
/usr/include/sys/socket.h:39: error: previous declaration of 'send' was here
/usr/include/w32api/winsock2.h:529: error: conflicting types for 'send'
/usr/include/sys/socket.h:39: error: previous declaration of 'send' was here
/usr/include/w32api/winsock2.h:530: error: conflicting types for 'sendto'
/usr/include/sys/socket.h:42: error: previous declaration of 'sendto' was here
/usr/include/w32api/winsock2.h:530: error: conflicting types for 'sendto'
/usr/include/sys/socket.h:42: error: previous declaration of 'sendto' was here
/usr/include/w32api/winsock2.h:531: error: conflicting types for 'setsockopt'
/usr/include/sys/socket.h:43: error: previous declaration of 'setsockopt' was here
/usr/include/w32api/winsock2.h:531: error: conflicting types for 'setsockopt'
/usr/include/sys/socket.h:43: error: previous declaration of 'setsockopt' was here
/usr/include/w32api/winsock2.h:532: error: conflicting types for 'shutdown'
/usr/include/sys/socket.h:45: error: previous declaration of 'shutdown' was here
/usr/include/w32api/winsock2.h:532: error: conflicting types for 'shutdown'
/usr/include/sys/socket.h:45: error: previous declaration of 'shutdown' was here
/usr/include/w32api/winsock2.h:533: error: conflicting types for 'socket'
/usr/include/sys/socket.h:46: error: previous declaration of 'socket' was here
/usr/include/w32api/winsock2.h:533: error: conflicting types for 'socket'
/usr/include/sys/socket.h:46: error: previous declaration of 'socket' was here
/usr/include/w32api/winsock2.h:534: error: conflicting types for 'gethostbyaddr'
/usr/include/netdb.h:139: error: previous declaration of 'gethostbyaddr' was here
/usr/include/w32api/winsock2.h:534: error: conflicting types for 'gethostbyaddr'
/usr/include/netdb.h:139: error: previous declaration of 'gethostbyaddr' was here
/usr/include/w32api/winsock2.h:535: error: conflicting types for 'gethostbyname'
/usr/include/netdb.h:140: error: previous declaration of 'gethostbyname' was here
/usr/include/w32api/winsock2.h:535: error: conflicting types for 'gethostbyname'
/usr/include/netdb.h:140: error: previous declaration of 'gethostbyname' was here
/usr/include/w32api/winsock2.h:536: error: conflicting types for 'getservbyport'
/usr/include/netdb.h:149: error: previous declaration of 'getservbyport' was here
/usr/include/w32api/winsock2.h:536: error: conflicting types for 'getservbyport'
/usr/include/netdb.h:149: error: previous declaration of 'getservbyport' was here
/usr/include/w32api/winsock2.h:537: error: conflicting types for 'getservbyname'
/usr/include/netdb.h:148: error: previous declaration of 'getservbyname' was here
/usr/include/w32api/winsock2.h:537: error: conflicting types for 'getservbyname'
/usr/include/netdb.h:148: error: previous declaration of 'getservbyname' was here
/usr/include/w32api/winsock2.h:538: error: conflicting types for 'getprotobynumber'
/usr/include/netdb.h:146: error: previous declaration of 'getprotobynumber' was here
/usr/include/w32api/winsock2.h:538: error: conflicting types for 'getprotobynumber'
/usr/include/netdb.h:146: error: previous declaration of 'getprotobynumber' was here
/usr/include/w32api/winsock2.h:539: error: conflicting types for 'getprotobyname'
/usr/include/netdb.h:145: error: previous declaration of 'getprotobyname' was here
/usr/include/w32api/winsock2.h:539: error: conflicting types for 'getprotobyname'
/usr/include/netdb.h:145: error: previous declaration of 'getprotobyname' was here
/usr/include/w32api/winsock2.h:608: error: parse error before '(' token
/usr/include/w32api/winsock2.h:608: error: parse error before '?' token
/usr/include/w32api/winsock2.h:609: error: parse error before '(' token
/usr/include/w32api/winsock2.h:609: error: parse error before '?' token
/usr/include/w32api/winsock2.h:610: error: parse error before '(' token
/usr/include/w32api/winsock2.h:610: error: parse error before '?' token
/usr/include/w32api/winsock2.h:611: error: parse error before '(' token
/usr/include/w32api/winsock2.h:611: error: parse error before '?' token
/usr/include/w32api/winsock2.h:612: error: conflicting types for 'select'
/usr/include/sys/select.h:31: error: previous declaration of 'select' was here
/usr/include/w32api/winsock2.h:612: error: conflicting types for 'select'
/usr/include/sys/select.h:31: error: previous declaration of 'select' was here
/usr/include/w32api/winsock2.h:615: error: conflicting types for 'gethostname'
/usr/include/sys/unistd.h:206: error: previous declaration of 'gethostname' was here
/usr/include/w32api/winsock2.h:615: error: conflicting types for 'gethostname'
/usr/include/sys/unistd.h:206: error: previous declaration of 'gethostname' was here
/whpd/SorenSpecial/MYDOCU~1/SRCtrees/WinPcap/include/pcap-stdinc.h:53:22: bittypes.h: No such file or directory
/whpd/SorenSpecial/MYDOCU~1/SRCtrees/WinPcap/include/pcap-stdinc.h:58:22: IP6_misc.h: No such file or directory

The versions on my system for the 3 most relevant Cygwin pkgs are as follows:

Cygwin Package Information
Package Version Status
cygwin 1.5.18-1 OK
gcc 3.4.4-1 OK
perl 5.8.6-4 OK

Regards and good luck,
Soren Andersen (somian)