tcpdump mailing list archives

[PATCH]: pcap and zero copy.


From: Yoann Vandoorselaere <yoann () prelude-ids org>
Date: Sun, 04 Jan 2004 12:02:13 +0000

Hi,

here is a patch I made to libpcap, permitting zero copy by allowing the
calling application to specify it's own allocation/freeing function for
the packet buffer, and the pcap header.

This patch was done in a way that it won't break the existing libpcap
API (except for the pcap_next function, but I could simply remove the
modification here and move them to pcap_next_ex, which is more
appropriate and would avoid API breakage for this function).

This patch allow application that need to keep track of packet to avoid
making a copy of the pcap buffer.

The change might be a little complicated to understand because we have
to deal with a number of issues: for example some of the pcap OS
dependant packet reading layer might put several packet in the same
buffer, and that's why pcap_header was modifier to hold a refcount.

I'm maintaining my own version of libpcap, kept in sync with this patch.
Seeing the new pcap_next_ex function within libpcap 0.8, that seemed
related to what I am doing with this patch (but which in fact is not
related at all), I just thought I would send this patch to the list to
know if :

- are people interested by the inclusion of this patch ?
- does people feel it should be done another way ?

It's really a lost of time to have to maintain a separate version of the
patch and keep it in sync with every released pcap version, so I'm
looking forward at this being included in the pcap main repository.


I'm looking forward to hearing from you,


-- 
Yoann Vandoorselaere <yoann () prelude-ids org>

Attachment: libpcap.diff
Description:


Current thread: