Fill in the packet flags for *Peek classic and tagged files.

Change-Id: I0f075c5bc7bb177a23be11e23e3701a7412a6e3d
Reviewed-on: https://code.wireshark.org/review/33153
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2019-05-10 15:21:41 -07:00
parent c2dc13873f
commit 16ca1b5aca
2 changed files with 29 additions and 10 deletions

View File

@ -113,7 +113,7 @@ typedef struct peekclassic_utime {
* Flag bits.
*/
#define FLAGS_CONTROL_FRAME 0x01 /* Frame is a control frame */
#define FLAGS_HAS_CRC_ERROR 0x02 /* Frame has aCRC error */
#define FLAGS_HAS_CRC_ERROR 0x02 /* Frame has a CRC error */
#define FLAGS_HAS_FRAME_ERROR 0x04 /* Frame has a frame error */
#define FLAGS_ROUTE_INFO 0x08 /* Frame has token ring routing information */
#define FLAGS_FRAME_TOO_LONG 0x10 /* Frame too long */
@ -401,9 +401,7 @@ static int peekclassic_read_packet_v7(wtap *wth, FILE_T fh,
#endif
guint16 length;
guint16 sliceLength;
#if 0
guint8 flags;
#endif
guint8 status;
guint64 timestamp;
time_t tsecs;
@ -419,9 +417,7 @@ static int peekclassic_read_packet_v7(wtap *wth, FILE_T fh,
#endif
length = pntoh16(&ep_pkt[PEEKCLASSIC_V7_LENGTH_OFFSET]);
sliceLength = pntoh16(&ep_pkt[PEEKCLASSIC_V7_SLICE_LENGTH_OFFSET]);
#if 0
flags = ep_pkt[PEEKCLASSIC_V7_FLAGS_OFFSET];
#endif
status = ep_pkt[PEEKCLASSIC_V7_STATUS_OFFSET];
timestamp = pntoh64(&ep_pkt[PEEKCLASSIC_V7_TIMESTAMP_OFFSET]);
@ -437,13 +433,20 @@ static int peekclassic_read_packet_v7(wtap *wth, FILE_T fh,
/* fill in packet header values */
rec->rec_type = REC_TYPE_PACKET;
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN|WTAP_HAS_PACK_FLAGS;
tsecs = (time_t) (timestamp/1000000);
tusecs = (guint32) (timestamp - tsecs*1000000);
rec->ts.secs = tsecs - mac2unix;
rec->ts.nsecs = tusecs * 1000;
rec->rec_header.packet_header.len = length;
rec->rec_header.packet_header.caplen = sliceLength;
rec->rec_header.packet_header.pack_flags = 0;
if (flags & FLAGS_HAS_CRC_ERROR)
rec->rec_header.packet_header.pack_flags |= PACK_FLAGS_CRC_ERROR;
if (flags & FLAGS_FRAME_TOO_LONG)
rec->rec_header.packet_header.pack_flags |= PACK_FLAGS_PACKET_TOO_LONG;
if (flags & FLAGS_FRAME_TOO_SHORT)
rec->rec_header.packet_header.pack_flags |= PACK_FLAGS_PACKET_TOO_SHORT;
switch (wth->file_encap) {
@ -568,8 +571,8 @@ static gboolean peekclassic_read_packet_v56(wtap *wth, FILE_T fh,
guint8 ep_pkt[PEEKCLASSIC_V56_PKT_SIZE];
guint16 length;
guint16 sliceLength;
#if 0
guint8 flags;
#if 0
guint8 status;
#endif
guint32 timestamp;
@ -588,8 +591,8 @@ static gboolean peekclassic_read_packet_v56(wtap *wth, FILE_T fh,
/* Extract the fields from the packet */
length = pntoh16(&ep_pkt[PEEKCLASSIC_V56_LENGTH_OFFSET]);
sliceLength = pntoh16(&ep_pkt[PEEKCLASSIC_V56_SLICE_LENGTH_OFFSET]);
#if 0
flags = ep_pkt[PEEKCLASSIC_V56_FLAGS_OFFSET];
#if 0
status = ep_pkt[PEEKCLASSIC_V56_STATUS_OFFSET];
#endif
timestamp = pntoh32(&ep_pkt[PEEKCLASSIC_V56_TIMESTAMP_OFFSET]);
@ -618,12 +621,19 @@ static gboolean peekclassic_read_packet_v56(wtap *wth, FILE_T fh,
/* fill in packet header values */
rec->rec_type = REC_TYPE_PACKET;
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN|WTAP_HAS_PACK_FLAGS;
/* timestamp is in milliseconds since reference_time */
rec->ts.secs = peekclassic->reference_time + (timestamp / 1000);
rec->ts.nsecs = 1000 * (timestamp % 1000) * 1000;
rec->rec_header.packet_header.len = length;
rec->rec_header.packet_header.caplen = sliceLength;
rec->rec_header.packet_header.pack_flags = 0;
if (flags & FLAGS_HAS_CRC_ERROR)
rec->rec_header.packet_header.pack_flags |= PACK_FLAGS_CRC_ERROR;
if (flags & FLAGS_FRAME_TOO_LONG)
rec->rec_header.packet_header.pack_flags |= PACK_FLAGS_PACKET_TOO_LONG;
if (flags & FLAGS_FRAME_TOO_SHORT)
rec->rec_header.packet_header.pack_flags |= PACK_FLAGS_PACKET_TOO_SHORT;
switch (wth->file_encap) {

View File

@ -419,7 +419,9 @@ peektagged_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
guint32 sliceLength = 0;
gboolean saw_timestamp_lower = FALSE;
gboolean saw_timestamp_upper = FALSE;
gboolean saw_flags_and_status = FALSE;
peektagged_utime timestamp;
guint32 flags_and_status = 0;
guint32 ext_flags = 0;
gboolean saw_data_rate_or_mcs_index = FALSE;
guint32 data_rate_or_mcs_index = 0;
@ -488,7 +490,8 @@ peektagged_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
break;
case TAG_PEEKTAGGED_FLAGS_AND_STATUS:
/* XXX - not used yet */
saw_flags_and_status = TRUE;
flags_and_status = pletoh32(&tag_value[2]);
break;
case TAG_PEEKTAGGED_CHANNEL:
@ -720,6 +723,12 @@ peektagged_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
rec->rec_header.packet_header.len = length;
rec->rec_header.packet_header.caplen = sliceLength;
if (saw_flags_and_status) {
rec->presence_flags |= WTAP_HAS_PACK_FLAGS;
rec->rec_header.packet_header.pack_flags = 0;
if (flags_and_status & FLAGS_HAS_CRC_ERROR)
rec->rec_header.packet_header.pack_flags |= PACK_FLAGS_CRC_ERROR;
}
/* calculate and fill in packet time stamp */
t = (((guint64) timestamp.upper) << 32) + timestamp.lower;