aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/tnef.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2014-05-08 22:59:19 -0400
committerMichael Mann <mmann78@netscape.net>2014-05-09 03:04:39 +0000
commit1abeb277f5e6bd27fbaebfecc8184e37ba9d008a (patch)
tree8cc6eaa5a6982454a00adc600fa4aab02bec3d73 /wiretap/tnef.c
parentaa3a968eb6e85c47014a4cec4a2b955357b0e77f (diff)
Refactor Wiretap
Start of refactoring Wiretap and breaking structures down into "generally useful fields for dissection" and "capture specific". Since this in intended as a "base" for Wiretap and Filetap, the "wft" prefix is used for "common" functionality. The "architectural" changes can be found in cfile.h, wtap.h, wtap-int.h and (new file) wftap-int.h. Most of the other (painstaking) changes were really just the result of compiling those new architecture changes. bug:9607 Change-Id: Ife858a61760d7a8a03be073546c0e7e582cab2ae Reviewed-on: https://code.wireshark.org/review/1485 Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'wiretap/tnef.c')
-rw-r--r--wiretap/tnef.c44
1 files changed, 24 insertions, 20 deletions
diff --git a/wiretap/tnef.c b/wiretap/tnef.c
index 5bd2fa1463..240a5fbcc5 100644
--- a/wiretap/tnef.c
+++ b/wiretap/tnef.c
@@ -25,18 +25,19 @@
#include <sys/stat.h>
#endif
+#include "wftap-int.h"
#include "wtap-int.h"
#include "file_wrappers.h"
#include "buffer.h"
#include "tnef.h"
-static gboolean tnef_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
+static gboolean tnef_read_file(wftap *wfth, FILE_T fh, struct wtap_pkthdr *phdr,
Buffer *buf, int *err, gchar **err_info)
{
gint64 file_size;
int packet_size;
- if ((file_size = wtap_file_size(wth, err)) == -1)
+ if ((file_size = wftap_file_size(wfth, err)) == -1)
return FALSE;
if (file_size > WTAP_MAX_PACKET_SIZE) {
@@ -46,7 +47,7 @@ static gboolean tnef_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
*/
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup_printf("tnef: File has %" G_GINT64_MODIFIER "d-byte packet, bigger than maximum of %u",
- file_size, WTAP_MAX_PACKET_SIZE);
+ file_size, WTAP_MAX_PACKET_SIZE);
return FALSE;
}
packet_size = (int)file_size;
@@ -62,13 +63,14 @@ static gboolean tnef_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
}
-static gboolean tnef_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+static gboolean tnef_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_offset)
{
gint64 offset;
+ wtap* wth = (wtap*)wfth->tap_specific_data;
*err = 0;
- offset = file_tell(wth->fh);
+ offset = file_tell(wfth->fh);
/* there is only ever one packet */
if (offset)
@@ -76,33 +78,35 @@ static gboolean tnef_read(wtap *wth, int *err, gchar **err_info, gint64 *data_of
*data_offset = offset;
- return tnef_read_file(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info);
+ return tnef_read_file(wfth, wfth->fh, &wth->phdr, wfth->frame_buffer, err, err_info);
}
-static gboolean tnef_seek_read(wtap *wth, gint64 seek_off,
- struct wtap_pkthdr *phdr,
+static gboolean tnef_seek_read(wftap *wfth, gint64 seek_off,
+ void* header,
Buffer *buf, int *err, gchar **err_info)
{
+ struct wtap_pkthdr *phdr = (struct wtap_pkthdr *)header;
+
/* there is only one packet */
if(seek_off > 0) {
*err = 0;
return FALSE;
}
- if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
+ if (file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
- return tnef_read_file(wth, wth->random_fh, phdr, buf, err, err_info);
+ return tnef_read_file(wfth, wfth->random_fh, phdr, buf, err, err_info);
}
-int tnef_open(wtap *wth, int *err, gchar **err_info)
+int tnef_open(wftap *wfth, int *err, gchar **err_info)
{
int bytes_read;
guint32 magic;
- bytes_read = file_read(&magic, sizeof magic, wth->fh);
+ bytes_read = file_read(&magic, sizeof magic, wfth->fh);
if (bytes_read != sizeof magic) {
- *err = file_error(wth->fh, err_info);
+ *err = file_error(wfth->fh, err_info);
return (*err != 0) ? -1 : 0;
}
@@ -111,16 +115,16 @@ int tnef_open(wtap *wth, int *err, gchar **err_info)
return 0;
/* seek back to the start of the file */
- if (file_seek(wth->fh, 0, SEEK_SET, err) == -1)
+ if (file_seek(wfth->fh, 0, SEEK_SET, err) == -1)
return -1;
- wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_TNEF;
- wth->file_encap = WTAP_ENCAP_TNEF;
- wth->snapshot_length = 0;
+ wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_TNEF;
+ wfth->file_encap = WTAP_ENCAP_TNEF;
+ wfth->snapshot_length = 0;
- wth->subtype_read = tnef_read;
- wth->subtype_seek_read = tnef_seek_read;
- wth->tsprecision = WTAP_FILE_TSPREC_SEC;
+ wfth->subtype_read = tnef_read;
+ wfth->subtype_seek_read = tnef_seek_read;
+ wfth->tsprecision = WTAP_FILE_TSPREC_SEC;
return 1;
}