aboutsummaryrefslogtreecommitdiffstats
path: root/capture-wpcap.c
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2006-05-21 21:32:04 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2006-05-21 21:32:04 +0000
commitd311604bc73ef8a43abfaff4d8648c5266f79a33 (patch)
treec409d2b15ce8779d6b8be480ebe7bf12212f2eab /capture-wpcap.c
parent62ff54088b38911f59d79dc952fbd1cd2e555cba (diff)
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. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@18201 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'capture-wpcap.c')
-rw-r--r--capture-wpcap.c23
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)
{