aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/toshiba.c
diff options
context:
space:
mode:
Diffstat (limited to 'wiretap/toshiba.c')
-rw-r--r--wiretap/toshiba.c59
1 files changed, 28 insertions, 31 deletions
diff --git a/wiretap/toshiba.c b/wiretap/toshiba.c
index 176f5bb866..6fcf40270b 100644
--- a/wiretap/toshiba.c
+++ b/wiretap/toshiba.c
@@ -19,7 +19,6 @@
*/
#include "config.h"
-#include "wftap-int.h"
#include "wtap-int.h"
#include "buffer.h"
#include "toshiba.h"
@@ -106,10 +105,10 @@ static const char toshiba_rec_magic[] = { '[', 'N', 'o', '.' };
*/
#define TOSHIBA_MAX_PACKET_LEN 16384
-static gboolean toshiba_read(wftap *wfth, int *err, gchar **err_info,
+static gboolean toshiba_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
-static gboolean toshiba_seek_read(wftap *wfth, gint64 seek_off,
- void* header, Buffer *buf, int *err, gchar **err_info);
+static gboolean toshiba_seek_read(wtap *wth, gint64 seek_off,
+ struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
static gboolean parse_single_hex_dump_line(char* rec, guint8 *buf,
guint byte_offset);
static gboolean parse_toshiba_packet(FILE_T fh, struct wtap_pkthdr *phdr,
@@ -118,21 +117,21 @@ static gboolean parse_toshiba_packet(FILE_T fh, struct wtap_pkthdr *phdr,
/* Seeks to the beginning of the next packet, and returns the
byte offset. Returns -1 on failure, and sets "*err" to the error
and "*err_info" to null or an additional error string. */
-static gint64 toshiba_seek_next_packet(wftap *wfth, int *err, gchar **err_info)
+static gint64 toshiba_seek_next_packet(wtap *wth, int *err, gchar **err_info)
{
int byte;
guint level = 0;
gint64 cur_off;
- while ((byte = file_getc(wfth->fh)) != EOF) {
+ while ((byte = file_getc(wth->fh)) != EOF) {
if (byte == toshiba_rec_magic[level]) {
level++;
if (level >= TOSHIBA_REC_MAGIC_SIZE) {
- /* note: we're leaving file pointer right after the magic characters */
- cur_off = file_tell(wfth->fh);
+ /* note: we're leaving file pointer right after the magic characters */
+ cur_off = file_tell(wth->fh);
if (cur_off == -1) {
/* Error. */
- *err = file_error(wfth->fh, err_info);
+ *err = file_error(wth->fh, err_info);
return -1;
}
return cur_off + 1;
@@ -142,7 +141,7 @@ static gint64 toshiba_seek_next_packet(wftap *wfth, int *err, gchar **err_info)
}
}
/* EOF or error. */
- *err = file_error(wfth->fh, err_info);
+ *err = file_error(wth->fh, err_info);
return -1;
}
@@ -156,7 +155,7 @@ static gint64 toshiba_seek_next_packet(wftap *wfth, int *err, gchar **err_info)
* if we get an I/O error, "*err" will be set to a non-zero value and
* "*err_info" will be set to null or an additional error string.
*/
-static gboolean toshiba_check_file_type(wftap *wfth, int *err, gchar **err_info)
+static gboolean toshiba_check_file_type(wtap *wth, int *err, gchar **err_info)
{
char buf[TOSHIBA_LINE_LENGTH];
guint i, reclen, level, line;
@@ -165,9 +164,9 @@ static gboolean toshiba_check_file_type(wftap *wfth, int *err, gchar **err_info)
buf[TOSHIBA_LINE_LENGTH-1] = 0;
for (line = 0; line < TOSHIBA_HEADER_LINES_TO_CHECK; line++) {
- if (file_gets(buf, TOSHIBA_LINE_LENGTH, wfth->fh) == NULL) {
+ if (file_gets(buf, TOSHIBA_LINE_LENGTH, wth->fh) == NULL) {
/* EOF or error. */
- *err = file_error(wfth->fh, err_info);
+ *err = file_error(wth->fh, err_info);
return FALSE;
}
@@ -195,54 +194,52 @@ static gboolean toshiba_check_file_type(wftap *wfth, int *err, gchar **err_info)
}
-int toshiba_open(wftap *wfth, int *err, gchar **err_info)
+int toshiba_open(wtap *wth, int *err, gchar **err_info)
{
/* Look for Toshiba header */
- if (!toshiba_check_file_type(wfth, err, err_info)) {
+ if (!toshiba_check_file_type(wth, err, err_info)) {
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
return -1;
return 0;
}
- wfth->file_encap = WTAP_ENCAP_PER_PACKET;
- wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_TOSHIBA;
- wfth->snapshot_length = 0; /* not known */
- wfth->subtype_read = toshiba_read;
- wfth->subtype_seek_read = toshiba_seek_read;
- wfth->tsprecision = WTAP_FILE_TSPREC_CSEC;
+ wth->file_encap = WTAP_ENCAP_PER_PACKET;
+ wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_TOSHIBA;
+ wth->snapshot_length = 0; /* not known */
+ wth->subtype_read = toshiba_read;
+ wth->subtype_seek_read = toshiba_seek_read;
+ wth->tsprecision = WTAP_FILE_TSPREC_CSEC;
return 1;
}
/* Find the next packet and parse it; called from wtap_read(). */
-static gboolean toshiba_read(wftap *wfth, int *err, gchar **err_info,
+static gboolean toshiba_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
gint64 offset;
- wtap* wth = (wtap*)wfth->tap_specific_data;
/* Find the next packet */
- offset = toshiba_seek_next_packet(wfth, err, err_info);
+ offset = toshiba_seek_next_packet(wth, err, err_info);
if (offset < 1)
return FALSE;
*data_offset = offset;
/* Parse the packet */
- return parse_toshiba_packet(wfth->fh, &wth->phdr, wfth->frame_buffer, err, err_info);
+ return parse_toshiba_packet(wth->fh, &wth->phdr, wth->frame_buffer,
+ err, err_info);
}
/* Used to read packets in random-access fashion */
static gboolean
-toshiba_seek_read(wftap *wfth, gint64 seek_off,
- void* header, Buffer *buf,
+toshiba_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;
-
- if (file_seek(wfth->random_fh, seek_off - 1, SEEK_SET, err) == -1)
+ if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1)
return FALSE;
- if (!parse_toshiba_packet(wfth->random_fh, phdr, buf, err, err_info)) {
+ if (!parse_toshiba_packet(wth->random_fh, phdr, buf, err, err_info)) {
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;