Added the function pcap_time which captures for a specified number of seconds. This was for implementing an option in tcpdump that does the same thing. It brings time.h into pcap.c
Timed capture doesn't require libpcap changes - and that code won't work on all platforms in any case. A call to the read method for a capture device can block indefinitely if no packets arrive (the timeout specified in pcap_open_live() is *not* guaranteed to be a timer that starts when you try to read packets; on Solaris, for example, the timer doesn't start until the first packet arrives, and, on some platforms, there isn't a timer.
Using alarm() in tcpdump would work on all UN*X platforms - without requiring a call to time() for each packet batch. On Windows, the multimedia timer might be usable; note the code that's already there in top-of-tree tcpdump, where, if you're capturing to a file with the "-w" flag, the "-v" flag causes tcpdump to periodically report how many packets it's captured.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Administrators of the "libpcap" SourceForge project have superseded this tracker item (formerly artifact 1832829, now patch 25) with issue 221 of the "libpcap" GitHub project.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
patch -i pcap_time.patch in the untarred directory. Based on 0.9.8
Logged In: YES
user_id=541179
Originator: NO
Timed capture doesn't require libpcap changes - and that code won't work on all platforms in any case. A call to the read method for a capture device can block indefinitely if no packets arrive (the timeout specified in pcap_open_live() is *not* guaranteed to be a timer that starts when you try to read packets; on Solaris, for example, the timer doesn't start until the first packet arrives, and, on some platforms, there isn't a timer.
Using alarm() in tcpdump would work on all UN*X platforms - without requiring a call to time() for each packet batch. On Windows, the multimedia timer might be usable; note the code that's already there in top-of-tree tcpdump, where, if you're capturing to a file with the "-w" flag, the "-v" flag causes tcpdump to periodically report how many packets it's captured.
Administrators of the "libpcap" SourceForge project have superseded this tracker item (formerly artifact 1832829, now patch 25) with issue 221 of the "libpcap" GitHub project.