I'm trying to do cross-platform development, windows 7 host, QNX Neutrino target. Before trying to get the cross-platform development working, I'd like to test and play around with the code on my host, but Pcap isn't supported on Windows.
How similar are the syntax/function calls between Pcap and WinPcap? Could I take code I wrote for WinPcap and have it work for Pcap and a different machine?
(Presumably you mean "libpcap and WinPcap"; "pcap" refers either to "libpcap and WinPcap" or to the file format they both use.)
WinPcap is a port of libpcap to Windows, and shares a lot of libpcap's code. It consists of:
As a result, the vast majority of the calls in libpcap and WinPcap are identical, and share as much code between libpcap and WinPcap as between, for example, libpcap-on-FreeBSD and libpcap-on-Linux.
The API differences are:
pcap_open()
and doesn't have remote-capture support (in the future, there will be common APIs for remote-capture support, so code can be written to do remote capture on Windows and various UN*Xes);pcap_setbuff()
, but newer versions let you set the capture buffer size if you use pcap_create()
and pcap_activate()
to open a live capture, and those routines are also in newer versions of WinPcap;select()
/poll()
vs. WaitForMultipleObjects()
), the APIs to get the handle on which to wait are, of necessity, different;pcap_fopen_offline()
, might never be, thanks to different versions of the MSVC support library not being binary compatible with each other).So, for almost all purposes, it should be possible to write pcap-based code that works on various UN*Xes (and, apparently, QNX Neutrino) and on Windows, as long as you deal with other differences between the platforms.