diff options
author | Guy Harris <guy@alum.mit.edu> | 2000-03-22 07:06:59 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2000-03-22 07:06:59 +0000 |
commit | 005588b8b94d679cc461ddd290bc9399b3d16f1b (patch) | |
tree | 900b9afc981b65ab61b957599a56dc60cf034b7b /wiretap/ngsniffer.c | |
parent | 8d47efa6f9bcd6422011379f4b5ccb27df8c12c4 (diff) |
In a Network Monitor capture file, get the starting offsets of frames
from the frame table - Network Monitor 2.x, at least, doesn't always
write frame N+1 right after frame N.
To do that, we need to mallocate a big array to hold the frame table,
and free it when we close the capture file; this requires that we have
capture-file-type-specific close routines as well as
capture-file-type-specific read routines - we let it the pointer to that
routine be null if it's not needed. Given that, we might as well get
rid of the switch statement in "wtap_close()", in favor of using
capture-file-type-specific close routines, as per the comment before
that switch statement.
svn path=/trunk/; revision=1740
Diffstat (limited to 'wiretap/ngsniffer.c')
-rw-r--r-- | wiretap/ngsniffer.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/wiretap/ngsniffer.c b/wiretap/ngsniffer.c index d151d1bf33..632be76b10 100644 --- a/wiretap/ngsniffer.c +++ b/wiretap/ngsniffer.c @@ -1,6 +1,6 @@ /* ngsniffer.c * - * $Id: ngsniffer.c,v 1.36 2000/02/19 08:00:07 guy Exp $ + * $Id: ngsniffer.c,v 1.37 2000/03/22 07:06:57 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org> @@ -247,6 +247,7 @@ struct frame4_rec { static double Usec[] = { 15.0, 0.838096, 15.0, 0.5, 2.0, 1.0, 0.1 }; static int ngsniffer_read(wtap *wth, int *err); +static void ngsniffer_close(wtap *wth); static gboolean ngsniffer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, const u_char *pd, int *err); static gboolean ngsniffer_dump_close(wtap_dumper *wdh, int *err); @@ -370,6 +371,7 @@ int ngsniffer_open(wtap *wth, int *err) wth->file_type = WTAP_FILE_NGSNIFFER; wth->capture.ngsniffer = g_malloc(sizeof(ngsniffer_t)); wth->subtype_read = ngsniffer_read; + wth->subtype_close = ngsniffer_close; wth->snapshot_length = 16384; /* not available in header, only in frame */ wth->capture.ngsniffer->timeunit = Usec[version.timeunit]; wth->file_encap = sniffer_encap[version.network]; @@ -638,6 +640,12 @@ found: return data_offset; } +static void +ngsniffer_close(wtap *wth) +{ + g_free(wth->capture.ngsniffer); +} + static const int wtap_encap[] = { -1, /* WTAP_ENCAP_UNKNOWN -> unsupported */ 1, /* WTAP_ENCAP_ETHERNET */ |