diff options
Diffstat (limited to 'wiretap/stanag4607.c')
-rw-r--r-- | wiretap/stanag4607.c | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/wiretap/stanag4607.c b/wiretap/stanag4607.c index 12bc05885c..9f2f2b8ec6 100644 --- a/wiretap/stanag4607.c +++ b/wiretap/stanag4607.c @@ -28,6 +28,7 @@ #include <sys/stat.h> #endif +#include "wftap-int.h" #include "wtap-int.h" #include "file_wrappers.h" #include "buffer.h" @@ -48,10 +49,10 @@ static gboolean is_valid_id(guint16 version_id) return TRUE; } -static gboolean stanag4607_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, +static gboolean stanag4607_read_file(wftap *wfth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { - stanag4607_t *stanag4607 = (stanag4607_t *)wth->priv; + stanag4607_t *stanag4607 = (stanag4607_t *)wfth->priv; guint32 millisecs, secs, nsecs; gint64 offset = 0; guint8 stanag_pkt_hdr[37]; @@ -138,42 +139,44 @@ static gboolean stanag4607_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *p return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info); fail: - *err = file_error(wth->fh, err_info); + *err = file_error(wfth->fh, err_info); return FALSE; } -static gboolean stanag4607_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) +static gboolean stanag4607_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); *data_offset = offset; - return stanag4607_read_file(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info); + return stanag4607_read_file(wfth, wfth->fh, &wth->phdr, wfth->frame_buffer, err, err_info); } -static gboolean stanag4607_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, +static gboolean stanag4607_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 stanag4607_read_file(wth, wth->random_fh, phdr, buf, err, err_info); + return stanag4607_read_file(wfth, wfth->random_fh, phdr, buf, err, err_info); } -int stanag4607_open(wtap *wth, int *err, gchar **err_info) +int stanag4607_open(wftap *wfth, int *err, gchar **err_info) { int bytes_read; guint16 version_id; stanag4607_t *stanag4607; - bytes_read = file_read(&version_id, sizeof version_id, wth->fh); + bytes_read = file_read(&version_id, sizeof version_id, wfth->fh); if (bytes_read != sizeof version_id) { - *err = file_error(wth->fh, err_info); + *err = file_error(wfth->fh, err_info); return (*err != 0) ? -1 : 0; } @@ -182,20 +185,20 @@ int stanag4607_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_STANAG_4607; - wth->file_encap = WTAP_ENCAP_STANAG_4607; - wth->snapshot_length = 0; /* not known */ + wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_STANAG_4607; + wfth->file_encap = WTAP_ENCAP_STANAG_4607; + wfth->snapshot_length = 0; /* not known */ stanag4607 = (stanag4607_t *)g_malloc(sizeof(stanag4607_t)); - wth->priv = (void *)stanag4607; + wfth->priv = (void *)stanag4607; stanag4607->base_secs = 0; /* unknown as of yet */ - wth->subtype_read = stanag4607_read; - wth->subtype_seek_read = stanag4607_seek_read; - wth->tsprecision = WTAP_FILE_TSPREC_MSEC; + wfth->subtype_read = stanag4607_read; + wfth->subtype_seek_read = stanag4607_seek_read; + wfth->tsprecision = WTAP_FILE_TSPREC_MSEC; return 1; } |