tcpdump mailing list archives

Re: libpcap pcap_sendpacket support across platforms.


From: Guy Harris <gharris () sonic net>
Date: Tue, 23 Mar 2004 11:22:41 -0800

On Sat, Mar 13, 2004 at 06:46:33AM -0800, Mark Pizzolato wrote:
However, that problem can easily be solved with the following:

       [...]
        fd  = open(device, O_RDWR);
        if (fd < 0 && errno == EACCES)
                fd  = open(device, O_RDONLY);
       [...]

This would then leave the pcap connection to behave in a more consistent way
across all platforms (i.e. you can write to the connection when you have
privilege/authority to do so).

OK.

Attached is a revised patch, which keeps prior behaviors, while also
providing for pcap_sendpacket when possible.

I've merged your changes with a version I'd been working on, based on
libnet and some stuff we had at Network Appliance, and checked the
result in.  It implements *two* APIs - "pcap_inject()", from OpenBSD,
and "pcap_sendpacket()", from WinPcap.

Some issues:

        on BPF, libpcap doesn't do anything with BIOCSHDRCMPLT - libnet
        does;

        on DLPI, there's #if'ed-out code to use the appropriate "raw
        data" primitives on HP-UX - I don't have access to an HP-UX
        system on which to test them;

        on Linux, the version I checked in uses "sendto()", as that's
        what libnet did;

        on SunOS 4.x with STREAMS NIT, the code I checked in uses
        "putmsg()" - libnet and your code used "sendto()", but, as I
        remember, the Network Appliance code used "putmsg()", which is
        what I'd expect to be the correct call to use on a STREAMS-based
        mechanism.

-
This is the TCPDUMP workers list. It is archived at
http://www.tcpdump.org/lists/workers/index.html
To unsubscribe use mailto:tcpdump-workers-request () tcpdump org?body=unsubscribe


Current thread: