Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Ethereal-dev: Re: [Ethereal-dev] Problem building on win32

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Guy Harris <guy@xxxxxxxxxx>
Date: Tue, 3 Dec 2002 14:45:00 -0800
On Tue, Dec 03, 2002 at 02:50:43PM -0500, Jason House wrote:
> if inclusion of pcap.h causes a problem, then I would recommend that
> there should be a simple wrapper file... the contents being similar to
> the following:
> 
> #ifndef _PCAP_WRAPPER
> #  define _PCAP_WRAPPER
> #  ifdef HAVE_PCAP_H
> #    ifdef HAVE_WINSOCK2_H
> #      include <winsock2.h>
> #    endif
> #    include "pcap.h"
> #  endif
> #endif

"pcap.h" includes <net/bpf.h>, and the WinPcap version of "net/bpf.h"
includes "winsock2.h", so the only difference that construct would make
would be to move the include of "winsock2.h" before the includes of
<sys/types.h>, <sys/timeb.h>, and <time.h> in "pcap.h" and the include
of <gnuc.h> in "net/bpf.h".

Unless one of those files is including "winsock.h", that won't make a
difference.

> That is the way to get around it on my copy of real (2k) windows... I
> assume the various windows flavors work similarly...
> Rather than swap the order, the easiest approach would be to simply try
> to include winsock2.h before winsock.h

That's not "simple".

*No* code in Ethereal directly includes "winsock.h", and the only .c files
that include "winsock2.h" are

	epan/resolv.c
	epan/to_str.c
	epan/inet_aton.c
	epan/int_ntop.c
	epan/inet_pton.c

and any .c file that includes <wiretap/wtap.h> or <wiretap/wtap-int.h>,
as those files also include "winsock2.h".

So in order to "try to include winsock2.h before winsock.h", we first
have to know where "winsock2.h" and "winsock.h" are being included; in
"gtk/capture_dlg.c", which is one of the source files with the problem,
<pcap.h> is being included, and that causes "winsock2.h" to be included
on Windows.  That still leaves the question of what's including
"winsock.h".

If, as Graham said, "the only ?? places including winsock.h are
Packet32.h and BPF.h in WinPCap", then he's using an old version of the
WinPcap developer's package, as the WinPcap 2.3 and 3.0a4 versions both
include "winsock2.h", *NOT* "winsock.h".

If so, then the fix is simple:

	if the currently installed WinPcap is prior to 2.3, uninstall it
	and install 2.3;

	uninstall the pre-2.3 version of the WinPcap developer's package
	and install the 2.3 version;

	do "make clean" from the top-level Ethereal directory;

	do a make.