diff options
author | 1999-07-20 04:49:54 +0000 | |
---|---|---|
committer | 1999-07-20 04:49:54 +0000 | |
commit | 01efc7ef8ab68f8ab38c9fcffd34efd1d036b4b9 (patch) | |
tree | dfb5b8767bf0f7b2e8338f28172ba9469908e509 /lib/libpcap/pcap.c | |
parent | sync (diff) | |
download | wireguard-openbsd-01efc7ef8ab68f8ab38c9fcffd34efd1d036b4b9.tar.xz wireguard-openbsd-01efc7ef8ab68f8ab38c9fcffd34efd1d036b4b9.zip |
changes brought in from v0.4; started by brad, more by me, being tested by mts
Diffstat (limited to 'lib/libpcap/pcap.c')
-rw-r--r-- | lib/libpcap/pcap.c | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/lib/libpcap/pcap.c b/lib/libpcap/pcap.c index 05eb2ee4861..0fd1adb9213 100644 --- a/lib/libpcap/pcap.c +++ b/lib/libpcap/pcap.c @@ -1,7 +1,7 @@ -/* $OpenBSD: pcap.c,v 1.5 1998/07/14 00:14:04 deraadt Exp $ */ +/* $OpenBSD: pcap.c,v 1.6 1999/07/20 04:49:55 deraadt Exp $ */ /* - * Copyright (c) 1993, 1994, 1995, 1996 + * Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -34,8 +34,8 @@ */ #ifndef lint -static char rcsid[] = - "@(#) Header: pcap.c,v 1.25 96/06/05 21:45:26 leres Exp (LBL)"; +static const char rcsid[] = + "@(#) $Header: /home/cvs/src/lib/libpcap/pcap.c,v 1.6 1999/07/20 04:49:55 deraadt Exp $ (LBL)"; #endif #include <sys/types.h> @@ -54,22 +54,29 @@ static char rcsid[] = int pcap_dispatch(pcap_t *p, int cnt, pcap_handler callback, u_char *user) { - register int cc; if (p->sf.rfile != NULL) return (pcap_offline_read(p, cnt, callback, user)); - /* XXX keep reading until we get something (or an error occurs) */ - do { - cc = pcap_read(p, cnt, callback, user); - } while (cc == 0); - return (cc); + return (pcap_read(p, cnt, callback, user)); } int pcap_loop(pcap_t *p, int cnt, pcap_handler callback, u_char *user) { + register int n; + for (;;) { - int n = pcap_dispatch(p, cnt, callback, user); + if (p->sf.rfile != NULL) + n = pcap_offline_read(p, cnt, callback, user); + else { + /* + * XXX keep reading until we get something + * (or an error occurs) + */ + do { + n = pcap_read(p, cnt, callback, user); + } while (n == 0); + } if (n <= 0) return (n); if (cnt > 0) { @@ -191,6 +198,10 @@ pcap_close(pcap_t *p) free(p->sf.base); } else if (p->buffer != NULL) free(p->buffer); - +#ifdef linux + if (p->md.device != NULL) + free(p->md.device); +#endif + free(p); } |