tcpdump mailing list archives

Re: [PATCH]: pcap and zero copy with requested modification


From: Yoann Vandoorselaere <yoann () prelude-ids org>
Date: Tue, 06 Jan 2004 17:14:32 +0000

On Tue, 2004-01-06 at 07:27, Guy Harris wrote:
On Tue, Jan 06, 2004 at 03:30:30PM +1300, Jesper Peterson wrote:
Yoann Vandoorselaere wrote:
+        if ( ! alloc_buffer_cb ) {
+                static struct pcap_pkthdr hdr;
+                return &hdr;
+        }

This isn't re-entrant. To allow multithreading and building libpcap as a DLL, 
the default header buffer should probably be in pcap_t.

I agree.

There already *is* one there in 0.8.1 and later - the "pcap_header"
member of a "pcap_t".

Have this fixed in my internal tree...

By the way, I yet have to port pcap_offline_read(), but looking at the
read_op function pointer within the pcap_t structure (which is also set
in the savefile backend), I wonder why the code in pcap_loop() doesn't
just call pcap_dispatch (which itself will call read_op). 

It'd be much cleaner to call pcap_dispatch, which already have the
pcap_buffer_lock modification, than reimplementing it in
pcap_offline_read itself. Am I correct that the only thing that will
change when reading from a savefile is the meaning of a return value of
0 ? Is the modification okay with you ?

Thanks,

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

Attachment: signature.asc
Description: This is a digitally signed message part


Current thread: