Add decoding of DOS-format dates and times (one of the N different
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 11 May 1999 01:18:30 +0000 (01:18 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 11 May 1999 01:18:30 +0000 (01:18 +0000)
date/time formats used in SMB...).

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@273 f5534014-38df-0310-8fa8-9805f1628bb7

packet-smb.c

index 0fc018a99197642b7d8a5357dc39a6266e570276..b90e4c6d542a374ddb4d8a7329dbb34553564be4 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for smb packet dissection
  * Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
  *
- * $Id: packet-smb.c,v 1.7 1999/05/11 00:28:18 guy Exp $
+ * $Id: packet-smb.c,v 1.8 1999/05/11 01:18:30 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@unicom.net>
@@ -324,6 +324,32 @@ dissect_unknown_smb(const u_char *pd, int offset, frame_data *fd, proto_tree *tr
 
 }
 
+/*
+ * Dissect a DOS-format date.
+ */
+static char *
+dissect_dos_date(guint16 date)
+{
+       static char datebuf[4+2+2+1];
+
+       sprintf(datebuf, "%04d-%02d-%02d",
+           ((date>>9)&0x7F) + 1980, (date>>5)&0x0F, date&0x1F);
+       return datebuf;
+}
+
+/*
+ * Dissect a DOS-format time.
+ */
+static char *
+dissect_dos_time(guint16 time)
+{
+       static char timebuf[2+2+2+1];
+
+       sprintf(timebuf, "%02d:%02d:%02d",
+           (time>>11)&0x1F, (time>>5)&0x3F, (time&0x1F)*2);
+       return timebuf;
+}
+
 /*
  * Each dissect routine is passed an offset to wct and works from there 
  */
@@ -743,8 +769,10 @@ dissect_negprot_smb(const u_char *pd, int offset, frame_data *fd, proto_tree *tr
 
     if (tree) {
 
-      proto_tree_add_item(tree, offset, 2, "Server Time: 0x%04x", GSHORT(pd, offset));
-      proto_tree_add_item(tree, offset + 2, 2, "Server Date: 0x%04x", GSHORT(pd, offset + 2));
+      proto_tree_add_item(tree, offset, 2, "Server Time: %s",
+                       dissect_dos_time(GSHORT(pd, offset)));
+      proto_tree_add_item(tree, offset + 2, 2, "Server Date: %s",
+                       dissect_dos_date(GSHORT(pd, offset + 2)));
 
     }