aboutsummaryrefslogtreecommitdiffstats
path: root/pcap-snoop.c
diff options
context:
space:
mode:
authorguy <guy>2003-11-04 07:05:32 +0000
committerguy <guy>2003-11-04 07:05:32 +0000
commit991d444f7116bef16893826b46f3950f62281507 (patch)
treea6e3cc271bc1560beb89dcc0d0c3893297bbba0b /pcap-snoop.c
parent4246a40e00fd598e3af4ab8e4251749968b086c1 (diff)
Add a "pcap_breakloop()" API to break out of the loop in
"pcap_dispatch()" and "pcap_loop()".
Diffstat (limited to 'pcap-snoop.c')
-rw-r--r--pcap-snoop.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/pcap-snoop.c b/pcap-snoop.c
index 69c6569..a1b530e 100644
--- a/pcap-snoop.c
+++ b/pcap-snoop.c
@@ -20,7 +20,7 @@
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/libpcap/pcap-snoop.c,v 1.44 2003-07-25 05:32:05 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/pcap-snoop.c,v 1.45 2003-11-04 07:05:37 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -68,13 +68,25 @@ pcap_read_snoop(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
register u_char *cp;
again:
+ /*
+ * Has "pcap_breakloop()" been called?
+ */
+ if (p->break_loop) {
+ /*
+ * Yes - clear the flag that indicates that it
+ * has, and return -2 to indicate that we were
+ * told to break out of the loop.
+ */
+ p->break_loop = 0;
+ return (-2);
+ }
cc = read(p->fd, (char *)p->buffer, p->bufsize);
if (cc < 0) {
/* Don't choke when we get ptraced */
switch (errno) {
case EINTR:
- goto again;
+ goto again;
case EWOULDBLOCK:
return (0); /* XXX */