diff options
author | Guy Harris <guy@alum.mit.edu> | 2014-05-09 05:18:49 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-05-09 05:21:01 +0000 |
commit | a1b1c8bed54b1576e4f0e9e7f583844a12d142bf (patch) | |
tree | fcadd72c61f9d936451163e83cc1be843073f3b4 /wiretap/vwr.c | |
parent | a651f3e5edb2f148a0e5f495b5cba0e7fa43e002 (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/vwr.c')
-rw-r--r-- | wiretap/vwr.c | 79 |
1 files changed, 38 insertions, 41 deletions
diff --git a/wiretap/vwr.c b/wiretap/vwr.c index b0bb33ad30..7d0b291c62 100644 --- a/wiretap/vwr.c +++ b/wiretap/vwr.c @@ -24,7 +24,6 @@ #include <errno.h> #include <string.h> -#include "wftap-int.h" #include "wtap-int.h" #include "file_wrappers.h" #include "buffer.h" @@ -497,8 +496,8 @@ static guint8 get_ofdm_rate(const guint8 *); static guint8 get_cck_rate(const guint8 *plcp); static void setup_defaults(vwr_t *, guint16); -static gboolean vwr_read(wftap *, int *, gchar **, gint64 *); -static gboolean vwr_seek_read(wftap *, gint64, void*, +static gboolean vwr_read(wtap *, int *, gchar **, gint64 *); +static gboolean vwr_seek_read(wtap *, gint64, struct wtap_pkthdr *phdr, Buffer *, int *, gchar **); static gboolean vwr_read_rec_header(vwr_t *, FILE_T, int *, int *, int *, gchar **); @@ -507,7 +506,7 @@ static gboolean vwr_process_rec_data(FILE_T fh, int rec_size, vwr_t *vwr, int IS_TX, int *err, gchar **err_info); -static int vwr_get_fpga_version(wftap *, int *, gchar **); +static int vwr_get_fpga_version(wtap *, int *, gchar **); static gboolean vwr_read_s1_W_rec(vwr_t *, struct wtap_pkthdr *, Buffer *, const guint8 *, int, int *, gchar **); @@ -526,14 +525,14 @@ static float getRate( guint8 plcpType, guint8 mcsIndex, guint16 rflags, g /* This does very little, except setting the wiretap header for a VWR file type */ /* and setting the timestamp precision to microseconds. */ -int vwr_open(wftap *wfth, int *err, gchar **err_info) +int vwr_open(wtap *wth, int *err, gchar **err_info) { int fpgaVer; vwr_t *vwr; *err = 0; - fpgaVer = vwr_get_fpga_version(wfth, err, err_info); + fpgaVer = vwr_get_fpga_version(wth, err, err_info); if (fpgaVer == -1) { return -1; /* I/O error */ } @@ -543,22 +542,22 @@ int vwr_open(wftap *wfth, int *err, gchar **err_info) /* This is a vwr file */ vwr = (vwr_t *)g_malloc0(sizeof(vwr_t)); - wfth->priv = (void *)vwr; + wth->priv = (void *)vwr; vwr->FPGA_VERSION = fpgaVer; /* set the local module options first */ setup_defaults(vwr, fpgaVer); - wfth->snapshot_length = 0; - wfth->subtype_read = vwr_read; - wfth->subtype_seek_read = vwr_seek_read; - wfth->tsprecision = WTAP_FILE_TSPREC_USEC; - wfth->file_encap = WTAP_ENCAP_IXVERIWAVE; + wth->snapshot_length = 0; + wth->subtype_read = vwr_read; + wth->subtype_seek_read = vwr_seek_read; + wth->tsprecision = WTAP_FILE_TSPREC_USEC; + wth->file_encap = WTAP_ENCAP_IXVERIWAVE; if (fpgaVer == S2_W_FPGA || fpgaVer == S1_W_FPGA || fpgaVer == S3_W_FPGA) - wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_VWR_80211; + wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_VWR_80211; else if (fpgaVer == vVW510012_E_FPGA || fpgaVer == vVW510024_E_FPGA) - wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_VWR_ETH; + wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_VWR_ETH; return 1; } @@ -572,36 +571,35 @@ int vwr_open(wftap *wfth, int *err, gchar **err_info) /* frame, and a 64-byte statistics block trailer. */ /* The PLCP frame consists of a 4-byte or 6-byte PLCP header, followed by the MAC frame */ -static gboolean vwr_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_offset) +static gboolean vwr_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { - vwr_t *vwr = (vwr_t *)wfth->priv; - wtap* wth = (wtap*)wfth->tap_specific_data; + vwr_t *vwr = (vwr_t *)wth->priv; int rec_size = 0, IS_TX; /* read the next frame record header in the capture file; if no more frames, return */ - if (!vwr_read_rec_header(vwr, wfth->fh, &rec_size, &IS_TX, err, err_info)) + if (!vwr_read_rec_header(vwr, wth->fh, &rec_size, &IS_TX, err, err_info)) return FALSE; /* Read error or EOF */ /* * We're past the header; return the offset of the header, not of * the data past the header. */ - *data_offset = (file_tell(wfth->fh) - VW_RECORD_HEADER_LENGTH); + *data_offset = (file_tell(wth->fh) - VW_RECORD_HEADER_LENGTH); /* got a frame record; read and process it */ - if (!vwr_process_rec_data(wfth->fh, rec_size, &wth->phdr, - wfth->frame_buffer, vwr, IS_TX, err, err_info)) + if (!vwr_process_rec_data(wth->fh, rec_size, &wth->phdr, + wth->frame_buffer, vwr, IS_TX, err, err_info)) return FALSE; /* If the per-file encapsulation isn't known, set it to this packet's encapsulation. */ /* If it *is* known, and it isn't this packet's encapsulation, 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; } return TRUE; @@ -609,22 +607,21 @@ static gboolean vwr_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_o /* read a random record in the middle of a file; the start of the record is @ seek_off */ -static gboolean vwr_seek_read(wftap *wfth, gint64 seek_off, - void* header, Buffer *buf, int *err, gchar **err_info) +static gboolean vwr_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; - vwr_t *vwr = (vwr_t *)wfth->priv; + vwr_t *vwr = (vwr_t *)wth->priv; int rec_size, IS_TX; /* first seek to the indicated record 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; /* read in the record header */ - if (!vwr_read_rec_header(vwr, wfth->random_fh, &rec_size, &IS_TX, err, err_info)) + if (!vwr_read_rec_header(vwr, wth->random_fh, &rec_size, &IS_TX, err, err_info)) return FALSE; /* Read error or EOF */ - return vwr_process_rec_data(wfth->random_fh, rec_size, phdr, buf, + return vwr_process_rec_data(wth->random_fh, rec_size, phdr, buf, vwr, IS_TX, err, err_info); } @@ -678,7 +675,7 @@ static gboolean vwr_read_rec_header(vwr_t *vwr, FILE_T fh, int *rec_size, int *I /* Return FPGA version if it's a known version, UNKNOWN_FPGA if it's not, */ /* and -1 on an I/O error. */ -static int vwr_get_fpga_version(wftap *wfth, int *err, gchar **err_info) +static int vwr_get_fpga_version(wtap *wth, int *err, gchar **err_info) { guint8 rec[B_SIZE]; /* local buffer (holds input record) */ guint8 header[VW_RECORD_HEADER_LENGTH]; @@ -694,9 +691,9 @@ static int vwr_get_fpga_version(wftap *wfth, int *err, gchar **err_info) guint16 fpga_version; int valid_but_empty_file = -1; - filePos = file_tell(wfth->fh); + filePos = file_tell(wth->fh); if (filePos == -1) { - *err = file_error(wfth->fh, err_info); + *err = file_error(wth->fh, err_info); return -1; } @@ -708,7 +705,7 @@ static int vwr_get_fpga_version(wftap *wfth, int *err, gchar **err_info) /* Each 16-byte message is decoded; if we run across a non-frame message followed by a */ /* variable-length item, we read the variable length item out and discard it. */ /* If we find a frame, we return (with the header in the passed buffer). */ - while ((file_read(header, VW_RECORD_HEADER_LENGTH, wfth->fh)) == VW_RECORD_HEADER_LENGTH) { + while ((file_read(header, VW_RECORD_HEADER_LENGTH, wth->fh)) == VW_RECORD_HEADER_LENGTH) { /* Got a header; invoke decode-message function to parse and process it. */ /* If the function returns a length, then a frame or variable-length message */ /* follows the 16-byte message. */ @@ -720,7 +717,7 @@ static int vwr_get_fpga_version(wftap *wfth, int *err, gchar **err_info) return UNKNOWN_FPGA; } else if (v_type != VT_FRAME) { - if (file_seek(wfth->fh, f_len, SEEK_CUR, err) < 0) + if (file_seek(wth->fh, f_len, SEEK_CUR, err) < 0) return -1; else if (v_type == VT_CPMSG) valid_but_empty_file = 1; @@ -729,8 +726,8 @@ static int vwr_get_fpga_version(wftap *wfth, int *err, gchar **err_info) rec_size = f_len; /* Got a frame record; read over entire record (frame + trailer) into a local buffer */ /* If we don't get it all, assume this isn't a vwr file */ - if (file_read(rec, rec_size, wfth->fh) != rec_size) { - *err = file_error(wfth->fh, err_info); + if (file_read(rec, rec_size, wth->fh) != rec_size) { + *err = file_error(wth->fh, err_info); if (*err != 0 && *err != WTAP_ERR_SHORT_READ) return -1; return UNKNOWN_FPGA; /* short read - not a vwr file */ @@ -809,7 +806,7 @@ static int vwr_get_fpga_version(wftap *wfth, int *err, gchar **err_info) if (fpga_version != 1000) { /* reset the file position offset */ - if (file_seek (wfth->fh, filePos, SEEK_SET, err) == -1) { + if (file_seek (wth->fh, filePos, SEEK_SET, err) == -1) { return (-1); } /* We found an FPGA that works */ @@ -823,7 +820,7 @@ static int vwr_get_fpga_version(wftap *wfth, int *err, gchar **err_info) if (valid_but_empty_file > 0) return(S3_W_FPGA); - *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 UNKNOWN_FPGA; /* short read - not a vwr file */ |