Ethereal-dev: [Ethereal-dev] pcap version info

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

From: Biot Olivier <olivier_biot@xxxxxxxxx>
Date: Fri, 12 Dec 2003 06:25:01 -0800 (PST)
Hi List,

[e-mail problems still not solved, hence I send via
external mail client]

There is seemingly no simple way to know whether we're
using libpcap or winpcap. I've been trying some stuff,
and eventually found an unexposed function in
Packet32.h called PacketGetVersion() returning a text
string. This only returns version information from
Packet.dll (libpacket.a) and is only available if you
declare it as external, and link with '-lpcap
-lpacket'. See for example attached code sample.

Is it a fair assumption that packet.dll and wpcap.dll
have the same version?

This might be useful for capture-wpcap.c and
pcap-util-unix.c. Maybe we should add some code in
acinclude.m4 for checking whether we're using libpcap
or winpcap, and how to check the pcap/winpcap version?

Regards,

Olivier

__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/
#include <pcap.h>
#include <stdio.h>

/* Defined in Packet32.h, included by pcap-int.h (containing non-exported code) */
extern char * PacketGetVersion(void);

int
main(int argc, char **argv)
{
#ifdef PCAP_VERSION_MAJOR
#ifdef PCAP_VERSION_MINOR
	printf("pcap %u.%u\n",
			PCAP_VERSION_MAJOR, PCAP_VERSION_MINOR);
#else /* PCAP_VERSION_MINOR */
	printf("pcap %u.%u\n",
			PCAP_VERSION_MAJOR);
#endif /* PCAP_VERSION_MINOR */
#else /* PCAP_VERSION_MAJOR */
	printf("pcap (unknown version)\n");
#endif

	printf(PacketGetVersion());
	return 0;
}