aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/mplog.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2018-02-08 16:19:12 -0800
committerGuy Harris <guy@alum.mit.edu>2018-02-09 00:29:51 +0000
commit1f5f63f8ef98bfe9c4d734674cee0df64855555d (patch)
tree133dd3563cc8d2d29dd85d4d43cd9a4636283192 /wiretap/mplog.c
parente4c5efafb7da2d25b7d47fe2dac3b1556c0b67b0 (diff)
Generalize wtap_pkthdr into a structure for packet and non-packet records.
Separate the stuff that any record could have from the stuff that only particular record types have; put the latter into a union, and put all that into a wtap_rec structure. Add some record-type checks as necessary. Change-Id: Id6b3486858f826fce4b096c59231f463e44bfaa2 Reviewed-on: https://code.wireshark.org/review/25696 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wiretap/mplog.c')
-rw-r--r--wiretap/mplog.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/wiretap/mplog.c b/wiretap/mplog.c
index 0f63963332..22e537f600 100644
--- a/wiretap/mplog.c
+++ b/wiretap/mplog.c
@@ -86,7 +86,7 @@
- if two blocks of our packet's block type are more than 200us apart,
we treat this as a packet boundary as described above
*/
-static gboolean mplog_read_packet(FILE_T fh, struct wtap_pkthdr *phdr,
+static gboolean mplog_read_packet(FILE_T fh, wtap_rec *rec,
Buffer *buf, int *err, gchar **err_info)
{
guint8 *p, *start_p;
@@ -169,13 +169,13 @@ static gboolean mplog_read_packet(FILE_T fh, struct wtap_pkthdr *phdr,
start_p[2] = pkt_bytes >> 8;
start_p[3] = pkt_bytes & 0xFF;
- phdr->rec_type = REC_TYPE_PACKET;
- phdr->pkt_encap = WTAP_ENCAP_ISO14443;
- phdr->presence_flags = WTAP_HAS_TS | WTAP_HAS_CAP_LEN;
- phdr->ts.secs = (time_t)((pkt_ctr*10)/(1000*1000*1000));
- phdr->ts.nsecs = (int)((pkt_ctr*10)%(1000*1000*1000));
- phdr->caplen = ISO14443_PSEUDO_HDR_LEN + pkt_bytes;
- phdr->len = phdr->caplen;
+ rec->rec_type = REC_TYPE_PACKET;
+ rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ISO14443;
+ rec->presence_flags = WTAP_HAS_TS | WTAP_HAS_CAP_LEN;
+ rec->ts.secs = (time_t)((pkt_ctr*10)/(1000*1000*1000));
+ rec->ts.nsecs = (int)((pkt_ctr*10)%(1000*1000*1000));
+ rec->rec_header.packet_header.caplen = ISO14443_PSEUDO_HDR_LEN + pkt_bytes;
+ rec->rec_header.packet_header.len = rec->rec_header.packet_header.caplen;
return TRUE;
}
@@ -187,18 +187,18 @@ mplog_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
*data_offset = file_tell(wth->fh);
return mplog_read_packet(
- wth->fh, &wth->phdr, wth->frame_buffer, err, err_info);
+ wth->fh, &wth->rec, wth->rec_data, err, err_info);
}
static gboolean
-mplog_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *pkthdr,
- Buffer *buf, int *err, gchar **err_info)
+mplog_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info)
{
if (-1 == file_seek(wth->random_fh, seek_off, SEEK_SET, err))
return FALSE;
- if (!mplog_read_packet(wth->random_fh, pkthdr, buf, err, err_info)) {
+ if (!mplog_read_packet(wth->random_fh, rec, buf, err, err_info)) {
/* Even if we got an immediate EOF, that's an error. */
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;