summaryrefslogtreecommitdiff
path: root/wiretap/packetlogger.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/packetlogger.c
parentaa3a968eb6e85c47014a4cec4a2b955357b0e77f (diff)
downloadwireshark-1abeb277f5e6bd27fbaebfecc8184e37ba9d008a.tar.gz
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/packetlogger.c')
-rw-r--r--wiretap/packetlogger.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/wiretap/packetlogger.c b/wiretap/packetlogger.c
index 313cf3e5b8..4033c78828 100644
--- a/wiretap/packetlogger.c
+++ b/wiretap/packetlogger.c
@@ -34,6 +34,7 @@
#include <string.h>
#include "wtap.h"
+#include "wftap-int.h"
#include "wtap-int.h"
#include "buffer.h"
#include "file_wrappers.h"
@@ -44,10 +45,10 @@ typedef struct packetlogger_header {
guint64 ts;
} packetlogger_header_t;
-static gboolean packetlogger_read(wtap *wth, int *err, gchar **err_info,
+static gboolean packetlogger_read(wftap *wfth, int *err, gchar **err_info,
gint64 *data_offset);
-static gboolean packetlogger_seek_read(wtap *wth, gint64 seek_off,
- struct wtap_pkthdr *phdr,
+static gboolean packetlogger_seek_read(wftap *wfth, gint64 seek_off,
+ void* header,
Buffer *buf, int *err, gchar **err_info);
static gboolean packetlogger_read_header(packetlogger_header_t *pl_hdr,
FILE_T fh, int *err, gchar **err_info);
@@ -55,19 +56,19 @@ static gboolean packetlogger_read_packet(FILE_T fh, struct wtap_pkthdr *phdr,
Buffer *buf, int *err,
gchar **err_info);
-int packetlogger_open(wtap *wth, int *err, gchar **err_info)
+int packetlogger_open(wftap *wfth, int *err, gchar **err_info)
{
packetlogger_header_t pl_hdr;
guint8 type;
- if(!packetlogger_read_header(&pl_hdr, wth->fh, err, err_info)) {
+ if(!packetlogger_read_header(&pl_hdr, wfth->fh, err, err_info)) {
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
return -1;
return 0;
}
- if (file_read(&type, 1, wth->fh) <= 0) {
- *err = file_error(wth->fh, err_info);
+ if (file_read(&type, 1, wfth->fh) <= 0) {
+ *err = file_error(wfth->fh, err_info);
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
return -1;
return 0;
@@ -79,37 +80,39 @@ int packetlogger_open(wtap *wth, int *err, gchar **err_info)
return 0;
/* No file header. Reset the fh to 0 so we can read the first packet */
- if (file_seek(wth->fh, 0, SEEK_SET, err) == -1)
+ if (file_seek(wfth->fh, 0, SEEK_SET, err) == -1)
return -1;
/* Set up the pointers to the handlers for this file type */
- wth->subtype_read = packetlogger_read;
- wth->subtype_seek_read = packetlogger_seek_read;
+ wfth->subtype_read = packetlogger_read;
+ wfth->subtype_seek_read = packetlogger_seek_read;
- wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_PACKETLOGGER;
- wth->file_encap = WTAP_ENCAP_PACKETLOGGER;
- wth->tsprecision = WTAP_FILE_TSPREC_USEC;
+ wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_PACKETLOGGER;
+ wfth->file_encap = WTAP_ENCAP_PACKETLOGGER;
+ wfth->tsprecision = WTAP_FILE_TSPREC_USEC;
return 1; /* Our kind of file */
}
static gboolean
-packetlogger_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+packetlogger_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_offset)
{
- *data_offset = file_tell(wth->fh);
+ wtap* wth = (wtap*)wfth->tap_specific_data;
+ *data_offset = file_tell(wfth->fh);
- return packetlogger_read_packet(wth->fh, &wth->phdr,
- wth->frame_buffer, err, err_info);
+ return packetlogger_read_packet(wfth->fh, &wth->phdr,
+ wfth->frame_buffer, err, err_info);
}
static gboolean
-packetlogger_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
+packetlogger_seek_read(wftap *wfth, gint64 seek_off, void* header,
Buffer *buf, int *err, gchar **err_info)
{
- if(file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
+ struct wtap_pkthdr *phdr = (struct wtap_pkthdr *)header;
+ if(file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
- if(!packetlogger_read_packet(wth->random_fh, phdr, buf, err, err_info)) {
+ if(!packetlogger_read_packet(wfth->random_fh, phdr, buf, err, err_info)) {
if(*err == 0)
*err = WTAP_ERR_SHORT_READ;