aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/netscreen.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-05-09 05:18:49 +0000
committerGuy Harris <guy@alum.mit.edu>2014-05-09 05:21:01 +0000
commita1b1c8bed54b1576e4f0e9e7f583844a12d142bf (patch)
treefcadd72c61f9d936451163e83cc1be843073f3b4 /wiretap/netscreen.c
parenta651f3e5edb2f148a0e5f495b5cba0e7fa43e002 (diff)
Revert "Refactor Wiretap"
This reverts commit 1abeb277f5e6bd27fbaebfecc8184e37ba9d008a. This isn't building, and looks as if it requires significant work to fix. Change-Id: I622b1bb243e353e874883a302ab419532b7601f2 Reviewed-on: https://code.wireshark.org/review/1568 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wiretap/netscreen.c')
-rw-r--r--wiretap/netscreen.c75
1 files changed, 36 insertions, 39 deletions
diff --git a/wiretap/netscreen.c b/wiretap/netscreen.c
index c1ef924fd4..bbb4a535e9 100644
--- a/wiretap/netscreen.c
+++ b/wiretap/netscreen.c
@@ -23,7 +23,6 @@
*/
#include "config.h"
-#include "wftap-int.h"
#include "wtap-int.h"
#include "buffer.h"
#include "netscreen.h"
@@ -64,14 +63,14 @@
*/
static gboolean info_line(const gchar *line);
-static gint64 netscreen_seek_next_packet(wftap *wfth, int *err, gchar **err_info,
+static gint64 netscreen_seek_next_packet(wtap *wth, int *err, gchar **err_info,
char *hdr);
-static gboolean netscreen_check_file_type(wftap *wfth, int *err,
+static gboolean netscreen_check_file_type(wtap *wth, int *err,
gchar **err_info);
-static gboolean netscreen_read(wftap *wfth, int *err, gchar **err_info,
+static gboolean netscreen_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
-static gboolean netscreen_seek_read(wftap *wfth, gint64 seek_off,
- void* header, Buffer *buf,
+static gboolean netscreen_seek_read(wtap *wth, gint64 seek_off,
+ struct wtap_pkthdr *phdr, Buffer *buf,
int *err, gchar **err_info);
static int parse_netscreen_rec_hdr(struct wtap_pkthdr *phdr, const char *line,
char *cap_int, gboolean *cap_dir, char *cap_dst,
@@ -103,22 +102,22 @@ static gboolean info_line(const gchar *line)
byte offset. Copy the header line to hdr. Returns -1 on failure,
and sets "*err" to the error and sets "*err_info" to null or an
additional error string. */
-static gint64 netscreen_seek_next_packet(wftap *wfth, int *err, gchar **err_info,
+static gint64 netscreen_seek_next_packet(wtap *wth, int *err, gchar **err_info,
char *hdr)
{
gint64 cur_off;
char buf[NETSCREEN_LINE_LENGTH];
while (1) {
- cur_off = file_tell(wfth->fh);
+ 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;
}
- if (file_gets(buf, sizeof(buf), wfth->fh) == NULL) {
+ if (file_gets(buf, sizeof(buf), wth->fh) == NULL) {
/* EOF or error. */
- *err = file_error(wfth->fh, err_info);
+ *err = file_error(wth->fh, err_info);
break;
}
if (strstr(buf, NETSCREEN_REC_MAGIC_STR1) ||
@@ -137,7 +136,7 @@ static gint64 netscreen_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" is set to null or an additional error string.
*/
-static gboolean netscreen_check_file_type(wftap *wfth, int *err, gchar **err_info)
+static gboolean netscreen_check_file_type(wtap *wth, int *err, gchar **err_info)
{
char buf[NETSCREEN_LINE_LENGTH];
guint reclen, line;
@@ -145,9 +144,9 @@ static gboolean netscreen_check_file_type(wftap *wfth, int *err, gchar **err_inf
buf[NETSCREEN_LINE_LENGTH-1] = '\0';
for (line = 0; line < NETSCREEN_HEADER_LINES_TO_CHECK; line++) {
- if (file_gets(buf, NETSCREEN_LINE_LENGTH, wfth->fh) == NULL) {
+ if (file_gets(buf, NETSCREEN_LINE_LENGTH, wth->fh) == NULL) {
/* EOF or error. */
- *err = file_error(wfth->fh, err_info);
+ *err = file_error(wth->fh, err_info);
return FALSE;
}
@@ -167,31 +166,31 @@ static gboolean netscreen_check_file_type(wftap *wfth, int *err, gchar **err_inf
}
-int netscreen_open(wftap *wfth, int *err, gchar **err_info)
+int netscreen_open(wtap *wth, int *err, gchar **err_info)
{
/* Look for a NetScreen snoop header line */
- if (!netscreen_check_file_type(wfth, err, err_info)) {
+ if (!netscreen_check_file_type(wth, err, err_info)) {
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
return -1;
return 0;
}
- if (file_seek(wfth->fh, 0L, SEEK_SET, err) == -1) /* rewind */
+ if (file_seek(wth->fh, 0L, SEEK_SET, err) == -1) /* rewind */
return -1;
- wfth->file_encap = WTAP_ENCAP_UNKNOWN;
- wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_NETSCREEN;
- wfth->snapshot_length = 0; /* not known */
- wfth->subtype_read = netscreen_read;
- wfth->subtype_seek_read = netscreen_seek_read;
- wfth->tsprecision = WTAP_FILE_TSPREC_DSEC;
+ wth->file_encap = WTAP_ENCAP_UNKNOWN;
+ wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_NETSCREEN;
+ wth->snapshot_length = 0; /* not known */
+ wth->subtype_read = netscreen_read;
+ wth->subtype_seek_read = netscreen_seek_read;
+ wth->tsprecision = WTAP_FILE_TSPREC_DSEC;
return 1;
}
/* Find the next packet and parse it; called from wtap_read(). */
-static gboolean netscreen_read(wftap *wfth, int *err, gchar **err_info,
+static gboolean netscreen_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
gint64 offset;
@@ -200,10 +199,9 @@ static gboolean netscreen_read(wftap *wfth, int *err, gchar **err_info,
char cap_int[NETSCREEN_MAX_INT_NAME_LENGTH];
gboolean cap_dir;
char cap_dst[13];
- wtap* wth = (wtap*)wfth->tap_specific_data;
/* Find the next packet */
- offset = netscreen_seek_next_packet(wfth, err, err_info, line);
+ offset = netscreen_seek_next_packet(wth, err, err_info, line);
if (offset < 0)
return FALSE;
@@ -215,8 +213,8 @@ static gboolean netscreen_read(wftap *wfth, int *err, gchar **err_info,
/* Convert the ASCII hex dump to binary data, and fill in some
struct wtap_pkthdr fields */
- if (!parse_netscreen_hex_dump(wfth->fh, pkt_len, cap_int,
- cap_dst, &wth->phdr, wfth->frame_buffer, err, err_info))
+ if (!parse_netscreen_hex_dump(wth->fh, pkt_len, cap_int,
+ cap_dst, &wth->phdr, wth->frame_buffer, err, err_info))
return FALSE;
/*
@@ -227,11 +225,11 @@ static gboolean netscreen_read(wftap *wfth, int *err, gchar **err_info,
* set it to WTAP_ENCAP_PER_PACKET, as this file doesn't
* have a single encapsulation for all packets in the file.
*/
- if (wfth->file_encap == WTAP_ENCAP_UNKNOWN)
- wfth->file_encap = wth->phdr.pkt_encap;
+ if (wth->file_encap == WTAP_ENCAP_UNKNOWN)
+ wth->file_encap = wth->phdr.pkt_encap;
else {
- if (wfth->file_encap != wth->phdr.pkt_encap)
- wfth->file_encap = WTAP_ENCAP_PER_PACKET;
+ if (wth->file_encap != wth->phdr.pkt_encap)
+ wth->file_encap = WTAP_ENCAP_PER_PACKET;
}
*data_offset = offset;
@@ -240,8 +238,8 @@ static gboolean netscreen_read(wftap *wfth, int *err, gchar **err_info,
/* Used to read packets in random-access fashion */
static gboolean
-netscreen_seek_read(wftap *wfth, gint64 seek_off,
- void* header, Buffer *buf,
+netscreen_seek_read(wtap *wth, gint64 seek_off,
+ struct wtap_pkthdr *phdr, Buffer *buf,
int *err, gchar **err_info)
{
int pkt_len;
@@ -249,14 +247,13 @@ netscreen_seek_read(wftap *wfth, gint64 seek_off,
char cap_int[NETSCREEN_MAX_INT_NAME_LENGTH];
gboolean cap_dir;
char cap_dst[13];
- struct wtap_pkthdr *phdr = (struct wtap_pkthdr *)header;
- if (file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1) {
+ if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) {
return FALSE;
}
- if (file_gets(line, NETSCREEN_LINE_LENGTH, wfth->random_fh) == NULL) {
- *err = file_error(wfth->random_fh, err_info);
+ if (file_gets(line, NETSCREEN_LINE_LENGTH, wth->random_fh) == NULL) {
+ *err = file_error(wth->random_fh, err_info);
if (*err == 0) {
*err = WTAP_ERR_SHORT_READ;
}
@@ -268,7 +265,7 @@ netscreen_seek_read(wftap *wfth, gint64 seek_off,
if (pkt_len == -1)
return FALSE;
- if (!parse_netscreen_hex_dump(wfth->random_fh, pkt_len, cap_int,
+ if (!parse_netscreen_hex_dump(wth->random_fh, pkt_len, cap_int,
cap_dst, phdr, buf, err, err_info))
return FALSE;
return TRUE;