aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/ngsniffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'wiretap/ngsniffer.c')
-rw-r--r--wiretap/ngsniffer.c249
1 files changed, 123 insertions, 126 deletions
diff --git a/wiretap/ngsniffer.c b/wiretap/ngsniffer.c
index f8d04367be..8138a31f44 100644
--- a/wiretap/ngsniffer.c
+++ b/wiretap/ngsniffer.c
@@ -56,7 +56,6 @@
#include <errno.h>
#include <string.h>
-#include "wftap-int.h"
#include "wtap-int.h"
#include "file_wrappers.h"
#include "buffer.h"
@@ -504,46 +503,46 @@ typedef struct {
#define DOS_DAY_SHIFT 0
#define DOS_DAY_MASK (0x1F<<DOS_DAY_SHIFT)
-static int process_header_records(wftap *wfth, int *err, gchar **err_info,
+static int process_header_records(wtap *wth, int *err, gchar **err_info,
gint16 maj_vers, guint8 network);
-static int process_rec_header2_v2(wftap *wfth, unsigned char *buffer,
+static int process_rec_header2_v2(wtap *wth, unsigned char *buffer,
guint16 length, int *err, gchar **err_info);
-static int process_rec_header2_v145(wftap *wfth, unsigned char *buffer,
+static int process_rec_header2_v145(wtap *wth, unsigned char *buffer,
guint16 length, gint16 maj_vers, int *err, gchar **err_info);
-static gboolean ngsniffer_read(wftap *wfth, int *err, gchar **err_info,
+static gboolean ngsniffer_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
-static gboolean ngsniffer_seek_read(wftap *wtfh, gint64 seek_off,
- void* header, Buffer *buf, int *err, gchar **err_info);
-static int ngsniffer_process_record(wftap *wfth, gboolean is_random,
+static gboolean ngsniffer_seek_read(wtap *wth, gint64 seek_off,
+ struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
+static int ngsniffer_process_record(wtap *wth, gboolean is_random,
guint *padding, struct wtap_pkthdr *phdr, Buffer *buf, int *err,
gchar **err_info);
-static void set_pseudo_header_frame2(wftap *wfth,
+static void set_pseudo_header_frame2(wtap *wth,
union wtap_pseudo_header *pseudo_header, struct frame2_rec *frame2);
static void set_pseudo_header_frame4(union wtap_pseudo_header *pseudo_header,
struct frame4_rec *frame4);
-static void set_pseudo_header_frame6(wftap *wfth,
+static void set_pseudo_header_frame6(wtap *wth,
union wtap_pseudo_header *pseudo_header, struct frame6_rec *frame6);
static int infer_pkt_encap(const guint8 *pd, int len);
static int fix_pseudo_header(int encap, Buffer *buf, int len,
union wtap_pseudo_header *pseudo_header);
-static void ngsniffer_sequential_close(wftap *wfth);
-static void ngsniffer_close(wftap *wfth);
-static gboolean ngsniffer_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
+static void ngsniffer_sequential_close(wtap *wth);
+static void ngsniffer_close(wtap *wth);
+static gboolean ngsniffer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const guint8 *pd, int *err);
-static gboolean ngsniffer_dump_close(wftap_dumper *wdh, int *err);
+static gboolean ngsniffer_dump_close(wtap_dumper *wdh, int *err);
static int SnifferDecompress( unsigned char * inbuf, size_t inlen,
unsigned char * outbuf, size_t outlen, int *err );
-static gint64 ng_file_read(void *buffer, unsigned int nbytes, wftap *wfth,
+static gint64 ng_file_read(void *buffer, unsigned int nbytes, wtap *wth,
gboolean is_random, int *err, gchar **err_info);
static int read_blob(FILE_T infile, ngsniffer_comp_stream_t *comp_stream,
int *err, gchar **err_info);
-static gboolean ng_file_skip_seq(wftap *wfth, gint64 delta, int *err,
+static gboolean ng_file_skip_seq(wtap *wth, gint64 delta, int *err,
gchar **err_info);
-static gboolean ng_file_seek_rand(wftap *wfth, gint64 offset, int *err,
+static gboolean ng_file_seek_rand(wtap *wth, gint64 offset, int *err,
gchar **err_info);
int
-ngsniffer_open(wftap *wfth, int *err, gchar **err_info)
+ngsniffer_open(wtap *wth, int *err, gchar **err_info)
{
int bytes_read;
char magic[sizeof ngsniffer_magic];
@@ -577,9 +576,9 @@ ngsniffer_open(wftap *wfth, int *err, gchar **err_info)
/* Read in the string that should be at the start of a Sniffer file */
errno = WTAP_ERR_CANT_READ;
- bytes_read = file_read(magic, sizeof magic, wfth->fh);
+ bytes_read = file_read(magic, sizeof magic, wth->fh);
if (bytes_read != sizeof magic) {
- *err = file_error(wfth->fh, err_info);
+ *err = file_error(wth->fh, err_info);
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
return -1;
return 0;
@@ -594,16 +593,16 @@ ngsniffer_open(wftap *wfth, int *err, gchar **err_info)
* record.
*/
errno = WTAP_ERR_CANT_READ;
- bytes_read = file_read(record_type, 2, wfth->fh);
+ bytes_read = file_read(record_type, 2, wth->fh);
if (bytes_read != 2) {
- *err = file_error(wfth->fh, err_info);
+ *err = file_error(wth->fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return -1;
}
- bytes_read = file_read(record_length, 4, wfth->fh);
+ bytes_read = file_read(record_length, 4, wth->fh);
if (bytes_read != 4) {
- *err = file_error(wfth->fh, err_info);
+ *err = file_error(wth->fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return -1;
@@ -618,9 +617,9 @@ ngsniffer_open(wftap *wfth, int *err, gchar **err_info)
}
errno = WTAP_ERR_CANT_READ;
- bytes_read = file_read(&version, sizeof version, wfth->fh);
+ bytes_read = file_read(&version, sizeof version, wth->fh);
if (bytes_read != sizeof version) {
- *err = file_error(wfth->fh, err_info);
+ *err = file_error(wth->fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return -1;
@@ -644,15 +643,15 @@ ngsniffer_open(wftap *wfth, int *err, gchar **err_info)
/* compressed or uncompressed Sniffer file? */
if (version.format != 1) {
- wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_NGSNIFFER_COMPRESSED;
+ wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_NGSNIFFER_COMPRESSED;
} else {
- wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_NGSNIFFER_UNCOMPRESSED;
+ wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_NGSNIFFER_UNCOMPRESSED;
}
/* Set encap type before reading header records because the
* header record may change encap type.
*/
- wfth->file_encap = sniffer_encap[version.network];
+ wth->file_encap = sniffer_encap[version.network];
/*
* We don't know how to handle the remaining header record types,
@@ -668,12 +667,12 @@ ngsniffer_open(wftap *wfth, int *err, gchar **err_info)
* the DOS Sniffer understands?
*/
maj_vers = pletoh16(&version.maj_vers);
- if (process_header_records(wfth, err, err_info, maj_vers,
+ if (process_header_records(wth, err, err_info, maj_vers,
version.network) < 0)
return -1;
if ((version.network == NETWORK_SYNCHRO ||
version.network == NETWORK_ASYNC) &&
- wfth->file_encap == WTAP_ENCAP_PER_PACKET) {
+ wth->file_encap == WTAP_ENCAP_PER_PACKET) {
/*
* Well, we haven't determined the internetwork analyzer
* subtype yet...
@@ -689,7 +688,7 @@ ngsniffer_open(wftap *wfth, int *err, gchar **err_info)
case 1:
case 2:
- wfth->file_encap = WTAP_ENCAP_ISDN;
+ wth->file_encap = WTAP_ENCAP_ISDN;
break;
}
break;
@@ -702,12 +701,12 @@ ngsniffer_open(wftap *wfth, int *err, gchar **err_info)
* one we've seen is a Frame Relay capture,
* so mark it as Frame Relay for now.
*/
- wfth->file_encap = WTAP_ENCAP_FRELAY_WITH_PHDR;
+ wth->file_encap = WTAP_ENCAP_FRELAY_WITH_PHDR;
break;
}
}
- current_offset = file_tell(wfth->fh);
+ current_offset = file_tell(wth->fh);
/*
* Now, if we have a random stream open, position it to the same
@@ -718,14 +717,14 @@ ngsniffer_open(wftap *wfth, int *err, gchar **err_info)
* or REC_EOF after this? If not, we can get rid of the loop in
* "ngsniffer_read()".
*/
- if (wfth->random_fh != NULL) {
- if (file_seek(wfth->random_fh, current_offset, SEEK_SET, err) == -1)
+ if (wth->random_fh != NULL) {
+ if (file_seek(wth->random_fh, current_offset, SEEK_SET, err) == -1)
return -1;
}
/* This is a ngsniffer file */
ngsniffer = (ngsniffer_t *)g_malloc(sizeof(ngsniffer_t));
- wfth->priv = (void *)ngsniffer;
+ wth->priv = (void *)ngsniffer;
ngsniffer->maj_vers = maj_vers;
ngsniffer->min_vers = pletoh16(&version.min_vers);
@@ -749,11 +748,11 @@ ngsniffer_open(wftap *wfth, int *err, gchar **err_info)
ngsniffer->last_blob = NULL;
ngsniffer->current_blob = NULL;
- wfth->subtype_read = ngsniffer_read;
- wfth->subtype_seek_read = ngsniffer_seek_read;
- wfth->subtype_sequential_close = ngsniffer_sequential_close;
- wfth->subtype_close = ngsniffer_close;
- wfth->snapshot_length = 0; /* not available in header, only in frame */
+ wth->subtype_read = ngsniffer_read;
+ wth->subtype_seek_read = ngsniffer_seek_read;
+ wth->subtype_sequential_close = ngsniffer_sequential_close;
+ wth->subtype_close = ngsniffer_close;
+ wth->snapshot_length = 0; /* not available in header, only in frame */
ngsniffer->timeunit = Psec[version.timeunit];
ngsniffer->network = version.network;
@@ -790,13 +789,13 @@ ngsniffer_open(wftap *wfth, int *err, gchar **err_info)
* isn't stored in the capture file.
*/
- wfth->tsprecision = WTAP_FILE_TSPREC_NSEC; /* XXX */
+ wth->tsprecision = WTAP_FILE_TSPREC_NSEC; /* XXX */
return 1;
}
static int
-process_header_records(wftap *wfth, int *err, gchar **err_info, gint16 maj_vers,
+process_header_records(wtap *wth, int *err, gchar **err_info, gint16 maj_vers,
guint8 network)
{
int bytes_read;
@@ -809,9 +808,9 @@ process_header_records(wftap *wfth, int *err, gchar **err_info, gint16 maj_vers,
for (;;) {
errno = WTAP_ERR_CANT_READ;
- bytes_read = file_read(record_type, 2, wfth->fh);
+ bytes_read = file_read(record_type, 2, wth->fh);
if (bytes_read != 2) {
- *err = file_error(wfth->fh, err_info);
+ *err = file_error(wth->fh, err_info);
if (*err != 0)
return -1;
if (bytes_read != 0) {
@@ -834,15 +833,15 @@ process_header_records(wftap *wfth, int *err, gchar **err_info, gint16 maj_vers,
* which implies data. Seek backwards over the
* two bytes we read, and return.
*/
- if (file_seek(wfth->fh, -2, SEEK_CUR, err) == -1)
+ if (file_seek(wth->fh, -2, SEEK_CUR, err) == -1)
return -1;
return 0;
}
errno = WTAP_ERR_CANT_READ;
- bytes_read = file_read(record_length, 4, wfth->fh);
+ bytes_read = file_read(record_length, 4, wth->fh);
if (bytes_read != 4) {
- *err = file_error(wfth->fh, err_info);
+ *err = file_error(wth->fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return -1;
@@ -868,9 +867,9 @@ process_header_records(wftap *wfth, int *err, gchar **err_info, gint16 maj_vers,
*/
bytes_to_read = MIN(length, (int)sizeof buffer);
bytes_read = file_read(buffer, bytes_to_read,
- wfth->fh);
+ wth->fh);
if (bytes_read != bytes_to_read) {
- *err = file_error(wfth->fh, err_info);
+ *err = file_error(wth->fh, err_info);
if (*err == 0) {
*err = WTAP_ERR_SHORT_READ;
return -1;
@@ -880,7 +879,7 @@ process_header_records(wftap *wfth, int *err, gchar **err_info, gint16 maj_vers,
switch (maj_vers) {
case 2:
- if (process_rec_header2_v2(wfth, buffer,
+ if (process_rec_header2_v2(wth, buffer,
length, err, err_info) < 0)
return -1;
break;
@@ -888,7 +887,7 @@ process_header_records(wftap *wfth, int *err, gchar **err_info, gint16 maj_vers,
case 1:
case 4:
case 5:
- if (process_rec_header2_v145(wfth, buffer,
+ if (process_rec_header2_v145(wth, buffer,
length, maj_vers, err, err_info) < 0)
return -1;
break;
@@ -898,20 +897,20 @@ process_header_records(wftap *wfth, int *err, gchar **err_info, gint16 maj_vers,
* Skip the rest of the record.
*/
if (length > sizeof buffer) {
- if (file_seek(wfth->fh, length - sizeof buffer,
+ if (file_seek(wth->fh, length - sizeof buffer,
SEEK_CUR, err) == -1)
return -1;
}
} else {
/* Nope, just skip over the data. */
- if (file_seek(wfth->fh, length, SEEK_CUR, err) == -1)
+ if (file_seek(wth->fh, length, SEEK_CUR, err) == -1)
return -1;
}
}
}
static int
-process_rec_header2_v2(wftap *wfth, unsigned char *buffer, guint16 length,
+process_rec_header2_v2(wtap *wth, unsigned char *buffer, guint16 length,
int *err, gchar **err_info)
{
static const char x_25_str[] = "HDLC\nX.25\n";
@@ -936,7 +935,7 @@ process_rec_header2_v2(wftap *wfth, unsigned char *buffer, guint16 length,
/*
* X.25.
*/
- wfth->file_encap = WTAP_ENCAP_LAPB;
+ wth->file_encap = WTAP_ENCAP_LAPB;
} else {
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
*err_info = g_strdup_printf("ngsniffer: WAN capture protocol string %.*s unknown",
@@ -947,7 +946,7 @@ process_rec_header2_v2(wftap *wfth, unsigned char *buffer, guint16 length,
}
static int
-process_rec_header2_v145(wftap *wfth, unsigned char *buffer, guint16 length,
+process_rec_header2_v145(wtap *wth, unsigned char *buffer, guint16 length,
gint16 maj_vers, int *err, gchar **err_info)
{
/*
@@ -989,15 +988,15 @@ process_rec_header2_v145(wftap *wfth, unsigned char *buffer, guint16 length,
switch (buffer[4]) {
case NET_SDLC:
- wfth->file_encap = WTAP_ENCAP_SDLC;
+ wth->file_encap = WTAP_ENCAP_SDLC;
break;
case NET_HDLC:
- wfth->file_encap = WTAP_ENCAP_PER_PACKET;
+ wth->file_encap = WTAP_ENCAP_PER_PACKET;
break;
case NET_FRAME_RELAY:
- wfth->file_encap = WTAP_ENCAP_FRELAY_WITH_PHDR;
+ wth->file_encap = WTAP_ENCAP_FRELAY_WITH_PHDR;
break;
case NET_ROUTER:
@@ -1014,12 +1013,12 @@ process_rec_header2_v145(wftap *wfth, unsigned char *buffer, guint16 length,
* a 0x01 in buffer[6]; none of the non-ISDN version
* 5 captures have it.
*/
- wfth->file_encap = WTAP_ENCAP_PER_PACKET;
+ wth->file_encap = WTAP_ENCAP_PER_PACKET;
switch (maj_vers) {
case 4:
if (buffer[1] == 0xfa)
- wfth->file_encap = WTAP_ENCAP_ISDN;
+ wth->file_encap = WTAP_ENCAP_ISDN;
break;
case 5:
@@ -1032,13 +1031,13 @@ process_rec_header2_v145(wftap *wfth, unsigned char *buffer, guint16 length,
return -1;
}
if (buffer[6] == 0x01)
- wfth->file_encap = WTAP_ENCAP_ISDN;
+ wth->file_encap = WTAP_ENCAP_ISDN;
break;
}
break;
case NET_PPP:
- wfth->file_encap = WTAP_ENCAP_PPP_WITH_PHDR;
+ wth->file_encap = WTAP_ENCAP_PPP_WITH_PHDR;
break;
default:
@@ -1055,14 +1054,13 @@ process_rec_header2_v145(wftap *wfth, unsigned char *buffer, guint16 length,
/* Read the next packet */
static gboolean
-ngsniffer_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_offset)
+ngsniffer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
{
ngsniffer_t *ngsniffer;
int ret;
guint padding;
- wtap* wth = (wtap*)wfth->tap_specific_data;
- ngsniffer = (ngsniffer_t *)wfth->priv;
+ ngsniffer = (ngsniffer_t *)wth->priv;
for (;;) {
/*
* We use the uncompressed offset, as that's what
@@ -1073,8 +1071,8 @@ ngsniffer_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_offset)
/*
* Process the record.
*/
- ret = ngsniffer_process_record(wfth, FALSE, &padding,
- &wth->phdr, wfth->frame_buffer, err, err_info);
+ ret = ngsniffer_process_record(wth, FALSE, &padding,
+ &wth->phdr, wth->frame_buffer, err, err_info);
if (ret < 0) {
/* Read error or short read */
return FALSE;
@@ -1093,7 +1091,7 @@ ngsniffer_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_offset)
* Skip any extra data in the record.
*/
if (padding != 0) {
- if (!ng_file_skip_seq(wfth, padding, err,
+ if (!ng_file_skip_seq(wth, padding, err,
err_info))
return FALSE;
}
@@ -1114,7 +1112,7 @@ ngsniffer_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_offset)
* and keep looping.
*/
if (padding != 0) {
- if (!ng_file_skip_seq(wfth, padding, err,
+ if (!ng_file_skip_seq(wth, padding, err,
err_info))
return FALSE;
}
@@ -1124,16 +1122,15 @@ ngsniffer_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_offset)
}
static gboolean
-ngsniffer_seek_read(wftap *wfth, gint64 seek_off,
- void* header, Buffer *buf, int *err, gchar **err_info)
+ngsniffer_seek_read(wtap *wth, gint64 seek_off,
+ struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
{
- struct wtap_pkthdr *phdr = (struct wtap_pkthdr*)header;
int ret;
- if (!ng_file_seek_rand(wfth, seek_off, err, err_info))
+ if (!ng_file_seek_rand(wth, seek_off, err, err_info))
return FALSE;
- ret = ngsniffer_process_record(wfth, TRUE, NULL, phdr, buf, err, err_info);
+ ret = ngsniffer_process_record(wth, TRUE, NULL, phdr, buf, err, err_info);
if (ret < 0) {
/* Read error or short read */
return FALSE;
@@ -1167,7 +1164,7 @@ ngsniffer_seek_read(wftap *wfth, gint64 seek_off,
* the end of the record.
*/
static int
-ngsniffer_process_record(wftap *wfth, gboolean is_random, guint *padding,
+ngsniffer_process_record(wtap *wth, gboolean is_random, guint *padding,
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
{
ngsniffer_t *ngsniffer;
@@ -1185,7 +1182,7 @@ ngsniffer_process_record(wftap *wfth, gboolean is_random, guint *padding,
/*
* Read the record header.
*/
- bytes_read = ng_file_read(record_type, 2, wfth, is_random, err,
+ bytes_read = ng_file_read(record_type, 2, wth, is_random, err,
err_info);
if (bytes_read != 2) {
if (*err != 0)
@@ -1196,7 +1193,7 @@ ngsniffer_process_record(wftap *wfth, gboolean is_random, guint *padding,
}
return REC_EOF;
}
- bytes_read = ng_file_read(record_length, 4, wfth, is_random, err,
+ bytes_read = ng_file_read(record_length, 4, wth, is_random, err,
err_info);
if (bytes_read != 4) {
if (*err == 0)
@@ -1207,7 +1204,7 @@ ngsniffer_process_record(wftap *wfth, gboolean is_random, guint *padding,
type = pletoh16(record_type);
length = pletoh16(record_length);
- ngsniffer = (ngsniffer_t *)wfth->priv;
+ ngsniffer = (ngsniffer_t *)wth->priv;
switch (type) {
case REC_FRAME2:
@@ -1223,7 +1220,7 @@ ngsniffer_process_record(wftap *wfth, gboolean is_random, guint *padding,
/* Read the f_frame2_struct */
bytes_read = ng_file_read(&frame2, (unsigned int)sizeof frame2,
- wfth, is_random, err, err_info);
+ wth, is_random, err, err_info);
if (bytes_read != sizeof frame2) {
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
@@ -1238,7 +1235,7 @@ ngsniffer_process_record(wftap *wfth, gboolean is_random, guint *padding,
length -= sizeof frame2; /* we already read that much */
- set_pseudo_header_frame2(wfth, &phdr->pseudo_header, &frame2);
+ set_pseudo_header_frame2(wth, &phdr->pseudo_header, &frame2);
break;
case REC_FRAME4:
@@ -1254,7 +1251,7 @@ ngsniffer_process_record(wftap *wfth, gboolean is_random, guint *padding,
/* Read the f_frame4_struct */
bytes_read = ng_file_read(&frame4, (unsigned int)sizeof frame4,
- wfth, is_random, err, err_info);
+ wth, is_random, err, err_info);
if (bytes_read != sizeof frame4) {
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
@@ -1287,7 +1284,7 @@ ngsniffer_process_record(wftap *wfth, gboolean is_random, guint *padding,
case REC_FRAME6:
/* Read the f_frame6_struct */
bytes_read = ng_file_read(&frame6, (unsigned int)sizeof frame6,
- wfth, is_random, err, err_info);
+ wth, is_random, err, err_info);
if (bytes_read != sizeof frame6) {
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
@@ -1302,7 +1299,7 @@ ngsniffer_process_record(wftap *wfth, gboolean is_random, guint *padding,
length -= sizeof frame6; /* we already read that much */
- set_pseudo_header_frame6(wfth, &phdr->pseudo_header, &frame6);
+ set_pseudo_header_frame6(wth, &phdr->pseudo_header, &frame6);
break;
case REC_EOF:
@@ -1358,7 +1355,7 @@ ngsniffer_process_record(wftap *wfth, gboolean is_random, guint *padding,
* Read the packet data.
*/
buffer_assure_space(buf, size);
- bytes_read = ng_file_read(buffer_start_ptr(buf), size, wfth,
+ bytes_read = ng_file_read(buffer_start_ptr(buf), size, wth,
is_random, err, err_info);
if (bytes_read != (gint64) size) {
if (*err == 0)
@@ -1366,7 +1363,7 @@ ngsniffer_process_record(wftap *wfth, gboolean is_random, guint *padding,
return -1;
}
- phdr->pkt_encap = fix_pseudo_header(wfth->file_encap,
+ phdr->pkt_encap = fix_pseudo_header(wth->file_encap,
buf, length, &phdr->pseudo_header);
/*
@@ -1404,7 +1401,7 @@ ngsniffer_process_record(wftap *wfth, gboolean is_random, guint *padding,
}
static void
-set_pseudo_header_frame2(wftap *wfth, union wtap_pseudo_header *pseudo_header,
+set_pseudo_header_frame2(wtap *wth, union wtap_pseudo_header *pseudo_header,
struct frame2_rec *frame2)
{
/*
@@ -1449,7 +1446,7 @@ set_pseudo_header_frame2(wftap *wfth, union wtap_pseudo_header *pseudo_header,
* correlation with anything. See previous comment
* about display filters.
*/
- switch (wfth->file_encap) {
+ switch (wth->file_encap) {
case WTAP_ENCAP_ETHERNET:
/*
@@ -1751,12 +1748,12 @@ set_pseudo_header_frame4(union wtap_pseudo_header *pseudo_header,
}
static void
-set_pseudo_header_frame6(wftap *wfth, union wtap_pseudo_header *pseudo_header,
+set_pseudo_header_frame6(wtap *wth, union wtap_pseudo_header *pseudo_header,
struct frame6_rec *frame6 _U_)
{
/* XXX - Once the frame format is divined, something will most likely go here */
- switch (wfth->file_encap) {
+ switch (wth->file_encap) {
case WTAP_ENCAP_ETHERNET:
/* XXX - is there an FCS? */
@@ -1952,11 +1949,11 @@ fix_pseudo_header(int encap, Buffer *buf, int len,
/* Throw away the buffers used by the sequential I/O stream, but not
those used by the random I/O stream. */
static void
-ngsniffer_sequential_close(wftap *wfth)
+ngsniffer_sequential_close(wtap *wth)
{
ngsniffer_t *ngsniffer;
- ngsniffer = (ngsniffer_t *)wfth->priv;
+ ngsniffer = (ngsniffer_t *)wth->priv;
if (ngsniffer->seq.buf != NULL) {
g_free(ngsniffer->seq.buf);
ngsniffer->seq.buf = NULL;
@@ -1974,11 +1971,11 @@ free_blob(gpointer data, gpointer user_data _U_)
for a capture file type, it'll be called before the "close" routine
is called, so we don't have to free the sequential buffer here.) */
static void
-ngsniffer_close(wftap *wfth)
+ngsniffer_close(wtap *wth)
{
ngsniffer_t *ngsniffer;
- ngsniffer = (ngsniffer_t *)wfth->priv;
+ ngsniffer = (ngsniffer_t *)wth->priv;
if (ngsniffer->rand.buf != NULL)
g_free(ngsniffer->rand.buf);
if (ngsniffer->first_blob != NULL) {
@@ -2033,7 +2030,7 @@ ngsniffer_dump_can_write_encap(int encap)
/* Returns TRUE on success, FALSE on failure; sets "*err" to an error code on
failure */
gboolean
-ngsniffer_dump_open(wftap_dumper *wdh, int *err)
+ngsniffer_dump_open(wtap_dumper *wdh, int *err)
{
ngsniffer_dump_t *ngsniffer;
char buf[6] = {REC_VERS, 0x00, 0x12, 0x00, 0x00, 0x00}; /* version record */
@@ -2048,10 +2045,10 @@ ngsniffer_dump_open(wftap_dumper *wdh, int *err)
ngsniffer->start = 0;
/* Write the file header. */
- if (!wftap_dump_file_write(wdh, ngsniffer_magic, sizeof ngsniffer_magic,
+ if (!wtap_dump_file_write(wdh, ngsniffer_magic, sizeof ngsniffer_magic,
err))
return FALSE;
- if (!wftap_dump_file_write(wdh, buf, 6, err))
+ if (!wtap_dump_file_write(wdh, buf, 6, err))
return FALSE;
return TRUE;
@@ -2060,7 +2057,7 @@ ngsniffer_dump_open(wftap_dumper *wdh, int *err)
/* Write a record for a packet to a dump file.
Returns TRUE on success, FALSE on failure. */
static gboolean
-ngsniffer_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
+ngsniffer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const guint8 *pd, int *err)
{
const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header;
@@ -2116,7 +2113,7 @@ ngsniffer_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
version.cmprs_level = 0;
version.rsvd[0] = 0;
version.rsvd[1] = 0;
- if (!wftap_dump_file_write(wdh, &version, sizeof version, err))
+ if (!wtap_dump_file_write(wdh, &version, sizeof version, err))
return FALSE;
}
@@ -2126,7 +2123,7 @@ ngsniffer_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
buf[3] = (char)((phdr->caplen + sizeof(struct frame2_rec))/256);
buf[4] = 0x00;
buf[5] = 0x00;
- if (!wftap_dump_file_write(wdh, buf, 6, err))
+ if (!wtap_dump_file_write(wdh, buf, 6, err))
return FALSE;
/* Seconds since the start of the capture */
tsecs = phdr->ts.secs - ngsniffer->start;
@@ -2182,9 +2179,9 @@ ngsniffer_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
rec_hdr.flags = 0;
rec_hdr.true_size = phdr->len != phdr->caplen ? GUINT16_TO_LE(phdr->len) : 0;
rec_hdr.rsvd = 0;
- if (!wftap_dump_file_write(wdh, &rec_hdr, sizeof rec_hdr, err))
+ if (!wtap_dump_file_write(wdh, &rec_hdr, sizeof rec_hdr, err))
return FALSE;
- if (!wftap_dump_file_write(wdh, pd, phdr->caplen, err))
+ if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err))
return FALSE;
return TRUE;
}
@@ -2192,12 +2189,12 @@ ngsniffer_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
/* Finish writing to a dump file.
Returns TRUE on success, FALSE on failure. */
static gboolean
-ngsniffer_dump_close(wftap_dumper *wdh, int *err)
+ngsniffer_dump_close(wtap_dumper *wdh, int *err)
{
/* EOF record */
char buf[6] = {REC_EOF, 0x00, 0x00, 0x00, 0x00, 0x00};
- if (!wftap_dump_file_write(wdh, buf, 6, err))
+ if (!wtap_dump_file_write(wdh, buf, 6, err))
return FALSE;
return TRUE;
}
@@ -2210,10 +2207,10 @@ ngsniffer_dump_close(wftap_dumper *wdh, int *err)
Parameters
inbuf - buffer of compressed bytes from file, not including
- the preceding length word
+ the preceding length word
inlen - length of inbuf in bytes (max 64k)
outbuf - decompressed contents, could contain a partial Sniffer
- record at the end.
+ record at the end.
outlen - length of outbuf.
Return value is the number of bytes in outbuf on return.
@@ -2416,7 +2413,7 @@ typedef struct {
} blob_info_t;
static gint64
-ng_file_read(void *buffer, unsigned int nbytes, wftap *wfth, gboolean is_random,
+ng_file_read(void *buffer, unsigned int nbytes, wtap *wth, gboolean is_random,
int *err, gchar **err_info)
{
ngsniffer_t *ngsniffer;
@@ -2429,16 +2426,16 @@ ng_file_read(void *buffer, unsigned int nbytes, wftap *wfth, gboolean is_random,
unsigned int bytes_to_copy;
unsigned int bytes_left;
- ngsniffer = (ngsniffer_t *)wfth->priv;
+ ngsniffer = (ngsniffer_t *)wth->priv;
if (is_random) {
- infile = wfth->random_fh;
+ infile = wth->random_fh;
comp_stream = &ngsniffer->rand;
} else {
- infile = wfth->fh;
+ infile = wth->fh;
comp_stream = &ngsniffer->seq;
}
- if (wfth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_NGSNIFFER_UNCOMPRESSED) {
+ if (wth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_NGSNIFFER_UNCOMPRESSED) {
errno = WTAP_ERR_CANT_READ;
copied_bytes = file_read(buffer, copybytes, infile);
if ((unsigned int) copied_bytes != copybytes)
@@ -2465,7 +2462,7 @@ ng_file_read(void *buffer, unsigned int nbytes, wftap *wfth, gboolean is_random,
/* This is the first sequential read; if we also have a
random stream open, allocate the first element for the
list of blobs, and make it the last element as well. */
- if (wfth->random_fh != NULL) {
+ if (wth->random_fh != NULL) {
g_assert(ngsniffer->first_blob == NULL);
blob = g_new(blob_info_t,1);
blob->blob_comp_offset = comp_stream->comp_offset;
@@ -2503,7 +2500,7 @@ ng_file_read(void *buffer, unsigned int nbytes, wftap *wfth, gboolean is_random,
non-empty, as we initialized it on the first sequential
read, so we just add the new element at the end, and
adjust the pointer to the last element to refer to it. */
- if (wfth->random_fh != NULL) {
+ if (wth->random_fh != NULL) {
blob = g_new(blob_info_t,1);
blob->blob_comp_offset = comp_stream->comp_offset;
blob->blob_uncomp_offset = comp_stream->uncomp_offset;
@@ -2598,17 +2595,17 @@ read_blob(FILE_T infile, ngsniffer_comp_stream_t *comp_stream, int *err,
/* Skip some number of bytes forward in the sequential stream. */
static gboolean
-ng_file_skip_seq(wftap *wfth, gint64 delta, int *err, gchar **err_info)
+ng_file_skip_seq(wtap *wth, gint64 delta, int *err, gchar **err_info)
{
ngsniffer_t *ngsniffer;
char *buf;
unsigned int amount_to_read;
- ngsniffer = (ngsniffer_t *)wfth->priv;
+ ngsniffer = (ngsniffer_t *)wth->priv;
- if (wfth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_NGSNIFFER_UNCOMPRESSED) {
+ if (wth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_NGSNIFFER_UNCOMPRESSED) {
ngsniffer->seq.uncomp_offset += delta;
- return file_skip(wfth->fh, delta, err);
+ return file_skip(wth->fh, delta, err);
}
g_assert(delta >= 0);
@@ -2621,7 +2618,7 @@ ng_file_skip_seq(wftap *wfth, gint64 delta, int *err, gchar **err_info)
else
amount_to_read = (unsigned int) delta;
- if (ng_file_read(buf, amount_to_read, wfth, FALSE, err, err_info) < 0) {
+ if (ng_file_read(buf, amount_to_read, wth, FALSE, err, err_info) < 0) {
g_free(buf);
return FALSE; /* error */
}
@@ -2642,17 +2639,17 @@ ng_file_skip_seq(wftap *wfth, gint64 delta, int *err, gchar **err_info)
position within the blob we have in memory (whether it's the blob we
already had in memory or, if necessary, the one we read in). */
static gboolean
-ng_file_seek_rand(wftap *wfth, gint64 offset, int *err, gchar **err_info)
+ng_file_seek_rand(wtap *wth, gint64 offset, int *err, gchar **err_info)
{
ngsniffer_t *ngsniffer;
gint64 delta;
GList *new_list, *next_list;
blob_info_t *next_blob, *new_blob;
- ngsniffer = (ngsniffer_t *)wfth->priv;
+ ngsniffer = (ngsniffer_t *)wth->priv;
- if (wfth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_NGSNIFFER_UNCOMPRESSED) {
- if (file_seek(wfth->random_fh, offset, SEEK_SET, err) == -1)
+ if (wth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_NGSNIFFER_UNCOMPRESSED) {
+ if (file_seek(wth->random_fh, offset, SEEK_SET, err) == -1)
return FALSE;
return TRUE;
}
@@ -2747,7 +2744,7 @@ ng_file_seek_rand(wftap *wfth, gint64 offset, int *err, gchar **err_info)
/* Seek in the compressed file to the offset in the compressed file
of the beginning of that blob. */
- if (file_seek(wfth->random_fh, new_blob->blob_comp_offset, SEEK_SET, err) == -1)
+ if (file_seek(wth->random_fh, new_blob->blob_comp_offset, SEEK_SET, err) == -1)
return FALSE;
/*
@@ -2769,7 +2766,7 @@ ng_file_seek_rand(wftap *wfth, gint64 offset, int *err, gchar **err_info)
ngsniffer->rand.comp_offset = new_blob->blob_comp_offset;
/* Now fill the buffer. */
- if (read_blob(wfth->random_fh, &ngsniffer->rand, err, err_info) < 0)
+ if (read_blob(wth->random_fh, &ngsniffer->rand, err, err_info) < 0)
return FALSE;
/* Set "delta" to the amount to move within this blob; it had