aboutsummaryrefslogtreecommitdiffstats
path: root/savefile.c
diff options
context:
space:
mode:
authorguy <guy>2008-04-14 20:40:58 +0000
committerguy <guy>2008-04-14 20:40:58 +0000
commit2527d1ac889ed9b6c6c36d1d312700a643beb346 (patch)
tree26a05e35cdf7c3c5aec5c65892c2a5f185a6a285 /savefile.c
parent0fdc174e4c2d9dfd58a11027ab8ce3b5f99874a5 (diff)
Turn close_op into cleanup_op; the routine that handles it can also be
used to clean up after a failed pcap_activate() call. Convert the existing close_op routines to cleanup_op routines, and use them to clean up; rename pcap_close_common() to pcap_cleanup_live_common(), and use it directly if there's no platform-dependent cleanup needed. That means we don't have to write the same cleanup code twice (and possibly forget stuff in the version done on a failed pcap_activate() call). Have the cleanup routines do whatever is necessary to indicate that cleanup has been done, and not do any particular cleaning up if it's already been done (i.e., don't free something if the pointer to it is null and null out the pointer once it's been freed, don't close an FD if it's -1 and set it to -1 once it's been closed, etc.). For device types/platforms where we don't support monitor mode, check for it and return PCAP_ERROR_RFMON_NOTSUP - but do so after we've checked whether we can open the device, so we return "no such device" or "permission denied" rather than "that device doesn't support monitor mode" if we can't open the device in the first place. Fix a comment.
Diffstat (limited to 'savefile.c')
-rw-r--r--savefile.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/savefile.c b/savefile.c
index 0f15664..4e73eef 100644
--- a/savefile.c
+++ b/savefile.c
@@ -30,7 +30,7 @@
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/savefile.c,v 1.174 2008-04-06 18:09:48 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/savefile.c,v 1.175 2008-04-14 20:40:58 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -1094,7 +1094,7 @@ sf_setdirection(pcap_t *p, pcap_direction_t d)
}
static void
-sf_close(pcap_t *p)
+sf_cleanup(pcap_t *p)
{
if (p->sf.rfile != stdin)
(void)fclose(p->sf.rfile);
@@ -1327,7 +1327,7 @@ pcap_fopen_offline(FILE *fp, char *errbuf)
p->setmode_op = sf_setmode;
p->setmintocopy_op = sf_setmintocopy;
#endif
- p->close_op = sf_close;
+ p->cleanup_op = sf_cleanup;
p->activated = 1;
return (p);