From 98473c77b6976eabae05a806af860d645fbf0cc7 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Fri, 26 Aug 2005 19:40:46 +0000 Subject: Ethereal now requires 64-bit integer support, so get rid of the tests of G_HAVE_GINT64. Get rid of the floating-point stuff in the Etherpeek Classic file reading code, just use 64-bit integers. Fix up the calculation of the nanoseconds portion of the time stamp. svn path=/trunk/; revision=15544 --- wiretap/erf.c | 20 +------------------- wiretap/erf.h | 7 +------ wiretap/etherpeek.c | 21 +++++++++------------ wiretap/wtap-int.h | 12 ++---------- 4 files changed, 13 insertions(+), 47 deletions(-) (limited to 'wiretap') diff --git a/wiretap/erf.c b/wiretap/erf.c index a71424eed6..9eb6511ef0 100644 --- a/wiretap/erf.c +++ b/wiretap/erf.c @@ -138,24 +138,12 @@ int erf_open(wtap *wth, int *err, gchar **err_info _U_) return 0; } -#ifdef G_HAVE_GINT64 if ((ts = pletohll(&header.ts)) < prevts) { /* reassembled AAL5 records may not be in time order, so allow 1 sec fudge */ if (header.type != TYPE_AAL5 || ((prevts-ts)>>32) > 1) { return 0; } } -#else - ts[0] = pletohl(&header.ts[0]); /* frac */ - ts[1] = pletohl(&header.ts[1]); /* sec */ - if ((ts[1] < prevts[1]) || - (ts[1] == prevts[1] && ts[0] < prevts[0])) { - /* reassembled AAL5 records may not be in time order, so allow 1 sec fudge */ - if (header.type != TYPE_AAL5 || (prevts[1]-ts[1]) > 1) { - return 0; - } - } -#endif memcpy(&prevts, &ts, sizeof(prevts)); if (common_type == 0) { @@ -327,8 +315,7 @@ static int erf_read_header( return FALSE; } - if (phdr != NULL ) { -#ifdef G_HAVE_GINT64 + if (phdr != NULL) { guint64 ts = pletohll(&erf_header->ts); phdr->ts.secs = (long) (ts >> 32); @@ -339,11 +326,6 @@ static int erf_read_header( phdr->ts.nsecs -= 1000000000; phdr->ts.secs += 1; } -#else - phdr->ts.tv_sec = pletohl(&erf_header->ts[1]); - phdr->ts.tv_usec = - (unsigned long)((pletohl(&erf_header->ts[0])*1000000.0)/0xffffffffUL); -#endif } switch (erf_header->type) { diff --git a/wiretap/erf.h b/wiretap/erf.h index 0b99fbc80d..6be021bd19 100644 --- a/wiretap/erf.h +++ b/wiretap/erf.h @@ -47,14 +47,9 @@ /* * The timestamp is 64bit unsigned fixed point little-endian value with - * 32 bits for second and 32 bits for fraction. For portablility it is - * given as two 32 bit valies here, ts[1] == secs, ts[0] == fraction + * 32 bits for second and 32 bits for fraction. */ -#ifdef G_HAVE_GINT64 typedef guint64 erf_timestamp_t; -#else -typedef guint32 erf_timestamp_t[2]; -#endif typedef struct erf_record { erf_timestamp_t ts; diff --git a/wiretap/etherpeek.c b/wiretap/etherpeek.c index 6aea88515b..6fc9ef1518 100644 --- a/wiretap/etherpeek.c +++ b/wiretap/etherpeek.c @@ -117,8 +117,7 @@ typedef struct etherpeek_utime { #define ETHERPEEK_V7_SLICE_LENGTH_OFFSET 4 #define ETHERPEEK_V7_FLAGS_OFFSET 6 #define ETHERPEEK_V7_STATUS_OFFSET 7 -#define ETHERPEEK_V7_TIMESTAMP_UPPER_OFFSET 8 -#define ETHERPEEK_V7_TIMESTAMP_LOWER_OFFSET 12 +#define ETHERPEEK_V7_TIMESTAMP_OFFSET 8 #define ETHERPEEK_V7_PKT_SIZE 16 /* @@ -372,8 +371,9 @@ static gboolean etherpeek_read_v7(wtap *wth, int *err, gchar **err_info, guint16 sliceLength; guint8 flags; guint8 status; - etherpeek_utime timestamp; - double t; + guint64 timestamp; + time_t tsecs; + guint32 tusecs; airopeek_radio_hdr_t radio_hdr; *data_offset = wth->data_offset; @@ -387,8 +387,7 @@ static gboolean etherpeek_read_v7(wtap *wth, int *err, gchar **err_info, sliceLength = pntohs(&ep_pkt[ETHERPEEK_V7_SLICE_LENGTH_OFFSET]); flags = ep_pkt[ETHERPEEK_V7_FLAGS_OFFSET]; status = ep_pkt[ETHERPEEK_V7_STATUS_OFFSET]; - timestamp.upper = pntohl(&ep_pkt[ETHERPEEK_V7_TIMESTAMP_UPPER_OFFSET]); - timestamp.lower = pntohl(&ep_pkt[ETHERPEEK_V7_TIMESTAMP_LOWER_OFFSET]); + timestamp = pntohll(&ep_pkt[ETHERPEEK_V7_TIMESTAMP_OFFSET]); /* force sliceLength to be the actual length of the packet */ if (0 == sliceLength) { @@ -447,12 +446,10 @@ static gboolean etherpeek_read_v7(wtap *wth, int *err, gchar **err_info, wth->data_offset += sliceLength; /* fill in packet header values */ - t = (double) timestamp.lower + - (double) timestamp.upper * 4294967296.0; - t -= (double) mac2unix * 1000000.0; - wth->phdr.ts.secs = (time_t) (t/1000000.0); - wth->phdr.ts.nsecs = (guint32) (t - (double) wth->phdr.ts.secs * - 1000000000.0); + tsecs = (time_t) (timestamp/1000000); + tusecs = (guint32) (timestamp - tsecs*1000000); + wth->phdr.ts.secs = tsecs - mac2unix; + wth->phdr.ts.nsecs = tusecs * 1000; if (wth->file_encap == WTAP_ENCAP_IEEE_802_11_WITH_RADIO) { /* diff --git a/wiretap/wtap-int.h b/wiretap/wtap-int.h index 91d1c6f685..b9559bcfa4 100644 --- a/wiretap/wtap-int.h +++ b/wiretap/wtap-int.h @@ -258,17 +258,13 @@ struct wtap_dumper { /* Turn host-byte-order values into little-endian values. */ #define htoles(s) GUINT16_TO_LE(s) #define htolel(l) GUINT32_TO_LE(l) -#ifdef G_HAVE_GINT64 #define htolell(ll) GUINT64_TO_LE(ll) -#endif /* G_HAVE_GINT64 */ /* Pointer versions of ntohs and ntohl. Given a pointer to a member of a * byte array, returns the value of the two or four bytes at the pointer. * The pletoh[sl] versions return the little-endian representation. - * - * If G_HAVE_GINT64 is defined, so we can use "gint64" and "guint64" to - * refer to 64-bit integral quantities, we also provide pntohll and - * phtolell, which extract 64-bit integral quantities. + * We also provide pntohll and phtolell, which extract 64-bit integral + * quantities. */ #ifndef pntohs @@ -290,7 +286,6 @@ struct wtap_dumper { (guint32)*((const guint8 *)(p)+3)<<0) #endif -#ifdef G_HAVE_GINT64 #ifndef pntohll #define pntohll(p) ((guint64)*((const guint8 *)(p)+0)<<56| \ (guint64)*((const guint8 *)(p)+1)<<48| \ @@ -301,7 +296,6 @@ struct wtap_dumper { (guint64)*((const guint8 *)(p)+6)<<8| \ (guint64)*((const guint8 *)(p)+7)<<0) #endif -#endif #ifndef phtons @@ -338,7 +332,6 @@ struct wtap_dumper { #endif -#ifdef G_HAVE_GINT64 #ifndef pletohll #define pletohll(p) ((guint64)*((const guint8 *)(p)+7)<<56| \ (guint64)*((const guint8 *)(p)+6)<<48| \ @@ -349,7 +342,6 @@ struct wtap_dumper { (guint64)*((const guint8 *)(p)+1)<<8| \ (guint64)*((const guint8 *)(p)+0)<<0) #endif -#endif #define wtap_file_read_unknown_bytes(target, num_bytes, fh, err) \ G_STMT_START \ -- cgit v1.2.3