From e7e62591fe23566d2bb5685ade31d2a925ed726c Mon Sep 17 00:00:00 2001 From: ulfl Date: Wed, 24 Aug 2005 21:31:56 +0000 Subject: [PATCH] EVERYTHING IN THE BUILDBOT IS GOING TO BE RED!!! Sorry! I've done more than a day to change the timestamp resolution from microseconds to nanoseconds. As I really don't want to loose those changes, I'm going to check in the changes I've done so far. Hopefully someone else will give me a helping hand with the things left ... What's done: I've changed the timestamp resolution from usec to nsec in almost any place in the sources. I've changed parts of the implementation in nstime.s/.h and a lot of places elsewhere. As I don't understand the editcap source (well, I'm maybe just too tired right now), hopefully someone else might be able to fix this soon. Doing all those changes, we get native nanosecond timestamp resolution in Ethereal. After fixing all the remaining issues, I'll take a look how to display this in a convenient way... As I've also changed the wiretap timestamp resolution from usec to nsec we might want to change the wiretap version number... git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@15520 f5534014-38df-0310-8fa8-9805f1628bb7 --- capinfos.c | 6 +-- cfile.h | 5 ++- epan/column-utils.c | 12 +++--- epan/dissectors/packet-afp.c | 11 ++--- epan/dissectors/packet-afs.c | 14 ++---- epan/dissectors/packet-aoe.c | 14 ++---- epan/dissectors/packet-dcerpc.c | 50 ++++++---------------- epan/dissectors/packet-fc.c | 14 ++---- epan/dissectors/packet-fcp.c | 19 ++++----- epan/dissectors/packet-frame.c | 9 ++-- epan/dissectors/packet-h225.c | 14 ++---- epan/dissectors/packet-iax2.c | 12 +++--- epan/dissectors/packet-iscsi.c | 19 ++------- epan/dissectors/packet-ldap.c | 10 +---- epan/dissectors/packet-ncp2222.inc | 17 ++------ epan/dissectors/packet-nlm.c | 11 +---- epan/dissectors/packet-rlogin.c | 16 +++---- epan/dissectors/packet-rpc.c | 13 ++---- epan/dissectors/packet-rtcp.c | 14 +++--- epan/dissectors/packet-rtcp.h | 3 +- epan/dissectors/packet-smb.c | 8 ++-- epan/dissectors/packet-tcp.c | 68 +++++++++--------------------- epan/frame_data.h | 10 ++--- epan/h225-persistentdata.c | 6 +-- epan/libethereal.def | 7 ++- epan/nstime.c | 37 ++++++++++++++-- epan/nstime.h | 19 ++++++--- epan/stats_tree.c | 8 ++-- epan/stats_tree_priv.h | 4 +- file.c | 59 +++++++++++--------------- gtk/file_dlg.c | 12 ++---- gtk/flow_graph.c | 4 +- gtk/io_stat.c | 5 +-- gtk/main.c | 2 +- gtk/mgcp_stat.c | 7 +-- gtk/packet_list.c | 22 +++++----- gtk/rpc_progs.c | 7 +-- gtk/rtp_analysis.c | 8 ++-- gtk/rtp_stream.c | 16 +++---- gtk/sctp_stat.c | 8 ++-- gtk/service_response_time_table.c | 5 +-- gtk/tcp_graph.c | 16 +++---- gtk/voip_calls.c | 60 +++++++++++++------------- merge.c | 10 ++--- plugins/mate/mate_runtime.c | 2 +- plugins/mgcp/packet-mgcp.c | 11 +---- proto_hier_stats.c | 10 +---- summary.c | 14 ++---- tap-afpstat.c | 5 +-- tap-dcerpcstat.c | 7 +-- tap-iostat.c | 2 +- tap-mgcpstat.c | 7 +-- tap-rpcprogs.c | 7 +-- tap-rpcstat.c | 7 +-- tap-smbstat.c | 5 +-- tethereal.c | 40 +++++++----------- timestats.c | 2 +- wiretap/5views.c | 8 ++-- wiretap/airopeek9.c | 4 +- wiretap/ascend.c | 4 +- wiretap/cosine.c | 4 +- wiretap/csids.c | 4 +- wiretap/dbs-etherwatch.c | 5 +-- wiretap/erf.c | 10 ++--- wiretap/etherpeek.c | 10 ++--- wiretap/eyesdn.c | 4 +- wiretap/file_access.c | 1 + wiretap/hcidump.c | 4 +- wiretap/i4btrace.c | 4 +- wiretap/iptrace.c | 8 ++-- wiretap/k12.c | 6 +-- wiretap/lanalyzer.c | 14 +++--- wiretap/libpcap.c | 16 ++++--- wiretap/netmon.c | 16 +++---- wiretap/nettl.c | 20 ++++----- wiretap/network_instruments.c | 14 +++--- wiretap/netxray.c | 32 +++++++------- wiretap/ngsniffer.c | 12 +++--- wiretap/pppdump.c | 4 +- wiretap/radcom.c | 4 +- wiretap/snoop.c | 8 ++-- wiretap/toshiba.c | 4 +- wiretap/visual.c | 10 ++--- wiretap/vms.c | 5 +-- wiretap/wtap-int.h | 6 ++- wiretap/wtap.c | 6 +++ wiretap/wtap.def | 1 + wiretap/wtap.h | 14 +++++- 88 files changed, 462 insertions(+), 610 deletions(-) diff --git a/capinfos.c b/capinfos.c index 60c73de3b3..0a27f0cd80 100644 --- a/capinfos.c +++ b/capinfos.c @@ -83,9 +83,9 @@ typedef struct _capture_info { } capture_info; static double -secs_usecs(guint32 s, guint32 us) +secs_nsecs(const struct wtap_nstime * nstime) { - return (us / 1000000.0) + (double)s; + return (nstime->nsecs / 1000000000.0) + (double)nstime->secs; } static void @@ -131,7 +131,7 @@ process_cap_file(wtap *wth, const char *filename) /* Tally up data that we need to parse through the file to find */ while (wtap_read(wth, &err, &err_info, &data_offset)) { phdr = wtap_phdr(wth); - cur_time = secs_usecs(phdr->ts.tv_sec, phdr->ts.tv_usec); + cur_time = secs_nsecs(&phdr->ts); if(packet==0) { start_time = cur_time; stop_time = cur_time; diff --git a/cfile.h b/cfile.h index db0c29bbbe..89cd3d61b2 100644 --- a/cfile.h +++ b/cfile.h @@ -55,8 +55,7 @@ typedef struct _capture_file { int marked_count; /* Number of marked frames */ gboolean drops_known; /* TRUE if we know how many packets were dropped */ guint32 drops; /* Dropped packets */ - guint32 esec; /* Elapsed seconds */ - guint32 eusec; /* Elapsed microseconds */ + nstime_t elapsed_time;/* Elapsed time (see: tsaccur below!) */ gboolean has_snap; /* TRUE if maximum capture packet length is known */ int snap; /* Maximum captured packet length */ wtap *wth; /* Wiretap session */ @@ -83,6 +82,8 @@ typedef struct _capture_file { epan_dissect_t *edt; /* Protocol dissection for currently selected packet */ field_info *finfo_selected; /* Field info for currently selected field */ struct ph_stats_s* pstats; /* accumulated stats (reset on redisplay in GUI)*/ + int tsprecision; /* timestamp precision + (WTAP_FILE_TSPREC_USEC or WTAP_FILE_TSPREC_NSEC) */ } capture_file; void init_cap_file(capture_file *); diff --git a/epan/column-utils.c b/epan/column-utils.c index da1db1a5c0..7120ce474a 100644 --- a/epan/column-utils.c +++ b/epan/column-utils.c @@ -473,7 +473,7 @@ col_set_abs_date_time(frame_data *fd, column_info *cinfo, int col) struct tm *tmp; time_t then; - then = fd->abs_secs; + then = fd->abs_ts.secs; tmp = localtime(&then); if (tmp != NULL) { g_snprintf(cinfo->col_buf[col], COL_MAX_LEN, @@ -484,7 +484,7 @@ col_set_abs_date_time(frame_data *fd, column_info *cinfo, int col) tmp->tm_hour, tmp->tm_min, tmp->tm_sec, - (long)fd->abs_usecs); + (long)fd->abs_ts.nsecs / 1000); /* XXX - this has to be improved */ } else { cinfo->col_buf[col][0] = '\0'; } @@ -497,7 +497,7 @@ static void col_set_rel_time(frame_data *fd, column_info *cinfo, int col) { display_signed_time(cinfo->col_buf[col], COL_MAX_LEN, - fd->rel_secs, fd->rel_usecs, USECS); + fd->rel_ts.secs, fd->rel_ts.nsecs / 1000, USECS); /* XXX - this has to be improved */ cinfo->col_data[col] = cinfo->col_buf[col]; strcpy(cinfo->col_expr[col],"frame.time_relative"); strcpy(cinfo->col_expr_val[col],cinfo->col_buf[col]); @@ -507,7 +507,7 @@ static void col_set_delta_time(frame_data *fd, column_info *cinfo, int col) { display_signed_time(cinfo->col_buf[col], COL_MAX_LEN, - fd->del_secs, fd->del_usecs, USECS); + fd->del_ts.secs, fd->del_ts.nsecs / 1000, USECS); cinfo->col_data[col] = cinfo->col_buf[col]; strcpy(cinfo->col_expr[col],"frame.time_delta"); strcpy(cinfo->col_expr_val[col],cinfo->col_buf[col]); @@ -521,14 +521,14 @@ col_set_abs_time(frame_data *fd, column_info *cinfo, int col) struct tm *tmp; time_t then; - then = fd->abs_secs; + then = fd->abs_ts.secs; tmp = localtime(&then); if (tmp != NULL) { g_snprintf(cinfo->col_buf[col], COL_MAX_LEN, "%02d:%02d:%02d.%06ld", tmp->tm_hour, tmp->tm_min, tmp->tm_sec, - (long)fd->abs_usecs); + (long)fd->abs_ts.nsecs / 1000); /* XXX - this has to be improved */ } else { cinfo->col_buf[col][0] = '\0'; } diff --git a/epan/dissectors/packet-afp.c b/epan/dissectors/packet-afp.c index 82c7efafd5..63158b8761 100644 --- a/epan/dissectors/packet-afp.c +++ b/epan/dissectors/packet-afp.c @@ -4010,7 +4010,7 @@ dissect_afp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) afp_request_key request_key, *new_request_key; afp_request_val *request_val; guint8 afp_command; - nstime_t t, deltat; + nstime_t delta_ts; int len = tvb_reported_length_remaining(tvb,0); gint col_info = check_col(pinfo->cinfo, COL_INFO); @@ -4044,8 +4044,7 @@ dissect_afp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) request_val->command = afp_command; request_val->frame_req = pinfo->fd->num; request_val->frame_res = 0; - request_val->req_time.secs=pinfo->fd->abs_secs; - request_val->req_time.nsecs=pinfo->fd->abs_usecs*1000; + request_val->req_time=pinfo->fd->abs_ts; g_hash_table_insert(afp_request_hash, new_request_key, request_val); @@ -4248,11 +4247,9 @@ dissect_afp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) ti = proto_tree_add_uint(afp_tree, hf_afp_response_to, tvb, 0, 0, request_val->frame_req); PROTO_ITEM_SET_GENERATED(ti); - t.secs = pinfo->fd->abs_secs; - t.nsecs = pinfo->fd->abs_usecs*1000; - get_timedelta(&deltat, &t, &request_val->req_time); + nstime_delta(&delta_ts, &pinfo->fd->abs_ts, &request_val->req_time); ti = proto_tree_add_time(afp_tree, hf_afp_time, tvb, - 0, 0, &deltat); + 0, 0, &delta_ts); PROTO_ITEM_SET_GENERATED(ti); } diff --git a/epan/dissectors/packet-afs.c b/epan/dissectors/packet-afs.c index 7f249d55d8..7d62b45ab8 100644 --- a/epan/dissectors/packet-afs.c +++ b/epan/dissectors/packet-afs.c @@ -172,7 +172,7 @@ dissect_afs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) int port, node, typenode, opcode; value_string const *vals; int offset = 0; - nstime_t ns; + nstime_t delta_ts; void (*dissector)(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode); @@ -226,8 +226,7 @@ dissect_afs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) request_val -> opcode = tvb_get_ntohl(tvb, offset); request_val -> req_num = pinfo->fd->num; request_val -> rep_num = 0; - request_val -> req_time.secs=pinfo->fd->abs_secs; - request_val -> req_time.nsecs=pinfo->fd->abs_usecs*1000; + request_val -> req_time = pinfo->fd->abs_ts; g_hash_table_insert(afs_request_hash, new_request_key, request_val); @@ -370,14 +369,9 @@ dissect_afs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) tvb, 0, 0, request_val->req_num, "This is a reply to a request in frame %u", request_val->req_num); - ns.secs= pinfo->fd->abs_secs-request_val->req_time.secs; - ns.nsecs=pinfo->fd->abs_usecs*1000-request_val->req_time.nsecs; - if(ns.nsecs<0){ - ns.nsecs+=1000000000; - ns.secs--; - } + nstime_delta(&delta_ts, &pinfo->fd->abs_ts, &request_val->req_time); proto_tree_add_time(afs_tree, hf_afs_time, tvb, offset, 0, - &ns); + &delta_ts); } diff --git a/epan/dissectors/packet-aoe.c b/epan/dissectors/packet-aoe.c index 5592fc8b48..3b55fd3d1f 100644 --- a/epan/dissectors/packet-aoe.c +++ b/epan/dissectors/packet-aoe.c @@ -242,8 +242,7 @@ dissect_ata_pdu(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, ata_info->request_frame=pinfo->fd->num; ata_info->response_frame=0; ata_info->cmd=tvb_get_guint8(tvb, offset+3); - ata_info->req_time.secs=pinfo->fd->abs_secs; - ata_info->req_time.nsecs=pinfo->fd->abs_usecs*1000; + ata_info->req_time=pinfo->fd->abs_ts; tmp_ata_info=g_hash_table_lookup(ata_cmd_unmatched, ata_info); if(tmp_ata_info){ @@ -273,16 +272,11 @@ dissect_ata_pdu(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, if(ata_info){ if(response){ if(ata_info->request_frame){ - nstime_t ns; + nstime_t delta_ts; tmp_item=proto_tree_add_uint(tree, hf_aoe_response_to, tvb, 0, 0, ata_info->request_frame); PROTO_ITEM_SET_GENERATED(tmp_item); - ns.secs= pinfo->fd->abs_secs-ata_info->req_time.secs; - ns.nsecs=pinfo->fd->abs_usecs*1000-ata_info->req_time.nsecs; - if(ns.nsecs<0){ - ns.nsecs+=1000000000; - ns.secs--; - } - tmp_item=proto_tree_add_time(tree, hf_aoe_time, tvb, offset, 0, &ns); + nstime_delta(&delta_ts, &pinfo->fd->abs_ts, &ata_info->req_time); + tmp_item=proto_tree_add_time(tree, hf_aoe_time, tvb, offset, 0, &delta_ts); PROTO_ITEM_SET_GENERATED(tmp_item); } } else { diff --git a/epan/dissectors/packet-dcerpc.c b/epan/dissectors/packet-dcerpc.c index c0be1a12b7..f21783f7a3 100644 --- a/epan/dissectors/packet-dcerpc.c +++ b/epan/dissectors/packet-dcerpc.c @@ -3371,8 +3371,7 @@ dissect_dcerpc_cn_rqst (tvbuff_t *tvb, gint offset, packet_info *pinfo, call_value->ver = bind_value->ver; call_value->opnum = opnum; call_value->req_frame=pinfo->fd->num; - call_value->req_time.secs=pinfo->fd->abs_secs; - call_value->req_time.nsecs=pinfo->fd->abs_usecs*1000; + call_value->req_time=pinfo->fd->abs_ts; call_value->rep_frame=0; call_value->max_ptr=0; call_value->private_data = NULL; @@ -3513,20 +3512,15 @@ dissect_dcerpc_cn_resp (tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree_add_uint (dcerpc_tree, hf_dcerpc_opnum, tvb, 0, 0, value->opnum); if(value->req_frame!=0){ - nstime_t ns; + nstime_t delta_ts; pi = proto_tree_add_uint(dcerpc_tree, hf_dcerpc_request_in, tvb, 0, 0, value->req_frame); PROTO_ITEM_SET_GENERATED(pi); if(parent_pi != NULL) { proto_item_append_text(parent_pi, ", [Req: #%u]", value->req_frame); } - ns.secs= pinfo->fd->abs_secs-value->req_time.secs; - ns.nsecs=pinfo->fd->abs_usecs*1000-value->req_time.nsecs; - if(ns.nsecs<0){ - ns.nsecs+=1000000000; - ns.secs--; - } - pi = proto_tree_add_time(dcerpc_tree, hf_dcerpc_time, tvb, offset, 0, &ns); + nstime_delta(&delta_ts, &pinfo->fd->abs_ts, &value->req_time); + pi = proto_tree_add_time(dcerpc_tree, hf_dcerpc_time, tvb, offset, 0, &delta_ts); PROTO_ITEM_SET_GENERATED(pi); } @@ -3636,7 +3630,7 @@ dissect_dcerpc_cn_fault (tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree_add_uint (dcerpc_tree, hf_dcerpc_opnum, tvb, 0, 0, value->opnum); if(value->req_frame!=0){ - nstime_t ns; + nstime_t delta_ts; pi = proto_tree_add_uint(dcerpc_tree, hf_dcerpc_request_in, tvb, 0, 0, value->req_frame); PROTO_ITEM_SET_GENERATED(pi); @@ -3644,13 +3638,8 @@ dissect_dcerpc_cn_fault (tvbuff_t *tvb, gint offset, packet_info *pinfo, if(parent_pi != NULL) { proto_item_append_text(parent_pi, ", [Req: #%u]", value->req_frame); } - ns.secs= pinfo->fd->abs_secs-value->req_time.secs; - ns.nsecs=pinfo->fd->abs_usecs*1000-value->req_time.nsecs; - if(ns.nsecs<0){ - ns.nsecs+=1000000000; - ns.secs--; - } - pi = proto_tree_add_time(dcerpc_tree, hf_dcerpc_time, tvb, offset, 0, &ns); + nstime_delta(&delta_ts, &pinfo->fd->abs_ts, &value->req_time); + pi = proto_tree_add_time(dcerpc_tree, hf_dcerpc_time, tvb, offset, 0, &delta_ts); PROTO_ITEM_SET_GENERATED(pi); } @@ -4477,8 +4466,7 @@ dissect_dcerpc_dg_rqst (tvbuff_t *tvb, int offset, packet_info *pinfo, call_value->ver = hdr->if_ver; call_value->opnum = hdr->opnum; call_value->req_frame=pinfo->fd->num; - call_value->req_time.secs=pinfo->fd->abs_secs; - call_value->req_time.nsecs=pinfo->fd->abs_usecs*1000; + call_value->req_time=pinfo->fd->abs_ts; call_value->rep_frame=0; call_value->max_ptr=0; call_value->private_data = NULL; @@ -4573,7 +4561,7 @@ dissect_dcerpc_dg_resp (tvbuff_t *tvb, int offset, packet_info *pinfo, di->call_data = value; if(value->req_frame!=0){ - nstime_t ns; + nstime_t delta_ts; pi = proto_tree_add_uint(dcerpc_tree, hf_dcerpc_request_in, tvb, 0, 0, value->req_frame); PROTO_ITEM_SET_GENERATED(pi); @@ -4581,13 +4569,8 @@ dissect_dcerpc_dg_resp (tvbuff_t *tvb, int offset, packet_info *pinfo, if(parent_pi != NULL) { proto_item_append_text(parent_pi, ", [Req: #%u]", value->req_frame); } - ns.secs= pinfo->fd->abs_secs-value->req_time.secs; - ns.nsecs=pinfo->fd->abs_usecs*1000-value->req_time.nsecs; - if(ns.nsecs<0){ - ns.nsecs+=1000000000; - ns.secs--; - } - pi = proto_tree_add_time(dcerpc_tree, hf_dcerpc_time, tvb, offset, 0, &ns); + nstime_delta(&delta_ts, &pinfo->fd->abs_ts, &value->req_time); + pi = proto_tree_add_time(dcerpc_tree, hf_dcerpc_time, tvb, offset, 0, &delta_ts); PROTO_ITEM_SET_GENERATED(pi); } dissect_dcerpc_dg_stub (tvb, offset, pinfo, dcerpc_tree, tree, hdr, di); @@ -4609,7 +4592,7 @@ dissect_dcerpc_dg_ping_ack (tvbuff_t *tvb, int offset, packet_info *pinfo, if((call_value=g_hash_table_lookup(dcerpc_dg_calls, &call_key))){ proto_item *pi; - nstime_t ns; + nstime_t delta_ts; pi = proto_tree_add_uint(dcerpc_tree, hf_dcerpc_request_in, tvb, 0, 0, call_value->req_frame); @@ -4622,13 +4605,8 @@ dissect_dcerpc_dg_ping_ack (tvbuff_t *tvb, int offset, packet_info *pinfo, if (check_col (pinfo->cinfo, COL_INFO)) col_append_fstr(pinfo->cinfo, COL_INFO, " [req: #%u]", call_value->req_frame); - ns.secs= pinfo->fd->abs_secs-call_value->req_time.secs; - ns.nsecs=pinfo->fd->abs_usecs*1000-call_value->req_time.nsecs; - if(ns.nsecs<0){ - ns.nsecs+=1000000000; - ns.secs--; - } - pi = proto_tree_add_time(dcerpc_tree, hf_dcerpc_time, tvb, offset, 0, &ns); + nstime_delta(&delta_ts, &pinfo->fd->abs_ts, &call_value->req_time); + pi = proto_tree_add_time(dcerpc_tree, hf_dcerpc_time, tvb, offset, 0, &delta_ts); PROTO_ITEM_SET_GENERATED(pi); /* }*/ } diff --git a/epan/dissectors/packet-fc.c b/epan/dissectors/packet-fc.c index f3893b8aa8..38f1b66033 100644 --- a/epan/dissectors/packet-fc.c +++ b/epan/dissectors/packet-fc.c @@ -860,8 +860,7 @@ dissect_fc_helper (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean COPY_ADDRESS(&old_fced->s_id, &fchdr.s_id); COPY_ADDRESS(&old_fced->d_id, &fchdr.d_id); old_fced->first_exchange_frame=pinfo->fd->num; - old_fced->fc_time.nsecs = pinfo->fd->abs_usecs*1000; - old_fced->fc_time.secs = pinfo->fd->abs_secs; + old_fced->fc_time = pinfo->fd->abs_ts; g_hash_table_insert(fc_exchange_unmatched, old_fced, old_fced); fc_ex=old_fced; } else { @@ -901,15 +900,10 @@ dissect_fc_helper (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean proto_tree_add_uint(fc_tree, hf_fc_exchange_last_frame, tvb, 0, 0, fc_ex->last_exchange_frame); } if(fchdr.fctl&FC_FCTL_EXCHANGE_LAST){ - nstime_t delta_time; + nstime_t delta_ts; proto_tree_add_uint(fc_tree, hf_fc_exchange_first_frame, tvb, 0, 0, fc_ex->first_exchange_frame); - delta_time.secs = pinfo->fd->abs_secs - fc_ex->fc_time.secs; - delta_time.nsecs = pinfo->fd->abs_usecs*1000 - fc_ex->fc_time.nsecs; - if (delta_time.nsecs<0){ - delta_time.nsecs+=1000000000; - delta_time.secs--; - } - proto_tree_add_time(ti, hf_fc_time, tvb, 0, 0, &delta_time); + nstime_delta(&delta_ts, &pinfo->fd->abs_ts, &fc_ex->fc_time); + proto_tree_add_time(ti, hf_fc_time, tvb, 0, 0, &delta_ts); } } fchdr.fced=fc_ex; diff --git a/epan/dissectors/packet-fcp.c b/epan/dissectors/packet-fcp.c index f84a1474b3..df9604901d 100644 --- a/epan/dissectors/packet-fcp.c +++ b/epan/dissectors/packet-fcp.c @@ -84,8 +84,7 @@ typedef struct _fcp_conv_key { typedef struct _fcp_conv_data { guint32 fcp_dl; gint32 fcp_lun; - guint32 abs_secs; - guint32 abs_usecs; + nstime_t abs_ts; } fcp_conv_data_t; GHashTable *fcp_req_hash = NULL; @@ -276,8 +275,7 @@ dissect_fcp_cmnd (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) * req. */ cdata->fcp_dl = tvb_get_ntohl (tvb, offset+12+16+add_len); - cdata->abs_usecs = pinfo->fd->abs_usecs; - cdata->abs_secs = pinfo->fd->abs_secs; + cdata->abs_ts = pinfo->fd->abs_ts; } else { req_key = se_alloc (sizeof(fcp_conv_key_t)); @@ -285,8 +283,7 @@ dissect_fcp_cmnd (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) cdata = se_alloc (sizeof(fcp_conv_data_t)); cdata->fcp_dl = tvb_get_ntohl (tvb, offset+12+16+add_len); - cdata->abs_usecs = pinfo->fd->abs_usecs; - cdata->abs_secs = pinfo->fd->abs_secs; + cdata->abs_ts = pinfo->fd->abs_ts; g_hash_table_insert (fcp_req_hash, req_key, cdata); } @@ -434,8 +431,9 @@ dissect_fcp_rsp (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_uint_hidden (fcp_tree, hf_fcp_type, tvb, offset, 0, 0); if (cdata) { - del_usecs = (pinfo->fd->abs_secs - cdata->abs_secs)* 1000000 + - (pinfo->fd->abs_usecs - cdata->abs_usecs); + /* XXX - this is ugly and should be replaced by a "standard way" */ + del_usecs = (pinfo->fd->abs_ts.secs - cdata->abs_ts.secs)* 1000000 + + (pinfo->fd->abs_ts.nsecs - cdata->abs_ts.nsecs) / 1000; if (del_usecs > 1000) proto_tree_add_text (fcp_tree, tvb, offset, 0, "Cmd Response Time: %d msecs", @@ -538,8 +536,9 @@ dissect_fcp_xfer_rdy (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_uint_hidden (fcp_tree, hf_fcp_type, tvb, offset, 0, 0); if (cdata) { - del_usecs = (pinfo->fd->abs_secs - cdata->abs_secs)* 1000000 + - (pinfo->fd->abs_usecs - cdata->abs_usecs); + /* XXX - this is ugly and should be replaced by a "standard way" */ + del_usecs = (pinfo->fd->abs_ts.secs - cdata->abs_ts.secs)* 1000000 + + (pinfo->fd->abs_ts.nsecs - cdata->abs_ts.nsecs) / 1000; if (del_usecs > 1000) proto_tree_add_text (fcp_tree, tvb, offset, 0, "Cmd Response Time: %d msecs", diff --git a/epan/dissectors/packet-frame.c b/epan/dissectors/packet-frame.c index 233d97e005..9b581d8913 100644 --- a/epan/dissectors/packet-frame.c +++ b/epan/dissectors/packet-frame.c @@ -167,21 +167,18 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) proto_tree_add_item(fh_tree, hf_frame_ref_time, tvb, 0, 0, FALSE); } - ts.secs = pinfo->fd->abs_secs; - ts.nsecs = pinfo->fd->abs_usecs*1000; + ts = pinfo->fd->abs_ts; proto_tree_add_time(fh_tree, hf_frame_arrival_time, tvb, 0, 0, &ts); - ts.secs = pinfo->fd->del_secs; - ts.nsecs = pinfo->fd->del_usecs*1000; + ts = pinfo->fd->del_ts; item = proto_tree_add_time(fh_tree, hf_frame_time_delta, tvb, 0, 0, &ts); PROTO_ITEM_SET_GENERATED(item); - ts.secs = pinfo->fd->rel_secs; - ts.nsecs = pinfo->fd->rel_usecs*1000; + ts = pinfo->fd->rel_ts; item = proto_tree_add_time(fh_tree, hf_frame_time_relative, tvb, 0, 0, &ts); diff --git a/epan/dissectors/packet-h225.c b/epan/dissectors/packet-h225.c index 804028d459..9ec2b5c06d 100644 --- a/epan/dissectors/packet-h225.c +++ b/epan/dissectors/packet-h225.c @@ -12732,9 +12732,9 @@ static void ras_call_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre /* if end of list is reached, exit loop and decide if request is duplicate or not. */ if (h225ras_call->next_call == NULL) { if ( (pinfo->fd->num > h225ras_call->rsp_num && h225ras_call->rsp_num != 0 - && pinfo->fd->abs_secs > (guint) (h225ras_call->req_time.secs + THRESHOLD_REPEATED_RESPONDED_CALL) ) + && pinfo->fd->abs_ts.secs > (h225ras_call->req_time.secs + THRESHOLD_REPEATED_RESPONDED_CALL) ) ||(pinfo->fd->num > h225ras_call->req_num && h225ras_call->rsp_num == 0 - && pinfo->fd->abs_secs > (guint) (h225ras_call->req_time.secs + THRESHOLD_REPEATED_NOT_RESPONDED_CALL) ) ) + && pinfo->fd->abs_ts.secs > (h225ras_call->req_time.secs + THRESHOLD_REPEATED_NOT_RESPONDED_CALL) ) ) { /* if last request has been responded and this request appears after last response (has bigger frame number) @@ -12830,14 +12830,8 @@ static void ras_call_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre PROTO_ITEM_SET_GENERATED(ti); /* Calculate RAS Service Response Time */ - delta.secs= pinfo->fd->abs_secs-h225ras_call->req_time.secs; - delta.nsecs=pinfo->fd->abs_usecs*1000-h225ras_call->req_time.nsecs; - if(delta.nsecs<0){ - delta.nsecs+=1000000000; - delta.secs--; - } - pi->delta_time.secs = delta.secs; /* give it to tap */ - pi->delta_time.nsecs = delta.nsecs; + nstime_delta(&delta, &pinfo->fd->abs_ts, &h225ras_call->req_time); + pi->delta_time = delta; /* give it to tap */ /* display Ras Service Response Time and make it filterable */ ti = proto_tree_add_time(tree, hf_h225_ras_deltatime, tvb, 0, 0, &(pi->delta_time)); diff --git a/epan/dissectors/packet-iax2.c b/epan/dissectors/packet-iax2.c index 3efba06205..4d0135f585 100644 --- a/epan/dissectors/packet-iax2.c +++ b/epan/dissectors/packet-iax2.c @@ -817,8 +817,7 @@ static iax_call_data *iax_new_call( packet_info *pinfo, call -> n_forward_circuit_ids = 0; call -> n_reverse_circuit_ids = 0; call -> subdissector = NULL; - call -> start_time.secs = pinfo->fd->abs_secs; - call -> start_time.nsecs = (pinfo->fd->abs_usecs-1000) * 1000; + call -> start_time = pinfo->fd->abs_ts; iax2_new_circuit_for_call(circuit_id,pinfo->fd->num,call,FALSE); @@ -1308,11 +1307,11 @@ static void iax2_add_ts_fields(packet_info * pinfo, proto_tree * iax2_tree, iax_ if(iax_packet->abstime.secs == -1) { time_t start_secs = iax_packet->call_data->start_time.secs; - guint32 abs_secs = start_secs + longts/1000; + gint32 abs_secs = start_secs + longts/1000; /* deal with short timestamps by assuming that packets are never more than * 16 seconds late */ - while(abs_secs < pinfo->fd->abs_secs - 16) { + while(abs_secs < pinfo->fd->abs_ts.secs - 16) { longts += 32768; abs_secs = start_secs + longts/1000; } @@ -1328,9 +1327,8 @@ static void iax2_add_ts_fields(packet_info * pinfo, proto_tree * iax2_tree, iax_ item = proto_tree_add_time(iax2_tree, hf_iax2_absts, NULL, 0, 0, &iax_packet->abstime); PROTO_ITEM_SET_GENERATED(item); - ts.secs = pinfo->fd->abs_secs; - ts.nsecs = pinfo->fd->abs_usecs * 1000; - get_timedelta(&ts, &ts, &iax_packet->abstime); + ts = pinfo->fd->abs_ts; + nstime_delta(&ts, &ts, &iax_packet->abstime); item = proto_tree_add_time(iax2_tree, hf_iax2_lateness, NULL, 0, 0, &ts); PROTO_ITEM_SET_GENERATED(item); diff --git a/epan/dissectors/packet-iscsi.c b/epan/dissectors/packet-iscsi.c index d98ee25a18..60354a46f2 100644 --- a/epan/dissectors/packet-iscsi.c +++ b/epan/dissectors/packet-iscsi.c @@ -964,8 +964,7 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off cdata->data_in_frame=0; cdata->data_out_frame=0; cdata->response_frame=0; - cdata->req_time.nsecs = pinfo->fd->abs_usecs*1000; - cdata->req_time.secs = pinfo->fd->abs_secs; + cdata->req_time = pinfo->fd->abs_ts; g_hash_table_insert (iscsi_req_unmatched, cdata, cdata); } else { @@ -1608,14 +1607,8 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off if (cdata->request_frame){ nstime_t delta_time; proto_tree_add_uint(ti, hf_iscsi_request_frame, tvb, 0, 0, cdata->request_frame); - delta_time.secs = pinfo->fd->abs_secs - cdata->req_time.secs; - delta_time.nsecs = pinfo->fd->abs_usecs*1000 - cdata->req_time.nsecs; - if (delta_time.nsecs<0){ - delta_time.nsecs+=1000000000; - delta_time.secs--; - } + nstime_delta(&delta_time, &pinfo->fd->abs_ts, &cdata->req_time); proto_tree_add_time(ti, hf_iscsi_time, tvb, 0, 0, &delta_time); - } if (cdata->data_in_frame) proto_tree_add_uint(ti, hf_iscsi_data_in_frame, tvb, 0, 0, cdata->data_in_frame); @@ -1634,14 +1627,8 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off if (cdata->request_frame){ nstime_t delta_time; proto_tree_add_uint(ti, hf_iscsi_request_frame, tvb, 0, 0, cdata->request_frame); - delta_time.secs = pinfo->fd->abs_secs - cdata->req_time.secs; - delta_time.nsecs = pinfo->fd->abs_usecs*1000 - cdata->req_time.nsecs; - if (delta_time.nsecs<0){ - delta_time.nsecs+=1000000000; - delta_time.secs--; - } + nstime_delta(&delta_time, &pinfo->fd->abs_ts, &cdata->req_time); proto_tree_add_time(ti, hf_iscsi_time, tvb, 0, 0, &delta_time); - } } if (cdata->data_out_frame) diff --git a/epan/dissectors/packet-ldap.c b/epan/dissectors/packet-ldap.c index 9e4c6f37af..faaf6ef49f 100644 --- a/epan/dissectors/packet-ldap.c +++ b/epan/dissectors/packet-ldap.c @@ -2026,8 +2026,7 @@ ldap_match_call_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, ld } lcrp->messageId=messageId; lcrp->req_frame=pinfo->fd->num; - lcrp->req_time.secs=pinfo->fd->abs_secs; - lcrp->req_time.nsecs=pinfo->fd->abs_usecs*1000; + lcrp->req_time=pinfo->fd->abs_ts; lcrp->rep_frame=0; lcrp->protocolOpTag=protocolOpTag; lcrp->is_request=TRUE; @@ -2097,12 +2096,7 @@ ldap_match_call_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, ld } else { nstime_t ns; proto_tree_add_uint(tree, hf_ldap_response_to, tvb, 0, 0, lcrp->req_frame); - ns.secs=pinfo->fd->abs_secs-lcrp->req_time.secs; - ns.nsecs=pinfo->fd->abs_usecs*1000-lcrp->req_time.nsecs; - if(ns.nsecs<0){ - ns.nsecs+=1000000000; - ns.secs--; - } + nstime_delta(&ns, &pinfo->fd->abs_ts, &lcrp->req_time); proto_tree_add_time(tree, hf_ldap_time, tvb, 0, 0, &ns); } return lcrp; diff --git a/epan/dissectors/packet-ncp2222.inc b/epan/dissectors/packet-ncp2222.inc index b762269556..5feb405434 100644 --- a/epan/dissectors/packet-ncp2222.inc +++ b/epan/dissectors/packet-ncp2222.inc @@ -4521,8 +4521,7 @@ dissect_ncp_request(tvbuff_t *tvb, packet_info *pinfo, } request_value = ncp_hash_insert(conversation, sequence, ncp_rec); request_value->req_frame_num = pinfo->fd->num; - request_value->req_frame_time.secs=pinfo->fd->abs_secs; - request_value->req_frame_time.nsecs=pinfo->fd->abs_usecs*1000; + request_value->req_frame_time=pinfo->fd->abs_ts; /* If this is the first time we're examining the packet, * check to see if this NCP type uses a "request condition". @@ -4896,14 +4895,8 @@ dissect_ncp_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree_add_uint(ncp_tree, hf_ncp_req_frame_num, tvb, 0, 0, request_value->req_frame_num); - ns.secs=pinfo->fd->abs_secs-request_value->req_frame_time.secs; - ns.nsecs=pinfo->fd->abs_usecs*1000-request_value->req_frame_time.nsecs; - if(ns.nsecs<0){ - ns.nsecs+=1000000000; - ns.secs--; - } + nstime_delta(&ns, &pinfo->fd->abs_ts, &request_value->req_frame_time); proto_tree_add_time(ncp_tree, hf_ncp_req_frame_time, tvb, 0, 0, &ns); - } /* Put the func (and maybe subfunc) from the request packet @@ -8296,8 +8289,7 @@ dissect_nds_request(tvbuff_t *tvb, packet_info *pinfo, if (!pinfo->fd->flags.visited) { request_value = ncp_hash_insert(conversation, sequence, ncp_rec); request_value->req_frame_num = pinfo->fd->num; - request_value->req_frame_time.secs=pinfo->fd->abs_secs; - request_value->req_frame_time.nsecs=pinfo->fd->abs_usecs*1000; + request_value->req_frame_time=pinfo->fd->abs_ts; /* If this is the first time we're examining the packet, * check to see if this NCP type uses a "request condition". @@ -8576,8 +8568,7 @@ dissect_ping_req(tvbuff_t *tvb, packet_info *pinfo, request_value = ncp_hash_insert(conversation, sequence, ncp_rec); request_value->req_frame_num = pinfo->fd->num; - request_value->req_frame_time.secs=pinfo->fd->abs_secs; - request_value->req_frame_time.nsecs=pinfo->fd->abs_usecs*1000; + request_value->req_frame_time=pinfo->fd->abs_ts; /* If this is the first time we're examining the packet, * check to see if this NCP type uses a "request condition". diff --git a/epan/dissectors/packet-nlm.c b/epan/dissectors/packet-nlm.c index 5727c0622a..457dfae9cb 100644 --- a/epan/dissectors/packet-nlm.c +++ b/epan/dissectors/packet-nlm.c @@ -208,14 +208,8 @@ nlm_print_msgres_reply(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb) if(md){ nstime_t ns; proto_tree_add_uint(tree, hf_nlm_request_in, tvb, 0, 0, md->req_frame); - ns.secs= pinfo->fd->abs_secs-md->ns.secs; - ns.nsecs=pinfo->fd->abs_usecs*1000-md->ns.nsecs; - if(ns.nsecs<0){ - ns.nsecs+=1000000000; - ns.secs--; - } + nstime_delta(&ns, &pinfo->fd->abs_ts, &md->ns); proto_tree_add_time(tree, hf_nlm_time, tvb, 0, 0, &ns); - } } @@ -300,8 +294,7 @@ nlm_register_unmatched_msg(packet_info *pinfo, tvbuff_t *tvb, int offset) /* allocate and build the unmatched structure for this request */ umd=g_malloc(sizeof(nlm_msg_res_unmatched_data)); umd->req_frame=pinfo->fd->num; - umd->ns.secs=pinfo->fd->abs_secs; - umd->ns.nsecs=pinfo->fd->abs_usecs*1000; + umd->ns=pinfo->fd->abs_ts; umd->cookie_len=tvb_get_ntohl(tvb, offset); umd->cookie=tvb_memdup(tvb, offset+4, umd->cookie_len); diff --git a/epan/dissectors/packet-rlogin.c b/epan/dissectors/packet-rlogin.c index a0100bb013..ab672450b8 100644 --- a/epan/dissectors/packet-rlogin.c +++ b/epan/dissectors/packet-rlogin.c @@ -74,8 +74,7 @@ typedef struct { #define DONE 2 #define BAD 2 -static guint32 last_abs_sec = 0; -static guint32 last_abs_usec= 0; +static nstime_t last_abs_ts = { 0, 0 }; static void rlogin_init(void) @@ -83,9 +82,7 @@ rlogin_init(void) /* Routine to initialize rlogin protocol before each capture or filter pass. */ - last_abs_sec = 0; - last_abs_usec= 0; - + nstime_set_zero(&last_abs_ts); } @@ -110,13 +107,12 @@ rlogin_state_machine( rlogin_hash_entry_t *hash_info, tvbuff_t *tvb, return; /* test timestamp */ - if (( last_abs_sec > pinfo->fd->abs_secs) || - (( last_abs_sec == pinfo->fd->abs_secs) && - ( last_abs_usec >= pinfo->fd->abs_usecs))) + if (( last_abs_ts.secs > pinfo->fd->abs_ts.secs) || + (( last_abs_ts.secs == pinfo->fd->abs_ts.secs) && + ( last_abs_ts.nsecs >= pinfo->fd->abs_ts.nsecs))) return; - last_abs_sec = pinfo->fd->abs_secs; /* save timestamp */ - last_abs_usec = pinfo->fd->abs_usecs; + last_abs_ts = pinfo->fd->abs_ts; /* save timestamp */ length = tvb_length(tvb); if ( length == 0) /* exit if no data */ diff --git a/epan/dissectors/packet-rpc.c b/epan/dissectors/packet-rpc.c index 2ac43a24f8..3a2edc817b 100644 --- a/epan/dissectors/packet-rpc.c +++ b/epan/dissectors/packet-rpc.c @@ -1871,8 +1871,7 @@ dissect_rpc_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rpc_call->gss_proc = 0; rpc_call->gss_svc = 0; rpc_call->proc_info = value; - rpc_call->req_time.secs=pinfo->fd->abs_secs; - rpc_call->req_time.nsecs=pinfo->fd->abs_usecs*1000; + rpc_call->req_time = pinfo->fd->abs_ts; /* store it */ g_hash_table_insert(rpc_calls, new_rpc_call_key, rpc_call); @@ -2167,8 +2166,7 @@ dissect_rpc_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rpc_call->gss_proc = gss_proc; rpc_call->gss_svc = gss_svc; rpc_call->proc_info = value; - rpc_call->req_time.secs=pinfo->fd->abs_secs; - rpc_call->req_time.nsecs=pinfo->fd->abs_usecs*1000; + rpc_call->req_time = pinfo->fd->abs_ts; /* store it */ g_hash_table_insert(rpc_calls, new_rpc_call_key, @@ -2289,12 +2287,7 @@ dissect_rpc_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, tvb, 0, 0, rpc_call->req_num, "This is a reply to a request in frame %u", rpc_call->req_num); - ns.secs= pinfo->fd->abs_secs-rpc_call->req_time.secs; - ns.nsecs=pinfo->fd->abs_usecs*1000-rpc_call->req_time.nsecs; - if(ns.nsecs<0){ - ns.nsecs+=1000000000; - ns.secs--; - } + nstime_delta(&ns, &pinfo->fd->abs_ts, &rpc_call->req_time); proto_tree_add_time(rpc_tree, hf_rpc_time, tvb, offset, 0, &ns); diff --git a/epan/dissectors/packet-rtcp.c b/epan/dissectors/packet-rtcp.c index 4e7eb9364f..9e7e974d16 100644 --- a/epan/dissectors/packet-rtcp.c +++ b/epan/dissectors/packet-rtcp.c @@ -1551,8 +1551,7 @@ static void remember_outgoing_sr(packet_info *pinfo, long lsr) /* Update conversation data */ p_conv_data->last_received_set = TRUE; p_conv_data->last_received_frame_number = pinfo->fd->num; - p_conv_data->last_received_time_secs = pinfo->fd->abs_secs; - p_conv_data->last_received_time_usecs = pinfo->fd->abs_usecs; + p_conv_data->last_received_timestamp = pinfo->fd->abs_ts; p_conv_data->last_received_ts = lsr; @@ -1576,8 +1575,7 @@ static void remember_outgoing_sr(packet_info *pinfo, long lsr) /* Copy current conversation data into packet info */ p_packet_data->last_received_set = TRUE; p_packet_data->last_received_frame_number = p_conv_data->last_received_frame_number; - p_packet_data->last_received_time_secs = p_conv_data->last_received_time_secs; - p_packet_data->last_received_time_usecs = p_conv_data->last_received_time_usecs; + p_packet_data->last_received_timestamp = p_conv_data->last_received_timestamp; } @@ -1656,13 +1654,13 @@ static void calculate_roundtrip_delay(tvbuff_t *tvb, packet_info *pinfo, { /* Look at time of since original packet was sent */ gint seconds_between_packets = - pinfo->fd->abs_secs - p_conv_data->last_received_time_secs; - gint useconds_between_packets = - pinfo->fd->abs_usecs - p_conv_data->last_received_time_usecs; + pinfo->fd->abs_ts.secs - p_conv_data->last_received_timestamp.secs; + gint nseconds_between_packets = + pinfo->fd->abs_ts.nsecs - p_conv_data->last_received_timestamp.nsecs; gint total_gap = ((seconds_between_packets*1000000) + - useconds_between_packets) / 1000; + nseconds_between_packets) / 1000000; gint delay = total_gap - (int)(((double)dlsr/(double)65536) * 1000.0); /* No useful calculation can be done if dlsr not set... */ diff --git a/epan/dissectors/packet-rtcp.h b/epan/dissectors/packet-rtcp.h index 5523c4db57..d09f5fb8cc 100644 --- a/epan/dissectors/packet-rtcp.h +++ b/epan/dissectors/packet-rtcp.h @@ -41,8 +41,7 @@ struct _rtcp_conversation_info /* Info used for roundtrip calculations */ guchar last_received_set; guint32 last_received_frame_number; - guint32 last_received_time_secs; - guint32 last_received_time_usecs; + nstime_t last_received_timestamp; guint32 last_received_ts; /* Stored result of calculation (ms) */ diff --git a/epan/dissectors/packet-smb.c b/epan/dissectors/packet-smb.c index 460e2b7356..8d96725f21 100644 --- a/epan/dissectors/packet-smb.c +++ b/epan/dissectors/packet-smb.c @@ -15012,8 +15012,7 @@ dissect_smb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) sip = se_alloc(sizeof(smb_saved_info_t)); sip->frame_req = pinfo->fd->num; sip->frame_res = 0; - sip->req_time.secs=pinfo->fd->abs_secs; - sip->req_time.nsecs=pinfo->fd->abs_usecs*1000; + sip->req_time = pinfo->fd->abs_ts; sip->flags = 0; if(g_hash_table_lookup(si->ct->tid_service, GUINT_TO_POINTER(si->tid)) == (void *)TID_IPC) { @@ -15063,9 +15062,8 @@ dissect_smb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) if (sip->frame_req != 0) { tmp_item=proto_tree_add_uint(htree, hf_smb_response_to, tvb, 0, 0, sip->frame_req); PROTO_ITEM_SET_GENERATED(tmp_item); - t.secs = pinfo->fd->abs_secs; - t.nsecs = pinfo->fd->abs_usecs*1000; - get_timedelta(&deltat, &t, &sip->req_time); + t = pinfo->fd->abs_ts; + nstime_delta(&deltat, &t, &sip->req_time); tmp_item=proto_tree_add_time(htree, hf_smb_time, tvb, 0, 0, &deltat); PROTO_ITEM_SET_GENERATED(tmp_item); diff --git a/epan/dissectors/packet-tcp.c b/epan/dissectors/packet-tcp.c index 5cb1a94ea7..07a004e295 100644 --- a/epan/dissectors/packet-tcp.c +++ b/epan/dissectors/packet-tcp.c @@ -430,8 +430,7 @@ scan_for_next_pdu(tvbuff_t *tvb, proto_tree *tcp_tree, packet_info *pinfo, int o */ if(seq>tnp->seq && nxtseq<=tnp->nxtpdu){ tnp->last_frame=pinfo->fd->num; - tnp->last_frame_time.secs=pinfo->fd->abs_secs; - tnp->last_frame_time.nsecs=pinfo->fd->abs_usecs*1000; + tnp->last_frame_time=pinfo->fd->abs_ts; g_hash_table_insert(tcp_pdu_skipping_table, GINT_TO_POINTER(pinfo->fd->num), (void *)tnp); print_pdu_tracking_data(pinfo, tvb, tcp_tree, tnp); @@ -456,16 +455,10 @@ scan_for_next_pdu(tvbuff_t *tvb, proto_tree *tcp_tree, packet_info *pinfo, int o item=proto_tree_add_uint(tcp_tree, hf_tcp_pdu_last_frame, tvb, 0, 0, tnp->last_frame); PROTO_ITEM_SET_GENERATED(item); - ns.secs =tnp->last_frame_time.secs-pinfo->fd->abs_secs; - ns.nsecs=tnp->last_frame_time.nsecs-pinfo->fd->abs_usecs*1000; - if(ns.nsecs<0){ - ns.nsecs+=1000000000; - ns.secs--; - } + nstime_delta(&ns, &tnp->last_frame_time, &pinfo->fd->abs_ts); item = proto_tree_add_time(tcp_tree, hf_tcp_pdu_time, tvb, 0, 0, &ns); PROTO_ITEM_SET_GENERATED(item); - } /* check if this is a segment in the middle of a pdu */ @@ -502,8 +495,7 @@ pdu_store_sequencenumber_of_next_pdu(packet_info *pinfo, guint32 seq, guint32 nx tnp->seq=seq; tnp->first_frame=pinfo->fd->num; tnp->last_frame=pinfo->fd->num; - tnp->last_frame_time.secs=pinfo->fd->abs_secs; - tnp->last_frame_time.nsecs=pinfo->fd->abs_usecs*1000; + tnp->last_frame_time=pinfo->fd->abs_ts; /* check direction and get pdu start list */ direction=CMP_ADDRESS(&pinfo->src, &pinfo->dst); @@ -673,14 +665,12 @@ tcp_analyze_sequence_number(packet_info *pinfo, guint32 seq, guint32 ack, guint3 if(!ack2_frame){ ack2_frame=pinfo->fd->num; ack2=ack; - ack2_time->secs=pinfo->fd->abs_secs; - ack2_time->nsecs=pinfo->fd->abs_usecs*1000; + *ack2_time=pinfo->fd->abs_ts; num2_acks=0; } else if(GT_SEQ(ack, ack2)){ ack2_frame=pinfo->fd->num; ack2=ack; - ack2_time->secs=pinfo->fd->abs_secs; - ack2_time->nsecs=pinfo->fd->abs_usecs*1000; + *ack2_time=pinfo->fd->abs_ts; num2_acks=0; } } @@ -729,8 +719,7 @@ printf(" Frame:%d seq:%d nseq:%d time:%d.%09d ack:%d:%d\n",u->frame,u->seq,u->n num2_acks=0; ual1->seq=seq; ual1->nextseq=seq+1; - ual1->ts.secs=pinfo->fd->abs_secs; - ual1->ts.nsecs=pinfo->fd->abs_usecs*1000; + ual1->ts=pinfo->fd->abs_ts; ual1->window=window; ual1->flags=0; if(tcp_relative_seq){ @@ -754,8 +743,7 @@ printf(" Frame:%d seq:%d nseq:%d time:%d.%09d ack:%d:%d\n",u->frame,u->seq,u->n ual1->frame=pinfo->fd->num; ual1->seq=seq; ual1->nextseq=seq+seglen; - ual1->ts.secs=pinfo->fd->abs_secs; - ual1->ts.nsecs=pinfo->fd->abs_usecs*1000; + ual1->ts=pinfo->fd->abs_ts; ual1->window=window; ual1->flags=0; if(tcp_relative_seq){ @@ -781,8 +769,7 @@ printf(" Frame:%d seq:%d nseq:%d time:%d.%09d ack:%d:%d\n",u->frame,u->seq,u->n ual->frame=pinfo->fd->num; ual->seq=seq; ual->nextseq=seq+seglen; - ual->ts.secs=pinfo->fd->abs_secs; - ual->ts.nsecs=pinfo->fd->abs_usecs*1000; + ual->ts=pinfo->fd->abs_ts; ual->window=window; ual->flags=0; ual1=ual; @@ -840,8 +827,8 @@ printf(" Frame:%d seq:%d nseq:%d time:%d.%09d ack:%d:%d\n",u->frame,u->seq,u->n if( (num1_acks>=4) && (seq==ack1) ){ guint32 t; - t=(pinfo->fd->abs_secs-ack1_time->secs)*1000000000; - t=t+(pinfo->fd->abs_usecs*1000)-ack1_time->nsecs; + t=(pinfo->fd->abs_ts.secs-ack1_time->secs)*1000000000; + t=t+(pinfo->fd->abs_ts.nsecs)-ack1_time->nsecs; if(t<10000000){ /* has to be a retransmission then */ struct tcp_acked *ta; @@ -888,15 +875,15 @@ printf(" Frame:%d seq:%d nseq:%d time:%d.%09d ack:%d:%d\n",u->frame,u->seq,u->n } } if(ntu){ - if(pinfo->fd->abs_secs>(guint32)(ntu->ts.secs+2)){ + if(pinfo->fd->abs_ts.secs > ntu->ts.secs+2){ outoforder=FALSE; - } else if((pinfo->fd->abs_secs+2)<(guint32)ntu->ts.secs){ + } else if(pinfo->fd->abs_ts.secs+2 < ntu->ts.secs){ outoforder=FALSE; } else { guint32 t; - t=(ntu->ts.secs-pinfo->fd->abs_secs)*1000000000; - t=t+ntu->ts.nsecs-(pinfo->fd->abs_usecs*1000); + t=(ntu->ts.secs-pinfo->fd->abs_ts.secs)*1000000000; + t=t+ntu->ts.nsecs-(pinfo->fd->abs_ts.nsecs); if(t>4000000){ outoforder=FALSE; @@ -952,12 +939,7 @@ printf(" Frame:%d seq:%d nseq:%d time:%d.%09d ack:%d:%d\n",u->frame,u->seq,u->n * segment with an equal or lower sequence * number. */ - ta->rto_ts.secs=pinfo->fd->abs_secs-ntu->ts.secs; - ta->rto_ts.nsecs=pinfo->fd->abs_usecs*1000-ntu->ts.nsecs; - if(ta->rto_ts.nsecs<0){ - ta->rto_ts.nsecs+=1000000000; - ta->rto_ts.secs--; - } + nstime_delta(&ta->rto_ts, &pinfo->fd->abs_ts, &ntu->ts); ta->rto_frame=ntu->frame; } else { /* we didnt see any previous packet so we @@ -974,8 +956,7 @@ printf(" Frame:%d seq:%d nseq:%d time:%d.%09d ack:%d:%d\n",u->frame,u->seq,u->n if(GT_SEQ((seq+seglen), ual1->nextseq)){ ual1->nextseq=seq+seglen; ual1->frame=pinfo->fd->num; - ual1->ts.secs=pinfo->fd->abs_secs; - ual1->ts.nsecs=pinfo->fd->abs_usecs*1000; + ual1->ts=pinfo->fd->abs_ts; } } goto seq_finished; @@ -987,8 +968,7 @@ printf(" Frame:%d seq:%d nseq:%d time:%d.%09d ack:%d:%d\n",u->frame,u->seq,u->n ual->frame=pinfo->fd->num; ual->seq=seq; ual->nextseq=seq+seglen; - ual->ts.secs=pinfo->fd->abs_secs; - ual->ts.nsecs=pinfo->fd->abs_usecs*1000; + ual->ts=pinfo->fd->abs_ts; ual->window=window; ual->flags=0; ual1=ual; @@ -1043,12 +1023,7 @@ seq_finished: ta=tcp_analyze_get_acked_struct(pinfo->fd->num, TRUE); ta->frame_acked=ual2->frame; - ta->ts.secs=pinfo->fd->abs_secs-ual2->ts.secs; - ta->ts.nsecs=pinfo->fd->abs_usecs*1000-ual2->ts.nsecs; - if(ta->ts.nsecs<0){ - ta->ts.nsecs+=1000000000; - ta->ts.secs--; - } + nstime_delta(&ta->ts, &pinfo->fd->abs_ts, &ual2->ts); /* its all been ACKed so we dont need to keep them anymore */ for(ual=ual2;ual2;ual2=ual){ @@ -1076,12 +1051,7 @@ seq_finished: ta=tcp_analyze_get_acked_struct(pinfo->fd->num, TRUE); ta->frame_acked=ackedual->frame; - ta->ts.secs=pinfo->fd->abs_secs-ackedual->ts.secs; - ta->ts.nsecs=pinfo->fd->abs_usecs*1000-ackedual->ts.nsecs; - if(ta->ts.nsecs<0){ - ta->ts.nsecs+=1000000000; - ta->ts.secs--; - } + nstime_delta(&ta->ts, &pinfo->fd->abs_ts, &ackedual->ts); /* just delete all ACKed segments */ tmpual=ual->next; diff --git a/epan/frame_data.h b/epan/frame_data.h index 05c28859da..db6d5034a4 100644 --- a/epan/frame_data.h +++ b/epan/frame_data.h @@ -27,6 +27,7 @@ #include "column_info.h" #include "tvbuff.h" +#include #if 0 /* Defined in color.h */ @@ -51,12 +52,9 @@ typedef struct _frame_data { guint32 pkt_len; /* Packet length */ guint32 cap_len; /* Amount actually captured */ guint32 cum_bytes; /* Cumulative bytes into the capture */ - gint32 rel_secs; /* Relative seconds (yes, it can be negative) */ - gint32 rel_usecs; /* Relative microseconds (yes, it can be negative) */ - guint32 abs_secs; /* Absolute seconds */ - guint32 abs_usecs; /* Absolute microseconds */ - gint32 del_secs; /* Delta seconds (yes, it can be negative) */ - gint32 del_usecs; /* Delta microseconds (yes, it can be negative) */ + nstime_t abs_ts; /* Absolute timestamp */ + nstime_t rel_ts; /* Relative timestamp (yes, it can be negative) */ + nstime_t del_ts; /* Delta timestamp (yes, it can be negative) */ long file_off; /* File offset */ int lnk_t; /* Per-packet encapsulation/data-link type */ struct { diff --git a/epan/h225-persistentdata.c b/epan/h225-persistentdata.c index 38804ecf6a..f9ae7539a9 100644 --- a/epan/h225-persistentdata.c +++ b/epan/h225-persistentdata.c @@ -95,8 +95,7 @@ h225ras_call_t * new_h225ras_call(h225ras_call_info_key *h225ras_call_key, packe h225ras_call->requestSeqNum = h225ras_call_key->reqSeqNum; h225ras_call->responded = FALSE; h225ras_call->next_call = NULL; - h225ras_call->req_time.secs=pinfo->fd->abs_secs; - h225ras_call->req_time.nsecs=pinfo->fd->abs_usecs*1000; + h225ras_call->req_time=pinfo->fd->abs_ts; memcpy(h225ras_call->guid, guid,16); /* store it */ g_hash_table_insert(ras_calls[category], new_h225ras_call_key, h225ras_call); @@ -119,8 +118,7 @@ h225ras_call_t * append_h225ras_call(h225ras_call_t *prev_call, packet_info *pin h225ras_call->requestSeqNum = prev_call->requestSeqNum; h225ras_call->responded = FALSE; h225ras_call->next_call = NULL; - h225ras_call->req_time.secs=pinfo->fd->abs_secs; - h225ras_call->req_time.nsecs=pinfo->fd->abs_usecs*1000; + h225ras_call->req_time=pinfo->fd->abs_ts; memcpy(h225ras_call->guid, guid,16); prev_call->next_call = h225ras_call; diff --git a/epan/libethereal.def b/epan/libethereal.def index 6221d736e3..ea14571675 100644 --- a/epan/libethereal.def +++ b/epan/libethereal.def @@ -307,8 +307,6 @@ get_plugins_pers_dir get_systemfile_dir get_tcp_port get_tempfile_path -get_timedelta -get_timesum get_timestamp_setting get_udp_port gsm_a_bssmap_msg_strings DATA @@ -351,7 +349,12 @@ mtp3_addr_to_str_buf mtp3_service_indicator_code_short_vals DATA new_create_dissector_handle new_register_dissector +nstime_delta +nstime_is_zero +nstime_set_zero +nstime_sum nstime_to_msec +nstime_to_sec nt_cmd_vals DATA num_tap_filters DATA num_tree_types DATA diff --git a/epan/nstime.c b/epan/nstime.c index b5089bb97c..e20159afcf 100644 --- a/epan/nstime.c +++ b/epan/nstime.c @@ -25,6 +25,7 @@ * */ +#include #include "nstime.h" /* this is #defined so that we can clearly see that we have the right number of @@ -32,12 +33,30 @@ changing ;) */ #define NS_PER_S 1000000000 +/* set the given nstime_t to zero */ +void nstime_set_zero(nstime_t *nstime) +{ + nstime->secs = 0; + nstime->nsecs = 0; +} + +/* is the given nstime_t currently zero? */ +gboolean nstime_is_zero(nstime_t *nstime) +{ + if(nstime->secs == 0 && nstime->nsecs == 0) { + return TRUE; + } else { + return FALSE; + } +} + + /* - * function: get_timedelta + * function: nstime_delta * delta = b - a */ -void get_timedelta(nstime_t *delta, const nstime_t *b, const nstime_t *a ) +void nstime_delta(nstime_t *delta, const nstime_t *b, const nstime_t *a ) { if (b->secs == a->secs) { /* The seconds part of b is the same as the seconds part of a, so if @@ -74,11 +93,11 @@ void get_timedelta(nstime_t *delta, const nstime_t *b, const nstime_t *a ) } /* - * function: get_timesum + * function: nstime_sum * sum = a + b */ -void get_timesum(nstime_t *sum, const nstime_t *a, const nstime_t *b) +void nstime_sum(nstime_t *sum, const nstime_t *a, const nstime_t *b) { sum->secs = a->secs + b->secs; sum->nsecs = a->nsecs + b->nsecs; @@ -101,3 +120,13 @@ double nstime_to_msec(const nstime_t *time) return ((double)time->secs*1000 + (double)time->nsecs/1000000); } +/* + * function: nstime_to_sec + * converts nstime to double, time base is seconds + */ + +double nstime_to_sec(const nstime_t *time) +{ + return ((double)time->secs + (double)time->nsecs/1000000000); +} + diff --git a/epan/nstime.h b/epan/nstime.h index 25c10d6bef..60fec42e01 100644 --- a/epan/nstime.h +++ b/epan/nstime.h @@ -34,14 +34,20 @@ typedef struct { /* functions */ -/* calculate the delta between two times +/* set the given nstime_t to zero */ +extern void nstime_set_zero(nstime_t *nstime); + +/* is the given nstime_t currently zero? */ +extern gboolean nstime_is_zero(nstime_t *nstime); + +/* calculate the delta between two times (can be negative!) * * delta = b-a * * Note that it is acceptable for two or more of the arguments to point at the * same structure. */ -extern void get_timedelta(nstime_t *delta, const nstime_t *b, const nstime_t *a ); +extern void nstime_delta(nstime_t *delta, const nstime_t *b, const nstime_t *a ); /* calculate the sum of two times * @@ -50,12 +56,15 @@ extern void get_timedelta(nstime_t *delta, const nstime_t *b, const nstime_t *a * Note that it is acceptable for two or more of the arguments to point at the * same structure. */ -extern void get_timesum(nstime_t *sum, const nstime_t *b, const nstime_t *a ); +extern void nstime_sum(nstime_t *sum, const nstime_t *b, const nstime_t *a ); /* sum += a */ -#define addtime(sum, a) get_timesum(sum, sum, a) +#define nstime_add(sum, a) nstime_sum(sum, sum, a) -/* converts nstime to double, time base is milli seconds*/ +/* converts nstime to double, time base is milli seconds */ extern double nstime_to_msec(const nstime_t *time); +/* converts nstime to double, time base is seconds */ +extern double nstime_to_sec(const nstime_t *time); + #endif /* __NSTIME_H__ */ diff --git a/epan/stats_tree.c b/epan/stats_tree.c index cb36ba2d26..47c94c53c8 100644 --- a/epan/stats_tree.c +++ b/epan/stats_tree.c @@ -52,7 +52,7 @@ extern void stats_tree_get_strs_from_node(const stat_node* node, guint8* value, if (rate) { *rate = '\0'; if (node->st->elapsed > 0.0) { - f = ((float)node->counter) / node->st->elapsed; + f = ((float)node->counter) / (float)node->st->elapsed; g_snprintf(rate,NUM_BUF_SIZE,"%f",f); } } @@ -306,13 +306,13 @@ extern stats_tree* stats_tree_new(stats_tree_cfg* cfg, tree_pres* pr,char* filte /* will be the tap packet cb */ extern int stats_tree_packet(void* p, packet_info* pinfo, epan_dissect_t *edt, const void *pri) { stats_tree* st = p; - float now; + double now; if (st->highest_seen >= pinfo->fd->num) return 0; st->highest_seen = pinfo->fd->num; - - now = (((float)pinfo->fd->rel_secs) + (((float)pinfo->fd->rel_usecs)/1000000) ); + + now = nstime_to_msec(&pinfo->fd->rel_ts); if (st->start < 0.0) st->start = now; diff --git a/epan/stats_tree_priv.h b/epan/stats_tree_priv.h index a29ab8e5dc..7d36a3c7d9 100644 --- a/epan/stats_tree_priv.h +++ b/epan/stats_tree_priv.h @@ -85,8 +85,8 @@ struct _stats_tree { guint32 highest_seen; /* times */ - float start; - float elapsed; + double start; + double elapsed; /* used to lookup named parents: * key: parent node name diff --git a/file.c b/file.c index 4e73f429fb..14a79a1ba7 100644 --- a/file.c +++ b/file.c @@ -86,8 +86,8 @@ gboolean auto_scroll_live; #endif -static guint32 firstsec, firstusec; -static guint32 prevsec, prevusec; +static nstime_t first_ts; +static nstime_t prev_ts; static guint32 cum_bytes = 0; static void cf_reset_state(capture_file *cf); @@ -197,14 +197,13 @@ cf_open(capture_file *cf, const char *fname, gboolean is_tempfile, int *err) /* If it's a temporary capture buffer file, mark it as not saved. */ cf->user_saved = !is_tempfile; - cf->cd_t = wtap_file_type(cf->wth); + cf->cd_t = wtap_file_type(cf->wth); + cf->tsprecision = wtap_file_tsprecision(cf->wth); cf->count = 0; cf->displayed_count = 0; cf->marked_count = 0; cf->drops_known = FALSE; cf->drops = 0; - cf->esec = 0; - cf->eusec = 0; cf->snap = wtap_snapshot_length(cf->wth); if (cf->snap == 0) { /* Snapshot length not known. */ @@ -212,8 +211,9 @@ cf_open(capture_file *cf, const char *fname, gboolean is_tempfile, int *err) cf->snap = WTAP_MAX_PACKET_SIZE; } else cf->has_snap = TRUE; - firstsec = 0, firstusec = 0; - prevsec = 0, prevusec = 0; + nstime_set_zero(&cf->elapsed_time); + nstime_set_zero(&first_ts); + nstime_set_zero(&prev_ts); cf->plist_chunk = g_mem_chunk_new("frame_data_chunk", sizeof(frame_data), @@ -284,8 +284,7 @@ cf_reset_state(capture_file *cf) cf->f_datalen = 0; cf->count = 0; - cf->esec = 0; - cf->eusec = 0; + nstime_set_zero(&cf->elapsed_time); reset_tap_listeners(); @@ -682,43 +681,37 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf, /* If we don't have the time stamp of the first packet in the capture, it's because this is the first packet. Save the time stamp of this packet as the time stamp of the first packet. */ - if (!firstsec && !firstusec) { - firstsec = fdata->abs_secs; - firstusec = fdata->abs_usecs; + if (nstime_is_zero(&first_ts)) { + first_ts = fdata->abs_ts; } /* if this frames is marked as a reference time frame, reset firstsec and firstusec to this frame */ if(fdata->flags.ref_time){ - firstsec = fdata->abs_secs; - firstusec = fdata->abs_usecs; + first_ts = fdata->abs_ts; } /* If we don't have the time stamp of the previous displayed packet, it's because this is the first displayed packet. Save the time stamp of this packet as the time stamp of the previous displayed packet. */ - if (!prevsec && !prevusec) { - prevsec = fdata->abs_secs; - prevusec = fdata->abs_usecs; + if (nstime_is_zero(&prev_ts)) { + prev_ts = fdata->abs_ts; } /* Get the time elapsed between the first packet and this packet. */ - compute_timestamp_diff(&fdata->rel_secs, &fdata->rel_usecs, - fdata->abs_secs, fdata->abs_usecs, firstsec, firstusec); + nstime_delta(&fdata->rel_ts, &fdata->abs_ts, &first_ts); /* If it's greater than the current elapsed time, set the elapsed time to it (we check for "greater than" so as not to be confused by time moving backwards). */ - if ((gint32)cf->esec < fdata->rel_secs - || ((gint32)cf->esec == fdata->rel_secs && (gint32)cf->eusec < fdata->rel_usecs)) { - cf->esec = fdata->rel_secs; - cf->eusec = fdata->rel_usecs; + if ((gint32)cf->elapsed_time.secs < fdata->rel_ts.secs + || ((gint32)cf->elapsed_time.secs == fdata->rel_ts.secs && (gint32)cf->elapsed_time.nsecs < fdata->rel_ts.nsecs)) { + cf->elapsed_time = fdata->rel_ts; } /* Get the time elapsed between the previous displayed packet and this packet. */ - compute_timestamp_diff(&fdata->del_secs, &fdata->del_usecs, - fdata->abs_secs, fdata->abs_usecs, prevsec, prevusec); + nstime_delta(&fdata->del_ts, &fdata->abs_ts, &prev_ts); /* If either @@ -807,8 +800,7 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf, /* Set the time of the previous displayed frame to the time of this frame. */ - prevsec = fdata->abs_secs; - prevusec = fdata->abs_usecs; + prev_ts = fdata->abs_ts; cf->displayed_count++; } else { @@ -841,13 +833,13 @@ read_packet(capture_file *cf, long offset) fdata->cap_len = phdr->caplen; fdata->file_off = offset; fdata->lnk_t = phdr->pkt_encap; - fdata->abs_secs = phdr->ts.tv_sec; - fdata->abs_usecs = phdr->ts.tv_usec; fdata->flags.encoding = CHAR_ASCII; fdata->flags.visited = 0; fdata->flags.marked = 0; fdata->flags.ref_time = 0; + fdata->abs_ts = *((nstime_t *) &phdr->ts); + passed = TRUE; if (cf->rfcode) { edt = epan_dissect_new(TRUE, FALSE); @@ -1241,10 +1233,8 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, /* Iterate through the list of frames. Call a routine for each frame to check whether it should be displayed and, if so, add it to the display list. */ - firstsec = 0; - firstusec = 0; - prevsec = 0; - prevusec = 0; + nstime_set_zero(&first_ts); + nstime_set_zero(&prev_ts); /* Update the progress bar when it gets to this value. */ progbar_nextstep = 0; @@ -3022,8 +3012,7 @@ save_packet(capture_file *cf _U_, frame_data *fdata, int err; /* init the wtap header for saving */ - hdr.ts.tv_sec = fdata->abs_secs; - hdr.ts.tv_usec = fdata->abs_usecs; + hdr.ts = *(struct wtap_nstime *) &fdata->abs_ts; hdr.caplen = fdata->cap_len; hdr.len = fdata->pkt_len; hdr.pkt_encap = fdata->lnk_t; diff --git a/gtk/file_dlg.c b/gtk/file_dlg.c index 4cdcd7faa4..7288dc8396 100644 --- a/gtk/file_dlg.c +++ b/gtk/file_dlg.c @@ -118,12 +118,6 @@ static GtkWidget *range_tb; #define PREVIEW_STR_MAX 200 -static double -secs_usecs( guint32 s, guint32 us) -{ - return (us / 1000000.0) + (double)s; -} - /* set a new filename for the preview widget */ static wtap * @@ -207,8 +201,8 @@ preview_do(GtkWidget *prev, wtap *wth) gchar *err_info; long data_offset; const struct wtap_pkthdr *phdr; - double start_time = 0; /* seconds, with msec resolution */ - double stop_time = 0; /* seconds, with msec resolution */ + double start_time = 0; /* seconds, with nsec resolution */ + double stop_time = 0; /* seconds, with nsec resolution */ double cur_time; unsigned int packets = 0; gboolean is_breaked = FALSE; @@ -220,7 +214,7 @@ preview_do(GtkWidget *prev, wtap *wth) time(&time_preview); while ( (wtap_read(wth, &err, &err_info, &data_offset)) ) { phdr = wtap_phdr(wth); - cur_time = secs_usecs(phdr->ts.tv_sec, phdr->ts.tv_usec); + cur_time = nstime_to_sec( (const nstime_t *) &phdr->ts ); if(packets == 0) { start_time = cur_time; stop_time = cur_time; diff --git a/gtk/flow_graph.c b/gtk/flow_graph.c index cdd92c2f56..dbdfbe4b56 100644 --- a/gtk/flow_graph.c +++ b/gtk/flow_graph.c @@ -194,7 +194,7 @@ static int flow_graph_frame_add_to_graph(packet_info *pinfo) gai = g_malloc(sizeof(graph_analysis_item_t)); gai->frame_num = pinfo->fd->num; - gai->time= (double)pinfo->fd->rel_secs + (double) pinfo->fd->rel_usecs/1000000; + gai->time= nstime_to_sec(&pinfo->fd->rel_ts); COPY_ADDRESS(&(gai->src_addr),&(pinfo->src)); COPY_ADDRESS(&(gai->dst_addr),&(pinfo->dst)); gai->port_src=pinfo->srcport; @@ -250,7 +250,7 @@ static int flow_graph_tcp_add_to_graph(packet_info *pinfo, const struct tcpheade gai = g_malloc(sizeof(graph_analysis_item_t)); gai->frame_num = pinfo->fd->num; - gai->time= (double)pinfo->fd->rel_secs + (double) pinfo->fd->rel_usecs/1000000; + gai->time= nstime_to_sec(&pinfo->fd->rel_ts); COPY_ADDRESS(&(gai->src_addr),&(pinfo->src)); COPY_ADDRESS(&(gai->dst_addr),&(pinfo->dst)); gai->port_src=pinfo->srcport; diff --git a/gtk/io_stat.c b/gtk/io_stat.c index 42274c9e15..1afabdd9bf 100644 --- a/gtk/io_stat.c +++ b/gtk/io_stat.c @@ -240,8 +240,7 @@ gtk_iostat_packet(void *g, packet_info *pinfo, epan_dissect_t *edt, const void * * Find which interval this is supposed to to in and store the * interval index as idx */ - time_delta.secs=pinfo->fd->rel_secs; - time_delta.nsecs=pinfo->fd->rel_usecs*1000; + time_delta=pinfo->fd->rel_ts; if(time_delta.nsecs<0){ time_delta.secs--; time_delta.nsecs+=1000000000; @@ -328,7 +327,7 @@ gtk_iostat_packet(void *g, packet_info *pinfo, epan_dissect_t *edt, const void * t=t*1000000+new_time->nsecs/1000; i=idx; /* handle current interval */ - pt=pinfo->fd->rel_secs*1000000+pinfo->fd->rel_usecs; + pt=pinfo->fd->rel_ts.secs*1000000+pinfo->fd->rel_ts.nsecs/1000; pt=pt%(git->io->interval*1000); if(pt>t){ pt=t; diff --git a/gtk/main.c b/gtk/main.c index 9d782b5966..a9b18b4d51 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -1221,7 +1221,7 @@ set_display_filename(capture_file *cf) /* statusbar */ status_msg = g_strdup_printf(" File: \"%s\" %s %02u:%02u:%02u", (cf->filename) ? cf->filename : "", size_str, - cf->esec/3600, cf->esec%3600/60, cf->esec%60); + cf->elapsed_time.secs/3600, cf->elapsed_time.secs%3600/60, cf->elapsed_time.secs%60); g_free(size_str); statusbar_push_file_msg(status_msg); g_free(status_msg); diff --git a/gtk/mgcp_stat.c b/gtk/mgcp_stat.c index 398f52639f..999d1f8af2 100644 --- a/gtk/mgcp_stat.c +++ b/gtk/mgcp_stat.c @@ -143,12 +143,7 @@ mgcpstat_packet(void *pms, packet_info *pinfo, epan_dissect_t *edt _U_, const vo else { ms->open_req_num--; /* calculate time delta between request and response */ - delta.secs=pinfo->fd->abs_secs-mi->req_time.secs; - delta.nsecs=pinfo->fd->abs_usecs*1000-mi->req_time.nsecs; - if(delta.nsecs<0){ - delta.nsecs+=1000000000; - delta.secs--; - } + nstime_delta(&delta, &pinfo->fd->abs_ts, &mi->req_time); if (strncasecmp(mi->code, "EPCF", 4) == 0 ) { time_stat_update(&(ms->rtd[0]),&delta, pinfo); diff --git a/gtk/packet_list.c b/gtk/packet_list.c index 2b00695d8f..880860bb60 100644 --- a/gtk/packet_list.c +++ b/gtk/packet_list.c @@ -121,13 +121,13 @@ GtkWidget *packet_list; a lower time stamp than any frame with a non-reference time; if both packets' times are reference times, we compare the times of the packets. */ -#define COMPARE_TS(secs, usecs) \ +#define COMPARE_TS(ts) \ ((fdata1->flags.ref_time && !fdata2->flags.ref_time) ? -1 : \ (!fdata1->flags.ref_time && fdata2->flags.ref_time) ? 1 : \ - (fdata1->secs < fdata2->secs) ? -1 : \ - (fdata1->secs > fdata2->secs) ? 1 : \ - (fdata1->usecs < fdata2->usecs) ? -1 :\ - (fdata1->usecs > fdata2->usecs) ? 1 : \ + (fdata1->ts.secs < fdata2->ts.secs) ? -1 : \ + (fdata1->ts.secs > fdata2->ts.secs) ? 1 : \ + (fdata1->ts.nsecs < fdata2->ts.nsecs) ? -1 :\ + (fdata1->ts.nsecs > fdata2->ts.nsecs) ? 1 : \ COMPARE_FRAME_NUM()) static gint packet_list_compare(EthCList *clist, gconstpointer ptr1, gconstpointer ptr2) @@ -162,25 +162,25 @@ packet_list_compare(EthCList *clist, gconstpointer ptr1, gconstpointer ptr2) case TS_ABSOLUTE: case TS_ABSOLUTE_WITH_DATE: - return COMPARE_TS(abs_secs, abs_usecs); + return COMPARE_TS(abs_ts); case TS_RELATIVE: - return COMPARE_TS(rel_secs, rel_usecs); + return COMPARE_TS(rel_ts); case TS_DELTA: - return COMPARE_TS(del_secs, del_usecs); + return COMPARE_TS(del_ts); } return 0; case COL_ABS_TIME: case COL_ABS_DATE_TIME: - return COMPARE_TS(abs_secs, abs_usecs); + return COMPARE_TS(abs_ts); case COL_REL_TIME: - return COMPARE_TS(rel_secs, rel_usecs); + return COMPARE_TS(rel_ts); case COL_DELTA_TIME: - return COMPARE_TS(del_secs, del_usecs); + return COMPARE_TS(del_ts); case COL_PACKET_LENGTH: return COMPARE_NUM(pkt_len); diff --git a/gtk/rpc_progs.c b/gtk/rpc_progs.c index a78095dcbf..8d8d46a8ff 100644 --- a/gtk/rpc_progs.c +++ b/gtk/rpc_progs.c @@ -215,12 +215,7 @@ rpcprogs_packet(void *dummy _U_, packet_info *pinfo, epan_dissect_t *edt _U_, co } /* calculate time delta between request and reply */ - delta.secs=pinfo->fd->abs_secs-ri->req_time.secs; - delta.nsecs=pinfo->fd->abs_usecs*1000-ri->req_time.nsecs; - if(delta.nsecs<0){ - delta.nsecs+=1000000000; - delta.secs--; - } + nstime_delta(&delta, &pinfo->fd->abs_ts, &ri->req_time); if((rp->max.secs==0) && (rp->max.nsecs==0) ){ diff --git a/gtk/rtp_analysis.c b/gtk/rtp_analysis.c index 5b5fad735e..e8310c6fe5 100644 --- a/gtk/rtp_analysis.c +++ b/gtk/rtp_analysis.c @@ -442,7 +442,7 @@ static int rtp_packet_add_graph(dialog_graph_graph_t *dgg, tap_rtp_stat_t *stati if (dgg->ud->dlg.dialog_graph.start_time == -1){ /* it is the first */ dgg->ud->dlg.dialog_graph.start_time = statinfo->start_time; } - rtp_time = ((double)pinfo->fd->rel_secs + (double) pinfo->fd->rel_usecs/1000000) - dgg->ud->dlg.dialog_graph.start_time; + rtp_time = nstime_to_sec(&pinfo->fd->rel_ts) - dgg->ud->dlg.dialog_graph.start_time; if(rtp_time<0){ return FALSE; } @@ -585,7 +585,7 @@ int rtp_packet_analyse(tap_rtp_stat_t *statinfo, clock_rate = get_clock_rate(statinfo->pt); /* store the current time and calculate the current jitter */ - current_time = (double)pinfo->fd->rel_secs + (double) pinfo->fd->rel_usecs/1000000; + current_time = nstime_to_sec(&pinfo->fd->rel_ts); current_diff = fabs (current_time - (statinfo->time) - ((double)(rtpinfo->info_timestamp)-(double)(statinfo->timestamp))/clock_rate); current_jitter = statinfo->jitter + ( current_diff - statinfo->jitter)/16; statinfo->delta = current_time-(statinfo->time); @@ -740,8 +740,8 @@ static int rtp_packet_add_info(GtkCList *clist, time_t then; gchar status[40]; GdkColor color = COLOR_DEFAULT; - then = pinfo->fd->abs_secs; - msecs = (guint16)(pinfo->fd->abs_usecs/1000); + then = pinfo->fd->abs_ts.secs; + msecs = (guint16)(pinfo->fd->abs_ts.nsecs/1000000); tm_tmp = localtime(&then); g_snprintf(timeStr,sizeof(timeStr),"%02d/%02d/%04d %02d:%02d:%02d.%03d", tm_tmp->tm_mon + 1, diff --git a/gtk/rtp_stream.c b/gtk/rtp_stream.c index a003b24c99..d145639413 100644 --- a/gtk/rtp_stream.c +++ b/gtk/rtp_stream.c @@ -229,10 +229,10 @@ static int rtpstream_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _ if (!strinfo) { tmp_strinfo.npackets = 0; tmp_strinfo.first_frame_num = pinfo->fd->num; - tmp_strinfo.start_sec = pinfo->fd->abs_secs; - tmp_strinfo.start_usec = pinfo->fd->abs_usecs; - tmp_strinfo.start_rel_sec = pinfo->fd->rel_secs; - tmp_strinfo.start_rel_usec = pinfo->fd->rel_usecs; + tmp_strinfo.start_sec = pinfo->fd->abs_ts.secs; + tmp_strinfo.start_usec = pinfo->fd->abs_ts.nsecs/1000; + tmp_strinfo.start_rel_sec = pinfo->fd->rel_ts.secs; + tmp_strinfo.start_rel_usec = pinfo->fd->rel_ts.nsecs/1000; tmp_strinfo.tag_vlan_error = 0; tmp_strinfo.tag_diffserv_error = 0; tmp_strinfo.vlan_id = 0; @@ -283,8 +283,8 @@ static int rtpstream_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _ /* increment the packets counter for this stream */ ++(strinfo->npackets); - strinfo->stop_rel_sec = pinfo->fd->rel_secs; - strinfo->stop_rel_usec = pinfo->fd->rel_usecs; + strinfo->stop_rel_sec = pinfo->fd->rel_ts.secs; + strinfo->stop_rel_usec = pinfo->fd->rel_ts.nsecs/1000; /* increment the packets counter of all streams */ ++(tapinfo->npackets); @@ -296,8 +296,8 @@ static int rtpstream_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _ /* XXX - what if rtpinfo->info_all_data_present is FALSE, so that we don't *have* all the data? */ sample.header.rec_time = - (pinfo->fd->abs_usecs + 1000000 - tapinfo->filter_stream_fwd->start_usec)/1000 - + (pinfo->fd->abs_secs - tapinfo->filter_stream_fwd->start_sec - 1)*1000; + (pinfo->fd->abs_ts.nsecs/1000 + 1000000 - tapinfo->filter_stream_fwd->start_usec)/1000 + + (pinfo->fd->abs_ts.secs - tapinfo->filter_stream_fwd->start_sec - 1)*1000; sample.header.frame_length = rtpinfo->info_data_len; sample.frame = rtpinfo->info_data; rtp_write_sample(&sample, tapinfo->save_file); diff --git a/gtk/sctp_stat.c b/gtk/sctp_stat.c index 5599ac41b7..30a842b716 100644 --- a/gtk/sctp_stat.c +++ b/gtk/sctp_stat.c @@ -917,8 +917,8 @@ packet(void *tapdata _U_, packet_info *pinfo , epan_dissect_t *edt _U_ , const v addr = g_malloc(tmp_info.dst.len); memcpy(addr, tmp_info.dst.data, tmp_info.dst.len); sack->dst.data = addr; - sack->secs=tsn->secs = (guint32)pinfo->fd->rel_secs; - sack->usecs=tsn->usecs = (guint32)pinfo->fd->rel_usecs; + sack->secs=tsn->secs = (guint32)pinfo->fd->rel_ts.secs; + sack->usecs=tsn->usecs = (guint32)pinfo->fd->rel_ts.nsecs/1000; if (((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_DATA_CHUNK_ID) || ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_SACK_CHUNK_ID)) { @@ -1131,8 +1131,8 @@ packet(void *tapdata _U_, packet_info *pinfo , epan_dissect_t *edt _U_ , const v addr = g_malloc(tmp_info.dst.len); memcpy(addr, tmp_info.dst.data, tmp_info.dst.len); sack->dst.data = addr; - sack->secs=tsn->secs = (guint32)pinfo->fd->rel_secs; - sack->usecs=tsn->usecs = (guint32)pinfo->fd->rel_usecs; + sack->secs=tsn->secs = (guint32)pinfo->fd->rel_ts.secs; + sack->usecs=tsn->usecs = (guint32)pinfo->fd->rel_ts.nsecs/1000; if (((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_DATA_CHUNK_ID) || ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_SACK_CHUNK_ID)) { diff --git a/gtk/service_response_time_table.c b/gtk/service_response_time_table.c index 1f7abb8cec..ca688c7a34 100644 --- a/gtk/service_response_time_table.c +++ b/gtk/service_response_time_table.c @@ -483,9 +483,8 @@ add_srt_table_data(srt_stat_table *rst, int index, const nstime_t *req_time, pac } /* calculate time delta between request and reply */ - t.secs=pinfo->fd->abs_secs; - t.nsecs=pinfo->fd->abs_usecs*1000; - get_timedelta(&delta, &t, req_time); + t=pinfo->fd->abs_ts; + nstime_delta(&delta, &t, req_time); time_stat_update(&rp->stats, &delta, pinfo); } diff --git a/gtk/tcp_graph.c b/gtk/tcp_graph.c index a914c6c084..5c2da9343c 100644 --- a/gtk/tcp_graph.c +++ b/gtk/tcp_graph.c @@ -1778,10 +1778,10 @@ tapall_tcpip_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, cons ts->direction)) { segment->next = NULL; segment->num = pinfo->fd->num; - segment->rel_secs = pinfo->fd->rel_secs; - segment->rel_usecs = pinfo->fd->rel_usecs; - segment->abs_secs = pinfo->fd->abs_secs; - segment->abs_usecs = pinfo->fd->abs_usecs; + segment->rel_secs = pinfo->fd->rel_ts.secs; + segment->rel_usecs = pinfo->fd->rel_ts.nsecs/1000; + segment->abs_secs = pinfo->fd->abs_ts.secs; + segment->abs_usecs = pinfo->fd->abs_ts.nsecs/1000; segment->th_seq=tcphdr->th_seq; segment->th_ack=tcphdr->th_ack; segment->th_win=tcphdr->th_win; @@ -1929,10 +1929,10 @@ static struct tcpheader *select_tcpip_session (capture_file *cf, struct segment } hdrs->num = fdata->num; - hdrs->rel_secs = fdata->rel_secs; - hdrs->rel_usecs = fdata->rel_usecs; - hdrs->abs_secs = fdata->abs_secs; - hdrs->abs_usecs = fdata->abs_usecs; + hdrs->rel_secs = fdata->rel_ts.secs; + hdrs->rel_usecs = fdata->rel_ts.nsecs/1000; + hdrs->abs_secs = fdata->abs_ts.secs; + hdrs->abs_usecs = fdata->abs_ts.nsecs/1000; hdrs->th_seq=th.tcphdr->th_seq; hdrs->th_ack=th.tcphdr->th_ack; hdrs->th_win=th.tcphdr->th_win; diff --git a/gtk/voip_calls.c b/gtk/voip_calls.c index 5b255b5318..8d7b793fab 100644 --- a/gtk/voip_calls.c +++ b/gtk/voip_calls.c @@ -196,7 +196,7 @@ static int add_to_graph(voip_calls_tapinfo_t *tapinfo _U_, packet_info *pinfo, c gai = g_malloc(sizeof(graph_analysis_item_t)); gai->frame_num = pinfo->fd->num; - gai->time= (double)pinfo->fd->rel_secs + (double) pinfo->fd->rel_usecs/1000000; + gai->time= nstime_to_sec(&pinfo->fd->rel_ts); COPY_ADDRESS(&(gai->src_addr),src_addr); COPY_ADDRESS(&(gai->dst_addr),dst_addr); @@ -479,8 +479,8 @@ RTP_packet( void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U_, const vo if (!strinfo->pt_str) strinfo->pt_str = g_strdup(val_to_str(strinfo->pt, rtp_payload_type_short_vals, "%u")); strinfo->npackets = 0; strinfo->first_frame_num = pinfo->fd->num; - strinfo->start_rel_sec = pinfo->fd->rel_secs; - strinfo->start_rel_usec = pinfo->fd->rel_usecs; + strinfo->start_rel_sec = pinfo->fd->rel_ts.secs; + strinfo->start_rel_usec = pinfo->fd->rel_ts.nsecs/1000; strinfo->setup_frame_number = pi->info_setup_frame_num; strinfo->rtp_event = -1; tapinfo->list = g_list_append(tapinfo->list, strinfo); @@ -489,8 +489,8 @@ RTP_packet( void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U_, const vo if (strinfo!=NULL){ /* Add the info to the existing RTP stream */ strinfo->npackets++; - strinfo->stop_rel_sec = pinfo->fd->rel_secs; - strinfo->stop_rel_usec = pinfo->fd->rel_usecs; + strinfo->stop_rel_sec = pinfo->fd->rel_ts.secs; + strinfo->stop_rel_usec = pinfo->fd->rel_ts.nsecs/1000; } the_tapinfo_struct.redraw = TRUE; @@ -661,8 +661,8 @@ SIPcalls_packet( void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U_, con COPY_ADDRESS(&(strinfo->initial_speaker),&(pinfo->src)); strinfo->first_frame_num=pinfo->fd->num; strinfo->selected=FALSE; - strinfo->start_sec=pinfo->fd->rel_secs; - strinfo->start_usec=pinfo->fd->rel_usecs; + strinfo->start_sec=pinfo->fd->rel_ts.secs; + strinfo->start_usec=pinfo->fd->rel_ts.nsecs/1000; strinfo->protocol=VOIP_SIP; strinfo->prot_info=g_malloc(sizeof(sip_calls_info_t)); tmp_sipinfo=strinfo->prot_info; @@ -726,8 +726,8 @@ SIPcalls_packet( void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U_, con } } - strinfo->stop_sec=pinfo->fd->rel_secs; - strinfo->stop_usec=pinfo->fd->rel_usecs; + strinfo->stop_sec=pinfo->fd->rel_ts.secs; + strinfo->stop_usec=pinfo->fd->rel_ts.nsecs/1000; strinfo->last_frame_num=pinfo->fd->num; ++(strinfo->npackets); /* increment the packets counter of all calls */ @@ -891,8 +891,8 @@ isup_calls_packet(void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U_, co COPY_ADDRESS(&(strinfo->initial_speaker),&(pinfo->src)); strinfo->selected=FALSE; strinfo->first_frame_num=pinfo->fd->num; - strinfo->start_sec=pinfo->fd->rel_secs; - strinfo->start_usec=pinfo->fd->rel_usecs; + strinfo->start_sec=pinfo->fd->rel_ts.secs; + strinfo->start_usec=pinfo->fd->rel_ts.nsecs/1000; strinfo->protocol=VOIP_ISUP; if (pi->calling_number!=NULL){ strinfo->from_identity=g_strdup(pi->calling_number); @@ -912,8 +912,8 @@ isup_calls_packet(void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U_, co } if (strinfo!=NULL){ - strinfo->stop_sec=pinfo->fd->rel_secs; - strinfo->stop_usec=pinfo->fd->rel_usecs; + strinfo->stop_sec=pinfo->fd->rel_ts.secs; + strinfo->stop_usec=pinfo->fd->rel_ts.nsecs/1000; strinfo->last_frame_num=pinfo->fd->num; ++(strinfo->npackets); @@ -1319,8 +1319,8 @@ q931_calls_packet(void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U_, co COPY_ADDRESS(&(strinfo->initial_speaker),actrace_direction?&pstn_add:&(pinfo->src)); strinfo->first_frame_num=pinfo->fd->num; strinfo->selected=FALSE; - strinfo->start_sec=pinfo->fd->rel_secs; - strinfo->start_usec=pinfo->fd->rel_usecs; + strinfo->start_sec=pinfo->fd->rel_ts.secs; + strinfo->start_usec=pinfo->fd->rel_ts.nsecs/1000; strinfo->protocol=VOIP_AC_ISDN; strinfo->prot_info=g_malloc(sizeof(actrace_isdn_calls_info_t)); tmp_actrace_isdn_info=strinfo->prot_info; @@ -1331,8 +1331,8 @@ q931_calls_packet(void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U_, co tapinfo->strinfo_list = g_list_append(tapinfo->strinfo_list, strinfo); } - strinfo->stop_sec=pinfo->fd->rel_secs; - strinfo->stop_usec=pinfo->fd->rel_usecs; + strinfo->stop_sec=pinfo->fd->rel_ts.secs; + strinfo->stop_usec=pinfo->fd->rel_ts.nsecs/1000; strinfo->last_frame_num=pinfo->fd->num; ++(strinfo->npackets); /* increment the packets counter of all calls */ @@ -1506,8 +1506,8 @@ H225calls_packet(void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U_, con COPY_ADDRESS(&(strinfo->initial_speaker),&(pinfo->src)); strinfo->selected=FALSE; strinfo->first_frame_num=pinfo->fd->num; - strinfo->start_sec=pinfo->fd->rel_secs; - strinfo->start_usec=pinfo->fd->rel_usecs; + strinfo->start_sec=pinfo->fd->rel_ts.secs; + strinfo->start_usec=pinfo->fd->rel_ts.nsecs/1000; strinfo->protocol=VOIP_H323; strinfo->prot_info=g_malloc(sizeof(h323_calls_info_t)); tmp_h323info = strinfo->prot_info; @@ -1538,8 +1538,8 @@ H225calls_packet(void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U_, con COPY_ADDRESS(&(tmp_src),&(pinfo->src)); COPY_ADDRESS(&(tmp_dst),&(pinfo->dst)); - strinfo->stop_sec=pinfo->fd->rel_secs; - strinfo->stop_usec=pinfo->fd->rel_usecs; + strinfo->stop_sec=pinfo->fd->rel_ts.secs; + strinfo->stop_usec=pinfo->fd->rel_ts.nsecs/1000; strinfo->last_frame_num=pinfo->fd->num; ++(strinfo->npackets); /* increment the packets counter of all calls */ @@ -2091,7 +2091,7 @@ MGCPcalls_packet( void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U_, co check first if it is an ended call. We consider an ended call after 1sec we don't get a packet in this Endpoint and the call has been released */ - diff_time = (pinfo->fd->rel_secs + (double)pinfo->fd->rel_secs/1000000) - (tmp_listinfo->stop_sec + (double)tmp_listinfo->stop_usec/1000000); + diff_time = nstime_to_sec(&pinfo->fd->rel_ts) - tmp_listinfo->stop_sec + (double)tmp_listinfo->stop_usec/1000000; if ( ((tmp_listinfo->call_state == VOIP_CANCELLED) || (tmp_listinfo->call_state == VOIP_COMPLETED) || (tmp_listinfo->call_state == VOIP_REJECTED)) && (diff_time > 1) ){ tmp_listinfo->call_active_state = VOIP_INACTIVE; } else { @@ -2162,8 +2162,8 @@ MGCPcalls_packet( void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U_, co COPY_ADDRESS(&(strinfo->initial_speaker),&(pinfo->src)); strinfo->first_frame_num=pinfo->fd->num; strinfo->selected=FALSE; - strinfo->start_sec=pinfo->fd->rel_secs; - strinfo->start_usec=pinfo->fd->rel_usecs; + strinfo->start_sec=pinfo->fd->rel_ts.secs; + strinfo->start_usec=pinfo->fd->rel_ts.nsecs/1000; strinfo->protocol=VOIP_MGCP; strinfo->prot_info=g_malloc(sizeof(mgcp_calls_info_t)); tmp_mgcpinfo=strinfo->prot_info; @@ -2249,8 +2249,8 @@ MGCPcalls_packet( void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U_, co comment = g_strdup_printf("MGCP %s %s%s", tmp_mgcpinfo->endpointId, (pi->mgcp_type == MGCP_REQUEST)?"Request":"Response", pi->is_duplicate?" Duplicate":""); - strinfo->stop_sec=pinfo->fd->rel_secs; - strinfo->stop_usec=pinfo->fd->rel_usecs; + strinfo->stop_sec=pinfo->fd->rel_ts.secs; + strinfo->stop_usec=pinfo->fd->rel_ts.nsecs/1000; strinfo->last_frame_num=pinfo->fd->num; ++(strinfo->npackets); /* increment the packets counter of all calls */ @@ -2373,8 +2373,8 @@ ACTRACEcalls_packet(void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U_, COPY_ADDRESS(&(strinfo->initial_speaker),actrace_direction?&pstn_add:&(pinfo->src)); strinfo->first_frame_num=pinfo->fd->num; strinfo->selected=FALSE; - strinfo->start_sec=pinfo->fd->rel_secs; - strinfo->start_usec=pinfo->fd->rel_usecs; + strinfo->start_sec=pinfo->fd->rel_ts.secs; + strinfo->start_usec=pinfo->fd->rel_ts.nsecs/1000; strinfo->protocol=VOIP_AC_CAS; strinfo->prot_info=g_malloc(sizeof(actrace_cas_calls_info_t)); tmp_actrace_cas_info=strinfo->prot_info; @@ -2385,8 +2385,8 @@ ACTRACEcalls_packet(void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U_, tapinfo->strinfo_list = g_list_append(tapinfo->strinfo_list, strinfo); } - strinfo->stop_sec=pinfo->fd->rel_secs; - strinfo->stop_usec=pinfo->fd->rel_usecs; + strinfo->stop_sec=pinfo->fd->rel_ts.secs; + strinfo->stop_usec=pinfo->fd->rel_ts.nsecs/1000; strinfo->last_frame_num=pinfo->fd->num; ++(strinfo->npackets); /* increment the packets counter of all calls */ diff --git a/merge.c b/merge.c index f2fb294aa2..8fd1c63af0 100644 --- a/merge.c +++ b/merge.c @@ -133,12 +133,12 @@ merge_max_snapshot_length(int count, merge_in_file_t in_files[]) * returns TRUE if first argument is earlier than second */ static gboolean -is_earlier(struct timeval *l, struct timeval *r) { - if (l->tv_sec > r->tv_sec) { /* left is later */ +is_earlier(struct wtap_nstime *l, struct wtap_nstime *r) { + if (l->secs > r->secs) { /* left is later */ return FALSE; - } else if (l->tv_sec < r->tv_sec) { /* left is earlier */ + } else if (l->secs < r->secs) { /* left is earlier */ return TRUE; - } else if (l->tv_usec > r->tv_usec) { /* tv_sec equal, l.usec later */ + } else if (l->nsecs > r->nsecs) { /* tv_sec equal, l.usec later */ return FALSE; } /* either one < two or one == two @@ -157,7 +157,7 @@ merge_read_packet(int in_file_count, merge_in_file_t in_files[], int *err, { int i; int ei = -1; - struct timeval tv = {LONG_MAX, LONG_MAX}; + struct wtap_nstime tv = {LONG_MAX, LONG_MAX}; struct wtap_pkthdr *phdr; /* diff --git a/plugins/mate/mate_runtime.c b/plugins/mate/mate_runtime.c index e314ab2216..362c8d3e31 100644 --- a/plugins/mate/mate_runtime.c +++ b/plugins/mate/mate_runtime.c @@ -847,7 +847,7 @@ extern void mate_analyze_frame(packet_info *pinfo, proto_tree* tree) { mate_pdu* pdu = NULL; mate_pdu* last = NULL; - rd->now = (((float)pinfo->fd->rel_secs) + (((float)pinfo->fd->rel_usecs) / 1000000) ); + rd->now = (float) nstime_to_sec(&pinfo->fd->rel_ts); if ( tree->tree_data && tree->tree_data->interesting_hfids && rd->highest_analyzed_frame < pinfo->fd->num ) { diff --git a/plugins/mgcp/packet-mgcp.c b/plugins/mgcp/packet-mgcp.c index e811cd221c..12df9ecda9 100644 --- a/plugins/mgcp/packet-mgcp.c +++ b/plugins/mgcp/packet-mgcp.c @@ -1507,13 +1507,7 @@ static void dissect_mgcp_firstline(tvbuff_t *tvb, packet_info *pinfo, proto_tree "This is a response to a request in frame %u", mgcp_call->req_num); PROTO_ITEM_SET_GENERATED(item); - delta.secs= pinfo->fd->abs_secs-mgcp_call->req_time.secs; - delta.nsecs=pinfo->fd->abs_usecs*1000-mgcp_call->req_time.nsecs; - if (delta.nsecs<0) - { - delta.nsecs+=1000000000; - delta.secs--; - } + nstime_delta(&delta, &pinfo->fd->abs_ts, &mgcp_call->req_time); item = proto_tree_add_time(tree, hf_mgcp_time, tvb, 0, 0, &delta); PROTO_ITEM_SET_GENERATED(item); } @@ -1655,8 +1649,7 @@ static void dissect_mgcp_firstline(tvbuff_t *tvb, packet_info *pinfo, proto_tree mgcp_call->rsp_num = 0; mgcp_call->transid = mi->transid; mgcp_call->responded = FALSE; - mgcp_call->req_time.secs=pinfo->fd->abs_secs; - mgcp_call->req_time.nsecs=pinfo->fd->abs_usecs*1000; + mgcp_call->req_time=pinfo->fd->abs_ts; strcpy(mgcp_call->code,mi->code); /* Store it */ diff --git a/proto_hier_stats.c b/proto_hier_stats.c index b634712d2e..f1e0d87ef1 100644 --- a/proto_hier_stats.c +++ b/proto_hier_stats.c @@ -42,11 +42,6 @@ #define STAT_NODE_STATS(n) ((ph_stats_node_t*)(n)->data) #define STAT_NODE_HFINFO(n) (STAT_NODE_STATS(n)->hfinfo) -static double -secs_usecs(guint32 s, guint32 us) -{ - return (us / 1000000.0) + (double)s; -} static GNode* find_stat_node(GNode *parent_stat_node, header_field_info *needle_hfinfo) @@ -161,7 +156,7 @@ process_frame(frame_data *frame, column_info *cinfo, ph_stats_t* ps) process_tree(edt->tree, ps, frame->pkt_len); /* Update times */ - cur_time = secs_usecs(frame->abs_secs, frame->abs_usecs); + cur_time = nstime_to_sec(&frame->abs_ts); if (cur_time < ps->first_time) { ps->first_time = cur_time; } @@ -256,8 +251,7 @@ ph_stats_new(void) if (frame->flags.passed_dfilter) { if (tot_packets == 0) { - double cur_time = secs_usecs(frame->abs_secs, - frame->abs_usecs); + double cur_time = nstime_to_sec(&frame->abs_ts); ps->first_time = cur_time; ps->last_time = cur_time; } diff --git a/summary.c b/summary.c index 511cf47f18..b21706c6be 100644 --- a/summary.c +++ b/summary.c @@ -34,18 +34,12 @@ #endif -static double -secs_usecs( guint32 s, guint32 us) -{ - return (us / 1000000.0) + (double)s; -} - static void tally_frame_data(frame_data *cur_frame, summary_tally *sum_tally) { double cur_time; - cur_time = secs_usecs(cur_frame->abs_secs, cur_frame->abs_usecs); + cur_time = nstime_to_sec(&cur_frame->abs_ts); if (cur_time < sum_tally->start_time) { sum_tally->start_time = cur_time; @@ -94,8 +88,8 @@ summary_fill_in(capture_file *cf, summary_tally *st) /* initialize the tally */ if (cf->plist != NULL) { first_frame = cf->plist; - st->start_time = secs_usecs(first_frame->abs_secs,first_frame->abs_usecs); - st->stop_time = secs_usecs(first_frame->abs_secs,first_frame->abs_usecs); + st->start_time = nstime_to_sec(&first_frame->abs_ts); + st->stop_time = nstime_to_sec(&first_frame->abs_ts); cur_glist = cf->plist; for (i = 0; i < cf->count; i++) { @@ -110,7 +104,7 @@ summary_fill_in(capture_file *cf, summary_tally *st) st->encap_type = cf->cd_t; st->has_snap = cf->has_snap; st->snap = cf->snap; - st->elapsed_time = secs_usecs(cf->esec, cf->eusec); + st->elapsed_time = nstime_to_sec(&cf->elapsed_time); st->packet_count = cf->count; st->drops_known = cf->drops_known; st->drops = cf->drops; diff --git a/tap-afpstat.c b/tap-afpstat.c index bedee12f1a..93e529e0de 100644 --- a/tap-afpstat.c +++ b/tap-afpstat.c @@ -64,9 +64,8 @@ afpstat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const voi sp=&(ss->proc[request_val->command]); /* calculate time delta between request and reply */ - t.secs=pinfo->fd->abs_secs; - t.nsecs=pinfo->fd->abs_usecs*1000; - get_timedelta(&deltat, &t, &request_val->req_time); + t=pinfo->fd->abs_ts; + nstime_delta(&deltat, &t, &request_val->req_time); if(sp){ time_stat_update(sp,&deltat, pinfo); diff --git a/tap-dcerpcstat.c b/tap-dcerpcstat.c index f87849a63f..32c0cab777 100644 --- a/tap-dcerpcstat.c +++ b/tap-dcerpcstat.c @@ -104,12 +104,7 @@ dcerpcstat_packet(void *prs, packet_info *pinfo, epan_dissect_t *edt _U_, const rp=&(rs->procedures[ri->call_data->opnum]); /* calculate time delta between request and reply */ - delta.secs=pinfo->fd->abs_secs-ri->call_data->req_time.secs; - delta.nsecs=pinfo->fd->abs_usecs*1000-ri->call_data->req_time.nsecs; - if(delta.nsecs<0){ - delta.nsecs+=1000000000; - delta.secs--; - } + nstime_delta(&delta, &pinfo->fd->abs_ts, &ri->call_data->req_time); if(rp->num==0){ rp->max.secs=delta.secs; diff --git a/tap-iostat.c b/tap-iostat.c index afe1740a20..f6dd2b4852 100644 --- a/tap-iostat.c +++ b/tap-iostat.c @@ -76,7 +76,7 @@ iostat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, const void GPtrArray *gp; guint i; - current_time=((pinfo->fd->rel_secs*1000)+(pinfo->fd->rel_usecs/1000)); + current_time=((pinfo->fd->rel_ts.secs*1000)+(pinfo->fd->rel_ts.nsecs/1000000)); /* the prev item before the main one is always the last interval we saw packets for */ it=mit->prev; diff --git a/tap-mgcpstat.c b/tap-mgcpstat.c index acd1980ae1..255970b7d4 100644 --- a/tap-mgcpstat.c +++ b/tap-mgcpstat.c @@ -101,12 +101,7 @@ mgcpstat_packet(void *pms, packet_info *pinfo, epan_dissect_t *edt _U_, const vo else { ms->open_req_num--; /* calculate time delta between request and response */ - delta.secs=pinfo->fd->abs_secs-mi->req_time.secs; - delta.nsecs=pinfo->fd->abs_usecs*1000-mi->req_time.nsecs; - if(delta.nsecs<0){ - delta.nsecs+=1000000000; - delta.secs--; - } + nstime_delta(&delta, &pinfo->fd->abs_ts, &mi->req_time); time_stat_update(&(ms->rtd[0]),&delta, pinfo); diff --git a/tap-rpcprogs.c b/tap-rpcprogs.c index 51fc6a160e..533db827fa 100644 --- a/tap-rpcprogs.c +++ b/tap-rpcprogs.c @@ -135,12 +135,7 @@ rpcprogs_packet(void *dummy1 _U_, packet_info *pinfo, epan_dissect_t *edt _U_, c } /* calculate time delta between request and reply */ - delta.secs=pinfo->fd->abs_secs-ri->req_time.secs; - delta.nsecs=pinfo->fd->abs_usecs*1000-ri->req_time.nsecs; - if(delta.nsecs<0){ - delta.nsecs+=1000000000; - delta.secs--; - } + nstime_delta(&delta, &pinfo->fd->abs_ts, &ri->req_time); if((rp->max.secs==0) && (rp->max.nsecs==0) ){ diff --git a/tap-rpcstat.c b/tap-rpcstat.c index 48d78fe0cb..b443116bb2 100644 --- a/tap-rpcstat.c +++ b/tap-rpcstat.c @@ -148,12 +148,7 @@ rpcstat_packet(void *prs, packet_info *pinfo, epan_dissect_t *edt _U_, const voi rp=&(rs->procedures[ri->proc]); /* calculate time delta between request and reply */ - delta.secs=pinfo->fd->abs_secs-ri->req_time.secs; - delta.nsecs=pinfo->fd->abs_usecs*1000-ri->req_time.nsecs; - if(delta.nsecs<0){ - delta.nsecs+=1000000000; - delta.secs--; - } + nstime_delta(&delta, &pinfo->fd->abs_ts, &ri->req_time); if(rp->num==0){ rp->max.secs=delta.secs; diff --git a/tap-smbstat.c b/tap-smbstat.c index 8173efd656..eac0346c20 100644 --- a/tap-smbstat.c +++ b/tap-smbstat.c @@ -87,9 +87,8 @@ smbstat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const voi } /* calculate time delta between request and reply */ - t.secs=pinfo->fd->abs_secs; - t.nsecs=pinfo->fd->abs_usecs*1000; - get_timedelta(&deltat, &t, &si->sip->req_time); + t=pinfo->fd->abs_ts; + nstime_delta(&deltat, &t, &si->sip->req_time); if(sp){ time_stat_update(sp,&deltat, pinfo); diff --git a/tethereal.c b/tethereal.c index 9f1324a329..65f933cd81 100644 --- a/tethereal.c +++ b/tethereal.c @@ -106,8 +106,8 @@ */ static const gchar decode_as_arg_template[] = "==,"; -static guint32 firstsec, firstusec; -static guint32 prevsec, prevusec; +static nstime_t first_ts; +static nstime_t prev_ts; static GString *comp_info_str, *runtime_info_str; static gboolean print_packet_info; /* TRUE if we're to print packet information */ @@ -2225,8 +2225,7 @@ fill_in_fdata(frame_data *fdata, capture_file *cf, fdata->cap_len = phdr->caplen; fdata->file_off = offset; fdata->lnk_t = phdr->pkt_encap; - fdata->abs_secs = phdr->ts.tv_sec; - fdata->abs_usecs = phdr->ts.tv_usec; + fdata->abs_ts = *((nstime_t *) &phdr->ts); fdata->flags.passed_dfilter = 0; fdata->flags.encoding = CHAR_ASCII; fdata->flags.visited = 0; @@ -2236,39 +2235,33 @@ fill_in_fdata(frame_data *fdata, capture_file *cf, /* If we don't have the time stamp of the first packet in the capture, it's because this is the first packet. Save the time stamp of this packet as the time stamp of the first packet. */ - if (!firstsec && !firstusec) { - firstsec = fdata->abs_secs; - firstusec = fdata->abs_usecs; + if (nstime_is_zero(&first_ts)) { + first_ts = fdata->abs_ts; } /* If we don't have the time stamp of the previous displayed packet, it's because this is the first displayed packet. Save the time stamp of this packet as the time stamp of the previous displayed packet. */ - if (!prevsec && !prevusec) { - prevsec = fdata->abs_secs; - prevusec = fdata->abs_usecs; + if (nstime_is_zero(&prev_ts)) { + prev_ts = fdata->abs_ts; } /* Get the time elapsed between the first packet and this packet. */ - compute_timestamp_diff(&fdata->rel_secs, &fdata->rel_usecs, - fdata->abs_secs, fdata->abs_usecs, firstsec, firstusec); + nstime_delta(&fdata->rel_ts, &fdata->abs_ts, &first_ts); /* If it's greater than the current elapsed time, set the elapsed time to it (we check for "greater than" so as not to be confused by time moving backwards). */ - if ((gint32)cf->esec < fdata->rel_secs - || ((gint32)cf->esec == fdata->rel_secs && (gint32)cf->eusec < fdata->rel_usecs)) { - cf->esec = fdata->rel_secs; - cf->eusec = fdata->rel_usecs; + if ((gint32)cf->elapsed_time.secs < fdata->rel_ts.secs + || ((gint32)cf->elapsed_time.secs == fdata->rel_ts.secs && (gint32)cf->elapsed_time.nsecs < fdata->rel_ts.nsecs)) { + cf->elapsed_time = fdata->rel_ts; } /* Get the time elapsed between the previous displayed packet and this packet. */ - compute_timestamp_diff(&fdata->del_secs, &fdata->del_usecs, - fdata->abs_secs, fdata->abs_usecs, prevsec, prevusec); - prevsec = fdata->abs_secs; - prevusec = fdata->abs_usecs; + nstime_delta(&fdata->del_ts, &fdata->abs_ts, &prev_ts); + prev_ts = fdata->abs_ts; } /* Free up all data attached to a "frame_data" structure. */ @@ -2987,8 +2980,6 @@ cf_open(capture_file *cf, const char *fname, gboolean is_tempfile, int *err) cf->count = 0; cf->drops_known = FALSE; cf->drops = 0; - cf->esec = 0; - cf->eusec = 0; cf->snap = wtap_snapshot_length(cf->wth); if (cf->snap == 0) { /* Snapshot length not known. */ @@ -2996,8 +2987,9 @@ cf_open(capture_file *cf, const char *fname, gboolean is_tempfile, int *err) cf->snap = WTAP_MAX_PACKET_SIZE; } else cf->has_snap = TRUE; - firstsec = 0, firstusec = 0; - prevsec = 0, prevusec = 0; + nstime_set_zero(&cf->elapsed_time); + nstime_set_zero(&first_ts); + nstime_set_zero(&prev_ts); return CF_OK; diff --git a/timestats.c b/timestats.c index ed5cd5a86f..ec644b3b37 100644 --- a/timestats.c +++ b/timestats.c @@ -63,7 +63,7 @@ time_stat_update(timestat_t *stats, const nstime_t *delta, packet_info *pinfo) stats->max_num=pinfo->fd->num; } - addtime(&stats->tot, delta); + nstime_add(&stats->tot, delta); stats->num++; } diff --git a/wiretap/5views.c b/wiretap/5views.c index c17101449d..38fc251ef9 100644 --- a/wiretap/5views.c +++ b/wiretap/5views.c @@ -251,8 +251,8 @@ _5views_read(wtap *wth, int *err, gchar **err_info _U_, long *data_offset) TimeStamped_Header.Utc = pletohl(&TimeStamped_Header.Utc); TimeStamped_Header.NanoSecondes = pletohl(&TimeStamped_Header.NanoSecondes); - wth->phdr.ts.tv_sec = TimeStamped_Header.Utc; - wth->phdr.ts.tv_usec = TimeStamped_Header.NanoSecondes/1000; + wth->phdr.ts.secs = TimeStamped_Header.Utc; + wth->phdr.ts.nsecs = TimeStamped_Header.NanoSecondes; wth->phdr.caplen = packet_size; wth->phdr.len = orig_size; @@ -414,8 +414,8 @@ static gboolean _5views_dump(wtap_dumper *wdh, HeaderFrame.RecNb = htolel(1); /* record-dependant fields */ - HeaderFrame.Utc = htolel(phdr->ts.tv_sec); - HeaderFrame.NanoSecondes = htolel(phdr->ts.tv_usec*1000); + HeaderFrame.Utc = htolel(phdr->ts.secs); + HeaderFrame.NanoSecondes = htolel(phdr->ts.nsecs); HeaderFrame.RecSize = htolel(phdr->len); HeaderFrame.RecInfo = htolel(0); diff --git a/wiretap/airopeek9.c b/wiretap/airopeek9.c index 8cc276f54a..2eee7f5f76 100644 --- a/wiretap/airopeek9.c +++ b/wiretap/airopeek9.c @@ -509,8 +509,8 @@ static gboolean airopeekv9_read(wtap *wth, int *err, gchar **err_info, t *= 1.0e-9; t -= TIME_FIXUP_CONSTANT; - wth->phdr.ts.tv_sec = (time_t) t; - wth->phdr.ts.tv_usec = (guint32) ((t - wth->phdr.ts.tv_sec)*1000000); + wth->phdr.ts.secs = (time_t) t; + wth->phdr.ts.nsecs = (guint32) ((t - wth->phdr.ts.secs)*1000000000); switch (wth->file_encap) { diff --git a/wiretap/ascend.c b/wiretap/ascend.c index 5c57279905..0145aec796 100644 --- a/wiretap/ascend.c +++ b/wiretap/ascend.c @@ -298,8 +298,8 @@ static gboolean ascend_read(wtap *wth, int *err, gchar **err_info, if (wth->capture.ascend->inittime > header.secs) wth->capture.ascend->inittime -= header.secs; } - wth->phdr.ts.tv_sec = header.secs + wth->capture.ascend->inittime; - wth->phdr.ts.tv_usec = header.usecs; + wth->phdr.ts.secs = header.secs + wth->capture.ascend->inittime; + wth->phdr.ts.nsecs = header.usecs * 1000; wth->phdr.caplen = header.caplen; wth->phdr.len = header.len; wth->data_offset = offset; diff --git a/wiretap/cosine.c b/wiretap/cosine.c index 2b8138910c..e185ea9f7f 100644 --- a/wiretap/cosine.c +++ b/wiretap/cosine.c @@ -418,8 +418,8 @@ parse_cosine_rec_hdr(wtap *wth, const char *line, tm.tm_min = min; tm.tm_sec = sec; tm.tm_isdst = -1; - wth->phdr.ts.tv_sec = mktime(&tm); - wth->phdr.ts.tv_usec = csec * 10000; + wth->phdr.ts.secs = mktime(&tm); + wth->phdr.ts.nsecs = csec * 10000000; wth->phdr.len = pkt_len; } /* XXX need to handle other encapsulations like Cisco HDLC, diff --git a/wiretap/csids.c b/wiretap/csids.c index 4312c3a4fa..ff7c55c687 100644 --- a/wiretap/csids.c +++ b/wiretap/csids.c @@ -180,8 +180,8 @@ static gboolean csids_read(wtap *wth, int *err, gchar **err_info _U_, wth->phdr.len = hdr.caplen; wth->phdr.caplen = hdr.caplen; - wth->phdr.ts.tv_sec = hdr.seconds; - wth->phdr.ts.tv_usec = 0; + wth->phdr.ts.secs = hdr.seconds; + wth->phdr.ts.nsecs = 0; if( wth->capture.csids->byteswapped == TRUE ) { guint16* swap = (guint16*)buf; diff --git a/wiretap/dbs-etherwatch.c b/wiretap/dbs-etherwatch.c index 7cd7ebc8e3..7331b694c1 100644 --- a/wiretap/dbs-etherwatch.c +++ b/wiretap/dbs-etherwatch.c @@ -474,9 +474,8 @@ parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err, tm.tm_year -= 1900; tm.tm_isdst = -1; - wth->phdr.ts.tv_sec = mktime(&tm); - - wth->phdr.ts.tv_usec = csec * 10000; + wth->phdr.ts.secs = mktime(&tm); + wth->phdr.ts.nsecs = csec * 10000000; wth->phdr.caplen = eth_hdr_len + pkt_len; wth->phdr.len = eth_hdr_len + pkt_len; } diff --git a/wiretap/erf.c b/wiretap/erf.c index cbde26704a..0937e9004b 100644 --- a/wiretap/erf.c +++ b/wiretap/erf.c @@ -330,13 +330,13 @@ static int erf_read_header( #ifdef G_HAVE_GINT64 guint64 ts = pletohll(&erf_header->ts); - phdr->ts.tv_sec = (long) (ts >> 32); + phdr->ts.secs = (long) (ts >> 32); ts = ((ts & 0xffffffff) * 1000 * 1000); ts += (ts & 0x80000000) << 1; /* rounding */ - phdr->ts.tv_usec = (long) (ts >> 32); - if (phdr->ts.tv_usec >= 1000000) { - phdr->ts.tv_usec -= 1000000; - phdr->ts.tv_sec += 1; + phdr->ts.nsecs = ((long) (ts >> 32)) * 1000; + if (phdr->ts.nsecs >= 1000000000) { + phdr->ts.nsecs -= 1000000000; + phdr->ts.secs += 1; } #else phdr->ts.tv_sec = pletohl(&erf_header->ts[1]); diff --git a/wiretap/etherpeek.c b/wiretap/etherpeek.c index 7967df2f90..afa8044f90 100644 --- a/wiretap/etherpeek.c +++ b/wiretap/etherpeek.c @@ -449,9 +449,9 @@ static gboolean etherpeek_read_v7(wtap *wth, int *err, gchar **err_info, t = (double) timestamp.lower + (double) timestamp.upper * 4294967296.0; t -= (double) mac2unix * 1000000.0; - wth->phdr.ts.tv_sec = (time_t) (t/1000000.0); - wth->phdr.ts.tv_usec = (guint32) (t - (double) wth->phdr.ts.tv_sec * - 1000000.0); + wth->phdr.ts.secs = (time_t) (t/1000000.0); + wth->phdr.ts.nsecs = (guint32) (t - (double) wth->phdr.ts.secs * + 1000000000.0); if (wth->file_encap == WTAP_ENCAP_IEEE_802_11_WITH_RADIO) { /* @@ -596,9 +596,9 @@ static gboolean etherpeek_read_v56(wtap *wth, int *err, gchar **err_info _U_, wth->phdr.len = length; wth->phdr.caplen = sliceLength; /* timestamp is in milliseconds since reference_time */ - wth->phdr.ts.tv_sec = wth->capture.etherpeek->reference_time.tv_sec + wth->phdr.ts.secs = wth->capture.etherpeek->reference_time.tv_sec + (timestamp / 1000); - wth->phdr.ts.tv_usec = 1000 * (timestamp % 1000); + wth->phdr.ts.nsecs = 1000 * (timestamp % 1000) * 1000; wth->phdr.pkt_encap = WTAP_ENCAP_UNKNOWN; for (i=0; iphdr.ts.tv_sec = secs; - wth->phdr.ts.tv_usec = usecs; + wth->phdr.ts.secs = secs; + wth->phdr.ts.nsecs = usecs * 1000; wth->phdr.caplen = pkt_len; wth->phdr.len = pkt_len; } diff --git a/wiretap/file_access.c b/wiretap/file_access.c index 1e9cf016d3..1881fc248a 100644 --- a/wiretap/file_access.c +++ b/wiretap/file_access.c @@ -279,6 +279,7 @@ wtap* wtap_open_offline(const char *filename, int *err, char **err_info, wth->data_offset = 0; wth->subtype_sequential_close = NULL; wth->subtype_close = NULL; + wth->tsprecision = WTAP_FILE_TSPREC_USEC; /* Try all file types */ for (i = 0; i < N_FILE_TYPES; i++) { diff --git a/wiretap/hcidump.c b/wiretap/hcidump.c index d9c5718999..ccca83ce8f 100644 --- a/wiretap/hcidump.c +++ b/wiretap/hcidump.c @@ -80,8 +80,8 @@ static gboolean hcidump_read(wtap *wth, int *err, gchar **err_info, } wth->data_offset += packet_size; - wth->phdr.ts.tv_sec = GUINT32_FROM_LE(dh.ts_sec); - wth->phdr.ts.tv_usec = GUINT32_FROM_LE(dh.ts_usec); + wth->phdr.ts.secs = GUINT32_FROM_LE(dh.ts_sec); + wth->phdr.ts.nsecs = GUINT32_FROM_LE(dh.ts_usec) * 1000; wth->phdr.caplen = packet_size; wth->phdr.len = packet_size; diff --git a/wiretap/i4btrace.c b/wiretap/i4btrace.c index 892e5fdb2b..11dc2cc2fd 100644 --- a/wiretap/i4btrace.c +++ b/wiretap/i4btrace.c @@ -142,8 +142,8 @@ static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info, wth->phdr.len = length; wth->phdr.caplen = length; - wth->phdr.ts.tv_sec = hdr.ts_sec; - wth->phdr.ts.tv_usec = hdr.ts_usec; + wth->phdr.ts.secs = hdr.ts_sec; + wth->phdr.ts.nsecs = hdr.ts_usec * 1000; /* * Read the packet data. diff --git a/wiretap/iptrace.c b/wiretap/iptrace.c index f427cff95b..9281b6b80c 100644 --- a/wiretap/iptrace.c +++ b/wiretap/iptrace.c @@ -179,8 +179,8 @@ static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info _U_, wth->phdr.len = packet_size; wth->phdr.caplen = packet_size; - wth->phdr.ts.tv_sec = pntohl(&header[4]); - wth->phdr.ts.tv_usec = 0; + wth->phdr.ts.secs = pntohl(&header[4]); + wth->phdr.ts.nsecs = 0; if (wth->phdr.pkt_encap == WTAP_ENCAP_UNKNOWN) { *err = WTAP_ERR_UNSUPPORTED_ENCAP; @@ -362,8 +362,8 @@ static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info _U_, wth->phdr.len = packet_size; wth->phdr.caplen = packet_size; - wth->phdr.ts.tv_sec = pntohl(&header[32]); - wth->phdr.ts.tv_usec = pntohl(&header[36]) / 1000; + wth->phdr.ts.secs = pntohl(&header[32]); + wth->phdr.ts.nsecs = pntohl(&header[36]); if (wth->phdr.pkt_encap == WTAP_ENCAP_UNKNOWN) { *err = WTAP_ERR_UNSUPPORTED_ENCAP; diff --git a/wiretap/k12.c b/wiretap/k12.c index 42e90f7205..ecd9b75185 100644 --- a/wiretap/k12.c +++ b/wiretap/k12.c @@ -212,8 +212,8 @@ static gboolean k12_read(wtap *wth, int *err, gchar **err_info _U_, long *data_o ts = pntohll(buffer + K12_PACKET_TIMESTAMP); - wth->phdr.ts.tv_usec = (guint32) ( (ts % 2000000) / 2); - wth->phdr.ts.tv_sec = (guint32) ((ts / 2000000) + 631152000); + wth->phdr.ts.secs = (guint32) ( (ts % 2000000) / 2); + wth->phdr.ts.nsecs = (guint32) ((ts / 2000000) + 631152000) * 1000; wth->phdr.len = wth->phdr.caplen = pntohl(buffer + K12_RECORD_FRAME_LEN) & 0x00001FFF; @@ -597,7 +597,7 @@ static gboolean k12_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, obj.record.frame_len = g_htonl(phdr->len); obj.record.input = g_htonl(pseudo_header->k12.input); - obj.record.ts = GUINT64_TO_BE((((guint64)phdr->ts.tv_sec - 631152000) * 2000000) + (phdr->ts.tv_usec * 2)); + obj.record.ts = GUINT64_TO_BE((((guint64)phdr->ts.secs - 631152000) * 2000000) + (phdr->ts.nsecs / 1000 * 2)); memcpy(obj.record.frame,pd,phdr->len); diff --git a/wiretap/lanalyzer.c b/wiretap/lanalyzer.c index 00679a94fb..a6553ecc60 100644 --- a/wiretap/lanalyzer.c +++ b/wiretap/lanalyzer.c @@ -370,9 +370,9 @@ static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info, 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)) - *1.0e6); + wth->phdr.ts.secs = (long)t; + wth->phdr.ts.nsecs = (unsigned long)((t-(double)(wth->phdr.ts.secs)) + *1.0e9); if (true_size - 4 >= packet_size) { /* @@ -556,6 +556,7 @@ static gboolean lanalyzer_dump(wtap_dumper *wdh, double x; int i; int len; + struct timeval tv; LA_TmpInfo *itmp = (LA_TmpInfo*)(wdh->dump.opaque); struct timeval td; @@ -576,19 +577,22 @@ static gboolean lanalyzer_dump(wtap_dumper *wdh, if (*err) return FALSE; + tv.tv_sec = phdr->ts.secs; + tv.tv_usec = phdr->ts.nsecs / 1000; if (!itmp->init) { /* collect some information for the * finally written header */ - itmp->start = phdr->ts; + /* XXX - this conversion could probably improved, if the start uses ns */ + itmp->start = tv; itmp->pkts = 0; itmp->init = TRUE; itmp->encap = wdh->encap; itmp->lastlen = 0; } - my_timersub(&(phdr->ts),&(itmp->start),&td); + my_timersub(&(tv),&(itmp->start),&td); x = (double) td.tv_usec; x += (double) td.tv_sec * 1000000; diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c index a7738c4af2..86bf798a6f 100644 --- a/wiretap/libpcap.c +++ b/wiretap/libpcap.c @@ -601,6 +601,10 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info) gboolean aix; int file_encap; + + /* XXX - this must be done depending on the magic number */ + /*wth->tsrecision = WTAP_FILE_TSPREC_NSEC;*/ + /* Read in the number that should be at the start of a "libpcap" file */ errno = WTAP_ERR_CANT_READ; bytes_read = file_read(&magic, 1, sizeof magic, wth->fh); @@ -1267,8 +1271,8 @@ static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info, return FALSE; /* Read error */ wth->data_offset += packet_size; - wth->phdr.ts.tv_sec = hdr.hdr.ts_sec; - wth->phdr.ts.tv_usec = hdr.hdr.ts_usec; + wth->phdr.ts.secs = hdr.hdr.ts_sec; + wth->phdr.ts.nsecs = hdr.hdr.ts_usec * 1000; wth->phdr.caplen = packet_size; wth->phdr.len = orig_size; @@ -1819,8 +1823,8 @@ wtap_process_pcap_packet(gint linktype, const struct pcap_pkthdr *phdr, be a "struct bpf_timeval", with member sizes wired to 32 bits - and we may go that way ourselves in the future, so copy the members individually. */ - whdr->ts.tv_sec = phdr->ts.tv_sec; - whdr->ts.tv_usec = phdr->ts.tv_usec; + whdr->ts.secs = phdr->ts.tv_sec; + whdr->ts.nsecs = phdr->ts.tv_usec * 1000; whdr->caplen = phdr->caplen; whdr->len = phdr->len; whdr->pkt_encap = linktype; @@ -2017,8 +2021,8 @@ static gboolean libpcap_dump(wtap_dumper *wdh, else hdrsize = 0; - rec_hdr.hdr.ts_sec = phdr->ts.tv_sec; - rec_hdr.hdr.ts_usec = phdr->ts.tv_usec; + rec_hdr.hdr.ts_sec = phdr->ts.secs; + rec_hdr.hdr.ts_usec = phdr->ts.nsecs / 1000; rec_hdr.hdr.incl_len = phdr->caplen + hdrsize; rec_hdr.hdr.orig_len = phdr->len + hdrsize; switch (wdh->file_type) { diff --git a/wiretap/netmon.c b/wiretap/netmon.c index bc10056510..c3c552d2d0 100644 --- a/wiretap/netmon.c +++ b/wiretap/netmon.c @@ -452,8 +452,8 @@ static gboolean netmon_read(wtap *wth, int *err, gchar **err_info, } secs = (time_t)(t/1000000); usecs = (guint32)(t - (double)secs*1000000); - wth->phdr.ts.tv_sec = netmon->start_secs + secs; - wth->phdr.ts.tv_usec = usecs; + wth->phdr.ts.secs = netmon->start_secs + secs; + wth->phdr.ts.nsecs = usecs * 1000; wth->phdr.caplen = packet_size; wth->phdr.len = orig_size; @@ -681,8 +681,8 @@ static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, case WTAP_FILE_NETMON_1_x: rec_1_x_hdr.ts_delta = htolel( - (phdr->ts.tv_sec - netmon->first_record_time.tv_sec)*1000 - + (phdr->ts.tv_usec - netmon->first_record_time.tv_usec + 500)/1000); + (phdr->ts.secs - netmon->first_record_time.secs)*1000 + + (phdr->ts.nsecs - netmon->first_record_time.nsecs + 500000)/1000000); rec_1_x_hdr.orig_len = htoles(phdr->len + atm_hdrsize); rec_1_x_hdr.incl_len = htoles(phdr->caplen + atm_hdrsize); hdrp = (char *)&rec_1_x_hdr; @@ -696,8 +696,8 @@ static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, * (even on 32-bit processors), so we do it in floating * point. */ - t = (phdr->ts.tv_sec - netmon->first_record_time.tv_sec)*1000000.0 - + (phdr->ts.tv_usec - netmon->first_record_time.tv_usec); + t = (phdr->ts.secs - netmon->first_record_time.secs)*1000000.0 + + (phdr->ts.nsecs - netmon->first_record_time.nsecs) / 1000; time_high = (guint32) (t/4294967296.0); time_low = (guint32) (t - (time_high*4294967296.0)); rec_2_x_hdr.ts_delta_lo = htolel(time_low); @@ -848,7 +848,7 @@ static gboolean netmon_dump_close(wtap_dumper *wdh, int *err) } file_hdr.network = htoles(wtap_encap[wdh->encap]); - tm = localtime(&netmon->first_record_time.tv_sec); + tm = localtime(&netmon->first_record_time.secs); if (tm != NULL) { file_hdr.ts_year = htoles(1900 + tm->tm_year); file_hdr.ts_month = htoles(tm->tm_mon + 1); @@ -866,7 +866,7 @@ static gboolean netmon_dump_close(wtap_dumper *wdh, int *err) file_hdr.ts_min = htoles(0); file_hdr.ts_sec = htoles(0); } - file_hdr.ts_msec = htoles(netmon->first_record_time.tv_usec/1000); + file_hdr.ts_msec = htoles(netmon->first_record_time.nsecs/1000000); /* XXX - what about rounding? */ file_hdr.frametableoffset = htolel(netmon->frame_table_offset); file_hdr.frametablelength = diff --git a/wiretap/nettl.c b/wiretap/nettl.c index 22d54d5148..75ffb9e1ca 100644 --- a/wiretap/nettl.c +++ b/wiretap/nettl.c @@ -501,8 +501,8 @@ nettl_read_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, phdr->caplen = pntohl(&ip_hdr.caplen); } - phdr->ts.tv_sec = pntohl(&ip_hdr.sec); - phdr->ts.tv_usec = pntohl(&ip_hdr.usec); + phdr->ts.secs = pntohl(&ip_hdr.sec); + phdr->ts.nsecs = pntohl(&ip_hdr.usec) * 1000; break; case NETTL_SUBSYS_NS_LS_DRIVER : @@ -546,8 +546,8 @@ nettl_read_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, phdr->len = length; phdr->caplen = pntohs(&drv_eth_hdr.caplen); - phdr->ts.tv_sec = pntohl(&ip_hdr.sec); - phdr->ts.tv_usec = pntohl(&ip_hdr.usec); + phdr->ts.secs = pntohl(&ip_hdr.sec); + phdr->ts.nsecs = pntohl(&ip_hdr.usec) * 1000; break; case NETTL_SUBSYS_SX25L2: @@ -567,8 +567,8 @@ nettl_read_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, if (length <= 0) return 0; phdr->len = length - 24; phdr->caplen = pntohl(&ip_hdr.caplen) - 24; - phdr->ts.tv_sec = pntohl(&ip_hdr.sec); - phdr->ts.tv_usec = pntohl(&ip_hdr.usec); + phdr->ts.secs = pntohl(&ip_hdr.sec); + phdr->ts.nsecs = pntohl(&ip_hdr.usec) * 1000; if (wth->capture.nettl->is_hpux_11) padlen = 28; else @@ -596,8 +596,8 @@ nettl_read_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, if (length <= 0) return 0; phdr->len = length; phdr->caplen = pntohl(&ip_hdr.caplen); - phdr->ts.tv_sec = pntohl(&ip_hdr.sec); - phdr->ts.tv_usec = pntohl(&ip_hdr.usec); + phdr->ts.secs = pntohl(&ip_hdr.sec); + phdr->ts.nsecs = pntohl(&ip_hdr.usec) * 1000; if (wth->capture.nettl->is_hpux_11) { if (file_seek(fh, 4, SEEK_CUR, err) == -1) return -1; offset += 4; @@ -737,8 +737,8 @@ static gboolean nettl_dump(wtap_dumper *wdh, memset(&rec_hdr,0,sizeof(rec_hdr)); rec_hdr.hdr_len = g_htons(sizeof(rec_hdr)); rec_hdr.hdr.kind = g_htonl(NETTL_HDR_PDUIN); - rec_hdr.hdr.sec = g_htonl(phdr->ts.tv_sec); - rec_hdr.hdr.usec = g_htonl(phdr->ts.tv_usec); + rec_hdr.hdr.sec = g_htonl(phdr->ts.secs); + rec_hdr.hdr.usec = g_htonl(phdr->ts.nsecs/1000); rec_hdr.hdr.caplen = g_htonl(phdr->caplen); rec_hdr.hdr.length = g_htonl(phdr->len); rec_hdr.hdr.devid = -1; diff --git a/wiretap/network_instruments.c b/wiretap/network_instruments.c index b5d7416e14..0e226e6e48 100644 --- a/wiretap/network_instruments.c +++ b/wiretap/network_instruments.c @@ -240,8 +240,8 @@ static gboolean observer_read(wtap *wth, int *err, gchar **err_info, wth->phdr.pkt_encap = observer_encap[packet_header.network_type]; wth->phdr.len = packet_header.network_size-4; /* neglect frame markers for wiretap */ wth->phdr.caplen = MIN(packet_header.captured_size, wth->phdr.len); - wth->phdr.ts.tv_sec = seconds; - wth->phdr.ts.tv_usec = useconds; + wth->phdr.ts.secs = seconds; + wth->phdr.ts.nsecs = useconds * 1000; /* get to the frame data */ packet_header.offset_to_frame = @@ -430,14 +430,14 @@ static gboolean observer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, size_t nwritten; guint64 capture_nanoseconds = 0; - if(phdr->ts.tv_sec<(long)seconds1970to2000) { - if(phdr->ts.tv_sec<0) + if(phdr->ts.secs<(long)seconds1970to2000) { + if(phdr->ts.secs<0) capture_nanoseconds = 0; else - capture_nanoseconds = phdr->ts.tv_sec; + capture_nanoseconds = phdr->ts.secs; } else - capture_nanoseconds = phdr->ts.tv_sec - seconds1970to2000; - capture_nanoseconds = ((capture_nanoseconds*1000000) + (guint64)phdr->ts.tv_usec)*1000; + capture_nanoseconds = phdr->ts.secs - seconds1970to2000; + capture_nanoseconds = ((capture_nanoseconds*1000000) + (guint64)phdr->ts.nsecs); memset(&packet_header, 0x00, sizeof(packet_entry_header)); packet_header.packet_magic = GUINT32_TO_LE(observer_packet_magic); diff --git a/wiretap/netxray.c b/wiretap/netxray.c index 93a5ef9bca..f5164a0615 100644 --- a/wiretap/netxray.c +++ b/wiretap/netxray.c @@ -808,9 +808,9 @@ reread: + (double)pletohl(&hdr.old_hdr.timehi)*4294967296.0; t /= wth->capture.netxray->timeunit; t -= wth->capture.netxray->start_timestamp; - wth->phdr.ts.tv_sec = wth->capture.netxray->start_time + (long)t; - wth->phdr.ts.tv_usec = (unsigned long)((t-(double)(unsigned long)(t)) - *1.0e6); + wth->phdr.ts.secs = wth->capture.netxray->start_time + (long)t; + wth->phdr.ts.nsecs = (unsigned long)((t-(double)(unsigned long)(t)) + *1.0e9); /* * We subtract the padding from the packet size, so our caller * doesn't see it. @@ -822,9 +822,9 @@ reread: + (double)pletohl(&hdr.hdr_1_x.timehi)*4294967296.0; t /= wth->capture.netxray->timeunit; t -= wth->capture.netxray->start_timestamp; - wth->phdr.ts.tv_sec = wth->capture.netxray->start_time + (long)t; - wth->phdr.ts.tv_usec = (unsigned long)((t-(double)(unsigned long)(t)) - *1.0e6); + wth->phdr.ts.secs = wth->capture.netxray->start_time + (long)t; + wth->phdr.ts.nsecs = (unsigned long)((t-(double)(unsigned long)(t)) + *1.0e9); /* * We subtract the padding from the packet size, so our caller * doesn't see it. @@ -1302,8 +1302,8 @@ gboolean netxray_dump_open_1_1(wtap_dumper *wdh, gboolean cant_seek, int *err) wdh->dump.netxray = g_malloc(sizeof(netxray_dump_t)); wdh->dump.netxray->first_frame = TRUE; - wdh->dump.netxray->start.tv_sec = 0; - wdh->dump.netxray->start.tv_usec = 0; + wdh->dump.netxray->start.secs = 0; + wdh->dump.netxray->start.nsecs = 0; wdh->dump.netxray->nframes = 0; return TRUE; @@ -1338,8 +1338,8 @@ static gboolean netxray_dump_1_1(wtap_dumper *wdh, /* build the header for each packet */ memset(&rec_hdr, '\0', sizeof(rec_hdr)); - timestamp = (phdr->ts.tv_sec - netxray->start.tv_sec)*1000000 + - phdr->ts.tv_usec; + timestamp = (phdr->ts.secs - netxray->start.secs)*1000000 + + phdr->ts.nsecs / 1000; rec_hdr.timelo = htolel(timestamp); rec_hdr.timehi = htolel(0); rec_hdr.orig_len = htoles(phdr->len); @@ -1399,7 +1399,7 @@ static gboolean netxray_dump_close_1_1(wtap_dumper *wdh, int *err) /* "sniffer" version ? */ memset(&file_hdr, '\0', sizeof file_hdr); memcpy(file_hdr.version, vers_1_1, sizeof vers_1_1); - file_hdr.start_time = htolel(netxray->start.tv_sec); + file_hdr.start_time = htolel(netxray->start.secs); file_hdr.nframes = htolel(netxray->nframes); file_hdr.start_offset = htolel(CAPTUREFILE_HEADER_SIZE); file_hdr.end_offset = htolel(filelen); @@ -1491,8 +1491,8 @@ gboolean netxray_dump_open_2_0(wtap_dumper *wdh, gboolean cant_seek, int *err) wdh->dump.netxray = g_malloc(sizeof(netxray_dump_t)); wdh->dump.netxray->first_frame = TRUE; - wdh->dump.netxray->start.tv_sec = 0; - wdh->dump.netxray->start.tv_usec = 0; + wdh->dump.netxray->start.secs = 0; + wdh->dump.netxray->start.nsecs = 0; wdh->dump.netxray->nframes = 0; return TRUE; @@ -1527,8 +1527,8 @@ static gboolean netxray_dump_2_0(wtap_dumper *wdh, /* build the header for each packet */ memset(&rec_hdr, '\0', sizeof(rec_hdr)); - timestamp = (phdr->ts.tv_sec - netxray->start.tv_sec)*1000000 + - phdr->ts.tv_usec; + timestamp = (phdr->ts.secs - netxray->start.secs)*1000000 + + phdr->ts.nsecs/1000; rec_hdr.timelo = htolel(timestamp); rec_hdr.timehi = htolel(0); rec_hdr.orig_len = htoles(phdr->len); @@ -1606,7 +1606,7 @@ static gboolean netxray_dump_close_2_0(wtap_dumper *wdh, int *err) /* "sniffer" version ? */ memset(&file_hdr, '\0', sizeof file_hdr); memcpy(file_hdr.version, vers_2_001, sizeof vers_2_001); - file_hdr.start_time = htolel(netxray->start.tv_sec); + file_hdr.start_time = htolel(netxray->start.secs); file_hdr.nframes = htolel(netxray->nframes); file_hdr.start_offset = htolel(CAPTUREFILE_HEADER_SIZE); file_hdr.end_offset = htolel(filelen); diff --git a/wiretap/ngsniffer.c b/wiretap/ngsniffer.c index 1d7768250d..04bcb78e89 100644 --- a/wiretap/ngsniffer.c +++ b/wiretap/ngsniffer.c @@ -1073,9 +1073,9 @@ found: t = t/1000000.0 * wth->capture.ngsniffer->timeunit; /* t = # of secs */ t += wth->capture.ngsniffer->start; - wth->phdr.ts.tv_sec = (long)t; - wth->phdr.ts.tv_usec = (unsigned long)((t-(double)(wth->phdr.ts.tv_sec)) - *1.0e6); + wth->phdr.ts.secs = (long)t; + wth->phdr.ts.nsecs = (unsigned long)((t-(double)(wth->phdr.ts.secs)) + *1.0e9); return TRUE; } @@ -1917,13 +1917,13 @@ static gboolean ngsniffer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, date. */ if (priv->first_frame) { priv->first_frame=FALSE; - tm = localtime(&phdr->ts.tv_sec); + tm = localtime(&phdr->ts.secs); if (tm != NULL) { start_date = (tm->tm_year - (1980 - 1900)) << 9; start_date |= (tm->tm_mon + 1) << 5; start_date |= tm->tm_mday; /* record the start date, not the start time */ - priv->start = phdr->ts.tv_sec - (3600*tm->tm_hour + 60*tm->tm_min + tm->tm_sec); + priv->start = phdr->ts.secs - (3600*tm->tm_hour + 60*tm->tm_min + tm->tm_sec); } else { start_date = 0; priv->start = 0; @@ -1968,7 +1968,7 @@ static gboolean ngsniffer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, *err = WTAP_ERR_SHORT_WRITE; return FALSE; } - t = (double)phdr->ts.tv_sec + (double)phdr->ts.tv_usec/1.0e6; /* # of secs */ + t = (double)phdr->ts.secs + (double)phdr->ts.nsecs/1.0e9; /* # of secs */ t = (t - priv->start)*1.0e6 / Usec[1]; /* timeunit = 1 */ t_low = (guint16)(t-(double)((guint32)(t/65536.0))*65536.0); t_med = (guint16)((guint32)(t/65536.0) % 65536); diff --git a/wiretap/pppdump.c b/wiretap/pppdump.c index 72061bdcd9..8913cd8c4a 100644 --- a/wiretap/pppdump.c +++ b/wiretap/pppdump.c @@ -355,8 +355,8 @@ pppdump_read(wtap *wth, int *err, gchar **err_info, long *data_offset) wth->phdr.len = num_bytes; wth->phdr.caplen = num_bytes; - wth->phdr.ts.tv_sec = state->timestamp; - wth->phdr.ts.tv_usec = state->tenths * 100000; + wth->phdr.ts.secs = state->timestamp; + wth->phdr.ts.nsecs = state->tenths * 100000000; wth->phdr.pkt_encap = WTAP_ENCAP_PPP_WITH_PHDR; wth->pseudo_header.p2p.sent = (direction == DIRECTION_SENT ? TRUE : FALSE); diff --git a/wiretap/radcom.c b/wiretap/radcom.c index 08524b23a3..9c3934504a 100644 --- a/wiretap/radcom.c +++ b/wiretap/radcom.c @@ -314,8 +314,8 @@ static gboolean radcom_read(wtap *wth, int *err, gchar **err_info _U_, tm.tm_min = (sec%3600)/60; tm.tm_sec = sec%60; tm.tm_isdst = -1; - wth->phdr.ts.tv_sec = mktime(&tm); - wth->phdr.ts.tv_usec = pletohl(&hdr.date.usec); + wth->phdr.ts.secs = mktime(&tm); + wth->phdr.ts.nsecs = pletohl(&hdr.date.usec) * 1000; switch (wth->file_encap) { diff --git a/wiretap/snoop.c b/wiretap/snoop.c index a19e4cd532..5dc0c2a27d 100644 --- a/wiretap/snoop.c +++ b/wiretap/snoop.c @@ -501,8 +501,8 @@ static gboolean snoop_read(wtap *wth, int *err, gchar **err_info, return FALSE; /* Read error */ wth->data_offset += packet_size; - wth->phdr.ts.tv_sec = g_ntohl(hdr.ts_sec); - wth->phdr.ts.tv_usec = g_ntohl(hdr.ts_usec); + wth->phdr.ts.secs = g_ntohl(hdr.ts_sec); + wth->phdr.ts.nsecs = g_ntohl(hdr.ts_usec) * 1000; wth->phdr.caplen = packet_size; wth->phdr.len = orig_size; @@ -808,8 +808,8 @@ static gboolean snoop_dump(wtap_dumper *wdh, rec_hdr.incl_len = g_htonl(phdr->caplen + atm_hdrsize); rec_hdr.rec_len = g_htonl(reclen); rec_hdr.cum_drops = 0; - rec_hdr.ts_sec = g_htonl(phdr->ts.tv_sec); - rec_hdr.ts_usec = g_htonl(phdr->ts.tv_usec); + rec_hdr.ts_sec = g_htonl(phdr->ts.secs); + rec_hdr.ts_usec = g_htonl(phdr->ts.nsecs) / 1000; nwritten = fwrite(&rec_hdr, 1, sizeof rec_hdr, wdh->fh); if (nwritten != sizeof rec_hdr) { if (nwritten == 0 && ferror(wdh->fh)) diff --git a/wiretap/toshiba.c b/wiretap/toshiba.c index 086ed50be8..a9cc44d503 100644 --- a/wiretap/toshiba.c +++ b/wiretap/toshiba.c @@ -353,8 +353,8 @@ parse_toshiba_rec_hdr(wtap *wth, FILE_T fh, } if (wth) { - wth->phdr.ts.tv_sec = hr * 3600 + min * 60 + sec; - wth->phdr.ts.tv_usec = csec * 10000; + wth->phdr.ts.secs = hr * 3600 + min * 60 + sec; + wth->phdr.ts.nsecs = csec * 10000000; wth->phdr.caplen = pkt_len; wth->phdr.len = pkt_len; } diff --git a/wiretap/visual.c b/wiretap/visual.c index 5725aa9375..b270d508fa 100644 --- a/wiretap/visual.c +++ b/wiretap/visual.c @@ -298,8 +298,8 @@ static gboolean visual_read(wtap *wth, int *err, gchar **err_info, t += ((double)pletohl(&vpkt_hdr.ts_delta))*1000; secs = (time_t)(t/1000000); usecs = (guint32)(t - secs*1000000); - wth->phdr.ts.tv_sec = secs; - wth->phdr.ts.tv_usec = usecs; + wth->phdr.ts.secs = secs; + wth->phdr.ts.nsecs = usecs * 1000; wth->phdr.caplen = packet_size; wth->phdr.len = pletohs(&vpkt_hdr.orig_len); @@ -489,7 +489,7 @@ static gboolean visual_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, if (visual->index_table_index == 0) { /* This is the first packet. Save its start time as the file time. */ - visual->start_time = phdr->ts.tv_sec; + visual->start_time = phdr->ts.secs; /* Initialize the index table */ visual->index_table = g_malloc(1024 * sizeof *visual->index_table); @@ -497,8 +497,8 @@ static gboolean visual_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, } /* Calculate milliseconds since capture start. */ - delta_msec = phdr->ts.tv_usec / 1000; - delta_msec += (phdr->ts.tv_sec - visual->start_time) * 1000; + delta_msec = phdr->ts.nsecs / 1000000; + delta_msec += (phdr->ts.secs - visual->start_time) * 1000; vpkt_hdr.ts_delta = htolel(delta_msec); /* Fill in the length fields. */ diff --git a/wiretap/vms.c b/wiretap/vms.c index fccd4b1c13..02d0e6cc8a 100644 --- a/wiretap/vms.c +++ b/wiretap/vms.c @@ -439,9 +439,8 @@ parse_vms_rec_hdr(wtap *wth, FILE_T fh, int *err, gchar **err_info) tm.tm_year -= 1900; tm.tm_isdst = -1; - wth->phdr.ts.tv_sec = mktime(&tm); - - wth->phdr.ts.tv_usec = csec * 10000; + wth->phdr.ts.secs = mktime(&tm); + wth->phdr.ts.nsecs = csec * 10000000; wth->phdr.caplen = pkt_len; wth->phdr.len = pkt_len; } diff --git a/wiretap/wtap-int.h b/wiretap/wtap-int.h index fbbe89ef12..91a7456a84 100644 --- a/wiretap/wtap-int.h +++ b/wiretap/wtap-int.h @@ -176,6 +176,8 @@ struct wtap { file formats that have per-file encapsulation types */ + int tsprecision; /* timestamp precision of the lower 32bits + * 6 is microseconds, 9 is nanoseconds */ }; struct wtap_dumper; @@ -192,13 +194,13 @@ typedef struct { typedef struct { gboolean first_frame; - struct timeval start; + struct wtap_nstime start; guint32 nframes; } netxray_dump_t; typedef struct { gboolean got_first_record_time; - struct timeval first_record_time; + struct wtap_nstime first_record_time; guint32 frame_table_offset; guint32 *frame_table; guint frame_table_index; diff --git a/wiretap/wtap.c b/wiretap/wtap.c index b1e981b1d1..cb12f65ba9 100644 --- a/wiretap/wtap.c +++ b/wiretap/wtap.c @@ -84,6 +84,12 @@ wtap_file_encap(wtap *wth) return wth->file_encap; } +int +wtap_file_tsprecision(wtap *wth) +{ + return wth->tsprecision; +} + /* Table of the encapsulation types we know about. */ static const struct encap_type_info { const char *name; diff --git a/wiretap/wtap.def b/wiretap/wtap.def index 1e314db475..74d11b8cb1 100644 --- a/wiretap/wtap.def +++ b/wiretap/wtap.def @@ -12,6 +12,7 @@ wtap_encap_short_string wtap_encap_string wtap_file_encap wtap_file_size +wtap_file_tsprecision wtap_file_type wtap_file_type_short_string wtap_file_type_string diff --git a/wiretap/wtap.h b/wiretap/wtap.h index b828a7e4b6..44da7e5c6a 100644 --- a/wiretap/wtap.h +++ b/wiretap/wtap.h @@ -33,6 +33,7 @@ #include #include +#include /* Encapsulation types. Choose names that truly reflect * what is contained in the packet trace file. @@ -223,6 +224,10 @@ /* last WTAP_FILE_ value + 1 */ #define WTAP_NUM_FILE_TYPES 41 +/* timestamp accuracy (currently only these values are supported) */ +#define WTAP_FILE_TSPREC_USEC 6 +#define WTAP_FILE_TSPREC_NSEC 9 + /* * Maximum packet size we'll support. * It must be at least 65535. @@ -492,8 +497,14 @@ union wtap_pseudo_header { struct k12_phdr k12; }; +struct wtap_nstime { + time_t secs; + int nsecs; +}; + + struct wtap_pkthdr { - struct timeval ts; + struct wtap_nstime ts; guint32 caplen; guint32 len; int pkt_encap; @@ -537,6 +548,7 @@ gint64 wtap_file_size(wtap *wth, int *err); int wtap_snapshot_length(wtap *wth); /* per file */ int wtap_file_type(wtap *wth); int wtap_file_encap(wtap *wth); +int wtap_file_tsprecision(wtap *wth); const char *wtap_file_type_string(int filetype); const char *wtap_file_type_short_string(int filetype); -- 2.34.1