I've been working on a system simulator (simh http://simh.trailing-edge.com) which provides ethernet device emulation for the systems which originally had ethernet devices (i.e. vax, pdp11 and pdp10).
The ethernet support for this package was originally implemented on Windows with Winpcap, and then ported back to other platforms leveraging the generic libpcap capabilities. The only lacking piece here, from an API poinit of view, has been pcap_sendpacket. Just to get by, we've had platform specific network code in the layer which uses libpcap to provide a pcap_sendpacket for the non Windows platforms. This only solves part of the problem since several platforms use pcap-bpf.c or pcap-pf.c or pcap-snit.c which open the network device O_RDONLY. To get useful functionality on these platforms, we've needed to hack pcap-bpf.c, or pcap-pf.c or pcap-snit.c and change O_RDONLY to O_RDWR. If would seem that the right thing to do is to generically include pcap_sendpacket and the related open requirements in the base pcap library. To that end, the attached set of patches implementes pcap_sendpacket where possible, and behaves reasonably otherwise. In pcap.h, I've messed with PCA_MINOR_VERSION in an attempt to have the code which uses pcap.h to have a compile time means of determinig if pcap_sendpacket is available: #if (_WIN32) || (PCAP_MAJOR_VERSION > 2) || ((PCAP_MAJOR_VERSION == 2) && (PCAP_MINOR_VERSION > 4)) #define HAS_PCAP_SENDPACKET 1 #endif Is there a better way to do this at compile time? I've tested this patched code on platforms which use pcap-bpf.c, pcap-linux.c, pcap-dlpi.c. If you accept this, I'll take a stab at updating the man page as well. Thanks. - Mark Pizzolato
pcap_sendpacket.patch
Description: Binary data
