tcpdump mailing list archives

Re: pcap_handler return value


From: Guy Harris <guy () alum mit edu>
Date: Wed, 24 Mar 2004 16:05:29 -0800


On Mar 24, 2004, at 3:19 PM, Christian Kreibich wrote:

would you guys consider changing the return value of the pcap_handler
callbacks to

typedef int (*pcap_handler)(u_char *, const struct pcap_pkthdr *,
                            const u_char *);

so that the callback gets a chance to stop a pcap_loop() or
pcap_dispatch() iteration, say when returning 0 as opposed to 1?

We might, if we also add new APIs to support the new callback.

Changing the *current* API's would break all existing apps using "pcap_loop()" or "pcap_dispatch()", as their callbacks return nothing and, if libpcap acts as if they do, the loop might randomly terminate depending on what value happens to be left in whatever location (a register, in most if not all ABI's) is used for the return value of an "int" function, so we won't consider doing that.

I've repreatedly found that it'd be nice to remain in control over when to
abort the loop.

Does "pcap_breakloop()" not work? (It's not present in pre-0.8 versions of libpcap - but a different callback API isn't present in them, either, but it also isn't present in 0.8[.x].)

-
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: