diff options
author | Gilbert Ramirez <gram@alumni.rice.edu> | 1998-12-13 05:08:05 +0000 |
---|---|---|
committer | Gilbert Ramirez <gram@alumni.rice.edu> | 1998-12-13 05:08:05 +0000 |
commit | 84e0fc12a0519a7772c3d6901e27f77eb3bd7300 (patch) | |
tree | 977828383612699fe168aae7934699dd91fa9ef8 /wiretap/lanalyzer.c | |
parent | 7dd4f76f59579f4ac1ae8343d5e049ce3fe8191f (diff) | |
download | wireshark-84e0fc12a0519a7772c3d6901e27f77eb3bd7300.tar.gz wireshark-84e0fc12a0519a7772c3d6901e27f77eb3bd7300.tar.bz2 wireshark-84e0fc12a0519a7772c3d6901e27f77eb3bd7300.zip |
Added Guy's patch to calculate date of Sniffer packet trace. I copied
bits of it to do the same for Lanalyzer packets.
svn path=/trunk/; revision=123
Diffstat (limited to 'wiretap/lanalyzer.c')
-rw-r--r-- | wiretap/lanalyzer.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/wiretap/lanalyzer.c b/wiretap/lanalyzer.c index b44fadc144..619bf4d117 100644 --- a/wiretap/lanalyzer.c +++ b/wiretap/lanalyzer.c @@ -1,6 +1,6 @@ /* lanalyzer.c * - * $Id: lanalyzer.c,v 1.4 1998/11/23 15:48:38 gram Exp $ + * $Id: lanalyzer.c,v 1.5 1998/12/13 05:08:03 gram Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu> @@ -21,6 +21,7 @@ * */ #include <stdlib.h> +#include <time.h> #include "wtap.h" #include "lanalyzer.h" @@ -33,6 +34,7 @@ int lanalyzer_open(wtap *wth) guint16 board_type, mxslc; guint16 type, length; guint8 cr_day, cr_month, cr_year; + struct tm tm; fseek(wth->fh, 0, SEEK_SET); bytes_read = fread(record_type, 1, 2, wth->fh); @@ -83,7 +85,25 @@ int lanalyzer_open(wtap *wth) cr_day = summary[0]; cr_month = summary[1]; cr_year = pletohs(&summary[2]); + /*g_message("Day %d Month %d Year %d (%04X)", cr_day, cr_month, + cr_year, cr_year);*/ + /* Get capture start time. I learned how to do + * this from Guy's code in ngsniffer.c + */ + /* this strange year offset is not in the + * lanalyzer file format documentation, but it + * works. */ + tm.tm_year = cr_year - (1900 - 1792); + tm.tm_mon = cr_month - 1; + tm.tm_mday = cr_day; + tm.tm_hour = 0; + tm.tm_min = 0; + tm.tm_sec = 0; + tm.tm_isdst = -1; + wth->capture.lanalyzer->start = mktime(&tm); + g_message("Day %d Month %d Year %d", tm.tm_mday, + tm.tm_mon, tm.tm_year); mxslc = pletohs(&summary[30]); wth->snapshot_length = mxslc; @@ -126,7 +146,7 @@ int lanalyzer_read(wtap *wth) gchar descriptor[32]; int data_offset; guint16 time_low, time_med, time_high, true_size; - double t, x; + double t; /* If this is the very first packet, then the fh cursor will already * be at the start of the packet data instead of at the start of the Trace @@ -183,10 +203,10 @@ int lanalyzer_read(wtap *wth) time_med = pletohs(&descriptor[10]); time_high = pletohs(&descriptor[12]); - x = 4.0 * (double)(1<<30); t = (double)time_low+(double)(time_med)*65536.0 + - (double)time_high*x; + (double)time_high*4294967296.0; t = t/1000000.0 * 0.5; /* t = # of secs */ + t += wth->capture.lanalyzer->start; wth->phdr.ts.tv_sec = (long)t; wth->phdr.ts.tv_usec = (unsigned long)((t-(double)(wth->phdr.ts.tv_sec)) |