From 1d42c94b05cf2e4ec056d780b919a05159a17b72 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Fri, 14 Sep 2001 07:10:13 +0000 Subject: [PATCH] Make the resolution for time values be nanoseconds rather than microseconds. Fix some "signed vs. unsigned" comparison warnings. svn path=/trunk/; revision=3934 --- doc/README.developer | 17 +++++---- epan/column-utils.c | 6 ++-- epan/ftypes/ftype-time.c | 66 +++++++++++++++++----------------- epan/ftypes/ftypes.h | 5 +-- epan/proto.c | 16 ++++----- epan/proto.h | 15 ++++---- epan/to_str.c | 76 ++++++++++++++++++++++++---------------- epan/to_str.h | 23 ++++++++---- packet-afs-macros.h | 31 ++++++++-------- packet-dns.c | 38 ++++++++++---------- packet-frame.c | 22 ++++++------ packet-lmi.c | 7 ++-- packet-mbtcp.c | 4 +-- packet-mip.c | 20 ++++++----- packet-netbios.c | 14 ++++---- packet-nisplus.c | 11 +++--- packet-osi.c | 4 +-- packet-q2931.c | 7 ++-- packet-q931.c | 6 ++-- packet-rx.c | 18 +++++----- packet-smb-pipe.c | 28 +++++++-------- packet-ssl.c | 8 ++--- packet-who.c | 26 +++++++------- packet-wsp.c | 14 ++++---- packet-wtls.c | 22 ++++++------ 25 files changed, 263 insertions(+), 241 deletions(-) diff --git a/doc/README.developer b/doc/README.developer index cee5244543..896aca0b40 100644 --- a/doc/README.developer +++ b/doc/README.developer @@ -1,4 +1,4 @@ -$Id: README.developer,v 1.35 2001/08/31 09:04:36 guy Exp $ +$Id: README.developer,v 1.36 2001/09/14 07:10:09 guy Exp $ This file is a HOWTO for Ethereal developers. It describes how to start coding a Ethereal protocol dissector and the use some of the important functions and @@ -85,7 +85,7 @@ code inside is needed only if you are using the "snprintf()" function. -The "$Id: README.developer,v 1.35 2001/08/31 09:04:36 guy Exp $" +The "$Id: README.developer,v 1.36 2001/09/14 07:10:09 guy Exp $" in the comment will be updated by CVS when the file is checked in; it will allow the RCS "ident" command to report which version of the file is currently checked out. @@ -95,7 +95,7 @@ version of the file is currently checked out. * Routines for PROTONAME dissection * Copyright 2000, YOUR_NAME * - * $Id: README.developer,v 1.35 2001/08/31 09:04:36 guy Exp $ + * $Id: README.developer,v 1.36 2001/09/14 07:10:09 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -1091,9 +1091,14 @@ the protocol tree when the dissector routines wants complete control over how the field and value will be represented on the GUI tree. For "proto_tree_add_time_format", the "value_ptr" argument is a pointer -to a "struct timeval" containing the time to be added; for those other -functions that take a "value_ptr" argument, that argument is a pointer -to the first byte of the value to be added. +to an "nstime_t", which is a structure containing the time to be added; +it has "secs" and "nsecs" members, giving the integral part and the +fractional part of a time in seconds, with "nsecs" being the number of +nanoseconds. For absolute times, "secs" is a UNIX-style seconds since +January 1, 1970, 00:00:00 GMT value. + +For the other functions that take a "value_ptr" argument, that argument +is a pointer to the first byte of the value to be added. For the other functions, the "value" argument is a 32-bit integral value to be added. diff --git a/epan/column-utils.c b/epan/column-utils.c index 15c8776a89..7920072c53 100644 --- a/epan/column-utils.c +++ b/epan/column-utils.c @@ -1,7 +1,7 @@ /* column-utils.c * Routines for column utilities. * - * $Id: column-utils.c,v 1.4 2001/07/15 19:14:02 guy Exp $ + * $Id: column-utils.c,v 1.5 2001/09/14 07:10:10 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -268,7 +268,7 @@ static void col_set_rel_time(frame_data *fd, int col) { display_signed_time(fd->cinfo->col_buf[col], COL_MAX_LEN, - fd->rel_secs, fd->rel_usecs); + fd->rel_secs, fd->rel_usecs, USECS); fd->cinfo->col_data[col] = fd->cinfo->col_buf[col]; } @@ -276,7 +276,7 @@ static void col_set_delta_time(frame_data *fd, int col) { display_signed_time(fd->cinfo->col_buf[col], COL_MAX_LEN, - fd->del_secs, fd->del_usecs); + fd->del_secs, fd->del_usecs, USECS); fd->cinfo->col_data[col] = fd->cinfo->col_buf[col]; } diff --git a/epan/ftypes/ftype-time.c b/epan/ftypes/ftype-time.c index aeab4c1c8e..e04055b631 100644 --- a/epan/ftypes/ftype-time.c +++ b/epan/ftypes/ftype-time.c @@ -1,5 +1,5 @@ /* - * $Id: ftype-time.c,v 1.10 2001/07/13 00:55:56 guy Exp $ + * $Id: ftype-time.c,v 1.11 2001/09/14 07:10:13 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -46,62 +46,62 @@ static gboolean cmp_eq(fvalue_t *a, fvalue_t *b) { - return ((a->value.time.tv_sec) ==(b->value.time.tv_sec)) - &&((a->value.time.tv_usec)==(b->value.time.tv_usec)); + return ((a->value.time.secs) ==(b->value.time.secs)) + &&((a->value.time.nsecs)==(b->value.time.nsecs)); } static gboolean cmp_ne(fvalue_t *a, fvalue_t *b) { - return (a->value.time.tv_sec !=b->value.time.tv_sec) - ||(a->value.time.tv_usec!=b->value.time.tv_usec); + return (a->value.time.secs !=b->value.time.secs) + ||(a->value.time.nsecs!=b->value.time.nsecs); } static gboolean cmp_gt(fvalue_t *a, fvalue_t *b) { - if (a->value.time.tv_sec > b->value.time.tv_sec) { + if (a->value.time.secs > b->value.time.secs) { return TRUE; } - if (a->value.time.tv_sec < b->value.time.tv_sec) { + if (a->value.time.secs < b->value.time.secs) { return FALSE; } - return a->value.time.tv_usec > b->value.time.tv_usec; + return a->value.time.nsecs > b->value.time.nsecs; } static gboolean cmp_ge(fvalue_t *a, fvalue_t *b) { - if (a->value.time.tv_sec > b->value.time.tv_sec) { + if (a->value.time.secs > b->value.time.secs) { return TRUE; } - if (a->value.time.tv_sec < b->value.time.tv_sec) { + if (a->value.time.secs < b->value.time.secs) { return FALSE; } - return a->value.time.tv_usec >= b->value.time.tv_usec; + return a->value.time.nsecs >= b->value.time.nsecs; } static gboolean cmp_lt(fvalue_t *a, fvalue_t *b) { - if (a->value.time.tv_sec < b->value.time.tv_sec) { + if (a->value.time.secs < b->value.time.secs) { return TRUE; } - if (a->value.time.tv_sec > b->value.time.tv_sec) { + if (a->value.time.secs > b->value.time.secs) { return FALSE; } - return a->value.time.tv_usec < b->value.time.tv_usec; + return a->value.time.nsecs < b->value.time.nsecs; } static gboolean cmp_le(fvalue_t *a, fvalue_t *b) { - if (a->value.time.tv_sec < b->value.time.tv_sec) { + if (a->value.time.secs < b->value.time.secs) { return TRUE; } - if (a->value.time.tv_sec > b->value.time.tv_sec) { + if (a->value.time.secs > b->value.time.secs) { return FALSE; } - return a->value.time.tv_usec <= b->value.time.tv_usec; + return a->value.time.nsecs <= b->value.time.nsecs; } @@ -120,7 +120,7 @@ relative_val_from_string(fvalue_t *fv, char *s, LogFunc log) /* * Get the seconds value. */ - fv->value.time.tv_sec = strtoul(curptr, &endptr, 10); + fv->value.time.secs = strtoul(curptr, &endptr, 10); if (endptr == curptr || (*endptr != '\0' && *endptr != '.')) goto fail; curptr = endptr; @@ -130,26 +130,26 @@ relative_val_from_string(fvalue_t *fv, char *s, LogFunc log) /* * No seconds value - it's 0. */ - fv->value.time.tv_sec = 0; + fv->value.time.secs = 0; curptr++; /* skip the decimal point */ } /* * If there's more stuff left in the string, it should be the - * microseconds value. + * nanoseconds value. */ if (*endptr != '\0') { /* - * Get the microseconds value. + * Get the nanoseconds value. */ - fv->value.time.tv_usec = strtoul(curptr, &endptr, 10); + fv->value.time.nsecs = strtoul(curptr, &endptr, 10); if (endptr == curptr || *endptr != '\0') goto fail; } else { /* - * No microseconds value - it's 0. + * No nanoseconds value - it's 0. */ - fv->value.time.tv_usec = 0; + fv->value.time.nsecs = 0; } /* @@ -174,28 +174,28 @@ absolute_val_from_string(fvalue_t *fv, char *s, LogFunc log) if (curptr == NULL) goto fail; tm.tm_isdst = -1; /* let the computer figure out if it's DST */ - fv->value.time.tv_sec = mktime(&tm); + fv->value.time.secs = mktime(&tm); if (*curptr != '\0') { /* * Something came after the seconds field; it must be - * a microseconds field. + * a nanoseconds field. */ if (*curptr != '.') goto fail; /* it's not */ curptr++; /* skip the "." */ if (!isdigit((unsigned char)*curptr)) goto fail; /* not a digit, so not valid */ - fv->value.time.tv_usec = strtoul(curptr, &endptr, 10); + fv->value.time.nsecs = strtoul(curptr, &endptr, 10); if (endptr == curptr || *endptr != '\0') goto fail; } else { /* - * No microseconds value - it's 0. + * No nanoseconds value - it's 0. */ - fv->value.time.tv_usec = 0; + fv->value.time.nsecs = 0; } - if (fv->value.time.tv_sec == -1) { + if (fv->value.time.secs == -1) { /* * XXX - should we supply an error message that mentions * that the time specified might be syntactically valid @@ -221,15 +221,15 @@ fail: static void time_fvalue_new(fvalue_t *fv) { - fv->value.time.tv_sec = 0; - fv->value.time.tv_usec = 0; + fv->value.time.secs = 0; + fv->value.time.nsecs = 0; } static void time_fvalue_set(fvalue_t *fv, gpointer value, gboolean already_copied) { g_assert(!already_copied); - memcpy(&(fv->value.time), value, sizeof(struct timeval)); + memcpy(&(fv->value.time), value, sizeof(nstime_t)); } static gpointer diff --git a/epan/ftypes/ftypes.h b/epan/ftypes/ftypes.h index 1e0dcf7dd2..5c7b047bbb 100644 --- a/epan/ftypes/ftypes.h +++ b/epan/ftypes/ftypes.h @@ -1,7 +1,7 @@ /* ftypes.h * Definitions for field types * - * $Id: ftypes.h,v 1.3 2001/08/12 11:46:23 sharpe Exp $ + * $Id: ftypes.h,v 1.4 2001/09/14 07:10:13 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -122,6 +122,7 @@ ftype_can_le(enum ftenum ftype); #endif #include "tvbuff.h" +#include "nstime.h" #include "dfilter/drange.h" typedef struct { @@ -135,7 +136,7 @@ typedef struct { GByteArray *bytes; ipv4_addr ipv4; guint8 ipv6[16]; - struct timeval time; + nstime_t time; tvbuff_t *tvb; } value; } fvalue_t; diff --git a/epan/proto.c b/epan/proto.c index 62786df695..9921bd71b6 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -1,7 +1,7 @@ /* proto.c * Routines for protocol tree * - * $Id: proto.c,v 1.34 2001/08/29 00:51:08 guy Exp $ + * $Id: proto.c,v 1.35 2001/09/14 07:10:10 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -85,7 +85,7 @@ proto_tree_set_bytes(field_info *fi, const guint8* start_ptr, gint length); static void proto_tree_set_bytes_tvb(field_info *fi, tvbuff_t *tvb, gint offset, gint length); static void -proto_tree_set_time(field_info *fi, struct timeval *value_ptr); +proto_tree_set_time(field_info *fi, nstime_t *value_ptr); static void proto_tree_set_string(field_info *fi, const char* value); static void @@ -725,7 +725,7 @@ proto_tree_set_bytes_tvb(field_info *fi, tvbuff_t *tvb, gint offset, gint length /* Add a FT_*TIME to a proto_tree */ proto_item * proto_tree_add_time(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, gint length, - struct timeval *value_ptr) + nstime_t *value_ptr) { proto_item *pi; field_info *new_fi; @@ -746,7 +746,7 @@ proto_tree_add_time(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, gi proto_item * proto_tree_add_time_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, gint length, - struct timeval *value_ptr) + nstime_t *value_ptr) { proto_item *pi; field_info *fi; @@ -763,7 +763,7 @@ proto_tree_add_time_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint st proto_item * proto_tree_add_time_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, gint length, - struct timeval *value_ptr, const char *format, ...) + nstime_t *value_ptr, const char *format, ...) { proto_item *pi; va_list ap; @@ -781,7 +781,7 @@ proto_tree_add_time_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint st /* Set the FT_*TIME value */ static void -proto_tree_set_time(field_info *fi, struct timeval *value_ptr) +proto_tree_set_time(field_info *fi, nstime_t *value_ptr) { fvalue_set(fi->value, value_ptr, FALSE); } @@ -2980,7 +2980,7 @@ proto_alloc_dfilter_string(field_info *finfo, guint8 *pd) case FT_ABSOLUTE_TIME: value_str = - abs_time_to_str((struct timeval *)fvalue_get(finfo->value)); + abs_time_to_str((nstime_t *)fvalue_get(finfo->value)); dfilter_len = abbrev_len + strlen(value_str) + 7; buf = g_malloc0(dfilter_len); snprintf(buf, dfilter_len, "%s == \"%s\"", @@ -2989,7 +2989,7 @@ proto_alloc_dfilter_string(field_info *finfo, guint8 *pd) case FT_RELATIVE_TIME: value_str = - rel_time_to_secs_str((struct timeval *)fvalue_get(finfo->value)); + rel_time_to_secs_str((nstime_t *)fvalue_get(finfo->value)); dfilter_len = abbrev_len + strlen(value_str) + 4; buf = g_malloc0(dfilter_len); snprintf(buf, dfilter_len, "%s == %s", diff --git a/epan/proto.h b/epan/proto.h index 81fdc48dfb..dedc478b2e 100644 --- a/epan/proto.h +++ b/epan/proto.h @@ -1,7 +1,7 @@ /* proto.h * Definitions for protocol display * - * $Id: proto.h,v 1.16 2001/08/29 00:51:08 guy Exp $ + * $Id: proto.h,v 1.17 2001/09/14 07:10:10 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -26,10 +26,6 @@ #ifndef __PROTO_H__ #define __PROTO_H__ -#ifdef HAVE_SYS_TIME_H -# include -#endif - #ifdef HAVE_STDARG_H # include #else @@ -41,6 +37,7 @@ #endif #include "ipv4.h" +#include "nstime.h" #include "tvbuff.h" #include "ftypes/ftypes.h" @@ -241,21 +238,21 @@ proto_tree_add_bytes_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint s /* Add a FT_*TIME to a proto_tree */ proto_item * proto_tree_add_time(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, - gint length, struct timeval* value_ptr); + gint length, nstime_t* value_ptr); proto_item * proto_tree_add_time_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, - gint length, struct timeval* value_ptr); + gint length, nstime_t* value_ptr); #if __GNUC__ >= 2 proto_item * proto_tree_add_time_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, - gint length, struct timeval* value_ptr, const char *format, ...) + gint length, nstime_t* value_ptr, const char *format, ...) __attribute__((format (printf, 7, 8))); #else proto_item * proto_tree_add_time_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, - gint length, struct timeval* value_ptr, const char *format, ...); + gint length, nstime_t* value_ptr, const char *format, ...); #endif /* Add a FT_IPXNET to a proto_tree */ diff --git a/epan/to_str.c b/epan/to_str.c index 01c64fba66..5e13e735a2 100644 --- a/epan/to_str.c +++ b/epan/to_str.c @@ -1,7 +1,7 @@ /* to_str.c * Routines for utilities to convert various other types to strings. * - * $Id: to_str.c,v 1.11 2001/08/01 08:27:00 guy Exp $ + * $Id: to_str.c,v 1.12 2001/09/14 07:10:10 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -38,7 +38,7 @@ #endif #ifdef HAVE_WINSOCK_H -# include /* for "struct timeval" and "u_char" */ +# include /* for "u_char" */ #endif #ifdef NEED_SNPRINTF_H @@ -277,11 +277,11 @@ vines_addr_to_str(const guint8 *addrp) * Convert a value in seconds and fractions of a second to a string, * giving time in days, hours, minutes, and seconds, and put the result * into a buffer. - * "is_usecs" says that "frac" is microseconds if true and milliseconds + * "is_nsecs" says that "frac" is microseconds if true and milliseconds * if false. */ static void -time_secs_to_str_buf(guint32 time, guint32 frac, gboolean is_usecs, +time_secs_to_str_buf(guint32 time, guint32 frac, gboolean is_nsecs, gchar *buf) { static gchar *p; @@ -316,8 +316,8 @@ time_secs_to_str_buf(guint32 time, guint32 frac, gboolean is_usecs, do_comma = 0; if (secs != 0 || frac != 0) { if (frac != 0) { - if (is_usecs) - sprintf(p, "%s%u.%06u seconds", COMMA(do_comma), secs, frac); + if (is_nsecs) + sprintf(p, "%s%u.%09u seconds", COMMA(do_comma), secs, frac); else sprintf(p, "%s%u.%03u seconds", COMMA(do_comma), secs, frac); } else @@ -391,7 +391,7 @@ static const char *mon_names[12] = { }; gchar * -abs_time_to_str(struct timeval *abs_time) +abs_time_to_str(nstime_t *abs_time) { struct tm *tmp; static gchar *cur; @@ -405,16 +405,16 @@ abs_time_to_str(struct timeval *abs_time) cur = &str[0][0]; } - tmp = localtime(&abs_time->tv_sec); + tmp = localtime(&abs_time->secs); if (tmp) { - sprintf(cur, "%s %2d, %d %02d:%02d:%02d.%06ld", + sprintf(cur, "%s %2d, %d %02d:%02d:%02d.%09ld", mon_names[tmp->tm_mon], tmp->tm_mday, tmp->tm_year + 1900, tmp->tm_hour, tmp->tm_min, tmp->tm_sec, - (long)abs_time->tv_usec); + (long)abs_time->nsecs); } else { strncpy(cur, "Not representable", sizeof(str[0])); } @@ -422,35 +422,49 @@ abs_time_to_str(struct timeval *abs_time) } void -display_signed_time(gchar *buf, int buflen, gint32 sec, gint32 usec) +display_signed_time(gchar *buf, int buflen, gint32 sec, gint32 frac, + time_res_t units) { char *sign; - /* If the microseconds part of the time stamp is negative, + /* If the fractional part of the time stamp is negative, print its absolute value and, if the seconds part isn't (the seconds part should be zero in that case), stick a "-" in front of the entire time stamp. */ sign = ""; - if (usec < 0) { - usec = -usec; + if (frac < 0) { + frac = -frac; if (sec >= 0) sign = "-"; } - snprintf(buf, buflen, "%s%d.%06d", sign, sec, usec); + switch (units) { + + case MSECS: + snprintf(buf, buflen, "%s%d.%03d", sign, sec, frac); + break; + + case USECS: + snprintf(buf, buflen, "%s%d.%06d", sign, sec, frac); + break; + + case NSECS: + snprintf(buf, buflen, "%s%d.%09d", sign, sec, frac); + break; + } } /* * Display a relative time as days/hours/minutes/seconds. */ gchar * -rel_time_to_str(struct timeval *rel_time) +rel_time_to_str(nstime_t *rel_time) { static gchar *cur; static char str[3][1+TIME_SECS_LEN+1+6+1]; char *p; char *sign; guint32 time; - gint32 usec; + gint32 nsec; if (cur == &str[0][0]) { cur = &str[1][0]; @@ -461,40 +475,40 @@ rel_time_to_str(struct timeval *rel_time) } p = cur; - /* If the microseconds part of the time stamp is negative, + /* If the nanoseconds part of the time stamp is negative, print its absolute value and, if the seconds part isn't (the seconds part should be zero in that case), stick a "-" in front of the entire time stamp. */ sign = ""; - time = rel_time->tv_sec; - usec = rel_time->tv_usec; - if (time == 0 && usec == 0) { - sprintf(cur, "0.000000 seconds"); + time = rel_time->secs; + nsec = rel_time->nsecs; + if (time == 0 && nsec == 0) { + sprintf(cur, "0.000000000 seconds"); return cur; } - if (usec < 0) { - usec = -usec; + if (nsec < 0) { + nsec = -nsec; *p++ = '-'; /* - * We assume here that "rel_time->tv_sec" is negative + * We assume here that "rel_time->secs" is negative * or zero; if it's not, the time stamp is bogus, * with a positive seconds and negative microseconds. */ - time = -rel_time->tv_sec; + time = -rel_time->secs; } - time_secs_to_str_buf(time, usec, TRUE, p); + time_secs_to_str_buf(time, nsec, TRUE, p); return cur; } -#define REL_TIME_SECS_LEN (1+10+1+6+1) +#define REL_TIME_SECS_LEN (1+10+1+9+1) /* * Display a relative time as seconds. */ gchar * -rel_time_to_secs_str(struct timeval *rel_time) +rel_time_to_secs_str(nstime_t *rel_time) { static gchar *cur; static char str[3][REL_TIME_SECS_LEN]; @@ -507,8 +521,8 @@ rel_time_to_secs_str(struct timeval *rel_time) cur = &str[0][0]; } - display_signed_time(cur, REL_TIME_SECS_LEN, rel_time->tv_sec, - rel_time->tv_usec); + display_signed_time(cur, REL_TIME_SECS_LEN, rel_time->secs, + rel_time->nsecs, NSECS); return cur; } diff --git a/epan/to_str.h b/epan/to_str.h index e706f9e60b..18a412f90e 100644 --- a/epan/to_str.h +++ b/epan/to_str.h @@ -1,7 +1,7 @@ /* to_str.h * Definitions for utilities to convert various other types to strings. * - * $Id: to_str.h,v 1.4 2001/08/01 08:27:00 guy Exp $ + * $Id: to_str.h,v 1.5 2001/09/14 07:10:10 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -25,7 +25,7 @@ #ifndef __TO_STR_H__ #define __TO_STR_H__ -#include "glib.h" +#include #ifdef HAVE_SYS_TYPES_H # include @@ -35,6 +35,17 @@ # include #endif +#include "nstime.h" + +/* + * Resolution of a time stamp. + */ +typedef enum { + MSECS, /* milliseconds */ + USECS, /* microseconds */ + NSECS /* nanoseconds */ +} time_res_t; + /* * These are utility functions which convert various types to strings, * but for which no more specific module applies. @@ -52,10 +63,10 @@ gchar* ipxnet_to_str_punct(const guint32 ad, char punct); gchar* vines_addr_to_str(const guint8 *addrp); gchar* time_secs_to_str(guint32); gchar* time_msecs_to_str(guint32); -gchar* abs_time_to_str(struct timeval*); -void display_signed_time(gchar *, int, gint32, gint32); -gchar* rel_time_to_str(struct timeval*); -gchar* rel_time_to_secs_str(struct timeval*); +gchar* abs_time_to_str(nstime_t*); +void display_signed_time(gchar *, int, gint32, gint32, time_res_t); +gchar* rel_time_to_str(nstime_t*); +gchar* rel_time_to_secs_str(nstime_t*); char * decode_bitfield_value(char *buf, guint32 val, guint32 mask, int width); diff --git a/packet-afs-macros.h b/packet-afs-macros.h index 71bacac162..a523366949 100644 --- a/packet-afs-macros.h +++ b/packet-afs-macros.h @@ -8,7 +8,7 @@ * Portions based on information/specs retrieved from the OpenAFS sources at * www.openafs.org, Copyright IBM. * - * $Id: packet-afs-macros.h,v 1.11 2001/07/16 05:16:57 guy Exp $ + * $Id: packet-afs-macros.h,v 1.12 2001/09/14 07:10:05 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -66,21 +66,22 @@ tvb_get_letohl(tvb, offset));\ offset += 4; -/* Output a UNIX seconds/microseconds timestamp, after converting to a timeval */ +/* Output a UNIX seconds/microseconds timestamp, after converting to an + nstime_t */ #define OUT_TIMESTAMP(field) \ - { struct timeval tv; \ - tv.tv_sec = tvb_get_ntohl(tvb, offset); \ - tv.tv_usec = tvb_get_ntohl(tvb, offset); \ - proto_tree_add_time(tree,field, tvb,offset,2*sizeof(guint32),&tv); \ + { nstime_t ts; \ + ts.secs = tvb_get_ntohl(tvb, offset); \ + ts.nsecs = tvb_get_ntohl(tvb, offset)*1000; \ + proto_tree_add_time(tree,field, tvb,offset,2*sizeof(guint32),&ts); \ offset += 8; \ } -/* Output a UNIX seconds-only timestamp, after converting to a timeval */ +/* Output a UNIX seconds-only timestamp, after converting to an nstime_t */ #define OUT_DATE(field) \ - { struct timeval tv; \ - tv.tv_sec = tvb_get_ntohl(tvb, offset); \ - tv.tv_usec = 0; \ - proto_tree_add_time(tree,field, tvb,offset,sizeof(guint32),&tv); \ + { nstime_t ts; \ + ts.secs = tvb_get_ntohl(tvb, offset); \ + ts.nsecs = 0; \ + proto_tree_add_time(tree,field, tvb,offset,sizeof(guint32),&ts); \ offset += 4; \ } @@ -466,20 +467,20 @@ #define OUT_UBIKVERSION(label) \ { proto_tree *save, *ti; \ unsigned int epoch,counter; \ - struct timeval tv; \ + nstime_t ts; \ epoch = tvb_get_ntohl(tvb, offset); \ offset += 4; \ counter = tvb_get_ntohl(tvb, offset); \ offset += 4; \ - tv.tv_sec = epoch; \ - tv.tv_usec = 0; \ + ts.secs = epoch; \ + ts.nsecs = 0; \ ti = proto_tree_add_text(tree, tvb, offset-8, 8, \ "UBIK Version (%s): %u.%u", label, epoch, counter ); \ save = tree; \ tree = proto_item_add_subtree(ti, ett_afs_ubikver); \ if ( epoch != 0 ) \ proto_tree_add_time(tree,hf_afs_ubik_version_epoch, tvb,offset-8, \ - sizeof(guint32),&tv); \ + sizeof(guint32),&ts); \ else \ proto_tree_add_text(tree, tvb, offset-8, \ sizeof(guint32),"Epoch: 0"); \ diff --git a/packet-dns.c b/packet-dns.c index c8af6e6eb4..5ca792e719 100644 --- a/packet-dns.c +++ b/packet-dns.c @@ -1,7 +1,7 @@ /* packet-dns.c * Routines for DNS packet disassembly * - * $Id: packet-dns.c,v 1.72 2001/08/29 00:51:06 guy Exp $ + * $Id: packet-dns.c,v 1.73 2001/09/14 07:10:05 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -1071,7 +1071,7 @@ dissect_dns_answer(tvbuff_t *tvb, int offset, int dns_data_offset, { int rr_len = data_len; guint16 type_covered; - struct timeval unixtime; + nstime_t nstime; char signer_name[MAXDNAME]; int signer_name_len; @@ -1099,17 +1099,17 @@ dissect_dns_answer(tvbuff_t *tvb, int offset, int dns_data_offset, cur_offset += 4; rr_len -= 4; - unixtime.tv_sec = tvb_get_ntohl(tvb, cur_offset); - unixtime.tv_usec = 0; + nstime.secs = tvb_get_ntohl(tvb, cur_offset); + nstime.nsecs = 0; proto_tree_add_text(rr_tree, tvb, cur_offset, 4, "Signature expiration: %s", - abs_time_to_str(&unixtime)); + abs_time_to_str(&nstime)); cur_offset += 4; rr_len -= 4; - unixtime.tv_sec = tvb_get_ntohl(tvb, cur_offset); - unixtime.tv_usec = 0; + nstime.secs = tvb_get_ntohl(tvb, cur_offset); + nstime.nsecs = 0; proto_tree_add_text(rr_tree, tvb, cur_offset, 4, "Time signed: %s", - abs_time_to_str(&unixtime)); + abs_time_to_str(&nstime)); cur_offset += 4; rr_len -= 4; @@ -1437,7 +1437,7 @@ dissect_dns_answer(tvbuff_t *tvb, int offset, int dns_data_offset, int tkey_algname_len; guint16 tkey_mode, tkey_error, tkey_keylen, tkey_otherlen; int rr_len = data_len; - struct timeval unixtime; + nstime_t nstime; static const value_string tkey_modes[] = { { TKEYMODE_SERVERASSIGNED, "Server assigned" }, { TKEYMODE_DIFFIEHELLMAN, "Diffie Hellman" }, @@ -1453,17 +1453,17 @@ dissect_dns_answer(tvbuff_t *tvb, int offset, int dns_data_offset, cur_offset += tkey_algname_len; rr_len -= tkey_algname_len; - unixtime.tv_sec = tvb_get_ntohl(tvb, cur_offset); - unixtime.tv_usec = 0; + nstime.secs = tvb_get_ntohl(tvb, cur_offset); + nstime.nsecs = 0; proto_tree_add_text(rr_tree, tvb, cur_offset, 4, "Signature inception: %s", - abs_time_to_str(&unixtime)); + abs_time_to_str(&nstime)); cur_offset += 4; rr_len -= 4; - unixtime.tv_sec = tvb_get_ntohl(tvb, cur_offset); - unixtime.tv_usec = 0; + nstime.secs = tvb_get_ntohl(tvb, cur_offset); + nstime.nsecs = 0; proto_tree_add_text(rr_tree, tvb, cur_offset, 4, "Signature expiration: %s", - abs_time_to_str(&unixtime)); + abs_time_to_str(&nstime)); cur_offset += 4; rr_len -= 4; @@ -1508,7 +1508,7 @@ dissect_dns_answer(tvbuff_t *tvb, int offset, int dns_data_offset, guint32 tsig_timelo; char tsig_algname[MAXDNAME]; int tsig_algname_len; - struct timeval unixtime; + nstime_t nstime; int rr_len = data_len; if (dns_tree != NULL) { @@ -1520,10 +1520,10 @@ dissect_dns_answer(tvbuff_t *tvb, int offset, int dns_data_offset, tsig_timehi = tvb_get_ntohs(tvb, cur_offset); tsig_timelo = tvb_get_ntohl(tvb, cur_offset + 2); - unixtime.tv_sec = tsig_timelo; - unixtime.tv_usec = 0; + nstime.secs = tsig_timelo; + nstime.nsecs = 0; proto_tree_add_text(rr_tree, tvb, cur_offset, 6, "Time signed: %s%s", - abs_time_to_str(&unixtime), tsig_timehi == 0 ? "" : "(high bits set)"); + abs_time_to_str(&nstime), tsig_timehi == 0 ? "" : "(high bits set)"); cur_offset += 6; rr_len -= 6; diff --git a/packet-frame.c b/packet-frame.c index 419bca6994..1fe0ac4c78 100644 --- a/packet-frame.c +++ b/packet-frame.c @@ -2,7 +2,7 @@ * * Top-most dissector. Decides dissector based on Wiretap Encapsulation Type. * - * $Id: packet-frame.c,v 1.8 2001/06/18 02:17:46 guy Exp $ + * $Id: packet-frame.c,v 1.9 2001/09/14 07:10:05 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -60,7 +60,7 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { proto_tree *fh_tree; proto_item *ti; - struct timeval tv; + nstime_t ts; int cap_len, pkt_len; pinfo->current_proto = "Frame"; @@ -82,23 +82,23 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) fh_tree = proto_item_add_subtree(ti, ett_frame); - tv.tv_sec = pinfo->fd->abs_secs; - tv.tv_usec = pinfo->fd->abs_usecs; + ts.secs = pinfo->fd->abs_secs; + ts.nsecs = pinfo->fd->abs_usecs*1000; proto_tree_add_time(fh_tree, hf_frame_arrival_time, tvb, - 0, 0, &tv); + 0, 0, &ts); - tv.tv_sec = pinfo->fd->del_secs; - tv.tv_usec = pinfo->fd->del_usecs; + ts.secs = pinfo->fd->del_secs; + ts.nsecs = pinfo->fd->del_usecs*1000; proto_tree_add_time(fh_tree, hf_frame_time_delta, tvb, - 0, 0, &tv); + 0, 0, &ts); - tv.tv_sec = pinfo->fd->rel_secs; - tv.tv_usec = pinfo->fd->rel_usecs; + ts.secs = pinfo->fd->rel_secs; + ts.nsecs = pinfo->fd->rel_usecs*1000; proto_tree_add_time(fh_tree, hf_frame_time_relative, tvb, - 0, 0, &tv); + 0, 0, &ts); proto_tree_add_uint(fh_tree, hf_frame_number, tvb, 0, 0, pinfo->fd->num); diff --git a/packet-lmi.c b/packet-lmi.c index 67fa7749e3..2b3055a75f 100644 --- a/packet-lmi.c +++ b/packet-lmi.c @@ -2,12 +2,11 @@ * Routines for Frame Relay Local Management Interface (LMI) disassembly * Copyright 2001, Jeffrey C. Foster * - * $Id: packet-lmi.c,v 1.5 2001/06/18 02:17:48 guy Exp $ + * $Id: packet-lmi.c,v 1.6 2001/09/14 07:10:05 guy Exp $ * * Ethereal - Network traffic analyzer - * By Gerald Combs + * By Gerald Combs * Copyright 1998 - * * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -160,7 +159,7 @@ dissect_lmi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_uint(lmi_tree, hf_lmi_msg_type, tvb, 1, 1, tvb_get_guint8( tvb, 1)); /* Display the LMI elements */ - while( offset < tvb_length( tvb)){ + while (tvb_reported_length_remaining(tvb, offset) > 0) { ele_id = tvb_get_guint8( tvb, offset); len = tvb_get_guint8( tvb, offset + 1); diff --git a/packet-mbtcp.c b/packet-mbtcp.c index 5248e1de71..bb110ba579 100644 --- a/packet-mbtcp.c +++ b/packet-mbtcp.c @@ -10,7 +10,7 @@ * * for information on Modbus/TCP. * - * $Id: packet-mbtcp.c,v 1.4 2001/06/18 02:17:48 guy Exp $ + * $Id: packet-mbtcp.c,v 1.5 2001/09/14 07:10:05 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -323,7 +323,7 @@ dissect_mbtcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } offset = offset + sizeof(mbtcp_hdr) + (mh.len - sizeof(modbus_hdr)); packet_num++; - } while ( offset < tvb_length(tvb) ); + } while ( tvb_reported_length_remaining(tvb, offset) > 0 ); /* Update entries in Info column on summary display */ diff --git a/packet-mip.c b/packet-mip.c index 3b129cc421..c789ee0a07 100644 --- a/packet-mip.c +++ b/packet-mip.c @@ -2,7 +2,7 @@ * Routines for Mobile IP dissection * Copyright 2000, Stefan Raab * - * $Id: packet-mip.c,v 1.18 2001/06/18 02:17:49 guy Exp $ + * $Id: packet-mip.c,v 1.19 2001/09/14 07:10:05 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -141,8 +141,8 @@ dissect_mip( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_item *ti; proto_tree *mip_tree=NULL, *ext_tree=NULL; guint8 type, code; - struct timeval ident_time; - int eoffset, elen; + nstime_t ident_time; + int eoffset, elen; /* Make entries in Protocol column and Info column on summary display */ @@ -177,12 +177,13 @@ dissect_mip( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_item(mip_tree, hf_mip_homeaddr, tvb, 4, 4, FALSE); proto_tree_add_item(mip_tree, hf_mip_haaddr, tvb, 8, 4, FALSE); proto_tree_add_item(mip_tree, hf_mip_coa, tvb, 12, 4, FALSE); - ident_time.tv_sec = tvb_get_ntohl(tvb,16)-(guint32) NTP_BASETIME; - ident_time.tv_usec = tvb_get_ntohl(tvb,20); + ident_time.secs = tvb_get_ntohl(tvb,16)-(guint32) NTP_BASETIME; + ident_time.nsecs = tvb_get_ntohl(tvb,20)*1000; proto_tree_add_time(mip_tree, hf_mip_ident, tvb, 16, 8, &ident_time); eoffset = 24; - while (eoffset < tvb_length(tvb)) { /* Registration Extensions */ + while (tvb_reported_length_remaining(tvb, eoffset) > 0) { + /* Registration Extensions */ if (eoffset ==24) { ti = proto_tree_add_text(mip_tree, tvb, 24, tvb_length(tvb)-24, "Extensions"); ext_tree = proto_item_add_subtree(ti, ett_mip_ext); @@ -232,12 +233,13 @@ dissect_mip( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_item(mip_tree, hf_mip_life, tvb, 2, 2, FALSE); proto_tree_add_item(mip_tree, hf_mip_homeaddr, tvb, 4, 4, FALSE); proto_tree_add_item(mip_tree, hf_mip_haaddr, tvb, 8, 4, FALSE); - ident_time.tv_sec = tvb_get_ntohl(tvb,12)-(guint32) NTP_BASETIME; - ident_time.tv_usec = tvb_get_ntohl(tvb,16); + ident_time.secs = tvb_get_ntohl(tvb,12)-(guint32) NTP_BASETIME; + ident_time.nsecs = tvb_get_ntohl(tvb,16)*1000; proto_tree_add_time(mip_tree, hf_mip_ident, tvb, 12, 8, &ident_time); eoffset = 20; - while (eoffset < tvb_length(tvb)) { /* Registration Extensions */ + while (tvb_reported_length_remaining(tvb, eoffset) > 0) { + /* Registration Extensions */ if (eoffset==20) { ti = proto_tree_add_text(mip_tree, tvb, 20, tvb_length(tvb)-20, "Extensions"); ext_tree = proto_item_add_subtree(ti, ett_mip_ext); diff --git a/packet-netbios.c b/packet-netbios.c index 4a2f5ca98e..d6b48a68f1 100644 --- a/packet-netbios.c +++ b/packet-netbios.c @@ -5,12 +5,11 @@ * * derived from the packet-nbns.c * - * $Id: packet-netbios.c,v 1.34 2001/06/18 02:17:49 guy Exp $ + * $Id: packet-netbios.c,v 1.35 2001/09/14 07:10:05 guy Exp $ * * Ethereal - Network traffic analyzer - * By Gerald Combs + * By Gerald Combs * Copyright 1998 Gerald Combs - * * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -27,8 +26,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - - #ifdef HAVE_CONFIG_H # include "config.h" #endif @@ -1037,10 +1034,11 @@ dissect_netbios(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) (dissect_netb[ command])( tvb, offset, netb_tree); } - /* Test for SMB data */ - if ( tvb_length(tvb)> ( hdr_len + 4)){ /* if enough data */ + offset += hdr_len; /* move past header */ - offset += hdr_len; /* move past header */ + /* Test for SMB data */ + + if (tvb_bytes_exist(tvb, offset, 4)){ /* if enough data */ if (( tvb_get_guint8( tvb, offset) == 0xff) && /* if SMB marker */ ( tvb_get_guint8( tvb, offset + 1) == 'S') && diff --git a/packet-nisplus.c b/packet-nisplus.c index 79cf345f75..52fd14fd34 100644 --- a/packet-nisplus.c +++ b/packet-nisplus.c @@ -1,7 +1,7 @@ /* packet-nisplus.c * 2001 Ronnie Sahlberg * - * $Id: packet-nisplus.c,v 1.7 2001/06/18 02:17:50 guy Exp $ + * $Id: packet-nisplus.c,v 1.8 2001/09/14 07:10:05 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -26,7 +26,6 @@ #include "config.h" #endif - #ifdef HAVE_SYS_TYPES_H #include #endif @@ -268,13 +267,13 @@ static const value_string ns_type[] = { static int dissect_nisplus_time(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, int hfindex) { - struct timeval tv; + nstime_t ts; - tv.tv_usec = 0; - tv.tv_sec = tvb_get_ntohl(tvb, offset); + ts.nsecs = 0; + ts.secs = tvb_get_ntohl(tvb, offset); offset += 4; - proto_tree_add_time(tree, hfindex, tvb, offset, 4, &tv); + proto_tree_add_time(tree, hfindex, tvb, offset, 4, &ts); return offset; } diff --git a/packet-osi.c b/packet-osi.c index 4b5c8900a8..1cbf57bc76 100644 --- a/packet-osi.c +++ b/packet-osi.c @@ -2,7 +2,7 @@ * Routines for ISO/OSI network and transport protocol packet disassembly * Main entrance point and common functions * - * $Id: packet-osi.c,v 1.45 2001/06/05 09:06:19 guy Exp $ + * $Id: packet-osi.c,v 1.46 2001/09/14 07:10:05 guy Exp $ * Laurent Deniel * Ralf Schneider * @@ -55,7 +55,7 @@ calc_checksum( tvbuff_t *tvb, int offset, u_int len, u_int checksum) { const guint8 *p; guint32 c0, c1; u_int seglen; - int i; + u_int i; if ( 0 == checksum ) return( NO_CKSUM ); diff --git a/packet-q2931.c b/packet-q2931.c index 06aa06b6bf..40948b98cd 100644 --- a/packet-q2931.c +++ b/packet-q2931.c @@ -2,12 +2,11 @@ * Routines for Q.2931 frame disassembly * Guy Harris * - * $Id: packet-q2931.c,v 1.18 2001/06/18 02:17:50 guy Exp $ + * $Id: packet-q2931.c,v 1.19 2001/09/14 07:10:05 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs * Copyright 1998 - * * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -1974,7 +1973,6 @@ static void dissect_q2931(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { int offset = 0; - guint reported_length; proto_tree *q2931_tree = NULL; proto_item *ti; proto_tree *ext_tree; @@ -2045,8 +2043,7 @@ dissect_q2931(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) */ codeset = 0; /* start out in codeset 0 */ non_locking_shift = TRUE; - reported_length = tvb_reported_length(tvb); - while (offset < reported_length) { + while (tvb_reported_length_remaining(tvb, offset) > 0) { info_element = tvb_get_guint8(tvb, offset); info_element_ext = tvb_get_guint8(tvb, offset + 1); info_element_len = tvb_get_ntohs(tvb, offset + 2); diff --git a/packet-q931.c b/packet-q931.c index c3a46b7e27..b126931b10 100644 --- a/packet-q931.c +++ b/packet-q931.c @@ -2,7 +2,7 @@ * Routines for Q.931 frame disassembly * Guy Harris * - * $Id: packet-q931.c,v 1.31 2001/07/03 04:56:45 guy Exp $ + * $Id: packet-q931.c,v 1.32 2001/09/14 07:10:05 guy Exp $ * * Modified by Andreas Sikkema for possible use with H.323 * @@ -2099,7 +2099,6 @@ q931_dissector(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean started_heuristic) { int offset = 0; - guint reported_length; proto_tree *q931_tree = NULL; proto_item *ti; proto_tree *ie_tree; @@ -2260,8 +2259,7 @@ q931_dissector(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, */ codeset = 0; /* start out in codeset 0 */ non_locking_shift = TRUE; - reported_length = tvb_reported_length(tvb); - while (offset < reported_length) { + while (tvb_reported_length_remaining(tvb, offset) > 0) { info_element = tvb_get_guint8(tvb, offset); /* diff --git a/packet-rx.c b/packet-rx.c index b6d6948755..147adc51ec 100644 --- a/packet-rx.c +++ b/packet-rx.c @@ -4,7 +4,7 @@ * Based on routines from tcpdump patches by * Ken Hornstein * - * $Id: packet-rx.c,v 1.25 2001/08/20 02:11:13 guy Exp $ + * $Id: packet-rx.c,v 1.26 2001/09/14 07:10:05 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -156,12 +156,12 @@ dissect_rx_response_encrypted(tvbuff_t *tvb, packet_info *pinfo, proto_tree *par /* epoch : 4 bytes */ { - struct timeval tv; - tv.tv_sec = tvb_get_ntohl(tvb, offset); - tv.tv_usec = 0; + nstime_t ts; + ts.secs = tvb_get_ntohl(tvb, offset); + ts.nsecs = 0; proto_tree_add_time(tree, hf_rx_epoch, tvb, - offset, 4, &tv); + offset, 4, &ts); offset += 4; } @@ -444,12 +444,12 @@ dissect_rx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) /* epoch : 4 bytes */ { - struct timeval tv; - tv.tv_sec = tvb_get_ntohl(tvb, offset); - tv.tv_usec = 0; + nstime_t ts;; + ts.secs = tvb_get_ntohl(tvb, offset); + ts.nsecs = 0; proto_tree_add_time(tree, hf_rx_epoch, tvb, - offset, 4, &tv); + offset, 4, &ts); offset += 4; } diff --git a/packet-smb-pipe.c b/packet-smb-pipe.c index 482237bcab..daeb4c3883 100644 --- a/packet-smb-pipe.c +++ b/packet-smb-pipe.c @@ -8,7 +8,7 @@ XXX Fixme : shouldnt show [malformed frame] for long packets * significant rewrite to tvbuffify the dissector, Ronnie Sahlberg and * Guy Harris 2001 * - * $Id: packet-smb-pipe.c,v 1.34 2001/08/27 20:04:21 guy Exp $ + * $Id: packet-smb-pipe.c,v 1.35 2001/09/14 07:10:05 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -419,13 +419,13 @@ static int add_reltime(tvbuff_t *tvb, int offset, int count, packet_info *pinfo, proto_tree *tree, int convert, int hf_index) { - struct timeval timeval; + nstime_t nstime; - timeval.tv_sec = tvb_get_letohl(tvb, offset); - timeval.tv_usec = 0; + nstime.secs = tvb_get_letohl(tvb, offset); + nstime.nsecs = 0; proto_tree_add_time_format(tree, hf_index, tvb, offset, 4, - &timeval, "%s: %s", proto_registrar_get_name(hf_index), - time_secs_to_str(timeval.tv_sec)); + &nstime, "%s: %s", proto_registrar_get_name(hf_index), + time_secs_to_str(nstime.secs)); offset += 4; return offset; } @@ -439,14 +439,14 @@ add_abstime_common(tvbuff_t *tvb, int offset, int count, packet_info *pinfo, proto_tree *tree, int convert, int hf_index, const char *absent_name) { - struct timeval timeval; + nstime_t nstime; struct tm *tmp; - timeval.tv_sec = tvb_get_letohl(tvb, offset); - timeval.tv_usec = 0; - if (timeval.tv_sec == -1) { + nstime.secs = tvb_get_letohl(tvb, offset); + nstime.nsecs = 0; + if (nstime.secs == -1) { proto_tree_add_time_format(tree, hf_index, tvb, offset, 4, - &timeval, "%s: %s", proto_registrar_get_name(hf_index), + &nstime, "%s: %s", proto_registrar_get_name(hf_index), absent_name); } else { /* @@ -454,11 +454,11 @@ add_abstime_common(tvbuff_t *tvb, int offset, int count, * run it through "mktime()" to put it back together * as UTC. */ - tmp = gmtime(&timeval.tv_sec); + tmp = gmtime(&nstime.secs); tmp->tm_isdst = -1; /* we don't know if it's DST or not */ - timeval.tv_sec = mktime(tmp); + nstime.secs = mktime(tmp); proto_tree_add_time(tree, hf_index, tvb, offset, 4, - &timeval); + &nstime); } offset += 4; return offset; diff --git a/packet-ssl.c b/packet-ssl.c index b63ea12e05..c75d80c4f4 100644 --- a/packet-ssl.c +++ b/packet-ssl.c @@ -2,7 +2,7 @@ * Routines for ssl dissection * Copyright (c) 2000-2001, Scott Renfro * - * $Id: packet-ssl.c,v 1.6 2001/09/03 10:33:07 guy Exp $ + * $Id: packet-ssl.c,v 1.7 2001/09/14 07:10:06 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -1117,14 +1117,14 @@ dissect_ssl3_hnd_hello_common(tvbuff_t *tvb, proto_tree *tree, { /* show the client's random challenge */ guint32 initial_offset = offset; - struct timeval gmt_unix_time; + nstime_t gmt_unix_time; guint8 session_id_length = 0; if (tree) { /* show the time */ - gmt_unix_time.tv_sec = tvb_get_ntohl(tvb, offset); - gmt_unix_time.tv_usec = 0; + gmt_unix_time.secs = tvb_get_ntohl(tvb, offset); + gmt_unix_time.nsecs = 0; proto_tree_add_time(tree, hf_ssl_handshake_random_time, tvb, offset, 4, &gmt_unix_time); offset += 4; diff --git a/packet-who.c b/packet-who.c index ddc1dc2d19..4e14c6a6d0 100644 --- a/packet-who.c +++ b/packet-who.c @@ -2,7 +2,7 @@ * Routines for who protocol (see man rwhod) * Gilbert Ramirez * - * $Id: packet-who.c,v 1.17 2001/06/18 02:17:54 guy Exp $ + * $Id: packet-who.c,v 1.18 2001/09/14 07:10:06 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -102,7 +102,7 @@ dissect_who(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_item *who_ti = NULL; gchar server_name[33]; double loadav_5 = 0.0, loadav_10 = 0.0, loadav_15 = 0.0; - struct timeval tv; + nstime_t ts; /* Summary information */ if (check_col(pinfo->fd, COL_PROTOCOL)) @@ -110,7 +110,7 @@ dissect_who(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (check_col(pinfo->fd, COL_INFO)) col_clear(pinfo->fd, COL_INFO); - tv.tv_usec = 0; + ts.nsecs = 0; if (tree) { who_ti = proto_tree_add_item(tree, proto_who, tvb, offset, @@ -130,16 +130,16 @@ dissect_who(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) offset += 2; if (tree) { - tv.tv_sec = tvb_get_ntohl(tvb, offset); + ts.secs = tvb_get_ntohl(tvb, offset); proto_tree_add_time(who_tree, hf_who_sendtime, tvb, offset, 4, - &tv); + &ts); } offset += 4; if (tree) { - tv.tv_sec = tvb_get_ntohl(tvb, offset); + ts.secs = tvb_get_ntohl(tvb, offset); proto_tree_add_time(who_tree, hf_who_recvtime, tvb, offset, 4, - &tv); + &ts); } offset += 4; @@ -173,9 +173,9 @@ dissect_who(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) server_name, loadav_5, loadav_10, loadav_15); if (tree) { - tv.tv_sec = tvb_get_ntohl(tvb, offset); + ts.secs = tvb_get_ntohl(tvb, offset); proto_tree_add_time(who_tree, hf_who_boottime, tvb, offset, 4, - &tv); + &ts); offset += 4; dissect_whoent(tvb, offset, who_tree); @@ -195,11 +195,11 @@ dissect_whoent(tvbuff_t *tvb, int offset, proto_tree *tree) int line_offset = offset; gchar out_line[9]; gchar out_name[9]; - struct timeval tv; + nstime_t ts; int whoent_num = 0; guint32 idle_secs; /* say that out loud... */ - tv.tv_usec = 0; + ts.nsecs = 0; while (tvb_reported_length_remaining(tvb, line_offset) > 0 && whoent_num < MAX_NUM_WHOENTS) { @@ -217,9 +217,9 @@ dissect_whoent(tvbuff_t *tvb, int offset, proto_tree *tree) 8, out_name); line_offset += 8; - tv.tv_sec = tvb_get_ntohl(tvb, line_offset); + ts.secs = tvb_get_ntohl(tvb, line_offset); proto_tree_add_time(whoent_tree, hf_who_timeon, tvb, - line_offset, 4, &tv); + line_offset, 4, &ts); line_offset += 4; idle_secs = tvb_get_ntohl(tvb, line_offset); diff --git a/packet-wsp.c b/packet-wsp.c index 83c9126725..8c5d14ea9b 100644 --- a/packet-wsp.c +++ b/packet-wsp.c @@ -2,7 +2,7 @@ * * Routines to dissect WSP component of WAP traffic. * - * $Id: packet-wsp.c,v 1.34 2001/09/03 18:05:57 guy Exp $ + * $Id: packet-wsp.c,v 1.35 2001/09/14 07:10:06 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -1611,7 +1611,7 @@ add_application_header (proto_tree *tree, tvbuff_t *tvb, int offset) int subvalueLen; int subvalueOffset; guint secs; - struct timeval timeValue; + nstime_t timeValue; int asvOffset; guint stringSize; @@ -1643,8 +1643,8 @@ add_application_header (proto_tree *tree, tvbuff_t *tvb, int offset) * there weren't WAP phones or Web servers back in * late 1969/early 1970, they're unlikely to be used. */ - timeValue.tv_sec = secs; - timeValue.tv_usec = 0; + timeValue.secs = secs; + timeValue.nsecs = 0; proto_tree_add_time (tree, hf_wsp_header_x_wap_tod, tvb, startOffset, offset - startOffset, &timeValue); } @@ -2727,7 +2727,7 @@ add_date_value_header (proto_tree *tree, tvbuff_t *header_buff, int valueLen, int hf_time, guint8 headerType) { guint secs; - struct timeval timeValue; + nstime_t timeValue; /* Attempt to get the date value from the buffer */ if (get_integer (value_buff, 0, valueLen, valueType, &secs) == 0) @@ -2741,8 +2741,8 @@ add_date_value_header (proto_tree *tree, tvbuff_t *header_buff, * there weren't WAP phones or Web servers back in * late 1969/early 1970, they're unlikely to be used. */ - timeValue.tv_sec = secs; - timeValue.tv_usec = 0; + timeValue.secs = secs; + timeValue.nsecs = 0; proto_tree_add_time (tree, hf_time, header_buff, 0, headerLen, &timeValue); } diff --git a/packet-wtls.c b/packet-wtls.c index f261baea54..57b9bcd1df 100644 --- a/packet-wtls.c +++ b/packet-wtls.c @@ -2,10 +2,10 @@ * * Routines to dissect WTLS component of WAP traffic. * - * $Id: packet-wtls.c,v 1.11 2001/07/20 09:10:16 guy Exp $ + * $Id: packet-wtls.c,v 1.12 2001/09/14 07:10:06 guy Exp $ * * Ethereal - Network traffic analyzer - * By Gerald Combs + * By Gerald Combs * Copyright 1998 Didier Jorand * * WAP dissector based on original work by Ben Fowler @@ -449,7 +449,7 @@ static void dissect_wtls_handshake(proto_tree *tree, tvbuff_t *tvb, guint offset, guint count) { char pdu_msg_type; - struct timeval timeValue; + nstime_t timeValue; int client_size = 0; guint value = 0; int size = 0; @@ -485,8 +485,8 @@ dissect_wtls_handshake(proto_tree *tree, tvbuff_t *tvb, guint offset, guint coun ti = proto_tree_add_item (wtls_msg_type_item_tree, hf_wtls_hands_cli_hello_version, tvb,offset,1,bo_big_endian); offset++; - timeValue.tv_sec = tvb_get_ntohl (tvb, offset); - timeValue.tv_usec = 0; + timeValue.secs = tvb_get_ntohl (tvb, offset); + timeValue.nsecs = 0; ti = proto_tree_add_time (wtls_msg_type_item_tree, hf_wtls_hands_cli_hello_gmt, tvb, offset, 4, &timeValue); offset+=4; @@ -870,8 +870,8 @@ dissect_wtls_handshake(proto_tree *tree, tvbuff_t *tvb, guint offset, guint coun ti = proto_tree_add_item (wtls_msg_type_item_tree, hf_wtls_hands_serv_hello_version, tvb,offset,1,bo_big_endian); offset++; - timeValue.tv_sec = tvb_get_ntohl (tvb, offset); - timeValue.tv_usec = 0; + timeValue.secs = tvb_get_ntohl (tvb, offset); + timeValue.nsecs = 0; ti = proto_tree_add_time (wtls_msg_type_item_tree, hf_wtls_hands_serv_hello_gmt, tvb, offset, 4, &timeValue); offset+=4; @@ -1008,15 +1008,15 @@ dissect_wtls_handshake(proto_tree *tree, tvbuff_t *tvb, guint offset, guint coun case IDENTIFIER_X509 : break; } - timeValue.tv_sec = tvb_get_ntohl (tvb, offset); - timeValue.tv_usec = 0; + timeValue.secs = tvb_get_ntohl (tvb, offset); + timeValue.nsecs = 0; ti = proto_tree_add_time (wtls_msg_type_item_sub_tree, hf_wtls_hands_certificate_wtls_valid_not_before, tvb, offset, 4, &timeValue); offset+=4; client_size+=4; - timeValue.tv_sec = tvb_get_ntohl (tvb, offset); - timeValue.tv_usec = 0; + timeValue.secs = tvb_get_ntohl (tvb, offset); + timeValue.nsecs = 0; ti = proto_tree_add_time (wtls_msg_type_item_sub_tree, hf_wtls_hands_certificate_wtls_valid_not_after, tvb, offset, 4, &timeValue);