aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2010-02-26 07:59:54 +0000
committerGuy Harris <guy@alum.mit.edu>2010-02-26 07:59:54 +0000
commit17392a865ac79a9f631e63652dff45b6bb1c64d2 (patch)
tree42c7ec409a0e898eea7c0ebf4ba34f2f633797b6
parentc4dd5ca6f3bb794c9f1736adf8a8f02c641a76e6 (diff)
Move the definitions of all the private data structures out of
wtap-int.h, and change the unions of pointers to those private data structures into just void *'s. Have the generic wtap close routine free up the private data, rather than the type-specific close routine, just as the wtap_dumper close routine does for its private data. Get rid of close routines that don't do anything any more. svn path=/trunk/; revision=32015
-rw-r--r--wiretap/5views.c17
-rw-r--r--wiretap/airopeek9.c26
-rw-r--r--wiretap/ascendtext.c53
-rw-r--r--wiretap/catapult_dct2000.c52
-rw-r--r--wiretap/csids.c24
-rw-r--r--wiretap/etherpeek.c22
-rw-r--r--wiretap/file_access.c7
-rw-r--r--wiretap/i4btrace.c22
-rw-r--r--wiretap/iseries.c6
-rw-r--r--wiretap/jpeg_jfif.c3
-rw-r--r--wiretap/k12.c79
-rw-r--r--wiretap/k12text.l11
-rw-r--r--wiretap/lanalyzer.c36
-rw-r--r--wiretap/libpcap.c34
-rw-r--r--wiretap/mpeg.c41
-rw-r--r--wiretap/netmon.c85
-rw-r--r--wiretap/netscaler.c183
-rw-r--r--wiretap/nettl.c26
-rw-r--r--wiretap/network_instruments.c23
-rw-r--r--wiretap/netxray.c124
-rw-r--r--wiretap/ngsniffer.c19
-rw-r--r--wiretap/pcapng.c67
-rw-r--r--wiretap/pppdump.c12
-rw-r--r--wiretap/visual.c33
-rw-r--r--wiretap/wtap-int.h151
-rw-r--r--wiretap/wtap.c3
26 files changed, 536 insertions, 623 deletions
diff --git a/wiretap/5views.c b/wiretap/5views.c
index b153e652fe..3eeb28eb5c 100644
--- a/wiretap/5views.c
+++ b/wiretap/5views.c
@@ -339,6 +339,10 @@ _5views_seek_read(wtap *wth, gint64 seek_off,
+typedef struct {
+ guint32 nframes;
+} _5views_dump_t;
+
static const int wtap_encap[] = {
-1, /* WTAP_ENCAP_UNKNOWN -> unsupported */
CST_5VW_CAPTURE_ETH_FILEID, /* WTAP_ENCAP_ETHERNET -> Ehernet Ethernet */
@@ -375,6 +379,7 @@ int _5views_dump_can_write_encap(int encap)
failure */
gboolean _5views_dump_open(wtap_dumper *wdh, gboolean cant_seek _U_, int *err)
{
+ _5views_dump_t *_5views;
/* We can't fill in all the fields in the file header, as we
haven't yet written any packets. As we'll have to rewrite
@@ -388,8 +393,9 @@ gboolean _5views_dump_open(wtap_dumper *wdh, gboolean cant_seek _U_, int *err)
/* This is a 5Views file */
wdh->subtype_write = _5views_dump;
wdh->subtype_close = _5views_dump_close;
- wdh->dump._5views = (_5views_dump_t *)g_malloc(sizeof(_5views_dump_t));
- wdh->dump._5views->nframes = 0;
+ _5views = (_5views_dump_t *)g_malloc(sizeof(_5views_dump_t));
+ wdh->priv = (void *)_5views;
+ _5views->nframes = 0;
return TRUE;
}
@@ -401,7 +407,7 @@ static gboolean _5views_dump(wtap_dumper *wdh,
const union wtap_pseudo_header *pseudo_header _U_,
const guchar *pd, int *err)
{
-
+ _5views_dump_t *_5views = (_5views_dump_t *)wdh->priv;
size_t nwritten;
static t_5VW_TimeStamped_Header HeaderFrame;
@@ -440,13 +446,14 @@ static gboolean _5views_dump(wtap_dumper *wdh,
return FALSE;
}
- wdh->dump._5views->nframes ++;
+ _5views->nframes ++;
return TRUE;
}
static gboolean _5views_dump_close(wtap_dumper *wdh, int *err)
{
+ _5views_dump_t *_5views = (_5views_dump_t *)wdh->priv;
t_5VW_Capture_Header file_hdr;
size_t nwritten;
@@ -486,7 +493,7 @@ static gboolean _5views_dump_close(wtap_dumper *wdh, int *err)
file_hdr.HeaderNbFrames.Nb = htoles(1); /* Number of elements */
/* fill in the number of frames saved */
- file_hdr.TramesStockeesInFile = htolel(wdh->dump._5views->nframes);
+ file_hdr.TramesStockeesInFile = htolel(_5views->nframes);
/* Write the file header. */
nwritten = fwrite(&file_hdr, 1, sizeof(t_5VW_Capture_Header), wdh->fh);
diff --git a/wiretap/airopeek9.c b/wiretap/airopeek9.c
index 1644d9f42a..a116ecf8e1 100644
--- a/wiretap/airopeek9.c
+++ b/wiretap/airopeek9.c
@@ -84,12 +84,15 @@ typedef struct airopeek_utime {
guint32 lower;
} airopeek_utime;
+typedef struct {
+ gboolean has_fcs;
+} airopeek9_t;
+
static gboolean airopeekv9_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean airopeekv9_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info);
-static void airopeekv9_close(wtap *wth);
static int wtap_file_read_pattern (wtap *wth, const char *pattern, int *err)
{
@@ -195,6 +198,7 @@ int airopeek9_open(wtap *wth, int *err, gchar **err_info)
WTAP_ENCAP_IEEE_802_11_WITH_RADIO
};
#define NUM_AIROPEEK9_ENCAPS (sizeof airopeek9_encap / sizeof airopeek9_encap[0])
+ airopeek9_t *airopeek9;
wtap_file_read_unknown_bytes(&ap_hdr, sizeof(ap_hdr), wth->fh, err);
@@ -307,20 +311,20 @@ int airopeek9_open(wtap *wth, int *err, gchar **err_info)
wth->file_encap = file_encap;
wth->subtype_read = airopeekv9_read;
wth->subtype_seek_read = airopeekv9_seek_read;
- wth->subtype_close = airopeekv9_close;
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
- wth->capture.airopeek9 = (airopeek9_t *)g_malloc(sizeof(airopeek9_t));
+ airopeek9 = (airopeek9_t *)g_malloc(sizeof(airopeek9_t));
+ wth->priv = (void *)airopeek9;
switch (mediaSubType) {
case AIROPEEK_V9_NST_ETHERNET:
case AIROPEEK_V9_NST_802_11:
case AIROPEEK_V9_NST_802_11_2:
- wth->capture.airopeek9->has_fcs = FALSE;
+ airopeek9->has_fcs = FALSE;
break;
case AIROPEEK_V9_NST_802_11_WITH_FCS:
- wth->capture.airopeek9->has_fcs = TRUE;
+ airopeek9->has_fcs = TRUE;
break;
}
@@ -485,6 +489,7 @@ airopeekv9_process_header(FILE_T fh, hdr_info_t *hdr_info, int *err,
static gboolean airopeekv9_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
+ airopeek9_t *airopeek9 = (airopeek9_t *)wth->priv;
hdr_info_t hdr_info;
int hdrlen;
double t;
@@ -534,7 +539,7 @@ static gboolean airopeekv9_read(wtap *wth, int *err, gchar **err_info,
* whether to supply it as an FCS or discard it.
*/
wth->pseudo_header.ieee_802_11 = hdr_info.ieee_802_11;
- if (wth->capture.airopeek9->has_fcs)
+ if (airopeek9->has_fcs)
wth->pseudo_header.ieee_802_11.fcs_len = 4;
else {
wth->pseudo_header.ieee_802_11.fcs_len = 0;
@@ -563,6 +568,7 @@ airopeekv9_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info)
{
+ airopeek9_t *airopeek9 = (airopeek9_t *)wth->priv;
hdr_info_t hdr_info;
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
@@ -576,7 +582,7 @@ airopeekv9_seek_read(wtap *wth, gint64 seek_off,
case WTAP_ENCAP_IEEE_802_11_WITH_RADIO:
pseudo_header->ieee_802_11 = hdr_info.ieee_802_11;
- if (wth->capture.airopeek9->has_fcs)
+ if (airopeek9->has_fcs)
pseudo_header->ieee_802_11.fcs_len = 4;
else
pseudo_header->ieee_802_11.fcs_len = 0;
@@ -594,9 +600,3 @@ airopeekv9_seek_read(wtap *wth, gint64 seek_off,
wtap_file_read_expected_bytes(pd, length, wth->random_fh, err);
return TRUE;
}
-
-static void
-airopeekv9_close(wtap *wth)
-{
- g_free(wth->capture.airopeek9);
-}
diff --git a/wiretap/ascendtext.c b/wiretap/ascendtext.c
index e019f94532..7c510f3ff7 100644
--- a/wiretap/ascendtext.c
+++ b/wiretap/ascendtext.c
@@ -78,12 +78,17 @@ static const ascend_magic_string ascend_magic[] = {
{ ASCEND_PFX_ETHER, "ETHER" },
};
+typedef struct {
+ time_t inittime;
+ int adjusted;
+ gint64 next_packet_seek_start;
+} ascend_t;
+
static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean ascend_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_head, guint8 *pd, int len,
int *err, gchar **err_info);
-static void ascend_close(wtap *wth);
/* Seeks to the beginning of the next packet, and returns the
byte offset at which the header for that packet begins.
@@ -174,11 +179,12 @@ int ascend_open(wtap *wth, int *err, gchar **err_info _U_)
guint8 buf[ASCEND_MAX_PKT_LEN];
ascend_pkthdr header;
gint64 dummy_seek_start;
+ ascend_t *ascend;
/* We haven't yet allocated a data structure for our private stuff;
set the pointer to null, so that "ascend_seek()" knows not to
fill it in. */
- wth->capture.ascend = NULL;
+ wth->priv = NULL;
offset = ascend_seek(wth, err);
if (offset == -1) {
@@ -215,13 +221,13 @@ int ascend_open(wtap *wth, int *err, gchar **err_info _U_)
wth->snapshot_length = ASCEND_MAX_PKT_LEN;
wth->subtype_read = ascend_read;
wth->subtype_seek_read = ascend_seek_read;
- wth->subtype_close = ascend_close;
- wth->capture.ascend = g_malloc(sizeof(ascend_t));
+ ascend = (ascend_t *)g_malloc(sizeof(ascend_t));
+ wth->priv = (void *)ascend;
/* The first packet we want to read is the one that "ascend_seek()"
just found; start searching for it at the offset at which it
found it. */
- wth->capture.ascend->next_packet_seek_start = offset;
+ ascend->next_packet_seek_start = offset;
/* MAXen and Pipelines report the time since reboot. In order to keep
from reporting packet times near the epoch, we subtract the first
@@ -230,11 +236,11 @@ int ascend_open(wtap *wth, int *err, gchar **err_info _U_)
*/
if (fstat(wth->fd, &statbuf) == -1) {
*err = errno;
- g_free(wth->capture.ascend);
+ g_free(ascend);
return -1;
}
- wth->capture.ascend->inittime = statbuf.st_ctime;
- wth->capture.ascend->adjusted = 0;
+ ascend->inittime = statbuf.st_ctime;
+ ascend->adjusted = 0;
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
init_parse_ascend();
@@ -265,6 +271,7 @@ static void config_pseudo_header(union wtap_pseudo_header *pseudo_head)
static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
+ ascend_t *ascend = (ascend_t *)wth->priv;
gint64 offset;
guint8 *buf = buffer_start_ptr(wth->frame_buffer);
ascend_pkthdr header;
@@ -273,7 +280,7 @@ static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
packet's header, to just after the last packet's header (ie. at the
start of the last packet's data). We have to get past the last
packet's header because we might mistake part of it for a new header. */
- if (file_seek(wth->fh, wth->capture.ascend->next_packet_seek_start,
+ if (file_seek(wth->fh, ascend->next_packet_seek_start,
SEEK_SET, err) == -1)
return FALSE;
@@ -281,7 +288,7 @@ static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
if (offset == -1)
return FALSE;
if (parse_ascend(wth->fh, buf, &wth->pseudo_header.ascend, &header,
- &(wth->capture.ascend->next_packet_seek_start)) != PARSED_RECORD) {
+ &(ascend->next_packet_seek_start)) != PARSED_RECORD) {
*err = WTAP_ERR_BAD_RECORD;
*err_info = g_strdup((ascend_parse_error != NULL) ? ascend_parse_error : "parse error");
return FALSE;
@@ -291,13 +298,13 @@ static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
config_pseudo_header(&wth->pseudo_header);
- if (! wth->capture.ascend->adjusted) {
- wth->capture.ascend->adjusted = 1;
+ if (! ascend->adjusted) {
+ ascend->adjusted = 1;
if (header.start_time != 0) {
/*
* Capture file contained a date and time.
* We do this only if this is the very first packet we've seen -
- * i.e., if "wth->capture.ascend->adjusted" is false - because
+ * i.e., if "ascend->adjusted" is false - because
* if we get a date and time after the first packet, we can't
* go back and adjust the time stamps of the packets we've already
* processed, and basing the time stamps of this and following
@@ -305,12 +312,12 @@ static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
* ctime of the capture file means times before this and after
* this can't be compared.
*/
- wth->capture.ascend->inittime = header.start_time;
+ ascend->inittime = header.start_time;
}
- if (wth->capture.ascend->inittime > header.secs)
- wth->capture.ascend->inittime -= header.secs;
+ if (ascend->inittime > header.secs)
+ ascend->inittime -= header.secs;
}
- wth->phdr.ts.secs = header.secs + wth->capture.ascend->inittime;
+ wth->phdr.ts.secs = header.secs + ascend->inittime;
wth->phdr.ts.nsecs = header.usecs * 1000;
wth->phdr.caplen = header.caplen;
wth->phdr.len = header.len;
@@ -321,16 +328,15 @@ static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
}
static gboolean ascend_seek_read(wtap *wth, gint64 seek_off,
- union wtap_pseudo_header *pseudo_head, guint8 *pd, int len,
+ union wtap_pseudo_header *pseudo_head, guint8 *pd, int len _U_,
int *err, gchar **err_info)
{
- /* don't care for length. */
- (void) len;
+ ascend_t *ascend = (ascend_t *)wth->priv;
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
if (parse_ascend(wth->random_fh, pd, &pseudo_head->ascend, NULL,
- &(wth->capture.ascend->next_packet_seek_start)) != PARSED_RECORD) {
+ &(ascend->next_packet_seek_start)) != PARSED_RECORD) {
*err = WTAP_ERR_BAD_RECORD;
*err_info = g_strdup((ascend_parse_error != NULL) ? ascend_parse_error : "parse error");
return FALSE;
@@ -339,8 +345,3 @@ static gboolean ascend_seek_read(wtap *wth, gint64 seek_off,
config_pseudo_header(pseudo_head);
return TRUE;
}
-
-static void ascend_close(wtap *wth)
-{
- g_free(wth->capture.ascend);
-}
diff --git a/wiretap/catapult_dct2000.c b/wiretap/catapult_dct2000.c
index 402e8c013f..9ad1199d6c 100644
--- a/wiretap/catapult_dct2000.c
+++ b/wiretap/catapult_dct2000.c
@@ -118,7 +118,6 @@ static void catapult_dct2000_close(wtap *wth);
static gboolean catapult_dct2000_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header,
const guchar *pd, int *err);
-static gboolean catapult_dct2000_dump_close(wtap_dumper *wdh, int *err);
/************************************************************/
@@ -257,7 +256,7 @@ int catapult_dct2000_open(wtap *wth, int *err, gchar **err_info _U_)
g_hash_table_new(packet_offset_hash_func, packet_offset_equal);
/* Set this wtap to point to the file_externals */
- wth->capture.generic = (void*)file_externals;
+ wth->priv = (void*)file_externals;
*err = errno;
return 1;
@@ -279,7 +278,7 @@ gboolean catapult_dct2000_read(wtap *wth, int *err, gchar **err_info _U_,
/* Get wtap external structure for this wtap */
dct2000_file_externals_t *file_externals =
- (dct2000_file_externals_t*)wth->capture.generic;
+ (dct2000_file_externals_t*)wth->priv;
/* There *has* to be an entry for this wth */
if (!file_externals) {
@@ -542,7 +541,7 @@ void catapult_dct2000_close(wtap *wth)
{
/* Get externals for this file */
dct2000_file_externals_t *file_externals =
- (dct2000_file_externals_t*)wth->capture.generic;
+ (dct2000_file_externals_t*)wth->priv;
/* The entry *has* to be found */
if (!file_externals) {
@@ -554,9 +553,6 @@ void catapult_dct2000_close(wtap *wth)
free_line_prefix_info, NULL);
/* Free up its line prefix table */
g_hash_table_destroy(file_externals->packet_prefix_table);
-
- /* Can now free this too */
- g_free(file_externals);
}
@@ -566,6 +562,11 @@ void catapult_dct2000_close(wtap *wth)
/* Dump functions */
/***************************/
+typedef struct {
+ gboolean first_packet_written;
+ struct wtap_nstime start_time;
+} dct2000_dump_t;
+
/*****************************************************/
/* The file that we are writing to has been opened. */
/* Set other dump callbacks. */
@@ -574,7 +575,6 @@ gboolean catapult_dct2000_dump_open(wtap_dumper *wdh, gboolean cant_seek _U_, in
{
/* Fill in other dump callbacks */
wdh->subtype_write = catapult_dct2000_dump;
- wdh->subtype_close = catapult_dct2000_dump_close;
return TRUE;
}
@@ -627,14 +627,16 @@ gboolean catapult_dct2000_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
line_prefix_info_t *prefix = NULL;
gchar time_string[16];
gboolean is_comment;
+ dct2000_dump_t *dct2000;
/******************************************************/
/* Get the file_externals structure for this file */
/* Find wtap external structure for this wtap */
dct2000_file_externals_t *file_externals =
- (dct2000_file_externals_t*)pseudo_header->dct2000.wth->capture.generic;
+ (dct2000_file_externals_t*)pseudo_header->dct2000.wth->priv;
- if (wdh->dump.dct2000 == NULL) {
+ dct2000 = (dct2000_dump_t *)wdh->priv;
+ if (dct2000 == NULL) {
/* Write out saved first line */
if (!do_fwrite(file_externals->firstline, 1, file_externals->firstline_length, wdh->fh, err)) {
@@ -655,15 +657,16 @@ gboolean catapult_dct2000_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
}
/* Allocate the dct2000-specific dump structure */
- wdh->dump.dct2000 = g_malloc(sizeof(dct2000_dump_t));
+ dct2000 = (dct2000_dump_t *)g_malloc(sizeof(dct2000_dump_t));
+ wdh->priv = (void *)dct2000;
/* Copy time of beginning of file */
- wdh->dump.dct2000->start_time.secs = file_externals->start_secs;
- wdh->dump.dct2000->start_time.nsecs =
+ dct2000->start_time.secs = file_externals->start_secs;
+ dct2000->start_time.nsecs =
(file_externals->start_usecs * 1000);
/* Set flag do don't write header out again */
- wdh->dump.dct2000->first_packet_written = TRUE;
+ dct2000->first_packet_written = TRUE;
}
@@ -683,15 +686,15 @@ gboolean catapult_dct2000_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
is_comment = (strstr(prefix->before_time, "/////") != NULL);
/* Calculate time of this packet to write, relative to start of dump */
- if (phdr->ts.nsecs >= wdh->dump.dct2000->start_time.nsecs) {
+ if (phdr->ts.nsecs >= dct2000->start_time.nsecs) {
g_snprintf(time_string, 16, "%ld.%04d",
- (long)(phdr->ts.secs - wdh->dump.dct2000->start_time.secs),
- (phdr->ts.nsecs - wdh->dump.dct2000->start_time.nsecs) / 100000);
+ (long)(phdr->ts.secs - dct2000->start_time.secs),
+ (phdr->ts.nsecs - dct2000->start_time.nsecs) / 100000);
}
else {
g_snprintf(time_string, 16, "%ld.%04u",
- (long)(phdr->ts.secs - wdh->dump.dct2000->start_time.secs-1),
- ((1000000000 + (phdr->ts.nsecs / 100000)) - (wdh->dump.dct2000->start_time.nsecs / 100000)) % 10000);
+ (long)(phdr->ts.secs - dct2000->start_time.secs-1),
+ ((1000000000 + (phdr->ts.nsecs / 100000)) - (dct2000->start_time.nsecs / 100000)) % 10000);
}
/* Write out the calculated timestamp */
@@ -782,17 +785,6 @@ gboolean catapult_dct2000_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
}
-/******************************************************/
-/* Close a file we've been writing to. */
-/******************************************************/
-static gboolean catapult_dct2000_dump_close(wtap_dumper *wdh _U_, int *err _U_)
-{
- return TRUE;
-}
-
-
-
-
/****************************/
/* Private helper functions */
/****************************/
diff --git a/wiretap/csids.c b/wiretap/csids.c
index bd84755210..c70c212466 100644
--- a/wiretap/csids.c
+++ b/wiretap/csids.c
@@ -49,7 +49,6 @@ static gboolean csids_read(wtap *wth, int *err, gchar **err_info,
static gboolean csids_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guint8 *pd, int len,
int *err, gchar **err_info);
-static void csids_close(wtap *wth);
struct csids_header {
guint32 seconds; /* seconds since epoch */
@@ -57,6 +56,10 @@ struct csids_header {
guint16 caplen; /* the capture length */
};
+typedef struct {
+ gboolean byteswapped;
+} csids_t;
+
/* XXX - return -1 on I/O error and actually do something with 'err'. */
int csids_open(wtap *wth, int *err, gchar **err_info _U_)
{
@@ -72,6 +75,7 @@ int csids_open(wtap *wth, int *err, gchar **err_info _U_)
gboolean byteswap = FALSE;
struct csids_header hdr;
+ csids_t *csids;
/* check the file to make sure it is a csids file. */
bytesRead = file_read( &hdr, 1, sizeof( struct csids_header), wth->fh );
@@ -133,14 +137,14 @@ int csids_open(wtap *wth, int *err, gchar **err_info _U_)
return -1;
wth->data_offset = 0;
- wth->capture.csids = g_malloc(sizeof(csids_t));
- wth->capture.csids->byteswapped = byteswap;
+ csids = (csids_t *)g_malloc(sizeof(csids_t));
+ wth->priv = (void *)csids;
+ csids->byteswapped = byteswap;
wth->file_encap = WTAP_ENCAP_RAW_IP;
wth->file_type = WTAP_FILE_CSIDS;
wth->snapshot_length = 0; /* not known */
wth->subtype_read = csids_read;
wth->subtype_seek_read = csids_seek_read;
- wth->subtype_close = csids_close;
wth->tsprecision = WTAP_FILE_TSPREC_SEC;
return 1;
@@ -150,6 +154,7 @@ int csids_open(wtap *wth, int *err, gchar **err_info _U_)
static gboolean csids_read(wtap *wth, int *err, gchar **err_info _U_,
gint64 *data_offset)
{
+ csids_t *csids = (csids_t *)wth->priv;
guint8 *buf;
int bytesRead = 0;
struct csids_header hdr;
@@ -187,7 +192,7 @@ static gboolean csids_read(wtap *wth, int *err, gchar **err_info _U_,
wth->phdr.ts.secs = hdr.seconds;
wth->phdr.ts.nsecs = 0;
- if( wth->capture.csids->byteswapped ) {
+ if( csids->byteswapped ) {
PBSWAP16(buf); /* the ip len */
PBSWAP16(buf+2); /* ip id */
PBSWAP16(buf+4); /* ip flags and fragoff */
@@ -206,6 +211,7 @@ csids_seek_read (wtap *wth,
int *err,
gchar **err_info)
{
+ csids_t *csids = (csids_t *)wth->priv;
int bytesRead;
struct csids_header hdr;
@@ -239,7 +245,7 @@ csids_seek_read (wtap *wth,
return FALSE;
}
- if( wth->capture.csids->byteswapped ) {
+ if( csids->byteswapped ) {
PBSWAP16(pd); /* the ip len */
PBSWAP16(pd+2); /* ip id */
PBSWAP16(pd+4); /* ip flags and fragoff */
@@ -247,9 +253,3 @@ csids_seek_read (wtap *wth,
return TRUE;
}
-
-static void
-csids_close(wtap *wth)
-{
- g_free(wth->capture.csids);
-}
diff --git a/wiretap/etherpeek.c b/wiretap/etherpeek.c
index e7202f58a2..81e4dba572 100644
--- a/wiretap/etherpeek.c
+++ b/wiretap/etherpeek.c
@@ -142,6 +142,10 @@ static const etherpeek_encap_lookup_t etherpeek_encap[] = {
#define NUM_ETHERPEEK_ENCAPS \
(sizeof (etherpeek_encap) / sizeof (etherpeek_encap[0]))
+typedef struct {
+ struct timeval reference_time;
+} etherpeek_t;
+
static gboolean etherpeek_read_v7(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean etherpeek_seek_read_v7(wtap *wth, gint64 seek_off,
@@ -154,13 +158,13 @@ static gboolean etherpeek_read_v56(wtap *wth, int *err, gchar **err_info,
static gboolean etherpeek_seek_read_v56(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info);
-static void etherpeek_close(wtap *wth);
int etherpeek_open(wtap *wth, int *err, gchar **err_info _U_)
{
etherpeek_header_t ep_hdr;
struct timeval reference_time;
int file_encap;
+ etherpeek_t *etherpeek;
/* EtherPeek files do not start with a magic value large enough
* to be unique; hence we use the following algorithm to determine
@@ -322,9 +326,9 @@ int etherpeek_open(wtap *wth, int *err, gchar **err_info _U_)
* At this point we have recognised the file type and have populated
* the whole ep_hdr structure in host byte order.
*/
- wth->capture.etherpeek = g_malloc(sizeof(etherpeek_t));
- wth->capture.etherpeek->reference_time = reference_time;
- wth->subtype_close = etherpeek_close;
+ etherpeek = (etherpeek_t *)g_malloc(sizeof(etherpeek_t));
+ wth->priv = (void *)etherpeek;
+ etherpeek->reference_time = reference_time;
switch (ep_hdr.master.version) {
case 5:
@@ -352,16 +356,11 @@ int etherpeek_open(wtap *wth, int *err, gchar **err_info _U_)
}
wth->snapshot_length = 0; /* not available in header */
- wth->tsprecision = WTAP_FILE_TSPREC_USEC;
+ wth->tsprecision = WTAP_FILE_TSPREC_USEC;
return 1;
}
-static void etherpeek_close(wtap *wth)
-{
- g_free(wth->capture.etherpeek);
-}
-
static gboolean etherpeek_read_v7(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
@@ -535,6 +534,7 @@ etherpeek_fill_pseudo_header_v7(union wtap_pseudo_header *pseudo_header,
static gboolean etherpeek_read_v56(wtap *wth, int *err, gchar **err_info _U_,
gint64 *data_offset)
{
+ etherpeek_t *etherpeek = (etherpeek_t *)wth->priv;
guchar ep_pkt[ETHERPEEK_V56_PKT_SIZE];
guint16 length;
guint16 sliceLength;
@@ -594,7 +594,7 @@ static gboolean etherpeek_read_v56(wtap *wth, int *err, gchar **err_info _U_,
wth->phdr.len = length;
wth->phdr.caplen = sliceLength;
/* timestamp is in milliseconds since reference_time */
- wth->phdr.ts.secs = wth->capture.etherpeek->reference_time.tv_sec
+ wth->phdr.ts.secs = etherpeek->reference_time.tv_sec
+ (timestamp / 1000);
wth->phdr.ts.nsecs = 1000 * (timestamp % 1000) * 1000;
diff --git a/wiretap/file_access.c b/wiretap/file_access.c
index 480dd9e5f8..fa4aaa90db 100644
--- a/wiretap/file_access.c
+++ b/wiretap/file_access.c
@@ -332,6 +332,7 @@ wtap* wtap_open_offline(const char *filename, int *err, char **err_info,
wth->subtype_sequential_close = NULL;
wth->subtype_close = NULL;
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
+ wth->priv = NULL;
init_open_routines();
@@ -893,7 +894,7 @@ static wtap_dumper* wtap_dump_alloc_wdh(int filetype, int encap, int snaplen,
wdh->encap = encap;
wdh->compressed = compressed;
wdh->bytes_dumped = 0;
- wdh->dump.opaque = NULL;
+ wdh->priv = NULL;
wdh->subtype_write = NULL;
wdh->subtype_close = NULL;
return wdh;
@@ -971,8 +972,8 @@ gboolean wtap_dump_close(wtap_dumper *wdh, int *err)
/* as we don't close stdout, at least try to flush it */
wtap_dump_flush(wdh);
}
- if (wdh->dump.opaque != NULL)
- g_free(wdh->dump.opaque);
+ if (wdh->priv != NULL)
+ g_free(wdh->priv);
g_free(wdh);
return ret;
}
diff --git a/wiretap/i4btrace.c b/wiretap/i4btrace.c
index 1b2bc08095..6c9dc4c619 100644
--- a/wiretap/i4btrace.c
+++ b/wiretap/i4btrace.c
@@ -33,6 +33,10 @@
#include "i4b_trace.h"
#include "i4btrace.h"
+typedef struct {
+ gboolean byte_swapped;
+} i4btrace_t;
+
static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean i4btrace_seek_read(wtap *wth, gint64 seek_off,
@@ -43,7 +47,6 @@ static void i4b_byte_swap_header(wtap *wth, i4b_trace_hdr_t *hdr);
static gboolean i4b_read_rec_data(FILE_T fh, guchar *pd, int length, int *err);
static void i4b_set_pseudo_header(i4b_trace_hdr_t *hdr,
union wtap_pseudo_header *pseudo_header);
-static void i4btrace_close(wtap *wth);
/*
* Test some fields in the header to see if they make sense.
@@ -58,6 +61,7 @@ int i4btrace_open(wtap *wth, int *err, gchar **err_info _U_)
int bytes_read;
i4b_trace_hdr_t hdr;
gboolean byte_swapped = FALSE;
+ i4btrace_t *i4btrace;
/* I4B trace files have no magic in the header... Sigh */
errno = WTAP_ERR_CANT_READ;
@@ -100,13 +104,13 @@ int i4btrace_open(wtap *wth, int *err, gchar **err_info _U_)
/* Get capture start time */
wth->file_type = WTAP_FILE_I4BTRACE;
- wth->capture.i4btrace = g_malloc(sizeof(i4btrace_t));
+ i4btrace = (i4btrace_t *)g_malloc(sizeof(i4btrace_t));
+ wth->priv = (void *)i4btrace;
wth->subtype_read = i4btrace_read;
wth->subtype_seek_read = i4btrace_seek_read;
- wth->subtype_close = i4btrace_close;
wth->snapshot_length = 0; /* not known */
- wth->capture.i4btrace->byte_swapped = byte_swapped;
+ i4btrace->byte_swapped = byte_swapped;
wth->file_encap = WTAP_ENCAP_ISDN;
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
@@ -235,7 +239,9 @@ i4b_read_rec_header(FILE_T fh, i4b_trace_hdr_t *hdr, int *err)
static void
i4b_byte_swap_header(wtap *wth, i4b_trace_hdr_t *hdr)
{
- if (wth->capture.i4btrace->byte_swapped) {
+ i4btrace_t *i4btrace = (i4btrace_t *)wth->priv;
+
+ if (i4btrace->byte_swapped) {
/*
* Byte-swap the header.
*/
@@ -296,9 +302,3 @@ i4b_set_pseudo_header(i4b_trace_hdr_t *hdr,
break;
}
}
-
-static void
-i4btrace_close(wtap *wth)
-{
- g_free(wth->capture.i4btrace);
-}
diff --git a/wiretap/iseries.c b/wiretap/iseries.c
index c143466839..91418ca48f 100644
--- a/wiretap/iseries.c
+++ b/wiretap/iseries.c
@@ -268,7 +268,7 @@ iseries_check_file_type (wtap * wth, int *err, int format)
/* Save trace format for passing between packets */
iseries = (iseries_t *) g_malloc (sizeof (iseries_t));
- wth->capture.generic = iseries;
+ wth->priv = (void *)iseries;
iseries->have_date = FALSE;
iseries->format = format;
iseries->tcp_formatted = FALSE;
@@ -377,11 +377,11 @@ iseries_read (wtap * wth, int *err, gchar ** err_info, gint64 *data_offset)
static gint64
iseries_seek_next_packet (wtap * wth, int *err)
{
+ iseries_t *iseries = (iseries_t *)wth->priv;
char buf[ISERIES_LINE_LENGTH];
int line;
gint64 cur_off;
long buflen;
- iseries_t *iseries = (iseries_t *)wth->capture.generic;
/*
* Seeks to the beginning of the next packet, and returns the
@@ -483,6 +483,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh,
union wtap_pseudo_header *pseudo_header, guint8 * pd,
int *err, gchar ** err_info)
{
+ iseries_t *iseries = (iseries_t *)wth->priv;
gint64 cur_off;
gboolean isValid, isCurrentPacket, IPread, TCPread, isDATA;
int num_items_scanned, line, pktline, buflen, i;
@@ -495,7 +496,6 @@ iseries_parse_packet (wtap * wth, FILE_T fh,
guint8 *buf;
char *tcpdatabuf, *workbuf, *asciibuf;
struct tm tm;
- iseries_t *iseries = (iseries_t *)wth->capture.generic;
/*
* Check for packet headers in first 3 lines this should handle page breaks
diff --git a/wiretap/jpeg_jfif.c b/wiretap/jpeg_jfif.c
index 613c958337..7823343b58 100644
--- a/wiretap/jpeg_jfif.c
+++ b/wiretap/jpeg_jfif.c
@@ -147,10 +147,7 @@ jpeg_jfif_open(wtap *wth, int *err, gchar **err_info)
wth->tsprecision = WTAP_FILE_TSPREC_SEC;
wth->subtype_read = jpeg_jfif_read;
wth->subtype_seek_read = jpeg_jfif_seek_read;
- wth->subtype_close = NULL;
wth->snapshot_length = 0;
-
- wth->capture.generic = NULL;
}
}
diff --git a/wiretap/k12.c b/wiretap/k12.c
index 7f6ae22871..99d8aae596 100644
--- a/wiretap/k12.c
+++ b/wiretap/k12.c
@@ -128,7 +128,7 @@ void k12_hexdump(guint level, gint64 offset, char* label, unsigned char* b, unsi
static const guint8 k12_file_magic[] = { 0x00, 0x00, 0x02, 0x00 ,0x12, 0x05, 0x00, 0x10 };
-struct _k12_t {
+typedef struct {
guint32 file_len;
guint32 num_of_records; /* XXX: not sure about this */
@@ -136,7 +136,7 @@ struct _k12_t {
GHashTable* src_by_name; /* k12_srcdsc_recs by stack_name */
Buffer extra_info; /* Buffer to hold per packet extra information */
-};
+} k12_t;
typedef struct _k12_src_desc_t {
guint32 input;
@@ -315,6 +315,7 @@ static gint get_record(guint8** bufferp, FILE* fh, gint64 file_offset) {
}
static gboolean k12_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data_offset) {
+ k12_t *k12 = (k12_t *)wth->priv;
k12_src_desc_t* src_desc;
guint8* buffer = NULL;
gint64 offset;
@@ -346,7 +347,7 @@ static gboolean k12_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data
src_id = pntohl(buffer + K12_RECORD_SRC_ID);
- if ( ! (src_desc = g_hash_table_lookup(wth->capture.k12->src_by_id,GUINT_TO_POINTER(src_id))) ) {
+ if ( ! (src_desc = g_hash_table_lookup(k12->src_by_id,GUINT_TO_POINTER(src_id))) ) {
/*
* Some records from K15 files have a port ID of an undeclared
* interface which happens to be the only one with the first byte changed.
@@ -354,7 +355,7 @@ static gboolean k12_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data
* If the lookup of the interface record fails we'll mask it
* and retry.
*/
- src_desc = g_hash_table_lookup(wth->capture.k12->src_by_id,GUINT_TO_POINTER(src_id&K12_RECORD_SRC_ID_MASK));
+ src_desc = g_hash_table_lookup(k12->src_by_id,GUINT_TO_POINTER(src_id&K12_RECORD_SRC_ID_MASK));
}
K12_DBG(5,("k12_read: record type=%x src_id=%x",type,src_id));
@@ -380,10 +381,10 @@ static gboolean k12_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data
memcpy(buffer_start_ptr(wth->frame_buffer), buffer + K12_PACKET_FRAME, wth->phdr.caplen);
/* extra information need by some protocols */
- buffer_assure_space(&(wth->capture.k12->extra_info), extra_len);
- memcpy(buffer_start_ptr(&(wth->capture.k12->extra_info)),
+ buffer_assure_space(&(k12->extra_info), extra_len);
+ memcpy(buffer_start_ptr(&(k12->extra_info)),
buffer + K12_PACKET_FRAME + wth->phdr.caplen, extra_len);
- wth->pseudo_header.k12.extra_info = (void*)buffer_start_ptr(&(wth->capture.k12->extra_info));
+ wth->pseudo_header.k12.extra_info = (void*)buffer_start_ptr(&(k12->extra_info));
wth->pseudo_header.k12.extra_length = extra_len;
wth->pseudo_header.k12.input = src_id;
@@ -410,13 +411,14 @@ static gboolean k12_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data
}
- wth->pseudo_header.k12.stuff = wth->capture.k12;
+ wth->pseudo_header.k12.stuff = k12;
return TRUE;
}
static gboolean k12_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err _U_, gchar **err_info _U_) {
+ k12_t *k12 = (k12_t *)wth->priv;
k12_src_desc_t* src_desc;
guint8* buffer;
gint len;
@@ -438,20 +440,20 @@ static gboolean k12_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_head
memcpy(pd, buffer + K12_PACKET_FRAME, length);
extra_len = len - K12_PACKET_FRAME - length;
- buffer_assure_space(&(wth->capture.k12->extra_info), extra_len);
- memcpy(buffer_start_ptr(&(wth->capture.k12->extra_info)),
+ buffer_assure_space(&(k12->extra_info), extra_len);
+ memcpy(buffer_start_ptr(&(k12->extra_info)),
buffer + K12_PACKET_FRAME + length, extra_len);
- wth->pseudo_header.k12.extra_info = (void*)buffer_start_ptr(&(wth->capture.k12->extra_info));
+ wth->pseudo_header.k12.extra_info = (void*)buffer_start_ptr(&(k12->extra_info));
wth->pseudo_header.k12.extra_length = extra_len;
if (pseudo_header) {
- pseudo_header->k12.extra_info = (void*)buffer_start_ptr(&(wth->capture.k12->extra_info));
+ pseudo_header->k12.extra_info = (void*)buffer_start_ptr(&(k12->extra_info));
pseudo_header->k12.extra_length = extra_len;
}
input = pntohl(buffer + K12_RECORD_SRC_ID);
K12_DBG(5,("k12_seek_read: input=%.8x",input));
- if ( ! (src_desc = g_hash_table_lookup(wth->capture.k12->src_by_id,GUINT_TO_POINTER(input))) ) {
+ if ( ! (src_desc = g_hash_table_lookup(k12->src_by_id,GUINT_TO_POINTER(input))) ) {
/*
* Some records from K15 files have a port ID of an undeclared
* interface which happens to be the only one with the first byte changed.
@@ -459,7 +461,7 @@ static gboolean k12_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_head
* If the lookup of the interface record fails we'll mask it
* and retry.
*/
- src_desc = g_hash_table_lookup(wth->capture.k12->src_by_id,GUINT_TO_POINTER(input&K12_RECORD_SRC_ID_MASK));
+ src_desc = g_hash_table_lookup(k12->src_by_id,GUINT_TO_POINTER(input&K12_RECORD_SRC_ID_MASK));
}
if (src_desc) {
@@ -519,11 +521,11 @@ static gboolean k12_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_head
if (pseudo_header) {
pseudo_header->k12.input = input;
- pseudo_header->k12.stuff = wth->capture.k12;
+ pseudo_header->k12.stuff = k12;
}
wth->pseudo_header.k12.input = input;
- wth->pseudo_header.k12.stuff = wth->capture.k12;
+ wth->pseudo_header.k12.stuff = k12;
K12_DBG(5,("k12_seek_read: DONE OK"));
@@ -563,7 +565,10 @@ static void destroy_k12_file_data(k12_t* fd) {
}
static void k12_close(wtap *wth) {
- destroy_k12_file_data(wth->capture.k12);
+ k12_t *k12 = (k12_t *)wth->priv;
+
+ destroy_k12_file_data(k12);
+ wth->priv = NULL; /* destroy_k12_file_data freed it */
#ifdef DEBUG_K12
K12_DBG(5,("k12_close: CLOSED"));
if (env_file) fclose(dbg_out);
@@ -622,6 +627,8 @@ int k12_open(wtap *wth, int *err, gchar **err_info _U_) {
if ( len <= 0 ) {
K12_DBG(1,("k12_open: BAD HEADER RECORD",len));
+ destroy_k12_file_data(file_data);
+ g_free(file_data);
return -1;
}
@@ -634,6 +641,7 @@ int k12_open(wtap *wth, int *err, gchar **err_info _U_) {
*/
if (file_seek(wth->fh, offset, SEEK_SET, err) == -1) {
destroy_k12_file_data(file_data);
+ g_free(file_data);
return -1;
}
K12_DBG(5,("k12_open: FIRST PACKET offset=%x",offset));
@@ -655,6 +663,8 @@ int k12_open(wtap *wth, int *err, gchar **err_info _U_) {
g_free(rec);
K12_DBG(5,("k12_open: failed (name_len == 0 || stack_len == 0 "
"|| 0x20 + extra_len + name_len + stack_len > rec_len) extra_len=%i name_len=%i stack_len=%i"));
+ destroy_k12_file_data(file_data);
+ g_free(file_data);
return 0;
}
@@ -710,12 +720,18 @@ int k12_open(wtap *wth, int *err, gchar **err_info _U_) {
wth->subtype_read = k12_read;
wth->subtype_seek_read = k12_seek_read;
wth->subtype_close = k12_close;
- wth->capture.k12 = file_data;
+ wth->priv = (void *)file_data;
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
return 1;
}
+typedef struct {
+ guint32 file_len;
+ guint32 num_of_records;
+ guint32 file_offset;
+} k12_dump_t;
+
int k12_dump_can_write_encap(int encap) {
if (encap == WTAP_ENCAP_PER_PACKET)
@@ -744,7 +760,8 @@ static gboolean do_fwrite(const void *data, size_t size, size_t count, FILE *str
}
static gboolean k12_dump_record(wtap_dumper *wdh, guint32 len, guint8* buffer, int *err_p) {
- guint32 junky_offset = (0x2000 - ( (wdh->dump.k12->file_offset - 0x200) % 0x2000 )) % 0x2000;
+ k12_dump_t *k12 = (k12_dump_t *)wdh->priv;
+ guint32 junky_offset = (0x2000 - ( (k12->file_offset - 0x200) % 0x2000 )) % 0x2000;
if (len > junky_offset) {
if (junky_offset) {
@@ -757,14 +774,14 @@ static gboolean k12_dump_record(wtap_dumper *wdh, guint32 len, guint8* buffer,
if (! do_fwrite(buffer+junky_offset, 1, len - junky_offset, wdh->fh, err_p))
return FALSE;
- wdh->dump.k12->file_offset += len + 0x10;
+ k12->file_offset += len + 0x10;
} else {
if (! do_fwrite(buffer, 1, len, wdh->fh, err_p))
return FALSE;
- wdh->dump.k12->file_offset += len;
+ k12->file_offset += len;
}
- wdh->dump.k12->num_of_records++;
+ k12->num_of_records++;
return TRUE;
}
@@ -879,6 +896,7 @@ static void k12_dump_src_setting(gpointer k _U_, gpointer v, gpointer p) {
static gboolean k12_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header,
const guchar *pd, int *err) {
+ k12_dump_t *k12 = (k12_dump_t *)wdh->priv;
guint32 len;
union {
guint8 buffer[0x2000];
@@ -896,7 +914,7 @@ static gboolean k12_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
} record;
} obj;
- if (wdh->dump.k12->num_of_records == 0) {
+ if (k12->num_of_records == 0) {
k12_t* file_data = pseudo_header->k12.stuff;
/* XXX: We'll assume that any fwrite errors in k12_dump_src_setting will */
/* repeat during the final k12_dump_record at the end of k12_dump */
@@ -926,6 +944,7 @@ static gboolean k12_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
static const guint8 k12_eof[] = {0xff,0xff};
static gboolean k12_dump_close(wtap_dumper *wdh, int *err) {
+ k12_dump_t *k12 = (k12_dump_t *)wdh->priv;
union {
guint8 b[sizeof(guint32)];
guint32 u;
@@ -939,12 +958,12 @@ static gboolean k12_dump_close(wtap_dumper *wdh, int *err) {
return FALSE;
}
- d.u = g_htonl(wdh->dump.k12->file_len);
+ d.u = g_htonl(k12->file_len);
if (! do_fwrite(d.b, 1, 4, wdh->fh, err))
return FALSE;
- d.u = g_htonl(wdh->dump.k12->num_of_records);
+ d.u = g_htonl(k12->num_of_records);
if (! do_fwrite(d.b, 1, 4, wdh->fh, err))
return FALSE;
@@ -954,6 +973,7 @@ static gboolean k12_dump_close(wtap_dumper *wdh, int *err) {
gboolean k12_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err) {
+ k12_dump_t *k12;
if (cant_seek) {
*err = WTAP_ERR_CANT_WRITE_TO_PIPE;
@@ -972,10 +992,11 @@ gboolean k12_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err) {
wdh->subtype_write = k12_dump;
wdh->subtype_close = k12_dump_close;
- wdh->dump.k12 = g_malloc(sizeof(k12_dump_t));
- wdh->dump.k12->file_len = 0x200;
- wdh->dump.k12->num_of_records = 0;
- wdh->dump.k12->file_offset = 0x200;
+ k12 = (k12_dump_t *)g_malloc(sizeof(k12_dump_t));
+ wdh->priv = (void *)k12;
+ k12->file_len = 0x200;
+ k12->num_of_records = 0;
+ k12->file_offset = 0x200;
return TRUE;
}
diff --git a/wiretap/k12text.l b/wiretap/k12text.l
index d8bded1911..0bfa8fc8ff 100644
--- a/wiretap/k12text.l
+++ b/wiretap/k12text.l
@@ -295,10 +295,6 @@ static gboolean k12text_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_
return TRUE;
}
-static void k12text_close(wtap *wth _U_) {
- (void)0;
-}
-
int k12text_open(wtap *wth, int *err, gchar **err_info _U_) {
k12text_reset(wth->fh); /* init lexer buffer and vars set by lexer */
@@ -318,8 +314,6 @@ int k12text_open(wtap *wth, int *err, gchar **err_info _U_) {
wth->snapshot_length = 0;
wth->subtype_read = k12text_read;
wth->subtype_seek_read = k12text_seek_read;
- wth->subtype_close = k12text_close;
- wth->capture.generic = NULL;
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
return 1;
@@ -382,10 +376,6 @@ static gboolean k12text_dump(wtap_dumper *wdh _U_, const struct wtap_pkthdr *phd
}
-static gboolean k12text_dump_close(wtap_dumper *wdh _U_ , int *err _U_) {
- return TRUE;
-}
-
gboolean k12text_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err) {
if (cant_seek) {
@@ -394,7 +384,6 @@ gboolean k12text_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err) {
}
wdh->subtype_write = k12text_dump;
- wdh->subtype_close = k12text_dump_close;
return TRUE;
}
diff --git a/wiretap/lanalyzer.c b/wiretap/lanalyzer.c
index f8c29cd823..2cfbec940f 100644
--- a/wiretap/lanalyzer.c
+++ b/wiretap/lanalyzer.c
@@ -126,7 +126,6 @@ static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info);
-static void lanalyzer_close(wtap *wth);
static gboolean lanalyzer_dump_close(wtap_dumper *wdh, int *err);
int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
@@ -164,17 +163,16 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
* from a record later in the file. */
wth->file_type = WTAP_FILE_LANALYZER;
lanalyzer = (lanalyzer_t *)g_malloc(sizeof(lanalyzer_t));;
- wth->capture.generic = lanalyzer;
+ wth->priv = (void *)lanalyzer;
wth->subtype_read = lanalyzer_read;
wth->subtype_seek_read = lanalyzer_seek_read;
- wth->subtype_close = lanalyzer_close;
wth->snapshot_length = 0;
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
/* Read records until we find the start of packets */
while (1) {
if (file_seek(wth->fh, record_length, SEEK_CUR, err) == -1) {
- g_free(wth->capture.generic);
+ g_free(wth->priv);
return -1;
}
wth->data_offset += record_length;
@@ -184,10 +182,10 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
if (bytes_read != 4) {
*err = file_error(wth->fh);
if (*err != 0) {
- g_free(wth->capture.generic);
+ g_free(wth->priv);
return -1;
}
- g_free(wth->capture.generic);
+ g_free(wth->priv);
return 0;
}
wth->data_offset += 4;
@@ -205,10 +203,10 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
if (bytes_read != sizeof summary) {
*err = file_error(wth->fh);
if (*err != 0) {
- g_free(wth->capture.generic);
+ g_free(wth->priv);
return -1;
}
- g_free(wth->capture.generic);
+ g_free(wth->priv);
return 0;
}
wth->data_offset += sizeof summary;
@@ -251,7 +249,7 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
wth->file_encap = WTAP_ENCAP_TOKEN_RING;
break;
default:
- g_free(wth->capture.generic);
+ g_free(wth->priv);
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
*err_info = g_strdup_printf("lanalyzer: board type %u unknown",
board_type);
@@ -264,7 +262,7 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
/* Go back header number ob ytes so that lanalyzer_read
* can read this header */
if (file_seek(wth->fh, -bytes_read, SEEK_CUR, err) == -1) {
- g_free(wth->capture.generic);
+ g_free(wth->priv);
return -1;
}
wth->data_offset -= bytes_read;
@@ -377,7 +375,7 @@ static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
t = (((guint64)time_low) << 0) + (((guint64)time_med) << 16) +
(((guint64)time_high) << 32);
tsecs = (time_t) (t/2000000);
- lanalyzer = (lanalyzer_t *)wth->capture.generic;
+ lanalyzer = (lanalyzer_t *)wth->priv;
wth->phdr.ts.secs = tsecs + lanalyzer->start;
wth->phdr.ts.nsecs = ((guint32) (t - tsecs*2000000)) * 500;
@@ -435,12 +433,6 @@ static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off,
return TRUE;
}
-static void
-lanalyzer_close(wtap *wth)
-{
- g_free(wth->capture.generic);
-}
-
/*---------------------------------------------------
* Returns 0 or error
* Write one block with error control
@@ -565,7 +557,7 @@ static gboolean lanalyzer_dump(wtap_dumper *wdh,
int len;
struct timeval tv;
- LA_TmpInfo *itmp = (LA_TmpInfo*)(wdh->dump.opaque);
+ LA_TmpInfo *itmp = (LA_TmpInfo*)(wdh->priv);
struct timeval td;
int thisSize = phdr->caplen + LA_PacketRecordSize + LA_RecordHeaderSize;
@@ -689,9 +681,9 @@ gboolean lanalyzer_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err)
}
((LA_TmpInfo*)tmp)->init = FALSE;
- wdh->dump.opaque = tmp;
- wdh->subtype_write = lanalyzer_dump;
- wdh->subtype_close = lanalyzer_dump_close;
+ wdh->priv = tmp;
+ wdh->subtype_write = lanalyzer_dump;
+ wdh->subtype_close = lanalyzer_dump_close;
/* Some of the fields in the file header aren't known yet so
just skip over it for now. It will be created after all
@@ -721,7 +713,7 @@ gboolean lanalyzer_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err)
*---------------------------------------------------*/
static gboolean lanalyzer_dump_header(wtap_dumper *wdh, int *err)
{
- LA_TmpInfo *itmp = (LA_TmpInfo*)(wdh->dump.opaque);
+ LA_TmpInfo *itmp = (LA_TmpInfo*)(wdh->priv);
struct tm *fT = localtime( (time_t *) &(itmp->start.tv_sec));
guint16 board_type = itmp->encap == WTAP_ENCAP_TOKEN_RING
? BOARD_325TR /* LANalyzer Board Type */
diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c
index a89ffd6e65..6a0d9aaecc 100644
--- a/wiretap/libpcap.c
+++ b/wiretap/libpcap.c
@@ -77,7 +77,6 @@ static int libpcap_read_header(wtap *wth, int *err, gchar **err_info,
static void adjust_header(wtap *wth, struct pcaprec_hdr *hdr);
static gboolean libpcap_read_rec_data(FILE_T fh, guchar *pd, int length,
int *err);
-static void libpcap_close(wtap *wth);
static gboolean libpcap_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
@@ -263,10 +262,9 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
libpcap->byte_swapped = byte_swapped;
libpcap->version_major = hdr.version_major;
libpcap->version_minor = hdr.version_minor;
- wth->capture.generic = libpcap;
+ wth->priv = (void *)libpcap;
wth->subtype_read = libpcap_read;
wth->subtype_seek_read = libpcap_seek_read;
- wth->subtype_close = libpcap_close;
wth->file_encap = file_encap;
wth->snapshot_length = hdr.snaplen;
@@ -367,7 +365,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
* Well, we couldn't even read it.
* Give up.
*/
- g_free(wth->capture.generic);
+ g_free(wth->priv);
return -1;
case THIS_FORMAT:
@@ -376,7 +374,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
* Put the seek pointer back, and return success.
*/
if (file_seek(wth->fh, wth->data_offset, SEEK_SET, err) == -1) {
- g_free(wth->capture.generic);
+ g_free(wth->priv);
return -1;
}
return 1;
@@ -397,7 +395,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
*/
wth->file_type = WTAP_FILE_PCAP_SS990915;
if (file_seek(wth->fh, wth->data_offset, SEEK_SET, err) == -1) {
- g_free(wth->capture.generic);
+ g_free(wth->priv);
return -1;
}
} else {
@@ -418,7 +416,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
* Well, we couldn't even read it.
* Give up.
*/
- g_free(wth->capture.generic);
+ g_free(wth->priv);
return -1;
case THIS_FORMAT:
@@ -428,7 +426,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
* Put the seek pointer back, and return success.
*/
if (file_seek(wth->fh, wth->data_offset, SEEK_SET, err) == -1) {
- g_free(wth->capture.generic);
+ g_free(wth->priv);
return -1;
}
return 1;
@@ -447,7 +445,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
*/
wth->file_type = WTAP_FILE_PCAP_SS990417;
if (file_seek(wth->fh, wth->data_offset, SEEK_SET, err) == -1) {
- g_free(wth->capture.generic);
+ g_free(wth->priv);
return -1;
}
switch (libpcap_try(wth, err)) {
@@ -457,7 +455,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
* Well, we couldn't even read it.
* Give up.
*/
- g_free(wth->capture.generic);
+ g_free(wth->priv);
return -1;
case THIS_FORMAT:
@@ -466,7 +464,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
* Put the seek pointer back, and return success.
*/
if (file_seek(wth->fh, wth->data_offset, SEEK_SET, err) == -1) {
- g_free(wth->capture.generic);
+ g_free(wth->priv);
return -1;
}
return 1;
@@ -487,7 +485,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
*/
wth->file_type = WTAP_FILE_PCAP_NOKIA;
if (file_seek(wth->fh, wth->data_offset, SEEK_SET, err) == -1) {
- g_free(wth->capture.generic);
+ g_free(wth->priv);
return -1;
}
}
@@ -643,7 +641,7 @@ static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info,
*data_offset = wth->data_offset;
- libpcap = (libpcap_t *)wth->capture.generic;
+ libpcap = (libpcap_t *)wth->priv;
phdr_len = pcap_process_pseudo_header(wth->fh, wth->file_type,
wth->file_encap, libpcap->byte_swapped, packet_size,
TRUE, &wth->phdr, &wth->pseudo_header, err, err_info);
@@ -714,7 +712,7 @@ libpcap_seek_read(wtap *wth, gint64 seek_off,
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
- libpcap = (libpcap_t *)wth->capture.generic;
+ libpcap = (libpcap_t *)wth->priv;
phdr_len = pcap_process_pseudo_header(wth->random_fh, wth->file_type,
wth->file_encap, libpcap->byte_swapped, length,
FALSE, NULL, pseudo_header, err, err_info);
@@ -840,7 +838,7 @@ adjust_header(wtap *wth, struct pcaprec_hdr *hdr)
guint32 temp;
libpcap_t *libpcap;
- libpcap = (libpcap_t *)wth->capture.generic;
+ libpcap = (libpcap_t *)wth->priv;
if (libpcap->byte_swapped) {
/* Byte-swap the record header fields. */
hdr->ts_sec = BSWAP32(hdr->ts_sec);
@@ -890,12 +888,6 @@ libpcap_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
return TRUE;
}
-static void
-libpcap_close(wtap *wth)
-{
- g_free(wth->capture.generic);
-}
-
/* Returns 0 if we could write the specified encapsulation type,
an error indication otherwise. */
int libpcap_dump_can_write_encap(int encap)
diff --git a/wiretap/mpeg.c b/wiretap/mpeg.c
index 8ce82a3af7..2cdbeea4bc 100644
--- a/wiretap/mpeg.c
+++ b/wiretap/mpeg.c
@@ -48,6 +48,11 @@
#define PES_PREFIX 1
#define PES_VALID(n) (((n) >> 8 & 0xffffff) == PES_PREFIX)
+typedef struct {
+ struct wtap_nstime now;
+ time_t t0;
+} mpeg_t;
+
static int
mpeg_resync(wtap *wth, int *err, gchar **err_info _U_)
{
@@ -111,10 +116,11 @@ static gboolean
mpeg_read(wtap *wth, int *err, gchar **err_info _U_,
gint64 *data_offset)
{
+ mpeg_t *mpeg = (mpeg_t *)wth->priv;
guint32 n;
int bytes_read = mpeg_read_header(wth, err, err_info, &n);
unsigned int packet_size;
- struct wtap_nstime ts = wth->capture.mpeg->now;
+ struct wtap_nstime ts = mpeg->now;
if (bytes_read == -1)
return FALSE;
@@ -177,12 +183,12 @@ mpeg_read(wtap *wth, int *err, gchar **err_info _U_,
unsigned ext = (unsigned)((bytes >> 1) & 0x1ff);
guint64 cr = 300 * ts_val + ext;
unsigned rem = (unsigned)(cr % SCRHZ);
- wth->capture.mpeg->now.secs
- = wth->capture.mpeg->t0 + (time_t)(cr / SCRHZ);
- wth->capture.mpeg->now.nsecs
+ mpeg->now.secs
+ = mpeg->t0 + (time_t)(cr / SCRHZ);
+ mpeg->now.nsecs
= (int)(G_GINT64_CONSTANT(1000000000) * rem / SCRHZ);
}
- ts = wth->capture.mpeg->now;
+ ts = mpeg->now;
break;
default:
packet_size = 12;
@@ -208,10 +214,10 @@ mpeg_read(wtap *wth, int *err, gchar **err_info _U_,
MPA_UNMARSHAL(&mpa, n);
if (MPA_VALID(&mpa)) {
packet_size = MPA_BYTES(&mpa);
- wth->capture.mpeg->now.nsecs += MPA_DURATION_NS(&mpa);
- if (wth->capture.mpeg->now.nsecs >= 1000000000) {
- wth->capture.mpeg->now.secs++;
- wth->capture.mpeg->now.nsecs -= 1000000000;
+ mpeg->now.nsecs += MPA_DURATION_NS(&mpa);
+ if (mpeg->now.nsecs >= 1000000000) {
+ mpeg->now.secs++;
+ mpeg->now.nsecs -= 1000000000;
}
} else {
packet_size = mpeg_resync(wth, err, err_info);
@@ -242,12 +248,6 @@ mpeg_seek_read(wtap *wth, gint64 seek_off,
return mpeg_read_rec_data(wth->random_fh, pd, length, err);
}
-static void
-mpeg_close(wtap *wth)
-{
- g_free(wth->capture.mpeg);
-}
-
struct _mpeg_magic {
size_t len;
const gchar* match;
@@ -265,6 +265,7 @@ mpeg_open(wtap *wth, int *err, gchar **err_info _U_)
int bytes_read;
char magic_buf[16];
struct _mpeg_magic* m;
+ mpeg_t *mpeg;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(magic_buf, 1, sizeof magic_buf, wth->fh);
@@ -292,13 +293,13 @@ good_magic:
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
wth->subtype_read = mpeg_read;
wth->subtype_seek_read = mpeg_seek_read;
- wth->subtype_close = mpeg_close;
wth->snapshot_length = 0;
- wth->capture.mpeg = g_malloc(sizeof(mpeg_t));
- wth->capture.mpeg->now.secs = time(NULL);
- wth->capture.mpeg->now.nsecs = 0;
- wth->capture.mpeg->t0 = wth->capture.mpeg->now.secs;
+ mpeg = (mpeg_t *)g_malloc(sizeof(mpeg_t));
+ wth->priv = (void *)mpeg;
+ mpeg->now.secs = time(NULL);
+ mpeg->now.nsecs = 0;
+ mpeg->t0 = mpeg->now.secs;
return 1;
}
diff --git a/wiretap/netmon.c b/wiretap/netmon.c
index 7c29e4febc..e56dc822ad 100644
--- a/wiretap/netmon.c
+++ b/wiretap/netmon.c
@@ -104,6 +104,15 @@ struct netmon_atm_hdr {
guint16 vci; /* VCI */
};
+typedef struct {
+ time_t start_secs;
+ guint32 start_usecs;
+ guint8 version_major;
+ guint32 *frame_table;
+ guint32 frame_table_size;
+ guint current_frame;
+} netmon_t;
+
static gboolean netmon_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean netmon_seek_read(wtap *wth, gint64 seek_off,
@@ -114,7 +123,6 @@ static gboolean netmon_read_atm_pseudoheader(FILE_T fh,
static gboolean netmon_read_rec_data(FILE_T fh, guchar *pd, int length,
int *err);
static void netmon_sequential_close(wtap *wth);
-static void netmon_close(wtap *wth);
static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
static gboolean netmon_dump_close(wtap_dumper *wdh, int *err);
@@ -148,6 +156,7 @@ int netmon_open(wtap *wth, int *err, gchar **err_info)
#ifdef WORDS_BIGENDIAN
unsigned int i;
#endif
+ netmon_t *netmon;
/* Read in the string that should be at the start of a Network
* Monitor file */
@@ -202,11 +211,11 @@ int netmon_open(wtap *wth, int *err, gchar **err_info)
/* This is a netmon file */
wth->file_type = file_type;
- wth->capture.netmon = g_malloc(sizeof(netmon_t));
+ netmon = (netmon_t *)g_malloc(sizeof(netmon_t));
+ wth->priv = (void *)netmon;
wth->subtype_read = netmon_read;
wth->subtype_seek_read = netmon_seek_read;
wth->subtype_sequential_close = netmon_sequential_close;
- wth->subtype_close = netmon_close;
/* NetMon capture file formats v2.1+ use per-packet encapsulation types. NetMon 3 sets the value in
* the header to 1 (Ethernet) for backwards compability. */
@@ -229,7 +238,7 @@ int netmon_open(wtap *wth, int *err, gchar **err_info)
tm.tm_min = pletohs(&hdr.ts_min);
tm.tm_sec = pletohs(&hdr.ts_sec);
tm.tm_isdst = -1;
- wth->capture.netmon->start_secs = mktime(&tm);
+ netmon->start_secs = mktime(&tm);
/*
* XXX - what if "secs" is -1? Unlikely, but if the capture was
* done in a time zone that switches between standard and summer
@@ -244,9 +253,9 @@ int netmon_open(wtap *wth, int *err, gchar **err_info)
* intervals since 1601-01-01 00:00:00 "UTC", there, instead
* of stuffing a SYSTEMTIME, which is time-zone-dependent, there?).
*/
- wth->capture.netmon->start_usecs = pletohs(&hdr.ts_msec)*1000;
+ netmon->start_usecs = pletohs(&hdr.ts_msec)*1000;
- wth->capture.netmon->version_major = hdr.ver_major;
+ netmon->version_major = hdr.ver_major;
/*
* Get the offset of the frame index table.
@@ -270,18 +279,18 @@ int netmon_open(wtap *wth, int *err, gchar **err_info)
*err = WTAP_ERR_UNSUPPORTED;
*err_info = g_strdup_printf("netmon: frame table length is %u, which is not a multiple of the size of an entry",
frame_table_length);
- g_free(wth->capture.netmon);
+ g_free(netmon);
return -1;
}
if (frame_table_size == 0) {
*err = WTAP_ERR_UNSUPPORTED;
*err_info = g_strdup_printf("netmon: frame table length is %u, which means it's less than one entry in size",
frame_table_length);
- g_free(wth->capture.netmon);
+ g_free(netmon);
return -1;
}
if (file_seek(wth->fh, frame_table_offset, SEEK_SET, err) == -1) {
- g_free(wth->capture.netmon);
+ g_free(netmon);
return -1;
}
frame_table = g_malloc(frame_table_length);
@@ -292,11 +301,11 @@ int netmon_open(wtap *wth, int *err, gchar **err_info)
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
g_free(frame_table);
- g_free(wth->capture.netmon);
+ g_free(netmon);
return -1;
}
- wth->capture.netmon->frame_table_size = frame_table_size;
- wth->capture.netmon->frame_table = frame_table;
+ netmon->frame_table_size = frame_table_size;
+ netmon->frame_table = frame_table;
#ifdef WORDS_BIGENDIAN
/*
@@ -307,7 +316,7 @@ int netmon_open(wtap *wth, int *err, gchar **err_info)
#endif
/* Set up to start reading at the first frame. */
- wth->capture.netmon->current_frame = 0;
+ netmon->current_frame = 0;
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
return 1;
@@ -317,7 +326,7 @@ int netmon_open(wtap *wth, int *err, gchar **err_info)
static gboolean netmon_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
- netmon_t *netmon = wth->capture.netmon;
+ netmon_t *netmon = (netmon_t *)wth->priv;
guint32 packet_size = 0;
guint32 orig_size = 0;
int bytes_read;
@@ -336,8 +345,8 @@ static gboolean netmon_read(wtap *wth, int *err, gchar **err_info,
if (netmon->current_frame >= netmon->frame_table_size) {
/* Yes. We won't need the frame table any more;
free it. */
- g_free(wth->capture.netmon->frame_table);
- wth->capture.netmon->frame_table = NULL;
+ g_free(netmon->frame_table);
+ netmon->frame_table = NULL;
*err = 0; /* it's just an EOF, not an error */
return FALSE;
}
@@ -576,21 +585,22 @@ netmon_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
static void
netmon_sequential_close(wtap *wth)
{
- if (wth->capture.netmon->frame_table != NULL) {
- g_free(wth->capture.netmon->frame_table);
- wth->capture.netmon->frame_table = NULL;
+ netmon_t *netmon = (netmon_t *)wth->priv;
+
+ if (netmon->frame_table != NULL) {
+ g_free(netmon->frame_table);
+ netmon->frame_table = NULL;
}
}
-/* Close stuff used by the random I/O stream, if any, and free up any
- private data structures. (If there's a "sequential_close" routine
- for a capture file type, it'll be called before the "close" routine
- is called, so we don't have to free the frame table here.) */
-static void
-netmon_close(wtap *wth)
-{
- g_free(wth->capture.netmon);
-}
+typedef struct {
+ gboolean got_first_record_time;
+ struct wtap_nstime first_record_time;
+ guint32 frame_table_offset;
+ guint32 *frame_table;
+ guint frame_table_index;
+ guint frame_table_size;
+} netmon_dump_t;
static const int wtap_encap[] = {
-1, /* WTAP_ENCAP_UNKNOWN -> unsupported */
@@ -628,6 +638,8 @@ int netmon_dump_can_write_encap(int encap)
failure */
gboolean netmon_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err)
{
+ netmon_dump_t *netmon;
+
/* This is a NetMon file. We can't fill in some fields in the
header until all the packets have been written, so we can't
write to a pipe. */
@@ -648,12 +660,13 @@ gboolean netmon_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err)
wdh->subtype_write = netmon_dump;
wdh->subtype_close = netmon_dump_close;
- wdh->dump.netmon = g_malloc(sizeof(netmon_dump_t));
- wdh->dump.netmon->frame_table_offset = CAPTUREFILE_HEADER_SIZE;
- wdh->dump.netmon->got_first_record_time = FALSE;
- wdh->dump.netmon->frame_table = NULL;
- wdh->dump.netmon->frame_table_index = 0;
- wdh->dump.netmon->frame_table_size = 0;
+ netmon = (netmon_dump_t *)g_malloc(sizeof(netmon_dump_t));
+ wdh->priv = (void *)netmon;
+ netmon->frame_table_offset = CAPTUREFILE_HEADER_SIZE;
+ netmon->got_first_record_time = FALSE;
+ netmon->frame_table = NULL;
+ netmon->frame_table_index = 0;
+ netmon->frame_table_size = 0;
return TRUE;
}
@@ -663,7 +676,7 @@ gboolean netmon_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err)
static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err)
{
- netmon_dump_t *netmon = wdh->dump.netmon;
+ netmon_dump_t *netmon = (netmon_dump_t *)wdh->priv;
struct netmonrec_1_x_hdr rec_1_x_hdr;
struct netmonrec_2_x_hdr rec_2_x_hdr;
char *hdrp;
@@ -796,7 +809,7 @@ static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
Returns TRUE on success, FALSE on failure. */
static gboolean netmon_dump_close(wtap_dumper *wdh, int *err)
{
- netmon_dump_t *netmon = wdh->dump.netmon;
+ netmon_dump_t *netmon = (netmon_dump_t *)wdh->priv;
size_t n_to_write;
size_t nwritten;
struct netmon_hdr file_hdr;
diff --git a/wiretap/netscaler.c b/wiretap/netscaler.c
index 01d9fa1b12..b1f3f589ac 100644
--- a/wiretap/netscaler.c
+++ b/wiretap/netscaler.c
@@ -377,24 +377,36 @@ typedef struct nspr_pktracepart_v23
#undef __TNL
-#define ns_setabstime(wth, AbsoluteTime, RelativeTimems) \
+#define ns_setabstime(nstrace, AbsoluteTime, RelativeTimems) \
do { \
- wth->capture.nstrace->nspm_curtime = AbsoluteTime; \
- wth->capture.nstrace->nspm_curtimemsec += RelativeTimems; \
- wth->capture.nstrace->nspm_curtimelastmsec = wth->capture.nstrace->nspm_curtimemsec; \
+ (nstrace)->nspm_curtime = AbsoluteTime; \
+ (nstrace)->nspm_curtimemsec += RelativeTimems; \
+ (nstrace)->nspm_curtimelastmsec = nstrace->nspm_curtimemsec; \
} while(0)
-#define ns_setrelativetime(wth, RelativeTimems) \
+#define ns_setrelativetime(nstrace, RelativeTimems) \
do { \
guint32 rsec; \
- wth->capture.nstrace->nspm_curtimemsec += RelativeTimems; \
- rsec = (guint32)(wth->capture.nstrace->nspm_curtimemsec - wth->capture.nstrace->nspm_curtimelastmsec)/1000; \
- wth->capture.nstrace->nspm_curtime += rsec; \
- wth->capture.nstrace->nspm_curtimelastmsec += rsec * 1000; \
+ (nstrace)->nspm_curtimemsec += RelativeTimems; \
+ rsec = (guint32)((nstrace)->nspm_curtimemsec - (nstrace)->nspm_curtimelastmsec)/1000; \
+ (nstrace)->nspm_curtime += rsec; \
+ (nstrace)->nspm_curtimelastmsec += rsec * 1000; \
} while (0)
+typedef struct {
+ gchar *pnstrace_buf;
+ gint32 nstrace_buf_offset;
+ gint32 nstrace_buflen;
+ /* Performance Monitor Time variables */
+ guint32 nspm_curtime; /* current time since 1970 */
+ guint64 nspm_curtimemsec; /* current time in mili second */
+ guint64 nspm_curtimelastmsec; /* nspm_curtime last update time in milisec */
+ guint64 nsg_creltime;
+ guint64 file_size;
+} nstrace_t;
+
guint32 nspm_signature_isv10(gchar *sigp);
guint32 nspm_signature_isv20(gchar *sigp);
guint32 nspm_signature_version(wtap*, gchar*, gint32);
@@ -447,6 +459,7 @@ int nstrace_open(wtap *wth, int *err, gchar **err_info)
gchar *nstrace_buf;
gint64 file_size;
gint32 page_size;
+ nstrace_t *nstrace;
errno = WTAP_ERR_CANT_READ;
@@ -491,15 +504,16 @@ int nstrace_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_seek_read = nstrace_seek_read;
wth->subtype_close = nstrace_close;
- wth->capture.nstrace = g_malloc(sizeof(nstrace_t));
- wth->capture.nstrace->pnstrace_buf = nstrace_buf;
- wth->capture.nstrace->nstrace_buflen = page_size;
- wth->capture.nstrace->nstrace_buf_offset = 0;
- wth->capture.nstrace->nspm_curtime = 0;
- wth->capture.nstrace->nspm_curtimemsec = 0;
- wth->capture.nstrace->nspm_curtimelastmsec = 0;
- wth->capture.nstrace->nsg_creltime = 0;
- wth->capture.nstrace->file_size = file_size;
+ nstrace = (nstrace_t *)g_malloc(sizeof(nstrace_t));
+ wth->priv = (void *)nstrace;
+ nstrace->pnstrace_buf = nstrace_buf;
+ nstrace->nstrace_buflen = page_size;
+ nstrace->nstrace_buf_offset = 0;
+ nstrace->nspm_curtime = 0;
+ nstrace->nspm_curtimemsec = 0;
+ nstrace->nspm_curtimelastmsec = 0;
+ nstrace->nsg_creltime = 0;
+ nstrace->file_size = file_size;
/* Set the start time by looking for the abstime record */
@@ -509,8 +523,8 @@ int nstrace_open(wtap *wth, int *err, gchar **err_info)
if ((file_seek(wth->fh, 0, SEEK_SET, err)) == -1)
{
*err = file_error(wth->fh);
- g_free(wth->capture.nstrace->pnstrace_buf);
- g_free(wth->capture.nstrace);
+ g_free(nstrace->pnstrace_buf);
+ g_free(nstrace);
return 0;
}
@@ -518,17 +532,17 @@ int nstrace_open(wtap *wth, int *err, gchar **err_info)
if (page_size != file_read(nstrace_buf, 1, page_size, wth->fh))
{
*err = file_error(wth->fh);
- g_free(wth->capture.nstrace->pnstrace_buf);
- g_free(wth->capture.nstrace);
+ g_free(nstrace->pnstrace_buf);
+ g_free(nstrace);
return 0;
}
/* reset the buffer offset */
- wth->capture.nstrace->nstrace_buf_offset = 0;
+ nstrace->nstrace_buf_offset = 0;
}
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
- wth->phdr.ts.secs = wth->capture.nstrace->nspm_curtime;
+ wth->phdr.ts.secs = nstrace->nspm_curtime;
wth->phdr.ts.nsecs = 0;
*err = 0;
@@ -593,9 +607,10 @@ nspm_signature_version(wtap *wth, gchar *nstrace_buf, gint32 len)
#define nstrace_set_start_time_ver(ver) \
gboolean nstrace_set_start_time_v##ver(wtap *wth) \
{\
- gchar* nstrace_buf = wth->capture.nstrace->pnstrace_buf;\
- gint32 nstrace_buf_offset = wth->capture.nstrace->nstrace_buf_offset;\
- gint32 nstrace_buflen = wth->capture.nstrace->nstrace_buflen;\
+ nstrace_t *nstrace = (nstrace_t *)wth->priv;\
+ gchar* nstrace_buf = nstrace->pnstrace_buf;\
+ gint32 nstrace_buf_offset = nstrace->nstrace_buf_offset;\
+ gint32 nstrace_buflen = nstrace->nstrace_buflen;\
do\
{\
while (nstrace_buf_offset < nstrace_buflen)\
@@ -604,9 +619,9 @@ nspm_signature_version(wtap *wth, gchar *nstrace_buf, gint32 len)
switch (nspr_getv##ver##recordtype(fp))\
{\
case NSPR_ABSTIME_V##ver:\
- ns_setabstime(wth, pletohl(&((nspr_abstime_v##ver##_t *) fp)->abs_Time), pletohs(&((nspr_abstime_v##ver##_t *) fp)->abs_RelTime));\
- wth->capture.nstrace->nstrace_buf_offset = nstrace_buf_offset + nspr_getv##ver##recordsize(fp);\
- wth->capture.nstrace->nstrace_buflen = nstrace_buflen;\
+ ns_setabstime(nstrace, pletohl(&((nspr_abstime_v##ver##_t *) fp)->abs_Time), pletohs(&((nspr_abstime_v##ver##_t *) fp)->abs_RelTime));\
+ nstrace->nstrace_buf_offset = nstrace_buf_offset + nspr_getv##ver##recordsize(fp);\
+ nstrace->nstrace_buflen = nstrace_buflen;\
return TRUE;\
case NSPR_UNUSEDSPACE_V10:\
nstrace_buf_offset = nstrace_buflen;\
@@ -617,7 +632,7 @@ nspm_signature_version(wtap *wth, gchar *nstrace_buf, gint32 len)
}\
nstrace_buf_offset = 0;\
wth->data_offset += nstrace_buflen;\
- nstrace_buflen = GET_READ_PAGE_SIZE((wth->capture.nstrace->file_size - wth->data_offset));\
+ nstrace_buflen = GET_READ_PAGE_SIZE((nstrace->file_size - wth->data_offset));\
}while((nstrace_buflen > 0) && (nstrace_buflen == (file_read(nstrace_buf, 1, nstrace_buflen, wth->fh))));\
return FALSE;\
}
@@ -664,11 +679,11 @@ gboolean nstrace_set_start_time(wtap *wth)
*/
gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
{
-
- guint64 nsg_creltime = wth->capture.nstrace->nsg_creltime;
- gchar *nstrace_buf = wth->capture.nstrace->pnstrace_buf;
- gint32 nstrace_buf_offset = wth->capture.nstrace->nstrace_buf_offset;
- gint32 nstrace_buflen = wth->capture.nstrace->nstrace_buflen;
+ nstrace_t *nstrace = (nstrace_t *)wth->priv;
+ guint64 nsg_creltime = nstrace->nsg_creltime;
+ gchar *nstrace_buf = nstrace->pnstrace_buf;
+ gint32 nstrace_buf_offset = nstrace->nstrace_buf_offset;
+ gint32 nstrace_buflen = nstrace->nstrace_buflen;
nspr_pktracefull_v10_t *fp;
nspr_pktracepart_v10_t *pp;
@@ -690,7 +705,7 @@ gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *data_of
case NSPR_PDPKTRACEFULLRX_V10:
nsg_creltime += ns_hrtime2nsec(pletohl(&fp->fp_RelTimeHr));
- wth->phdr.ts.secs = wth->capture.nstrace->nspm_curtime + (guint32) (nsg_creltime / 1000000000);
+ wth->phdr.ts.secs = nstrace->nspm_curtime + (guint32) (nsg_creltime / 1000000000);
wth->phdr.ts.nsecs = (guint32) (nsg_creltime % 1000000000);
wth->phdr.len = pletohs(&fp->nsprRecordSize);
@@ -703,9 +718,9 @@ gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *data_of
memcpy(buffer_start_ptr(wth->frame_buffer), fp, wth->phdr.caplen);
*data_offset = wth->data_offset + nstrace_buf_offset;
- wth->capture.nstrace->nstrace_buf_offset = nstrace_buf_offset + wth->phdr.len;
- wth->capture.nstrace->nstrace_buflen = nstrace_buflen;
- wth->capture.nstrace->nsg_creltime = nsg_creltime;
+ nstrace->nstrace_buf_offset = nstrace_buf_offset + wth->phdr.len;
+ nstrace->nstrace_buflen = nstrace_buflen;
+ nstrace->nsg_creltime = nsg_creltime;
return TRUE;
@@ -714,7 +729,7 @@ gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *data_of
case NSPR_PDPKTRACEPARTRX_V10:
nsg_creltime += ns_hrtime2nsec(pletohl(&pp->pp_RelTimeHr));
- wth->phdr.ts.secs = wth->capture.nstrace->nspm_curtime + (guint32) (nsg_creltime / 1000000000);
+ wth->phdr.ts.secs = nstrace->nspm_curtime + (guint32) (nsg_creltime / 1000000000);
wth->phdr.ts.nsecs = (guint32) (nsg_creltime % 1000000000);
wth->phdr.len = pletohs(&pp->pp_PktSizeOrg) + nspr_pktracepart_v10_s;
@@ -726,21 +741,21 @@ gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *data_of
memcpy(buffer_start_ptr(wth->frame_buffer), pp, wth->phdr.caplen);
*data_offset = wth->data_offset + nstrace_buf_offset;
- wth->capture.nstrace->nstrace_buf_offset = nstrace_buf_offset + wth->phdr.caplen;
- wth->capture.nstrace->nsg_creltime = nsg_creltime;
- wth->capture.nstrace->nstrace_buflen = nstrace_buflen;
+ nstrace->nstrace_buf_offset = nstrace_buf_offset + wth->phdr.caplen;
+ nstrace->nsg_creltime = nsg_creltime;
+ nstrace->nstrace_buflen = nstrace_buflen;
return TRUE;
case NSPR_ABSTIME_V10:
- ns_setabstime(wth, pletohl(&((nspr_abstime_v10_t *) fp)->abs_Time), pletohl(&((nspr_abstime_v10_t *) fp)->abs_RelTime));
+ ns_setabstime(nstrace, pletohl(&((nspr_abstime_v10_t *) fp)->abs_Time), pletohl(&((nspr_abstime_v10_t *) fp)->abs_RelTime));
nstrace_buf_offset += pletohs(&fp->nsprRecordSize);
break;
case NSPR_RELTIME_V10:
- ns_setrelativetime(wth, ((nspr_abstime_v10_t *) fp)->abs_RelTime);
+ ns_setrelativetime(nstrace, ((nspr_abstime_v10_t *) fp)->abs_RelTime);
nstrace_buf_offset += pletohs(&fp->nsprRecordSize);
break;
@@ -758,7 +773,7 @@ gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *data_of
nstrace_buf_offset = 0;
wth->data_offset += nstrace_buflen;
- nstrace_buflen = GET_READ_PAGE_SIZE((wth->capture.nstrace->file_size - wth->data_offset));
+ nstrace_buflen = GET_READ_PAGE_SIZE((nstrace->file_size - wth->data_offset));
}while((nstrace_buflen > 0) && (nstrace_buflen == (file_read(nstrace_buf, 1, nstrace_buflen, wth->fh))));
return FALSE;
@@ -767,7 +782,7 @@ gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *data_of
#define TIMEDEFV20(fp,type) \
do {\
nsg_creltime += ns_hrtime2nsec(pletohl(&fp->type##_RelTimeHr));\
- wth->phdr.ts.secs = wth->capture.nstrace->nspm_curtime + (guint32) (nsg_creltime / 1000000000);\
+ wth->phdr.ts.secs = nstrace->nspm_curtime + (guint32) (nsg_creltime / 1000000000);\
wth->phdr.ts.nsecs = (guint32) (nsg_creltime % 1000000000);\
}while(0)
@@ -811,19 +826,20 @@ gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *data_of
buffer_assure_space(wth->frame_buffer, wth->phdr.caplen);\
memcpy(buffer_start_ptr(wth->frame_buffer), fp, wth->phdr.caplen);\
*data_offset = wth->data_offset + nstrace_buf_offset;\
- wth->capture.nstrace->nstrace_buf_offset = nstrace_buf_offset + nspr_getv20recordsize((nspr_hd_v20_t *)fp);\
- wth->capture.nstrace->nstrace_buflen = nstrace_buflen;\
- wth->capture.nstrace->nsg_creltime = nsg_creltime;\
+ nstrace->nstrace_buf_offset = nstrace_buf_offset + nspr_getv20recordsize((nspr_hd_v20_t *)fp);\
+ nstrace->nstrace_buflen = nstrace_buflen;\
+ nstrace->nsg_creltime = nsg_creltime;\
wth->pseudo_header.nstr.rec_type = NSPR_HEADER_VERSION##TYPE;\
return TRUE;\
}while(0)
gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
{
- guint64 nsg_creltime = wth->capture.nstrace->nsg_creltime;
- gchar *nstrace_buf = wth->capture.nstrace->pnstrace_buf;
- gint32 nstrace_buf_offset = wth->capture.nstrace->nstrace_buf_offset;
- gint32 nstrace_buflen = wth->capture.nstrace->nstrace_buflen;
+ nstrace_t *nstrace = (nstrace_t *)wth->priv;
+ guint64 nsg_creltime = nstrace->nsg_creltime;
+ gchar *nstrace_buf = nstrace->pnstrace_buf;
+ gint32 nstrace_buf_offset = nstrace->nstrace_buf_offset;
+ gint32 nstrace_buflen = nstrace->nstrace_buflen;
nspr_pktracefull_v20_t *fp20;
nspr_pktracefull_v21_t *fp21;
@@ -865,14 +881,14 @@ gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *data_of
{
fp20 = (nspr_pktracefull_v20_t *) &nstrace_buf[nstrace_buf_offset];
nstrace_buf_offset += nspr_getv20recordsize((nspr_hd_v20_t *)fp20);
- ns_setabstime(wth, pletohl(&((nspr_abstime_v20_t *) fp20)->abs_Time), pletohs(&((nspr_abstime_v20_t *) fp20)->abs_RelTime));
+ ns_setabstime(nstrace, pletohl(&((nspr_abstime_v20_t *) fp20)->abs_Time), pletohs(&((nspr_abstime_v20_t *) fp20)->abs_RelTime));
break;
}
case NSPR_RELTIME_V20:
{
fp20 = (nspr_pktracefull_v20_t *) &nstrace_buf[nstrace_buf_offset];
- ns_setrelativetime(wth, pletohs(&((nspr_abstime_v20_t *) fp20)->abs_RelTime));
+ ns_setrelativetime(nstrace, pletohs(&((nspr_abstime_v20_t *) fp20)->abs_RelTime));
nstrace_buf_offset += nspr_getv20recordsize((nspr_hd_v20_t *)fp20);
break;
}
@@ -897,7 +913,7 @@ gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *data_of
nstrace_buf_offset = 0;
wth->data_offset += nstrace_buflen;
- nstrace_buflen = GET_READ_PAGE_SIZE((wth->capture.nstrace->file_size - wth->data_offset));
+ nstrace_buflen = GET_READ_PAGE_SIZE((nstrace->file_size - wth->data_offset));
}while((nstrace_buflen > 0) && (nstrace_buflen == (file_read(nstrace_buf, 1, nstrace_buflen, wth->fh))));
return FALSE;
@@ -1001,13 +1017,18 @@ gboolean nstrace_seek_read(wtap *wth, gint64 seek_off,
*/
void nstrace_close(wtap *wth)
{
+ nstrace_t *nstrace = (nstrace_t *)wth->priv;
- g_free(wth->capture.nstrace->pnstrace_buf);
- g_free(wth->capture.nstrace);
- return;
+ g_free(nstrace->pnstrace_buf);
}
+typedef struct {
+ guint16 page_offset;
+ guint16 page_len;
+ guint32 absrec_time;
+} nstrace_dump_t;
+
/* Returns 0 if we could write the specified encapsulation type,
** an error indication otherwise. */
int nstrace_10_dump_can_write_encap(int encap)
@@ -1034,6 +1055,8 @@ int nstrace_20_dump_can_write_encap(int encap)
** failure */
gboolean nstrace_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err)
{
+ nstrace_dump_t *nstrace;
+
if (cant_seek)
{
*err = WTAP_ERR_CANT_WRITE_TO_PIPE;
@@ -1042,10 +1065,11 @@ gboolean nstrace_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err)
wdh->subtype_write = nstrace_dump;
- wdh->dump.nstr = g_malloc(sizeof(nstrace_dump_t));
- wdh->dump.nstr->page_offset = 0;
- wdh->dump.nstr->page_len = NSPR_PAGESIZE;
- wdh->dump.nstr->absrec_time = 0;
+ nstrace = (nstrace_dump_t *)g_malloc(sizeof(nstrace_dump_t));
+ wdh->priv = (void *)nstrace;
+ nstrace->page_offset = 0;
+ nstrace->page_len = NSPR_PAGESIZE;
+ nstrace->absrec_time = 0;
return TRUE;
}
@@ -1053,6 +1077,7 @@ gboolean nstrace_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err)
gboolean nstrace_add_signature(wtap_dumper *wdh)
{
+ nstrace_dump_t *nstrace = (nstrace_dump_t *)wdh->priv;
size_t nwritten;
if (wdh->file_type == WTAP_FILE_NETSCALER_1_0)
@@ -1070,7 +1095,7 @@ gboolean nstrace_add_signature(wtap_dumper *wdh)
return FALSE;
/* Move forward the page offset */
- wdh->dump.nstr->page_offset += (guint16) nwritten;
+ nstrace->page_offset += (guint16) nwritten;
} else if (wdh->file_type == WTAP_FILE_NETSCALER_2_0)
{
@@ -1088,7 +1113,7 @@ gboolean nstrace_add_signature(wtap_dumper *wdh)
return FALSE;
/* Move forward the page offset */
- wdh->dump.nstr->page_offset += (guint16) nwritten;
+ nstrace->page_offset += (guint16) nwritten;
} else
{
@@ -1103,6 +1128,7 @@ gboolean nstrace_add_signature(wtap_dumper *wdh)
gboolean nstrace_add_abstime(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const guchar *pd)
{
+ nstrace_dump_t *nstrace = (nstrace_dump_t *)wdh->priv;
size_t nwritten;
guint64 nsg_creltime;
@@ -1127,7 +1153,7 @@ gboolean nstrace_add_abstime(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
return FALSE;
/* Move forward the page offset */
- wdh->dump.nstr->page_offset += nspr_abstime_v10_s;
+ nstrace->page_offset += nspr_abstime_v10_s;
} else if (wdh->file_type == WTAP_FILE_NETSCALER_2_0)
{
@@ -1149,7 +1175,7 @@ gboolean nstrace_add_abstime(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
return FALSE;
/* Move forward the page offset */
- wdh->dump.nstr->page_offset += nspr_abstime_v20_s;
+ nstrace->page_offset += nspr_abstime_v20_s;
} else
{
@@ -1166,9 +1192,10 @@ gboolean nstrace_add_abstime(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
static gboolean nstrace_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err)
{
+ nstrace_dump_t *nstrace = (nstrace_dump_t *)wdh->priv;
size_t nwritten;
- if (wdh->dump.nstr->page_offset == 0)
+ if (nstrace->page_offset == 0)
{
/* Add the signature record and abs time record */
if (wdh->file_type == WTAP_FILE_NETSCALER_1_0)
@@ -1192,16 +1219,16 @@ static gboolean nstrace_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
if (wdh->file_type == WTAP_FILE_NETSCALER_1_0)
{
- if (wdh->dump.nstr->page_offset + phdr->caplen >= wdh->dump.nstr->page_len)
+ if (nstrace->page_offset + phdr->caplen >= nstrace->page_len)
{
/* Start on the next page */
- if (fseek(wdh->fh, (wdh->dump.nstr->page_len - wdh->dump.nstr->page_offset), SEEK_CUR) == -1)
+ if (fseek(wdh->fh, (nstrace->page_len - nstrace->page_offset), SEEK_CUR) == -1)
{
*err = errno;
return FALSE;
}
- wdh->dump.nstr->page_offset = 0;
+ nstrace->page_offset = 0;
/* Possibly add signature and abstime records and increment offset */
if (nstrace_add_signature(wdh) == FALSE)
@@ -1220,7 +1247,7 @@ static gboolean nstrace_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
return FALSE;
}
- wdh->dump.nstr->page_offset += (guint16) nwritten;
+ nstrace->page_offset += (guint16) nwritten;
} else if (wdh->file_type == WTAP_FILE_NETSCALER_2_0)
{
*err = WTAP_ERR_UNSUPPORTED_FILE_TYPE;
@@ -1240,16 +1267,16 @@ static gboolean nstrace_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
return FALSE;
} else if (wdh->file_type == WTAP_FILE_NETSCALER_2_0)
{
- if (wdh->dump.nstr->page_offset + phdr->caplen >= wdh->dump.nstr->page_len)
+ if (nstrace->page_offset + phdr->caplen >= nstrace->page_len)
{
/* Start on the next page */
- if (fseek(wdh->fh, (wdh->dump.nstr->page_len - wdh->dump.nstr->page_offset), SEEK_CUR) == -1)
+ if (fseek(wdh->fh, (nstrace->page_len - nstrace->page_offset), SEEK_CUR) == -1)
{
*err = errno;
return FALSE;
}
- wdh->dump.nstr->page_offset = 0;
+ nstrace->page_offset = 0;
/* Possibly add signature and abstime records and increment offset */
if (nstrace_add_signature(wdh) == FALSE)
@@ -1269,7 +1296,7 @@ static gboolean nstrace_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
return FALSE;
}
- wdh->dump.nstr->page_offset += (guint16) nwritten;
+ nstrace->page_offset += (guint16) nwritten;
}
break;
diff --git a/wiretap/nettl.c b/wiretap/nettl.c
index 2bccaca99c..14fd6877ee 100644
--- a/wiretap/nettl.c
+++ b/wiretap/nettl.c
@@ -175,6 +175,10 @@ struct nettlrec_ns_ls_drv_eth_hdr {
/* header is followed by data and once again the total length (2 bytes) ! */
+typedef struct {
+ gboolean is_hpux_11;
+} nettl_t;
+
static gboolean nettl_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean nettl_seek_read(wtap *wth, gint64 seek_off,
@@ -185,7 +189,6 @@ static int nettl_read_rec_header(wtap *wth, FILE_T fh,
int *err, gchar **err_info, gboolean *fddihack);
static gboolean nettl_read_rec_data(FILE_T fh, guchar *pd, int length,
int *err, gboolean fddihack);
-static void nettl_close(wtap *wth);
static gboolean nettl_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
@@ -195,6 +198,7 @@ int nettl_open(wtap *wth, int *err, gchar **err_info _U_)
guint16 dummy[2];
int subsys;
int bytes_read;
+ nettl_t *nettl;
/* Read in the string that should be at the start of a HP file */
errno = WTAP_ERR_CANT_READ;
@@ -223,14 +227,14 @@ int nettl_open(wtap *wth, int *err, gchar **err_info _U_)
/* This is an nettl file */
wth->file_type = WTAP_FILE_NETTL;
- wth->capture.nettl = g_malloc(sizeof(nettl_t));
+ nettl = g_malloc(sizeof(nettl_t));
+ wth->priv = (void *)nettl;
if (file_hdr.os_vers[2] == '1' && file_hdr.os_vers[3] == '1')
- wth->capture.nettl->is_hpux_11 = TRUE;
+ nettl->is_hpux_11 = TRUE;
else
- wth->capture.nettl->is_hpux_11 = FALSE;
+ nettl->is_hpux_11 = FALSE;
wth->subtype_read = nettl_read;
wth->subtype_seek_read = nettl_seek_read;
- wth->subtype_close = nettl_close;
wth->snapshot_length = 0; /* not available */
/* read the first header to take a guess at the file encap */
@@ -240,7 +244,7 @@ int nettl_open(wtap *wth, int *err, gchar **err_info _U_)
return -1;
if (bytes_read != 0) {
*err = WTAP_ERR_SHORT_READ;
- g_free(wth->capture.nettl);
+ g_free(nettl);
return -1;
}
return 0;
@@ -280,7 +284,7 @@ int nettl_open(wtap *wth, int *err, gchar **err_info _U_)
}
if (file_seek(wth->fh, FILE_HDR_SIZE, SEEK_SET, err) == -1) {
- g_free(wth->capture.nettl);
+ g_free(nettl);
return -1;
}
wth->data_offset = FILE_HDR_SIZE;
@@ -367,6 +371,7 @@ nettl_read_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
union wtap_pseudo_header *pseudo_header, int *err,
gchar **err_info, gboolean *fddihack)
{
+ nettl_t *nettl = (nettl_t *)wth->priv;
int bytes_read;
struct nettlrec_hdr rec_hdr;
guint16 hdr_len;
@@ -562,7 +567,7 @@ nettl_read_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
*
* And what are the extra two bytes?
*/
- if (wth->capture.nettl->is_hpux_11) {
+ if (nettl->is_hpux_11) {
if (file_seek(fh, 2, SEEK_CUR, err) == -1) return -1;
offset += 2;
}
@@ -674,11 +679,6 @@ nettl_read_rec_data(FILE_T fh, guchar *pd, int length, int *err, gboolean fddiha
return TRUE;
}
-static void nettl_close(wtap *wth)
-{
- g_free(wth->capture.nettl);
-}
-
/* Returns 0 if we could write the specified encapsulation type,
an error indication otherwise. nettl files are WTAP_ENCAP_UNKNOWN
diff --git a/wiretap/network_instruments.c b/wiretap/network_instruments.c
index 64fdbb557d..731a4be8d8 100644
--- a/wiretap/network_instruments.c
+++ b/wiretap/network_instruments.c
@@ -99,7 +99,6 @@ static gboolean read_packet_data(FILE_T fh, int offset_to_frame, int offset,
guint8 *pd, int length, int *err, char **err_info);
static gboolean skip_to_next_packet(wtap *wth, int offset,
int offset_to_next_packet, int *err, char **err_info);
-static gboolean observer_dump_close(wtap_dumper *wdh, int *err);
static gboolean observer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
@@ -450,6 +449,11 @@ skip_to_next_packet(wtap *wth, int offset, int offset_to_next_packet, int *err,
return TRUE;
}
+typedef struct {
+ guint64 packet_count;
+ guint8 network_type;
+} niobserver_dump_t;
+
/* Returns 0 if we could write the specified encapsulation type,
an error indication otherwise. */
int network_instruments_dump_can_write_encap(int encap)
@@ -473,6 +477,7 @@ gboolean network_instruments_dump_open(wtap_dumper *wdh, gboolean cant_seek, int
char comment[64];
struct tm *current_time;
time_t system_time;
+ niobserver_dump_t *niobserver;
if (cant_seek) {
*err = WTAP_ERR_CANT_WRITE_TO_PIPE;
@@ -480,11 +485,11 @@ gboolean network_instruments_dump_open(wtap_dumper *wdh, gboolean cant_seek, int
}
wdh->subtype_write = observer_dump;
- wdh->subtype_close = observer_dump_close;
- wdh->dump.niobserver = g_malloc(sizeof(niobserver_dump_t));
- wdh->dump.niobserver->packet_count = 0;
- wdh->dump.niobserver->network_type = from_wtap_encap[wdh->encap];
+ niobserver = (niobserver_dump_t *)g_malloc(sizeof(niobserver_dump_t));
+ wdh->priv = (void *)niobserver;
+ niobserver->packet_count = 0;
+ niobserver->network_type = from_wtap_encap[wdh->encap];
/* create the file comment */
time(&system_time);
@@ -531,7 +536,7 @@ static gboolean observer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header _U_, const guchar *pd,
int *err)
{
- niobserver_dump_t *niobserver = wdh->dump.niobserver;
+ niobserver_dump_t *niobserver = (niobserver_dump_t *)wdh->priv;
packet_entry_header packet_header;
size_t nwritten;
guint64 capture_nanoseconds;
@@ -581,9 +586,3 @@ static gboolean observer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
return TRUE;
}
-
-/* just returns TRUE, there is no clean up needed */
-static gboolean observer_dump_close(wtap_dumper *wdh _U_, int *err _U_)
-{
- return TRUE;
-}
diff --git a/wiretap/netxray.c b/wiretap/netxray.c
index 4518701e59..cba22a0d7f 100644
--- a/wiretap/netxray.c
+++ b/wiretap/netxray.c
@@ -306,6 +306,19 @@ union netxrayrec_hdr {
struct netxrayrec_2_x_hdr hdr_2_x;
};
+typedef struct {
+ time_t start_time;
+ double ticks_per_sec;
+ double start_timestamp;
+ gboolean wrapped;
+ guint32 nframes;
+ gint64 start_offset;
+ gint64 end_offset;
+ int version_major;
+ gboolean fcs_valid; /* if packets have valid FCS at the end */
+ guint isdn_type; /* 1 = E1 PRI, 2 = T1 PRI, 3 = BRI */
+} netxray_t;
+
static gboolean netxray_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean netxray_seek_read(wtap *wth, gint64 seek_off,
@@ -317,7 +330,6 @@ static guint netxray_set_pseudo_header(wtap *wth, const guint8 *pd, int len,
union wtap_pseudo_header *pseudo_header, union netxrayrec_hdr *hdr);
static gboolean netxray_read_rec_data(FILE_T fh, guint8 *data_ptr,
guint32 packet_size, int *err);
-static void netxray_close(wtap *wth);
static gboolean netxray_dump_1_1(wtap_dumper *wdh,
const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
@@ -364,6 +376,7 @@ int netxray_open(wtap *wth, int *err, gchar **err_info)
#define NUM_NETXRAY_ENCAPS (sizeof netxray_encap / sizeof netxray_encap[0])
int file_encap;
guint isdn_type = 0;
+ netxray_t *netxray;
/* Read in the string that should be at the start of a NetXRay
* file */
@@ -761,22 +774,22 @@ int netxray_open(wtap *wth, int *err, gchar **err_info)
/* This is a netxray file */
wth->file_type = file_type;
- wth->capture.netxray = g_malloc(sizeof(netxray_t));
+ netxray = (netxray_t *)g_malloc(sizeof(netxray_t));
+ wth->priv = (void *)netxray;
wth->subtype_read = netxray_read;
wth->subtype_seek_read = netxray_seek_read;
- wth->subtype_close = netxray_close;
wth->file_encap = file_encap;
wth->snapshot_length = 0; /* not available in header */
- wth->capture.netxray->start_time = pletohl(&hdr.start_time);
- wth->capture.netxray->ticks_per_sec = ticks_per_sec;
- wth->capture.netxray->start_timestamp = start_timestamp;
- wth->capture.netxray->version_major = version_major;
+ netxray->start_time = pletohl(&hdr.start_time);
+ netxray->ticks_per_sec = ticks_per_sec;
+ netxray->start_timestamp = start_timestamp;
+ netxray->version_major = version_major;
/*
* If frames have an extra 4 bytes of stuff at the end, is
* it an FCS, or just junk?
*/
- wth->capture.netxray->fcs_valid = FALSE;
+ netxray->fcs_valid = FALSE;
switch (file_encap) {
case WTAP_ENCAP_ETHERNET:
@@ -863,7 +876,7 @@ int netxray_open(wtap *wth, int *err, gchar **err_info)
*/
if (version_major == 2) {
if (hdr.realtick[1] == 0x34 && hdr.realtick[2] == 0x12)
- wth->capture.netxray->fcs_valid = TRUE;
+ netxray->fcs_valid = TRUE;
}
break;
}
@@ -872,21 +885,21 @@ int netxray_open(wtap *wth, int *err, gchar **err_info)
* Remember the ISDN type, as we need it to interpret the
* channel number in ISDN captures.
*/
- wth->capture.netxray->isdn_type = isdn_type;
+ netxray->isdn_type = isdn_type;
/* Remember the offset after the last packet in the capture (which
* isn't necessarily the last packet in the file), as it appears
* there's sometimes crud after it.
* XXX: Remember 'start_offset' to help testing for 'short file' at EOF
*/
- wth->capture.netxray->wrapped = FALSE;
- wth->capture.netxray->nframes = pletohl(&hdr.nframes);
- wth->capture.netxray->start_offset = pletohl(&hdr.start_offset);
- wth->capture.netxray->end_offset = pletohl(&hdr.end_offset);
+ netxray->wrapped = FALSE;
+ netxray->nframes = pletohl(&hdr.nframes);
+ netxray->start_offset = pletohl(&hdr.start_offset);
+ netxray->end_offset = pletohl(&hdr.end_offset);
/* Seek to the beginning of the data records. */
if (file_seek(wth->fh, pletohl(&hdr.start_offset), SEEK_SET, err) == -1) {
- g_free(wth->capture.netxray);
+ g_free(netxray);
return -1;
}
wth->data_offset = pletohl(&hdr.start_offset);
@@ -898,6 +911,7 @@ int netxray_open(wtap *wth, int *err, gchar **err_info)
static gboolean netxray_read(wtap *wth, int *err, gchar **err_info _U_,
gint64 *data_offset)
{
+ netxray_t *netxray = (netxray_t *)wth->priv;
guint32 packet_size;
union netxrayrec_hdr hdr;
int hdr_size;
@@ -907,7 +921,7 @@ static gboolean netxray_read(wtap *wth, int *err, gchar **err_info _U_,
reread:
/* Have we reached the end of the packet data? */
- if (wth->data_offset == wth->capture.netxray->end_offset) {
+ if (wth->data_offset == netxray->end_offset) {
/* Yes. */
*err = 0; /* it's just an EOF, not an error */
return FALSE;
@@ -945,14 +959,14 @@ reread:
* partial frame header (or partial frame data) record, then the
* netxray_read... functions will detect the short record.
*/
- if (wth->capture.netxray->start_offset < wth->capture.netxray->end_offset) {
+ if (netxray->start_offset < netxray->end_offset) {
*err = WTAP_ERR_SHORT_READ;
return FALSE;
}
- if (!wth->capture.netxray->wrapped) {
+ if (!netxray->wrapped) {
/* Yes. Remember that we did. */
- wth->capture.netxray->wrapped = TRUE;
+ netxray->wrapped = TRUE;
if (file_seek(wth->fh, CAPTUREFILE_HEADER_SIZE,
SEEK_SET, err) == -1)
return FALSE;
@@ -974,7 +988,7 @@ reread:
/*
* Read the packet data.
*/
- if (wth->capture.netxray->version_major == 0)
+ if (netxray->version_major == 0)
packet_size = pletohs(&hdr.old_hdr.len);
else
packet_size = pletohs(&hdr.hdr_1_x.incl_len);
@@ -990,12 +1004,12 @@ reread:
padding = netxray_set_pseudo_header(wth, pd, packet_size,
&wth->pseudo_header, &hdr);
- if (wth->capture.netxray->version_major == 0) {
+ if (netxray->version_major == 0) {
t = (double)pletohl(&hdr.old_hdr.timelo)
+ (double)pletohl(&hdr.old_hdr.timehi)*4294967296.0;
- t /= wth->capture.netxray->ticks_per_sec;
- t -= wth->capture.netxray->start_timestamp;
- wth->phdr.ts.secs = wth->capture.netxray->start_time + (long)t;
+ t /= netxray->ticks_per_sec;
+ t -= netxray->start_timestamp;
+ wth->phdr.ts.secs = netxray->start_time + (long)t;
wth->phdr.ts.nsecs = (int)((t-(double)(unsigned long)(t))
*1.0e9);
/*
@@ -1007,9 +1021,9 @@ reread:
} else {
t = (double)pletohl(&hdr.hdr_1_x.timelo)
+ (double)pletohl(&hdr.hdr_1_x.timehi)*4294967296.0;
- t /= wth->capture.netxray->ticks_per_sec;
- t -= wth->capture.netxray->start_timestamp;
- wth->phdr.ts.secs = wth->capture.netxray->start_time + (time_t)t;
+ t /= netxray->ticks_per_sec;
+ t -= netxray->start_timestamp;
+ wth->phdr.ts.secs = netxray->start_time + (time_t)t;
wth->phdr.ts.nsecs = (int)((t-(double)(unsigned long)(t))
*1.0e9);
/*
@@ -1064,11 +1078,12 @@ static int
netxray_read_rec_header(wtap *wth, FILE_T fh, union netxrayrec_hdr *hdr,
int *err)
{
+ netxray_t *netxray = (netxray_t *)wth->priv;
int bytes_read;
int hdr_size = 0;
/* Read record header. */
- switch (wth->capture.netxray->version_major) {
+ switch (netxray->version_major) {
case 0:
hdr_size = sizeof (struct old_netxrayrec_hdr);
@@ -1106,13 +1121,14 @@ static guint
netxray_set_pseudo_header(wtap *wth, const guint8 *pd, int len,
union wtap_pseudo_header *pseudo_header, union netxrayrec_hdr *hdr)
{
+ netxray_t *netxray = (netxray_t *)wth->priv;
guint padding = 0;
/*
* If this is Ethernet, 802.11, ISDN, X.25, or ATM, set the
* pseudo-header.
*/
- switch (wth->capture.netxray->version_major) {
+ switch (netxray->version_major) {
case 1:
switch (wth->file_encap) {
@@ -1156,7 +1172,7 @@ netxray_set_pseudo_header(wtap *wth, const guint8 *pd, int len,
* We have 4 bytes of stuff at the
* end of the frame - FCS, or junk?
*/
- if (wth->capture.netxray->fcs_valid) {
+ if (netxray->fcs_valid) {
/*
* FCS.
*/
@@ -1197,7 +1213,7 @@ netxray_set_pseudo_header(wtap *wth, const guint8 *pd, int len,
* We have 4 bytes of stuff at the
* end of the frame - FCS, or junk?
*/
- if (wth->capture.netxray->fcs_valid) {
+ if (netxray->fcs_valid) {
/*
* FCS.
*/
@@ -1241,7 +1257,7 @@ netxray_set_pseudo_header(wtap *wth, const guint8 *pd, int len,
(hdr->hdr_2_x.xxx[12] & 0x01);
pseudo_header->isdn.channel =
hdr->hdr_2_x.xxx[13] & 0x1F;
- switch (wth->capture.netxray->isdn_type) {
+ switch (netxray->isdn_type) {
case 1:
/*
@@ -1442,11 +1458,11 @@ netxray_read_rec_data(FILE_T fh, guint8 *data_ptr, guint32 packet_size,
return TRUE;
}
-static void
-netxray_close(wtap *wth)
-{
- g_free(wth->capture.netxray);
-}
+typedef struct {
+ gboolean first_frame;
+ struct wtap_nstime start;
+ guint32 nframes;
+} netxray_dump_t;
static const struct {
int wtap_encap_value;
@@ -1490,6 +1506,8 @@ int netxray_dump_can_write_encap_1_1(int encap)
failure */
gboolean netxray_dump_open_1_1(wtap_dumper *wdh, gboolean cant_seek, int *err)
{
+ netxray_dump_t *netxray;
+
/* This is a NetXRay file. We can't fill in some fields in the header
until all the packets have been written, so we can't write to a
pipe. */
@@ -1510,11 +1528,12 @@ gboolean netxray_dump_open_1_1(wtap_dumper *wdh, gboolean cant_seek, int *err)
return FALSE;
}
- wdh->dump.netxray = g_malloc(sizeof(netxray_dump_t));
- wdh->dump.netxray->first_frame = TRUE;
- wdh->dump.netxray->start.secs = 0;
- wdh->dump.netxray->start.nsecs = 0;
- wdh->dump.netxray->nframes = 0;
+ netxray = (netxray_dump_t *)g_malloc(sizeof(netxray_dump_t));
+ wdh->priv = (void *)netxray;
+ netxray->first_frame = TRUE;
+ netxray->start.secs = 0;
+ netxray->start.nsecs = 0;
+ netxray->nframes = 0;
return TRUE;
}
@@ -1526,7 +1545,7 @@ static gboolean netxray_dump_1_1(wtap_dumper *wdh,
const union wtap_pseudo_header *pseudo_header _U_,
const guchar *pd, int *err)
{
- netxray_dump_t *netxray = wdh->dump.netxray;
+ netxray_dump_t *netxray = (netxray_dump_t *)wdh->priv;
guint64 timestamp;
guint32 t32;
struct netxrayrec_1_x_hdr rec_hdr;
@@ -1587,7 +1606,7 @@ static gboolean netxray_dump_1_1(wtap_dumper *wdh,
static gboolean netxray_dump_close_1_1(wtap_dumper *wdh, int *err)
{
char hdr_buf[CAPTUREFILE_HEADER_SIZE - sizeof(netxray_magic)];
- netxray_dump_t *netxray = wdh->dump.netxray;
+ netxray_dump_t *netxray = (netxray_dump_t *)wdh->priv;
guint32 filelen;
struct netxray_hdr file_hdr;
size_t nwritten;
@@ -1682,6 +1701,8 @@ int netxray_dump_can_write_encap_2_0(int encap)
failure */
gboolean netxray_dump_open_2_0(wtap_dumper *wdh, gboolean cant_seek, int *err)
{
+ netxray_dump_t *netxray;
+
/* This is a NetXRay file. We can't fill in some fields in the header
until all the packets have been written, so we can't write to a
pipe. */
@@ -1702,11 +1723,12 @@ gboolean netxray_dump_open_2_0(wtap_dumper *wdh, gboolean cant_seek, int *err)
return FALSE;
}
- wdh->dump.netxray = g_malloc(sizeof(netxray_dump_t));
- wdh->dump.netxray->first_frame = TRUE;
- wdh->dump.netxray->start.secs = 0;
- wdh->dump.netxray->start.nsecs = 0;
- wdh->dump.netxray->nframes = 0;
+ netxray = (netxray_dump_t *)g_malloc(sizeof(netxray_dump_t));
+ wdh->priv = (void *)netxray;
+ netxray->first_frame = TRUE;
+ netxray->start.secs = 0;
+ netxray->start.nsecs = 0;
+ netxray->nframes = 0;
return TRUE;
}
@@ -1718,7 +1740,7 @@ static gboolean netxray_dump_2_0(wtap_dumper *wdh,
const union wtap_pseudo_header *pseudo_header _U_,
const guchar *pd, int *err)
{
- netxray_dump_t *netxray = wdh->dump.netxray;
+ netxray_dump_t *netxray = (netxray_dump_t *)wdh->priv;
guint64 timestamp;
guint32 t32;
struct netxrayrec_2_x_hdr rec_hdr;
@@ -1797,7 +1819,7 @@ static gboolean netxray_dump_2_0(wtap_dumper *wdh,
static gboolean netxray_dump_close_2_0(wtap_dumper *wdh, int *err)
{
char hdr_buf[CAPTUREFILE_HEADER_SIZE - sizeof(netxray_magic)];
- netxray_dump_t *netxray = wdh->dump.netxray;
+ netxray_dump_t *netxray = (netxray_dump_t *)wdh->priv;
guint32 filelen;
struct netxray_hdr file_hdr;
size_t nwritten;
diff --git a/wiretap/ngsniffer.c b/wiretap/ngsniffer.c
index f2b35d6f73..b9e1613f59 100644
--- a/wiretap/ngsniffer.c
+++ b/wiretap/ngsniffer.c
@@ -701,7 +701,7 @@ int ngsniffer_open(wtap *wth, int *err, gchar **err_info)
/* This is a ngsniffer file */
ngsniffer = (ngsniffer_t *)g_malloc(sizeof(ngsniffer_t));
- wth->capture.generic = ngsniffer;
+ wth->priv = (void *)ngsniffer;
ngsniffer->maj_vers = maj_vers;
ngsniffer->min_vers = pletohs(&version.min_vers);
@@ -1040,7 +1040,7 @@ static gboolean ngsniffer_read(wtap *wth, int *err, gchar **err_info,
guint64 t, tsecs, tpsecs;
guchar *pd;
- ngsniffer = (ngsniffer_t *)wth->capture.generic;
+ ngsniffer = (ngsniffer_t *)wth->priv;
for (;;) {
/*
* Read the record header.
@@ -1950,7 +1950,7 @@ static void ngsniffer_sequential_close(wtap *wth)
{
ngsniffer_t *ngsniffer;
- ngsniffer = (ngsniffer_t *)wth->capture.generic;
+ ngsniffer = (ngsniffer_t *)wth->priv;
if (ngsniffer->seq.buf != NULL) {
g_free(ngsniffer->seq.buf);
ngsniffer->seq.buf = NULL;
@@ -1970,14 +1970,13 @@ static void ngsniffer_close(wtap *wth)
{
ngsniffer_t *ngsniffer;
- ngsniffer = (ngsniffer_t *)wth->capture.generic;
+ ngsniffer = (ngsniffer_t *)wth->priv;
if (ngsniffer->rand.buf != NULL)
g_free(ngsniffer->rand.buf);
if (ngsniffer->first_blob != NULL) {
g_list_foreach(ngsniffer->first_blob, free_blob, NULL);
g_list_free(ngsniffer->first_blob);
}
- g_free(ngsniffer);
}
typedef struct {
@@ -2034,7 +2033,7 @@ gboolean ngsniffer_dump_open(wtap_dumper *wdh, gboolean cant_seek _U_, int *err)
wdh->subtype_close = ngsniffer_dump_close;
ngsniffer = (ngsniffer_dump_t *)g_malloc(sizeof(ngsniffer_dump_t));
- wdh->dump.opaque = ngsniffer;
+ wdh->priv = (void *)ngsniffer;
ngsniffer->first_frame = TRUE;
ngsniffer->start = 0;
@@ -2064,7 +2063,7 @@ gboolean ngsniffer_dump_open(wtap_dumper *wdh, gboolean cant_seek _U_, int *err)
static gboolean ngsniffer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err)
{
- ngsniffer_dump_t *ngsniffer = (ngsniffer_dump_t *)wdh->dump.opaque;
+ ngsniffer_dump_t *ngsniffer = (ngsniffer_dump_t *)wdh->priv;
struct frame2_rec rec_hdr;
size_t nwritten;
char buf[6];
@@ -2454,7 +2453,7 @@ ng_file_read(void *buffer, size_t elementsize, size_t numelements, wtap *wth,
size_t bytes_to_copy;
size_t bytes_left;
- ngsniffer = (ngsniffer_t *)wth->capture.generic;
+ ngsniffer = (ngsniffer_t *)wth->priv;
if (is_random) {
infile = wth->random_fh;
comp_stream = &ngsniffer->rand;
@@ -2615,7 +2614,7 @@ ng_file_seek_seq(wtap *wth, gint64 offset, int whence, int *err)
if (wth->file_type == WTAP_FILE_NGSNIFFER_UNCOMPRESSED)
return file_seek(wth->fh, offset, whence, err);
- ngsniffer = (ngsniffer_t *)wth->capture.generic;
+ ngsniffer = (ngsniffer_t *)wth->priv;
switch (whence) {
case SEEK_SET:
@@ -2664,7 +2663,7 @@ ng_file_seek_rand(wtap *wth, gint64 offset, int whence, int *err)
if (wth->file_type == WTAP_FILE_NGSNIFFER_UNCOMPRESSED)
return file_seek(wth->random_fh, offset, whence, err);
- ngsniffer = (ngsniffer_t *)wth->capture.generic;
+ ngsniffer = (ngsniffer_t *)wth->priv;
switch (whence) {
diff --git a/wiretap/pcapng.c b/wiretap/pcapng.c
index 905d96a73d..3529abd6d7 100644
--- a/wiretap/pcapng.c
+++ b/wiretap/pcapng.c
@@ -274,6 +274,15 @@ typedef struct interface_data_s {
} interface_data_t;
+typedef struct {
+ gboolean byte_swapped;
+ guint16 version_major;
+ guint16 version_minor;
+ gint8 if_fcslen;
+ GArray *interface_data;
+ guint number_of_interfaces;
+} pcapng_t;
+
static int
pcapng_get_encap(gint id, pcapng_t *pn)
{
@@ -1231,7 +1240,7 @@ pcapng_open(wtap *wth, int *err, gchar **err_info)
int bytes_read;
pcapng_t pn;
wtapng_block_t wblock;
-
+ pcapng_t *pcapng;
/* we don't know the byte swapping of the file yet */
pn.byte_swapped = FALSE;
@@ -1273,8 +1282,9 @@ pcapng_open(wtap *wth, int *err, gchar **err_info)
wth->file_encap = WTAP_ENCAP_UNKNOWN;
wth->snapshot_length = 0;
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
- wth->capture.pcapng = (pcapng_t *)g_malloc(sizeof(pcapng_t));
- *wth->capture.pcapng = pn;
+ pcapng = (pcapng_t *)g_malloc(sizeof(pcapng_t));
+ wth->priv = (void *)pcapng;
+ *pcapng = pn;
wth->subtype_read = pcapng_read;
wth->subtype_seek_read = pcapng_seek_read;
wth->subtype_close = pcapng_close;
@@ -1288,11 +1298,11 @@ pcapng_open(wtap *wth, int *err, gchar **err_info)
static gboolean
pcapng_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
{
+ pcapng_t *pcapng = (pcapng_t *)wth->priv;
int bytes_read;
guint64 ts;
wtapng_block_t wblock;
-
pcapng_debug1("pcapng_read: wth->data_offset is initially %" G_GINT64_MODIFIER "u", wth->data_offset);
*data_offset = wth->data_offset;
pcapng_debug1("pcapng_read: *data_offset is initially set to %" G_GINT64_MODIFIER "u", *data_offset);
@@ -1313,7 +1323,7 @@ pcapng_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
/* read next block */
while (1) {
- bytes_read = pcapng_read_block(wth->fh, wth->capture.pcapng, &wblock, err, err_info);
+ bytes_read = pcapng_read_block(wth->fh, pcapng, &wblock, err, err_info);
if (bytes_read <= 0) {
pcapng_debug0("pcapng_read: couldn't read packet block");
return FALSE;
@@ -1335,13 +1345,13 @@ pcapng_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
wth->phdr.caplen = wblock.data.packet.cap_len - wblock.data.packet.pseudo_header_len;
wth->phdr.len = wblock.data.packet.packet_len - wblock.data.packet.pseudo_header_len;
- if (wblock.data.packet.interface_id < wth->capture.pcapng->number_of_interfaces) {
+ if (wblock.data.packet.interface_id < pcapng->number_of_interfaces) {
interface_data_t int_data;
guint64 time_units_per_second;
gint id;
id = (gint)wblock.data.packet.interface_id;
- int_data = g_array_index(wth->capture.pcapng->interface_data, interface_data_t, id);
+ int_data = g_array_index(pcapng->interface_data, interface_data_t, id);
time_units_per_second = int_data.time_units_per_second;
wth->phdr.pkt_encap = int_data.wtap_encap;
wth->phdr.ts.secs = (time_t)(ts / time_units_per_second);
@@ -1368,6 +1378,7 @@ pcapng_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length _U_,
int *err, gchar **err_info)
{
+ pcapng_t *pcapng = (pcapng_t *)wth->priv;
guint64 bytes_read64;
int bytes_read;
wtapng_block_t wblock;
@@ -1386,7 +1397,7 @@ pcapng_seek_read(wtap *wth, gint64 seek_off,
wblock.file_encap = &wth->file_encap;
/* read the block */
- bytes_read = pcapng_read_block(wth->random_fh, wth->capture.pcapng, &wblock, err, err_info);
+ bytes_read = pcapng_read_block(wth->random_fh, pcapng, &wblock, err, err_info);
if (bytes_read <= 0) {
*err = file_error(wth->random_fh);
pcapng_debug3("pcapng_seek_read: couldn't read packet block (err=%d, errno=%d, bytes_read=%d).",
@@ -1408,15 +1419,21 @@ pcapng_seek_read(wtap *wth, gint64 seek_off,
static void
pcapng_close(wtap *wth)
{
+ pcapng_t *pcapng = (pcapng_t *)wth->priv;
+
pcapng_debug0("pcapng_close: closing file");
- if (wth->capture.pcapng->interface_data != NULL) {
- g_array_free(wth->capture.pcapng->interface_data, TRUE);
+ if (pcapng->interface_data != NULL) {
+ g_array_free(pcapng->interface_data, TRUE);
}
- g_free(wth->capture.pcapng);
}
+typedef struct {
+ GArray *interface_data;
+ guint number_of_interfaces;
+} pcapng_dump_t;
+
static gboolean
pcapng_write_section_header_block(wtap_dumper *wdh, wtapng_block_t *wblock, int *err)
{
@@ -1658,9 +1675,10 @@ pcapng_lookup_interface_id_by_encap(int wtap_encap, wtap_dumper *wdh)
{
gint i;
interface_data_t int_data;
-
- for(i = 0; i < (gint)wdh->dump.pcapng->number_of_interfaces; i++) {
- int_data = g_array_index(wdh->dump.pcapng->interface_data, interface_data_t, i);
+ pcapng_dump_t *pcapng = (pcapng_dump_t *)wdh->priv;
+
+ for(i = 0; i < (gint)pcapng->number_of_interfaces; i++) {
+ int_data = g_array_index(pcapng->interface_data, interface_data_t, i);
if (wtap_encap == int_data.wtap_encap) {
return (guint32)i;
}
@@ -1678,6 +1696,7 @@ static gboolean pcapng_dump(wtap_dumper *wdh,
interface_data_t int_data;
guint32 interface_id;
guint64 ts;
+ pcapng_dump_t *pcapng = (pcapng_dump_t *)wdh->priv;
pcapng_debug2("pcapng_dump: encap = %d (%s)",
phdr->pkt_encap,
@@ -1704,11 +1723,11 @@ static gboolean pcapng_dump(wtap_dumper *wdh,
return FALSE;
}
- interface_id = wdh->dump.pcapng->number_of_interfaces;
+ interface_id = pcapng->number_of_interfaces;
int_data.wtap_encap = phdr->pkt_encap;
int_data.time_units_per_second = 0;
- g_array_append_val(wdh->dump.pcapng->interface_data, int_data);
- wdh->dump.pcapng->number_of_interfaces++;
+ g_array_append_val(pcapng->interface_data, int_data);
+ pcapng->number_of_interfaces++;
pcapng_debug3("pcapng_dump: added interface description block with index %u for encap = %d (%s).",
interface_id,
@@ -1752,9 +1771,11 @@ static gboolean pcapng_dump(wtap_dumper *wdh,
Returns TRUE on success, FALSE on failure. */
static gboolean pcapng_dump_close(wtap_dumper *wdh, int *err _U_)
{
+ pcapng_dump_t *pcapng = (pcapng_dump_t *)wdh->priv;
+
pcapng_debug0("pcapng_dump_close");
- g_array_free(wdh->dump.pcapng->interface_data, TRUE);
- wdh->dump.pcapng->number_of_interfaces = 0;
+ g_array_free(pcapng->interface_data, TRUE);
+ pcapng->number_of_interfaces = 0;
return TRUE;
}
@@ -1765,6 +1786,7 @@ gboolean
pcapng_dump_open(wtap_dumper *wdh, gboolean cant_seek _U_, int *err)
{
wtapng_block_t wblock;
+ pcapng_dump_t *pcapng;
wblock.frame_buffer = NULL;
wblock.pseudo_header = NULL;
@@ -1775,9 +1797,10 @@ pcapng_dump_open(wtap_dumper *wdh, gboolean cant_seek _U_, int *err)
/* This is a pcapng file */
wdh->subtype_write = pcapng_dump;
wdh->subtype_close = pcapng_dump_close;
- wdh->dump.pcapng = (pcapng_dump_t *)g_malloc(sizeof(pcapng_dump_t));
- wdh->dump.pcapng->interface_data = g_array_new(FALSE, FALSE, sizeof(interface_data_t));
- wdh->dump.pcapng->number_of_interfaces = 0;
+ pcapng = (pcapng_dump_t *)g_malloc(sizeof(pcapng_dump_t));
+ wdh->priv = (void *)pcapng;
+ pcapng->interface_data = g_array_new(FALSE, FALSE, sizeof(interface_data_t));
+ pcapng->number_of_interfaces = 0;
/* write the section header block */
wblock.type = BLOCK_TYPE_SHB;
diff --git a/wiretap/pppdump.c b/wiretap/pppdump.c
index e889065b0b..a0d51ebc1e 100644
--- a/wiretap/pppdump.c
+++ b/wiretap/pppdump.c
@@ -281,7 +281,8 @@ pppdump_open(wtap *wth, int *err, gchar **err_info _U_)
if (file_seek(wth->fh, 5, SEEK_SET, err) == -1)
return -1;
- state = wth->capture.generic = g_malloc(sizeof(pppdump_t));
+ state = (pppdump_t *)g_malloc(sizeof(pppdump_t));
+ wth->priv = (void *)state;
state->timestamp = pntohl(&buffer[1]);
state->tenths = 0;
@@ -324,7 +325,7 @@ pppdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
buffer_assure_space(wth->frame_buffer, PPPD_BUF_SIZE);
buf = buffer_start_ptr(wth->frame_buffer);
- state = wth->capture.generic;
+ state = wth->priv;
/* If we have a random stream open, allocate a structure to hold
the information needed to read this packet's data again. */
@@ -718,7 +719,7 @@ pppdump_seek_read(wtap *wth,
pkt_id *pid;
gint64 num_bytes_to_skip;
- state = wth->capture.generic;
+ state = wth->priv;
pid = g_ptr_array_index(state->pids, seek_off);
if (!pid) {
@@ -769,7 +770,7 @@ pppdump_close(wtap *wth)
{
pppdump_t *state;
- state = wth->capture.generic;
+ state = (pppdump_t *)wth->priv;
if (state->seek_state) { /* should always be TRUE */
g_free(state->seek_state);
@@ -782,7 +783,4 @@ pppdump_close(wtap *wth)
}
g_ptr_array_free(state->pids, TRUE);
}
-
- g_free(state);
-
}
diff --git a/wiretap/visual.c b/wiretap/visual.c
index 7227a335ee..4d9452b617 100644
--- a/wiretap/visual.c
+++ b/wiretap/visual.c
@@ -164,7 +164,6 @@ struct visual_write_info
/* Local functions to handle file reads and writes */
static gboolean visual_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
-static void visual_close(wtap *wth);
static gboolean visual_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size,
int *err, gchar **err_info);
@@ -274,12 +273,11 @@ int visual_open(wtap *wth, int *err, gchar **err_info)
/* Set up the pointers to the handlers for this file type */
wth->subtype_read = visual_read;
wth->subtype_seek_read = visual_seek_read;
- wth->subtype_close = visual_close;
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
/* Add Visual-specific information to the wiretap struct for later use. */
- visual = g_malloc(sizeof(struct visual_read_info));
- wth->capture.generic = visual;
+ visual = (struct visual_read_info *)g_malloc(sizeof(struct visual_read_info));
+ wth->priv = (void *)visual;
visual->num_pkts = pletohl(&vfile_hdr.num_pkts);
visual->start_time = ((double) pletohl(&vfile_hdr.start_time)) * 1000000;
visual->current_pkt = 1;
@@ -295,7 +293,7 @@ int visual_open(wtap *wth, int *err, gchar **err_info)
static gboolean visual_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
- struct visual_read_info *visual = wth->capture.generic;
+ struct visual_read_info *visual = (struct visual_read_info *)wth->priv;
guint32 packet_size = 0;
int bytes_read;
struct visual_pkt_hdr vpkt_hdr;
@@ -475,17 +473,6 @@ static gboolean visual_read(wtap *wth, int *err, gchar **err_info,
return TRUE;
}
-
-/* Close a file opened for reading. */
-static void visual_close(wtap *wth)
-{
- /* Free the info allocated by a Visual file reader. */
- if (wth->capture.generic)
- g_free(wth->capture.generic);
- wth->capture.generic = 0;
-}
-
-
/* Read packet data for random access.
This gets the packet data and rebuilds the pseudo header so that
the direction flag works. */
@@ -691,8 +678,8 @@ gboolean visual_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err)
/* Create a struct to hold file information for the duration
of the write */
- visual = g_malloc(sizeof(struct visual_write_info));
- wdh->dump.opaque = visual;
+ visual = (struct visual_write_info *)g_malloc(sizeof(struct visual_write_info));
+ wdh->priv = (void *)visual;
visual->index_table_index = 0;
visual->index_table_size = 1024;
visual->index_table = 0;
@@ -715,7 +702,7 @@ gboolean visual_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err)
static gboolean visual_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err)
{
- struct visual_write_info * visual = wdh->dump.opaque;
+ struct visual_write_info * visual = wdh->priv;
struct visual_pkt_hdr vpkt_hdr;
size_t hdr_size = sizeof vpkt_hdr;
size_t nwritten;
@@ -841,7 +828,7 @@ static gboolean visual_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
Returns TRUE on success, FALSE on failure. */
static gboolean visual_dump_close(wtap_dumper *wdh, int *err)
{
- struct visual_write_info * visual = wdh->dump.opaque;
+ struct visual_write_info * visual = wdh->priv;
size_t n_to_write;
size_t nwritten;
struct visual_file_hdr vfile_hdr;
@@ -950,16 +937,12 @@ static gboolean visual_dump_close(wtap_dumper *wdh, int *err)
/* Free the memory allocated by a visual file writer. */
static void visual_dump_free(wtap_dumper *wdh)
{
- struct visual_write_info * visual = wdh->dump.opaque;
+ struct visual_write_info * visual = wdh->priv;
if (visual)
{
/* Free the index table memory. */
if (visual->index_table)
g_free(visual->index_table);
-
- /* Free the write file info struct. */
- g_free(visual);
- wdh->dump.opaque = 0;
}
}
diff --git a/wiretap/wtap-int.h b/wiretap/wtap-int.h
index 317fec49e0..c85c26af15 100644
--- a/wiretap/wtap-int.h
+++ b/wiretap/wtap-int.h
@@ -44,83 +44,6 @@
#include "wtap.h"
-typedef struct {
- gboolean byte_swapped;
-} i4btrace_t;
-
-typedef struct {
- gboolean is_hpux_11;
-} nettl_t;
-
-typedef struct {
- gboolean byte_swapped;
- guint16 version_major;
- guint16 version_minor;
- gint8 if_fcslen;
- GArray *interface_data;
- guint number_of_interfaces;
-} pcapng_t;
-
-typedef struct {
- time_t start_secs;
- guint32 start_usecs;
- guint8 version_major;
- guint32 *frame_table;
- guint32 frame_table_size;
- guint current_frame;
-} netmon_t;
-
-typedef struct {
- time_t start_time;
- double ticks_per_sec;
- double start_timestamp;
- gboolean wrapped;
- guint32 nframes;
- gint64 start_offset;
- gint64 end_offset;
- int version_major;
- gboolean fcs_valid; /* if packets have valid FCS at the end */
- guint isdn_type; /* 1 = E1 PRI, 2 = T1 PRI, 3 = BRI */
-} netxray_t;
-
-typedef struct {
- time_t inittime;
- int adjusted;
- gint64 next_packet_seek_start;
-} ascend_t;
-
-typedef struct {
- gboolean byteswapped;
-} csids_t;
-
-typedef struct {
- struct timeval reference_time;
-} etherpeek_t;
-
-typedef struct {
- gboolean has_fcs;
-} airopeek9_t;
-
-typedef struct _k12_t k12_t;
-
-typedef struct {
- struct wtap_nstime now;
- time_t t0;
-} mpeg_t;
-
-typedef struct {
- gchar *pnstrace_buf;
- gint32 nstrace_buf_offset;
- gint32 nstrace_buflen;
- /* Performance Monitor Time variables */
- guint32 nspm_curtime; /* current time since 1970 */
- guint64 nspm_curtimemsec; /* current time in mili second */
- guint64 nspm_curtimelastmsec; /* nspm_curtime last update time in milisec */
- guint64 nsg_creltime;
- guint64 file_size;
-} nstrace_t;
-
-
typedef gboolean (*subtype_read_func)(struct wtap*, int*, char**, gint64*);
typedef gboolean (*subtype_seek_read_func)(struct wtap*, gint64, union wtap_pseudo_header*,
guint8*, int, int *, char **);
@@ -136,21 +59,7 @@ struct wtap {
gint64 data_offset;
- union {
- i4btrace_t *i4btrace;
- nettl_t *nettl;
- netmon_t *netmon;
- netxray_t *netxray;
- ascend_t *ascend;
- csids_t *csids;
- etherpeek_t *etherpeek;
- airopeek9_t *airopeek9;
- k12_t *k12;
- mpeg_t *mpeg;
- nstrace_t *nstrace;
- void *generic;
- pcapng_t *pcapng;
- } capture;
+ void *priv;
subtype_read_func subtype_read;
subtype_seek_read_func subtype_seek_read;
@@ -171,52 +80,6 @@ typedef gboolean (*subtype_write_func)(struct wtap_dumper*,
const guchar*, int*);
typedef gboolean (*subtype_close_func)(struct wtap_dumper*, int*);
-typedef struct {
- gboolean first_frame;
- struct wtap_nstime start;
- guint32 nframes;
-} netxray_dump_t;
-
-typedef struct {
- gboolean got_first_record_time;
- struct wtap_nstime first_record_time;
- guint32 frame_table_offset;
- guint32 *frame_table;
- guint frame_table_index;
- guint frame_table_size;
-} netmon_dump_t;
-
-typedef struct {
- guint16 page_offset;
- guint16 page_len;
- guint32 absrec_time;
-} nstrace_dump_t;
-
-typedef struct {
- guint32 nframes;
-} _5views_dump_t;
-
-typedef struct {
- guint64 packet_count;
- guint8 network_type;
-} niobserver_dump_t;
-
-typedef struct {
- guint32 file_len;
- guint32 num_of_records;
- guint32 file_offset;
-} k12_dump_t;
-
-typedef struct {
- gboolean first_packet_written;
- struct wtap_nstime start_time;
-} dct2000_dump_t;
-
-typedef struct {
- GArray *interface_data;
- guint number_of_interfaces;
-} pcapng_dump_t;
-
struct wtap_dumper {
FILE* fh;
int file_type;
@@ -225,17 +88,7 @@ struct wtap_dumper {
gboolean compressed;
gint64 bytes_dumped;
- union {
- void *opaque;
- netmon_dump_t *netmon;
- netxray_dump_t *netxray;
- _5views_dump_t *_5views;
- niobserver_dump_t *niobserver;
- k12_dump_t *k12;
- dct2000_dump_t *dct2000;
- nstrace_dump_t *nstr;
- pcapng_dump_t *pcapng;
- } dump;
+ void *priv;
subtype_write_func subtype_write;
subtype_close_func subtype_close;
diff --git a/wiretap/wtap.c b/wiretap/wtap.c
index 808343ccd2..55f7dee547 100644
--- a/wiretap/wtap.c
+++ b/wiretap/wtap.c
@@ -627,6 +627,9 @@ wtap_close(wtap *wth)
if (wth->random_fh != NULL)
file_close(wth->random_fh);
+ if (wth->priv != NULL)
+ g_free(wth->priv);
+
g_free(wth);
}