diff options
author | Michael Mann <mmann78@netscape.net> | 2014-05-08 22:59:19 -0400 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2014-05-09 03:04:39 +0000 |
commit | 1abeb277f5e6bd27fbaebfecc8184e37ba9d008a (patch) | |
tree | 8cc6eaa5a6982454a00adc600fa4aab02bec3d73 /wiretap/dct3trace.c | |
parent | aa3a968eb6e85c47014a4cec4a2b955357b0e77f (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/dct3trace.c')
-rw-r--r-- | wiretap/dct3trace.c | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/wiretap/dct3trace.c b/wiretap/dct3trace.c index 2a0eb9103a..36df2ab822 100644 --- a/wiretap/dct3trace.c +++ b/wiretap/dct3trace.c @@ -25,6 +25,7 @@ */ #include "config.h" +#include "wftap-int.h" #include "wtap-int.h" #include "buffer.h" #include "dct3trace.h" @@ -73,10 +74,10 @@ static const char dct3trace_magic_end[] = "</dump>"; #define MAX_PACKET_LEN 23 -static gboolean dct3trace_read(wtap *wth, int *err, gchar **err_info, +static gboolean dct3trace_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_offset); -static gboolean dct3trace_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); +static gboolean dct3trace_seek_read(wftap *wfth, gint64 seek_off, + void* header, Buffer *buf, int *err, gchar **err_info); /* * Following 3 functions taken from gsmdecode-0.7bis, with permission - http://wiki.thc.org/gsm @@ -155,15 +156,15 @@ xml_get_int(int *val, const char *str, const char *pattern) } -int dct3trace_open(wtap *wth, int *err, gchar **err_info) +int dct3trace_open(wftap *wfth, int *err, gchar **err_info) { char line1[64], line2[64]; /* Look for Gammu DCT3 trace header */ - if (file_gets(line1, sizeof(line1), wth->fh) == NULL || - file_gets(line2, sizeof(line2), wth->fh) == NULL) + if (file_gets(line1, sizeof(line1), wfth->fh) == NULL || + file_gets(line2, sizeof(line2), wfth->fh) == NULL) { - *err = file_error(wth->fh, err_info); + *err = file_error(wfth->fh, err_info); if (*err != 0 && *err != WTAP_ERR_SHORT_READ) return -1; return 0; @@ -176,12 +177,12 @@ int dct3trace_open(wtap *wth, int *err, gchar **err_info) return 0; } - wth->file_encap = WTAP_ENCAP_GSM_UM; - wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_DCT3TRACE; - wth->snapshot_length = 0; /* not known */ - wth->subtype_read = dct3trace_read; - wth->subtype_seek_read = dct3trace_seek_read; - wth->tsprecision = WTAP_FILE_TSPREC_SEC; + wfth->file_encap = WTAP_ENCAP_GSM_UM; + wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_DCT3TRACE; + wfth->snapshot_length = 0; /* not known */ + wfth->subtype_read = dct3trace_read; + wfth->subtype_seek_read = dct3trace_seek_read; + wfth->tsprecision = WTAP_FILE_TSPREC_SEC; return 1; } @@ -346,24 +347,26 @@ baddata: /* Find the next packet and parse it; called from wtap_read(). */ -static gboolean dct3trace_read(wtap *wth, int *err, gchar **err_info, +static gboolean dct3trace_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 dct3trace_get_packet(wth->fh, &wth->phdr, wth->frame_buffer, + return dct3trace_get_packet(wfth->fh, &wth->phdr, wfth->frame_buffer, err, err_info); } /* Used to read packets in random-access fashion */ -static gboolean dct3trace_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) +static gboolean dct3trace_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; } - return dct3trace_get_packet(wth->random_fh, phdr, buf, err, err_info); + return dct3trace_get_packet(wfth->random_fh, phdr, buf, err, err_info); } |