diff options
author | Guy Harris <guy@alum.mit.edu> | 2006-05-21 21:32:04 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2006-05-21 21:32:04 +0000 |
commit | aa1e053ce638e4f2c91184a43703f4c99998b5bb (patch) | |
tree | c409d2b15ce8779d6b8be480ebe7bf12212f2eab /capture-wpcap.c | |
parent | 4fa7a8c9b83e62759c286b67254280a7204845f9 (diff) | |
download | wireshark-aa1e053ce638e4f2c91184a43703f4c99998b5bb.tar.gz wireshark-aa1e053ce638e4f2c91184a43703f4c99998b5bb.tar.bz2 wireshark-aa1e053ce638e4f2c91184a43703f4c99998b5bb.zip |
If we have pcap_breakloop(), at least on UN*X we can stop the capture
with a pcap_breakloop() call - we don't need to call select() before
calling pcap_dispatch().
Even if we do need to call select(), we don't need to supply it with a
timeout - it's OK if we block indefinitely, as the signal will interrupt
select().
That also means we can pass -1 as the count to pcap_dispatch(), as
pcap_breakloop() will terminate the loop in pcap_dispatch().
Use sigaction() to catch SIGUSR1, so we can make sure that the signal
handler doesn't get reset when the signal is delivered, and that system
calls don't restart when we return from the signal handler.
svn path=/trunk/; revision=18201
Diffstat (limited to 'capture-wpcap.c')
-rw-r--r-- | capture-wpcap.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/capture-wpcap.c b/capture-wpcap.c index ebff52e05e..bb06067352 100644 --- a/capture-wpcap.c +++ b/capture-wpcap.c @@ -49,6 +49,11 @@ gboolean has_wpcap = FALSE; #ifdef HAVE_LIBPCAP +/* + * XXX - should we require at least WinPcap 3.1 both for building an + * for using Wireshark? + */ + static char* (*p_pcap_lookupdev) (char *); static void (*p_pcap_close) (pcap_t *); static int (*p_pcap_stats) (pcap_t *, struct pcap_stat *); @@ -80,6 +85,9 @@ static int (*p_pcap_datalink_name_to_val) (const char *); #ifdef HAVE_PCAP_DATALINK_VAL_TO_NAME static const char *(*p_pcap_datalink_val_to_name) (int); #endif +#ifdef HAVE_PCAP_BREAKLOOP +static void (*p_pcap_breakloop) (pcap_t *); +#endif static const char *(*p_pcap_lib_version) (void); static int (*p_pcap_setbuff) (pcap_t *, int dim); static int (*p_pcap_next_ex) (pcap_t *, struct pcap_pkthdr **pkt_header, const u_char **pkt_data); @@ -121,6 +129,14 @@ load_wpcap(void) #ifdef HAVE_PCAP_DATALINK_VAL_TO_NAME SYM(pcap_datalink_val_to_name, TRUE), #endif +#ifdef HAVE_PCAP_BREAKLOOP + /* + * We don't try to work around the lack of this at + * run time; it's present in WinPcap 3.1, which is + * the version we build with and ship with. + */ + SYM(pcap_breakloop, FALSE), +#endif SYM(pcap_lib_version, TRUE), SYM(pcap_setbuff, TRUE), SYM(pcap_next_ex, TRUE), @@ -422,6 +438,13 @@ pcap_datalink_val_to_name(int dlt) } #endif +#ifdef HAVE_PCAP_BREAKLOOP +void pcap_breakloop(pcap_t *a) +{ + p_pcap_breakloop(a); +} +#endif + /* setbuff is win32 specific! */ int pcap_setbuff(pcap_t *a, int b) { |