diff options
Diffstat (limited to 'epan/dissectors')
-rw-r--r-- | epan/dissectors/packet-dis-fields.c | 55 | ||||
-rw-r--r-- | epan/dissectors/packet-dis-fields.h | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-dis-pdus.c | 4 |
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, |