EVERYTHING IN THE BUILDBOT IS GOING TO BE RED!!! Sorry!
authorulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 24 Aug 2005 21:31:56 +0000 (21:31 +0000)
committerulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 24 Aug 2005 21:31:56 +0000 (21:31 +0000)
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

88 files changed:
capinfos.c
cfile.h
epan/column-utils.c
epan/dissectors/packet-afp.c
epan/dissectors/packet-afs.c
epan/dissectors/packet-aoe.c
epan/dissectors/packet-dcerpc.c
epan/dissectors/packet-fc.c
epan/dissectors/packet-fcp.c
epan/dissectors/packet-frame.c
epan/dissectors/packet-h225.c
epan/dissectors/packet-iax2.c
epan/dissectors/packet-iscsi.c
epan/dissectors/packet-ldap.c
epan/dissectors/packet-ncp2222.inc
epan/dissectors/packet-nlm.c
epan/dissectors/packet-rlogin.c
epan/dissectors/packet-rpc.c
epan/dissectors/packet-rtcp.c
epan/dissectors/packet-rtcp.h
epan/dissectors/packet-smb.c
epan/dissectors/packet-tcp.c
epan/frame_data.h
epan/h225-persistentdata.c
epan/libethereal.def
epan/nstime.c
epan/nstime.h
epan/stats_tree.c
epan/stats_tree_priv.h
file.c
gtk/file_dlg.c
gtk/flow_graph.c
gtk/io_stat.c
gtk/main.c
gtk/mgcp_stat.c
gtk/packet_list.c
gtk/rpc_progs.c
gtk/rtp_analysis.c
gtk/rtp_stream.c
gtk/sctp_stat.c
gtk/service_response_time_table.c
gtk/tcp_graph.c
gtk/voip_calls.c
merge.c
plugins/mate/mate_runtime.c
plugins/mgcp/packet-mgcp.c
proto_hier_stats.c
summary.c
tap-afpstat.c
tap-dcerpcstat.c
tap-iostat.c
tap-mgcpstat.c
tap-rpcprogs.c
tap-rpcstat.c
tap-smbstat.c
tethereal.c
timestats.c
wiretap/5views.c
wiretap/airopeek9.c
wiretap/ascend.c
wiretap/cosine.c
wiretap/csids.c
wiretap/dbs-etherwatch.c
wiretap/erf.c
wiretap/etherpeek.c
wiretap/eyesdn.c
wiretap/file_access.c
wiretap/hcidump.c
wiretap/i4btrace.c
wiretap/iptrace.c
wiretap/k12.c
wiretap/lanalyzer.c
wiretap/libpcap.c
wiretap/netmon.c
wiretap/nettl.c
wiretap/network_instruments.c
wiretap/netxray.c
wiretap/ngsniffer.c
wiretap/pppdump.c
wiretap/radcom.c
wiretap/snoop.c
wiretap/toshiba.c
wiretap/visual.c
wiretap/vms.c
wiretap/wtap-int.h
wiretap/wtap.c
wiretap/wtap.def
wiretap/wtap.h

index 60c73de3b3ccae1d0da696d61c919979e92bdccd..0a27f0cd80c7ca267631b8d460ffa2d6d02d69af 100644 (file)
@@ -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 db0c29bbbe818bca3897da07d57a213948b39218..89cd3d61b2c8ca3de6a84d73ba5663a1eec41e93 100644 (file)
--- 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 *);
index da1db1a5c04c7a49db1ff634e18f167533234ad2..7120ce474aff02060a37725c92499980596837cb 100644 (file)
@@ -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';
   }
index 82c7efafd541f8ea53c6eabf0220740c8914f2de..63158b8761d2bb3cf40df65e26ccb50272b8510b 100644 (file)
@@ -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);
                }
 
index 7f249d55d8766f5c50b22c077abaecf15f85a351..7d62b45ab8d6b0964f5e7c31e7dfdfd7a295d2bb 100644 (file)
@@ -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);
                }
 
 
index 5592fc8b48c3aded130ccae8fc6aa1abdd5d56e4..3b55fd3d1f15b98887495288d28e74f955ed8d77 100644 (file)
@@ -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 {
index c0be1a12b7342c6471ecdbd3037c1b5da7ed7bb0..f21783f7a33032ae8f87428d724cabe8442af510 100644 (file)
@@ -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);
 /*    }*/
     }
index f3893b8aa8101db403effccc30a21c5848a7f710..38f1b66033a6f61877a9eaec82ecc4a85229b3c3 100644 (file)
@@ -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;
index f84a1474b3f780d47f6f36385c76537ebe6dcb4b..df9604901d3c0cde1d3b384be10fbbff0da045c5 100644 (file)
@@ -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",
index 233d97e005146b553d5d453a9e6f747aa07dc6be..9b581d891330ecc8ba0f7ebca5453d26c3ae9772 100644 (file)
@@ -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);
index 804028d459326fe229579998749a409b019b8468..9ec2b5c06d0f8fa9a8d0a90f18058b613cc83cfe 100644 (file)
@@ -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));
index 3efba06205565af548d6cc65974149a1e9dd3b82..4d0135f585d4305e19d82dd81f6583004356e28d 100644 (file)
@@ -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);
index d98ee25a18bf0edebc1b21a3ee304d77d599375e..60354a46f25172a231b607d40c9010e9468bc6b4 100644 (file)
@@ -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)
index 9e4c6f37afe7f298c3408eb0775526e85900d0ab..faaf6ef49fa67d12768156969c4f836aba3b360b 100644 (file)
@@ -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;
index b76226955666e01cd59895d0627dbabb00e3f85c..5feb4054349f6ef4219957ac60b6b351168d11ca 100644 (file)
@@ -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".
index 5727c0622a18cc6b013ac075ee5b92d40e11ff41..457dfae9cb8c036c7e100dbb6355327cd67c3d98 100644 (file)
@@ -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);
 
index a0100bb0132ab48c3615ae5517d007c13e9d6c4e..ab672450b8a6e47ad7d351aa1698aa9c02600959 100644 (file)
@@ -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 */
index 2ac43a24f83ccd386529177397c2cd30c927d208..3a2edc817ba6a72eb3112a87bf83841474b0687f 100644 (file)
@@ -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);
 
index 4e7eb9364f9cc228fec3f9170dbcd3e8b7a8c9b1..9e7e974d1612810ca90d17996f5a14bbd753c52d 100644 (file)
@@ -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... */
index 5523c4db5718293f61336f304ed3b69962fee754..d09f5fb8cc5a4e6bacf1f0b6992ccd45c80ad142 100644 (file)
@@ -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) */
index 460e2b7356d92edfb3b2c74c5c004b07036223d9..8d96725f218394f88f740609901d973032264e0d 100644 (file)
@@ -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);
index 5cb1a94ea7f08e2c62342a97e451e1419cf802f6..07a004e29579be11e1ba2466b15719098bd54d0f 100644 (file)
@@ -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;
index 05c28859daf87735f14a082fe197b26659b683ba..db6d5034a45d3463cf28103dc96660a3f9e39d88 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "column_info.h"
 #include "tvbuff.h"
+#include <epan/nstime.h>
 
 #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 {
index 38804ecf6a5384b7b27edebbbdbb5e22f0e8e23b..f9ae7539a9f51b61ff739a3d1a3182c5e724584f 100644 (file)
@@ -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;
index 6221d736e3bcba02db0a8d8a8d05df114b08f2f5..ea14571675544d454de03c947556a80cd1cf1300 100644 (file)
@@ -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
index b5089bb97c666fa4cfea69b3b08114d87169567e..e20159afcfd0cbbd948869ee553eca8421b05b85 100644 (file)
@@ -25,6 +25,7 @@
  *
  */
 
+#include <glib.h>
 #include "nstime.h"
 
 /* this is #defined so that we can clearly see that we have the right number of
    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);
+}
+
index 25c10d6bef8dad0358c90dddea9913ec7d4ebb75..60fec42e0179926e46fee64020adec80ecf8e11e 100644 (file)
@@ -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__  */
index cb36ba2d2668098f2fc0eae0a3c111f74d169a32..47c94c53c87c85c43e0ed9c4ab7c1716ff5447f1 100644 (file)
@@ -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;
        
index a29ab8e5dcca5226f4b1a10eb4fb4220e748b050..7d36a3c7d97915c01b1cc7b9e3fcfe004be605d9 100644 (file)
@@ -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 4e73f429fb25e53b0898a0098c38ec8bcb03c8f3..14a79a1ba7ab4f4db9efdaabdf1385a9fc31ac62 100644 (file)
--- 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;
index 4cdcd7faa4bcd1d7e92a9c1069b6821e004de242..7288dc8396bdbd4cd15b810dff1bd31ab1d74008 100644 (file)
@@ -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;
index cdd92c2f56fa7259f1768c9ff2b4cec032830230..dbdfbe4b563667f2d5a9701cef13f6a79e7bfe53 100644 (file)
@@ -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;
index 42274c9e15bcc5687cac3b61ba36f43e92bb1847..1afabdd9bffb3e6a00aeb341047fe5d7703bb8ae 100644 (file)
@@ -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;
index 9d782b5966d8d17f091e52cb423459c24f7bb2ac..a9b18b4d51f56817b12fe6089b931f9409a9eca3 100644 (file)
@@ -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);
index 398f52639f1bb8d60701ea91a21e5246e36f074f..999d1f8af2c47b3904d2c5d145403bf2b52e8dba 100644 (file)
@@ -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);
index 2b00695d8f3d735906feed76963f2e73be288dff..880860bb6045bcff3d41fb11c1bec3886ff8dc57 100644 (file)
@@ -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);
index a78095dcbfcdc1006218f51825b4156125dbf275..8d8d46a8ff5f89c1b916e4537e4c037286397342 100644 (file)
@@ -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) ){
index 5b5fad735e86ff63cca80e8ce371e6bbb25e93b2..e8310c6fe5b5a05a9ad0eaef998375842b7b0859 100644 (file)
@@ -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,
index a003b24c99c43af28cd0c18a2c6de8c68779b113..d145639413352fee1314e68d78327ca5d84437c5 100644 (file)
@@ -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);
index 5599ac41b78a142cbf194b79ad5f9c75497b1e50..30a842b716a225d3c156c603562e6fb850593531 100644 (file)
@@ -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))
                        {
index 1f7abb8cecca04786814849a1cb52fbf7fa989d0..ca688c7a347f44e5e2f1b94521c120b8a65f846a 100644 (file)
@@ -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);
 }
index a914c6c084e8f896a01484c459b49e14c8e2772f..5c2da9343cc81194335d64bfc7edc37b44ca1064 100644 (file)
@@ -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;
index 5b255b53182f05edbb08c439e922d26ac8246efc..8d7b793fabc0ef5fa5d3dc33fe21c608d651918e 100644 (file)
@@ -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 f2fb294aa205b5de22f220e2d832dde667b43c52..8fd1c63af097a46bc1534ef5698afff30176de55 100644 (file)
--- 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;
 
   /*
index e314ab2216f50fc32ea00dfdcef3292caffda71c..362c8d3e3127163a8dfcb98412931572afa7cb94 100644 (file)
@@ -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 ) {
index e811cd221cae51e32cec558338d3f9c21b776f4c..12df9ecda923eadb85fcc2fb04dde90db28a34bc 100644 (file)
@@ -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 */
index b634712d2e7ddd6164972c778bb87a1eb5806598..f1e0d87ef1e387086b738dd665766ba8252be20b 100644 (file)
 #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;
                        }
index 511cf47f18bd87b86db6932963f9eb319cfce89f..b21706c6be82d2db28257ce695545ad2231430d4 100644 (file)
--- a/summary.c
+++ b/summary.c
 #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;
index bedee12f1ad39d0995c206b2b739b5cf6082c41a..93e529e0de85266993702c2f5ef009921e4c2b37 100644 (file)
@@ -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);
index f87849a63f2ea92e3bff238c707bfc547232f4ae..32c0cab7771d05cec07f8e0ae076a14be2a36756 100644 (file)
@@ -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;
index afe1740a2083b1be575821409e1eb984520f34bf..f6dd2b4852244e27bd1709f476a971a1d7732a74 100644 (file)
@@ -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;
index acd1980ae1d4b69ea6f716c8684c686f8c215b72..255970b7d49e2b23ba8f21608e7c77f4c3de97fd 100644 (file)
@@ -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);
 
index 51fc6a160e7aa7645a7d7ca1adde099085493567..533db827fa3db3dc07f7e5900818553d392f3062 100644 (file)
@@ -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) ){
index 48d78fe0cb1d0205b1a7d21411bac77f97cdcd65..b443116bb206125ca554657913c0e01e5b8c3291 100644 (file)
@@ -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;
index 8173efd65651e759d31291b8063faa3f22275259..eac0346c20cd82278c9825071bd0d3fec6c45115 100644 (file)
@@ -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);
index 9f1324a329433aa3525771d50fd9fe3998ae3510..65f933cd8129d56e5de7e461660c0504a6bd5b79 100644 (file)
  */
 static const gchar decode_as_arg_template[] = "<layer_type>==<selector>,<decode_as_protocol>";
 
-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;
 
index ed5cd5a86fbc0a97f048fb1d4eb4b9548f4df01c..ec644b3b3798fe1c93d5ad4ab99645f7e22043d1 100644 (file)
@@ -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++;
 }
index c17101449dfa90a055f23239e8f2bf5ff6f233cf..38fc251ef9d9a3a60c2fa2b95f3f4a083d7e6604 100644 (file)
@@ -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);
 
index 8cc276f54afb11f4de13365d7b65da876cb9a343..2eee7f5f76b5736249ce7ae975ac1f6fe6de8758 100644 (file)
@@ -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) {
 
index 5c572799053b76dd4c21660d200300914f53e81c..0145aec7968343eb6a9f9aee2f38655eae69d70e 100644 (file)
@@ -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;
index 2b8138910c3c384a5c1a6869504240975aa5f302..e185ea9f7f4d185dd4ce33898c858dca176ca4df 100644 (file)
@@ -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,
index 4312c3a4fa8646147354e1165f5d3532b773c0bd..ff7c55c687b7630a00822827982cbe6b97ea5f11 100644 (file)
@@ -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;
index 7cd7ebc8e302bfbce71e24e3e42c020afebe5465..7331b694c1351751ef488471a31f6dfa6ed73de3 100644 (file)
@@ -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;
        }
index cbde26704a6ce8393c218dda45d97db2e86e36ca..0937e9004b4f474c255d541d737e2064701608c4 100644 (file)
@@ -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]);
index 7967df2f900e2bfb5a176a25bf2961541e4a2279..afa8044f900d525b64dc1dc2c5d12de5fabc4781 100644 (file)
@@ -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; i<NUM_ETHERPEEK_ENCAPS; i++) {
index 73a964d374e3a1a0f2f150bd3156012b64de48af..277a4684ecc85ac10775f12bafb8b4495e11153e 100644 (file)
@@ -280,8 +280,8 @@ parse_eyesdn_rec_hdr(wtap *wth, FILE_T fh,
        }
 
        if (wth) {
-               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 = pkt_len;
                wth->phdr.len = pkt_len;
        }
index 1e9cf016d3b3625c9178ccc49d466ef487876b6a..1881fc248a57abad76073d2b274bfbaa94d7b41f 100644 (file)
@@ -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++) {
index d9c57189996493a05a4d868cc4747649be832631..ccca83ce8f42aad1dca3682e0b31064f2677f85a 100644 (file)
@@ -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;
 
index 892e5fdb2bd6b155c36ba377758882d6074576cc..11dc2cc2fd415fe9e3912376dd1ee6de092ac592 100644 (file)
@@ -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.
index f427cff95ba47e827739786e6a4d0c1a4b725100..9281b6b80ceb7063ab56f8491bb7473932a7dbec 100644 (file)
@@ -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;
index 42e90f72059786a4dc0506c2be1b045ffff97825..ecd9b751855ff560e1a691918f19f17edf45da28 100644 (file)
@@ -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);
        
index 00679a94fb10b3c03e17411c8734568d52b434b0..a6553ecc602cfc64e024693b33a60394ac4fe42d 100644 (file)
@@ -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;
index a7738c4af25a9c0dc92289b4e439bc3292b2ec4a..86bf798a6f023b0a628f39dfbfd0c99fa640826e 100644 (file)
@@ -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) {
index bc10056510deaef41f12bead3ee2e687ec9b27cd..c3c552d2d0346f7a169c20ec0c42920adb181f38 100644 (file)
@@ -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 =
index 22d54d51481ccbb331ea3c861f2267c9348680a1..75ffb9e1ca4aed95a98ffe1ec92123e6a4695708 100644 (file)
@@ -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;
index b5d7416e14d107faa6970cbdc8bc5131154887a2..0e226e6e481f5f103867691742a7b46441d3908d 100644 (file)
@@ -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);
index 93a5ef9bcaa56d3b633d138e2f4284efde47e178..f5164a06157391b6526f3668a6a7c2f40867b4ab 100644 (file)
@@ -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);
index 1d7768250d1a67ecc2886b5388b3fa544b053ecd..04bcb78e89994383847a9c3354b9629f2303396d 100644 (file)
@@ -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);
index 72061bdcd969a348b862d4aa4080ea2cc25173ea..8913cd8c4a010278342cb87d742b581df9e7b63d 100644 (file)
@@ -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);
index 08524b23a37a5e10f7b3efd1c601caa3af690e6c..9c3934504a4d20214beaf79ff35281029e50e06b 100644 (file)
@@ -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) {
 
index a19e4cd532882511f655347fc8220c6e94c998ab..5dc0c2a27d8580204fe1206a88daed477202124d 100644 (file)
@@ -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))
index 086ed50be8e49caf77a14ddf5573ffb94baf6201..a9cc44d50328fc5f27a12753359929f23acee36d 100644 (file)
@@ -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;
        }
index 5725aa9375a05e1e2030bb9454c1a348f4fc0a31..b270d508facb397b01f42ccc57ed7b9164d22d73 100644 (file)
@@ -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. */
index fccd4b1c137aab884131cf86270c8ac9fb55a4b8..02d0e6cc8a59057771c27fe1c71f0f12baa105ba 100644 (file)
@@ -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;
     }
index fbbe89ef12fee08baec2d9d7269c875cec597b8a..91a7456a84524c907fbf2c2ea7302c64103d6433 100644 (file)
@@ -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;
index b1e981b1d190d3732780df0b98763491fb2dadb1..cb12f65ba9899a1254bf17c3c273c5ca32c7362e 100644 (file)
@@ -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;
index 1e314db4750908974cb52b2faef3da003523d67a..74d11b8cb11d444d0e343a699effe2365d88c0a4 100644 (file)
@@ -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
index b828a7e4b6cda30e3d24252a7d082ad753ce1073..44da7e5c6a3fbf7a20213b0ad510a78dd89845ff 100644 (file)
@@ -33,6 +33,7 @@
 
 #include <glib.h>
 #include <stdio.h>
+#include <time.h>
 
 /* Encapsulation types. Choose names that truly reflect
  * what is contained in the packet trace file.
 /* 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);