aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorJaap Keuter <jaap.keuter@xs4all.nl>2008-08-20 06:32:08 +0000
committerJaap Keuter <jaap.keuter@xs4all.nl>2008-08-20 06:32:08 +0000
commit45705aadc3d97462af794e780413053c37300c24 (patch)
tree0fcc03c9ee335b0b0bf05920e1ba6af0e26ca443 /epan
parent90af2cb097582f97cd139a0daa0e24d53f4dd56d (diff)
From Scott Bailey:
It takes a calculator to decode the timestamps. But no more! Timestamps using the attached patch are displayed as follows: Timestamp = MM:SS mmm absolute (UTM) or Timestamp = MM:SS mmm relative where M is minutes, S is seconds, and m is milliseconds. This is in accord with 'IEEE Std 1278.1-1995' section 5.2.31. svn path=/trunk/; revision=26047
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-dis-fields.c55
-rw-r--r--epan/dissectors/packet-dis-fields.h2
-rw-r--r--epan/dissectors/packet-dis-pdus.c4
3 files changed, 59 insertions, 2 deletions
diff --git a/epan/dissectors/packet-dis-fields.c b/epan/dissectors/packet-dis-fields.c
index 53991ed41a..a17b89544b 100644
--- a/epan/dissectors/packet-dis-fields.c
+++ b/epan/dissectors/packet-dis-fields.c
@@ -503,3 +503,58 @@ gint parseField_Double(tvbuff_t *tvb, proto_tree *tree, gint offset, DIS_ParserN
return offset;
}
+
+/* Parse the Timestamp */
+gint parseField_Timestamp(tvbuff_t *tvb, proto_tree *tree, gint offset, DIS_ParserNode parserNode)
+{
+ /* some consts */
+ static double MSEC_PER_SECOND = 1000.0;
+ static double MSEC_PER_MINUTE = 60.0 * 1000.0 ;
+ static double MSEC_PER_HOUR = 60.0 * 60.0 * 1000.0;
+ static double FSV = 0x7fffffff;
+ /* variables */
+ guint isAbsolute = 0;
+ guint32 uintVal;
+ guint minutes;
+ guint seconds;
+ guint milliseconds;
+ double ms;
+
+ offset = alignOffset(offset, 4);
+
+ /* convert to host value */
+ uintVal = tvb_get_ntohl(tvb, offset);
+ /* determine absolute vis sim time */
+ if( uintVal & 1 )
+ isAbsolute = 1;
+
+ /* convert TS to MS */
+ ms = (uintVal >> 1) * MSEC_PER_HOUR / FSV;
+ ms += 0.5;
+
+ /* calc minutes and reduce ms */
+ minutes = (guint) (ms / MSEC_PER_MINUTE);
+ ms -= (minutes * MSEC_PER_MINUTE);
+
+ /* calc seconds and reduce ms */
+ seconds = (guint) (ms / MSEC_PER_SECOND);
+ ms -= (seconds * MSEC_PER_SECOND);
+
+ /* truncate milliseconds */
+ milliseconds = (guint) ms;
+
+ /* push out the values */
+ if( isAbsolute )
+ {
+ proto_tree_add_text(tree, tvb, offset, 4, "%s = %02d:%02d %03d absolute (UTM)",
+ parserNode.fieldLabel, minutes, seconds, milliseconds);
+ }
+ else
+ {
+ proto_tree_add_text(tree, tvb, offset, 4, "%s = %02d:%02d %03d relative",
+ parserNode.fieldLabel, minutes, seconds, milliseconds);
+ }
+
+ offset += 4;
+ return offset;
+}
diff --git a/epan/dissectors/packet-dis-fields.h b/epan/dissectors/packet-dis-fields.h
index 52f0752495..998d32bfe2 100644
--- a/epan/dissectors/packet-dis-fields.h
+++ b/epan/dissectors/packet-dis-fields.h
@@ -161,6 +161,8 @@ gint parseField_Float(tvbuff_t *tvb, proto_tree *tree, gint offset, DIS_ParserNo
gint parseField_Double(tvbuff_t *tvb, proto_tree *tree, gint offset, DIS_ParserNode parserNode);
+gint parseField_Timestamp(tvbuff_t *tvb, proto_tree *tree, gint offset, DIS_ParserNode parserNode);
+
extern guint32 pduType;
extern guint32 entityKind;
extern guint32 entityDomain;
diff --git a/epan/dissectors/packet-dis-pdus.c b/epan/dissectors/packet-dis-pdus.c
index b1ea364cf3..27bc7c5817 100644
--- a/epan/dissectors/packet-dis-pdus.c
+++ b/epan/dissectors/packet-dis-pdus.c
@@ -344,8 +344,8 @@ gint parseFields(tvbuff_t *tvb, proto_tree *tree, gint offset, DIS_ParserNode pa
parserNodes[fieldIndex], 1);
break;
case DIS_FIELDTYPE_TIMESTAMP:
- offset = parseField_UInt(tvb, tree, offset,
- parserNodes[fieldIndex], 4);
+ offset = parseField_Timestamp(tvb, tree, offset,
+ parserNodes[fieldIndex]);
break;
case DIS_FIELDTYPE_WARHEAD:
offset = parseField_UInt(tvb, tree, offset,