diff options
Diffstat (limited to 'epan')
27 files changed, 170 insertions, 269 deletions
diff --git a/epan/column-utils.c b/epan/column-utils.c index da1db1a5c0..7120ce474a 100644 --- a/epan/column-utils.c +++ b/epan/column-utils.c @@ -473,7 +473,7 @@ col_set_abs_date_time(frame_data *fd, column_info *cinfo, int col) struct tm *tmp; time_t then; - then = fd->abs_secs; + then = fd->abs_ts.secs; tmp = localtime(&then); if (tmp != NULL) { g_snprintf(cinfo->col_buf[col], COL_MAX_LEN, @@ -484,7 +484,7 @@ col_set_abs_date_time(frame_data *fd, column_info *cinfo, int col) tmp->tm_hour, tmp->tm_min, tmp->tm_sec, - (long)fd->abs_usecs); + (long)fd->abs_ts.nsecs / 1000); /* XXX - this has to be improved */ } else { cinfo->col_buf[col][0] = '\0'; } @@ -497,7 +497,7 @@ static void col_set_rel_time(frame_data *fd, column_info *cinfo, int col) { display_signed_time(cinfo->col_buf[col], COL_MAX_LEN, - fd->rel_secs, fd->rel_usecs, USECS); + fd->rel_ts.secs, fd->rel_ts.nsecs / 1000, USECS); /* XXX - this has to be improved */ cinfo->col_data[col] = cinfo->col_buf[col]; strcpy(cinfo->col_expr[col],"frame.time_relative"); strcpy(cinfo->col_expr_val[col],cinfo->col_buf[col]); @@ -507,7 +507,7 @@ static void col_set_delta_time(frame_data *fd, column_info *cinfo, int col) { display_signed_time(cinfo->col_buf[col], COL_MAX_LEN, - fd->del_secs, fd->del_usecs, USECS); + fd->del_ts.secs, fd->del_ts.nsecs / 1000, USECS); cinfo->col_data[col] = cinfo->col_buf[col]; strcpy(cinfo->col_expr[col],"frame.time_delta"); strcpy(cinfo->col_expr_val[col],cinfo->col_buf[col]); @@ -521,14 +521,14 @@ col_set_abs_time(frame_data *fd, column_info *cinfo, int col) struct tm *tmp; time_t then; - then = fd->abs_secs; + then = fd->abs_ts.secs; tmp = localtime(&then); if (tmp != NULL) { g_snprintf(cinfo->col_buf[col], COL_MAX_LEN, "%02d:%02d:%02d.%06ld", tmp->tm_hour, tmp->tm_min, tmp->tm_sec, - (long)fd->abs_usecs); + (long)fd->abs_ts.nsecs / 1000); /* XXX - this has to be improved */ } else { cinfo->col_buf[col][0] = '\0'; } diff --git a/epan/dissectors/packet-afp.c b/epan/dissectors/packet-afp.c index 82c7efafd5..63158b8761 100644 --- a/epan/dissectors/packet-afp.c +++ b/epan/dissectors/packet-afp.c @@ -4010,7 +4010,7 @@ dissect_afp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) afp_request_key request_key, *new_request_key; afp_request_val *request_val; guint8 afp_command; - nstime_t t, deltat; + nstime_t delta_ts; int len = tvb_reported_length_remaining(tvb,0); gint col_info = check_col(pinfo->cinfo, COL_INFO); @@ -4044,8 +4044,7 @@ dissect_afp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) request_val->command = afp_command; request_val->frame_req = pinfo->fd->num; request_val->frame_res = 0; - request_val->req_time.secs=pinfo->fd->abs_secs; - request_val->req_time.nsecs=pinfo->fd->abs_usecs*1000; + request_val->req_time=pinfo->fd->abs_ts; g_hash_table_insert(afp_request_hash, new_request_key, request_val); @@ -4248,11 +4247,9 @@ dissect_afp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) ti = proto_tree_add_uint(afp_tree, hf_afp_response_to, tvb, 0, 0, request_val->frame_req); PROTO_ITEM_SET_GENERATED(ti); - t.secs = pinfo->fd->abs_secs; - t.nsecs = pinfo->fd->abs_usecs*1000; - get_timedelta(&deltat, &t, &request_val->req_time); + nstime_delta(&delta_ts, &pinfo->fd->abs_ts, &request_val->req_time); ti = proto_tree_add_time(afp_tree, hf_afp_time, tvb, - 0, 0, &deltat); + 0, 0, &delta_ts); PROTO_ITEM_SET_GENERATED(ti); } diff --git a/epan/dissectors/packet-afs.c b/epan/dissectors/packet-afs.c index 7f249d55d8..7d62b45ab8 100644 --- a/epan/dissectors/packet-afs.c +++ b/epan/dissectors/packet-afs.c @@ -172,7 +172,7 @@ dissect_afs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) int port, node, typenode, opcode; value_string const *vals; int offset = 0; - nstime_t ns; + nstime_t delta_ts; void (*dissector)(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode); @@ -226,8 +226,7 @@ dissect_afs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) request_val -> opcode = tvb_get_ntohl(tvb, offset); request_val -> req_num = pinfo->fd->num; request_val -> rep_num = 0; - request_val -> req_time.secs=pinfo->fd->abs_secs; - request_val -> req_time.nsecs=pinfo->fd->abs_usecs*1000; + request_val -> req_time = pinfo->fd->abs_ts; g_hash_table_insert(afs_request_hash, new_request_key, request_val); @@ -370,14 +369,9 @@ dissect_afs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) tvb, 0, 0, request_val->req_num, "This is a reply to a request in frame %u", request_val->req_num); - ns.secs= pinfo->fd->abs_secs-request_val->req_time.secs; - ns.nsecs=pinfo->fd->abs_usecs*1000-request_val->req_time.nsecs; - if(ns.nsecs<0){ - ns.nsecs+=1000000000; - ns.secs--; - } + nstime_delta(&delta_ts, &pinfo->fd->abs_ts, &request_val->req_time); proto_tree_add_time(afs_tree, hf_afs_time, tvb, offset, 0, - &ns); + &delta_ts); } diff --git a/epan/dissectors/packet-aoe.c b/epan/dissectors/packet-aoe.c index 5592fc8b48..3b55fd3d1f 100644 --- a/epan/dissectors/packet-aoe.c +++ b/epan/dissectors/packet-aoe.c @@ -242,8 +242,7 @@ dissect_ata_pdu(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, ata_info->request_frame=pinfo->fd->num; ata_info->response_frame=0; ata_info->cmd=tvb_get_guint8(tvb, offset+3); - ata_info->req_time.secs=pinfo->fd->abs_secs; - ata_info->req_time.nsecs=pinfo->fd->abs_usecs*1000; + ata_info->req_time=pinfo->fd->abs_ts; tmp_ata_info=g_hash_table_lookup(ata_cmd_unmatched, ata_info); if(tmp_ata_info){ @@ -273,16 +272,11 @@ dissect_ata_pdu(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, if(ata_info){ if(response){ if(ata_info->request_frame){ - nstime_t ns; + nstime_t delta_ts; tmp_item=proto_tree_add_uint(tree, hf_aoe_response_to, tvb, 0, 0, ata_info->request_frame); PROTO_ITEM_SET_GENERATED(tmp_item); - ns.secs= pinfo->fd->abs_secs-ata_info->req_time.secs; - ns.nsecs=pinfo->fd->abs_usecs*1000-ata_info->req_time.nsecs; - if(ns.nsecs<0){ - ns.nsecs+=1000000000; - ns.secs--; - } - tmp_item=proto_tree_add_time(tree, hf_aoe_time, tvb, offset, 0, &ns); + nstime_delta(&delta_ts, &pinfo->fd->abs_ts, &ata_info->req_time); + tmp_item=proto_tree_add_time(tree, hf_aoe_time, tvb, offset, 0, &delta_ts); PROTO_ITEM_SET_GENERATED(tmp_item); } } else { diff --git a/epan/dissectors/packet-dcerpc.c b/epan/dissectors/packet-dcerpc.c index c0be1a12b7..f21783f7a3 100644 --- a/epan/dissectors/packet-dcerpc.c +++ b/epan/dissectors/packet-dcerpc.c @@ -3371,8 +3371,7 @@ dissect_dcerpc_cn_rqst (tvbuff_t *tvb, gint offset, packet_info *pinfo, call_value->ver = bind_value->ver; call_value->opnum = opnum; call_value->req_frame=pinfo->fd->num; - call_value->req_time.secs=pinfo->fd->abs_secs; - call_value->req_time.nsecs=pinfo->fd->abs_usecs*1000; + call_value->req_time=pinfo->fd->abs_ts; call_value->rep_frame=0; call_value->max_ptr=0; call_value->private_data = NULL; @@ -3513,20 +3512,15 @@ dissect_dcerpc_cn_resp (tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree_add_uint (dcerpc_tree, hf_dcerpc_opnum, tvb, 0, 0, value->opnum); if(value->req_frame!=0){ - nstime_t ns; + nstime_t delta_ts; pi = proto_tree_add_uint(dcerpc_tree, hf_dcerpc_request_in, tvb, 0, 0, value->req_frame); PROTO_ITEM_SET_GENERATED(pi); if(parent_pi != NULL) { proto_item_append_text(parent_pi, ", [Req: #%u]", value->req_frame); } - ns.secs= pinfo->fd->abs_secs-value->req_time.secs; - ns.nsecs=pinfo->fd->abs_usecs*1000-value->req_time.nsecs; - if(ns.nsecs<0){ - ns.nsecs+=1000000000; - ns.secs--; - } - pi = proto_tree_add_time(dcerpc_tree, hf_dcerpc_time, tvb, offset, 0, &ns); + nstime_delta(&delta_ts, &pinfo->fd->abs_ts, &value->req_time); + pi = proto_tree_add_time(dcerpc_tree, hf_dcerpc_time, tvb, offset, 0, &delta_ts); PROTO_ITEM_SET_GENERATED(pi); } @@ -3636,7 +3630,7 @@ dissect_dcerpc_cn_fault (tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree_add_uint (dcerpc_tree, hf_dcerpc_opnum, tvb, 0, 0, value->opnum); if(value->req_frame!=0){ - nstime_t ns; + nstime_t delta_ts; pi = proto_tree_add_uint(dcerpc_tree, hf_dcerpc_request_in, tvb, 0, 0, value->req_frame); PROTO_ITEM_SET_GENERATED(pi); @@ -3644,13 +3638,8 @@ dissect_dcerpc_cn_fault (tvbuff_t *tvb, gint offset, packet_info *pinfo, if(parent_pi != NULL) { proto_item_append_text(parent_pi, ", [Req: #%u]", value->req_frame); } - ns.secs= pinfo->fd->abs_secs-value->req_time.secs; - ns.nsecs=pinfo->fd->abs_usecs*1000-value->req_time.nsecs; - if(ns.nsecs<0){ - ns.nsecs+=1000000000; - ns.secs--; - } - pi = proto_tree_add_time(dcerpc_tree, hf_dcerpc_time, tvb, offset, 0, &ns); + nstime_delta(&delta_ts, &pinfo->fd->abs_ts, &value->req_time); + pi = proto_tree_add_time(dcerpc_tree, hf_dcerpc_time, tvb, offset, 0, &delta_ts); PROTO_ITEM_SET_GENERATED(pi); } @@ -4477,8 +4466,7 @@ dissect_dcerpc_dg_rqst (tvbuff_t *tvb, int offset, packet_info *pinfo, call_value->ver = hdr->if_ver; call_value->opnum = hdr->opnum; call_value->req_frame=pinfo->fd->num; - call_value->req_time.secs=pinfo->fd->abs_secs; - call_value->req_time.nsecs=pinfo->fd->abs_usecs*1000; + call_value->req_time=pinfo->fd->abs_ts; call_value->rep_frame=0; call_value->max_ptr=0; call_value->private_data = NULL; @@ -4573,7 +4561,7 @@ dissect_dcerpc_dg_resp (tvbuff_t *tvb, int offset, packet_info *pinfo, di->call_data = value; if(value->req_frame!=0){ - nstime_t ns; + nstime_t delta_ts; pi = proto_tree_add_uint(dcerpc_tree, hf_dcerpc_request_in, tvb, 0, 0, value->req_frame); PROTO_ITEM_SET_GENERATED(pi); @@ -4581,13 +4569,8 @@ dissect_dcerpc_dg_resp (tvbuff_t *tvb, int offset, packet_info *pinfo, if(parent_pi != NULL) { proto_item_append_text(parent_pi, ", [Req: #%u]", value->req_frame); } - ns.secs= pinfo->fd->abs_secs-value->req_time.secs; - ns.nsecs=pinfo->fd->abs_usecs*1000-value->req_time.nsecs; - if(ns.nsecs<0){ - ns.nsecs+=1000000000; - ns.secs--; - } - pi = proto_tree_add_time(dcerpc_tree, hf_dcerpc_time, tvb, offset, 0, &ns); + nstime_delta(&delta_ts, &pinfo->fd->abs_ts, &value->req_time); + pi = proto_tree_add_time(dcerpc_tree, hf_dcerpc_time, tvb, offset, 0, &delta_ts); PROTO_ITEM_SET_GENERATED(pi); } dissect_dcerpc_dg_stub (tvb, offset, pinfo, dcerpc_tree, tree, hdr, di); @@ -4609,7 +4592,7 @@ dissect_dcerpc_dg_ping_ack (tvbuff_t *tvb, int offset, packet_info *pinfo, if((call_value=g_hash_table_lookup(dcerpc_dg_calls, &call_key))){ proto_item *pi; - nstime_t ns; + nstime_t delta_ts; pi = proto_tree_add_uint(dcerpc_tree, hf_dcerpc_request_in, tvb, 0, 0, call_value->req_frame); @@ -4622,13 +4605,8 @@ dissect_dcerpc_dg_ping_ack (tvbuff_t *tvb, int offset, packet_info *pinfo, if (check_col (pinfo->cinfo, COL_INFO)) col_append_fstr(pinfo->cinfo, COL_INFO, " [req: #%u]", call_value->req_frame); - ns.secs= pinfo->fd->abs_secs-call_value->req_time.secs; - ns.nsecs=pinfo->fd->abs_usecs*1000-call_value->req_time.nsecs; - if(ns.nsecs<0){ - ns.nsecs+=1000000000; - ns.secs--; - } - pi = proto_tree_add_time(dcerpc_tree, hf_dcerpc_time, tvb, offset, 0, &ns); + nstime_delta(&delta_ts, &pinfo->fd->abs_ts, &call_value->req_time); + pi = proto_tree_add_time(dcerpc_tree, hf_dcerpc_time, tvb, offset, 0, &delta_ts); PROTO_ITEM_SET_GENERATED(pi); /* }*/ } diff --git a/epan/dissectors/packet-fc.c b/epan/dissectors/packet-fc.c index f3893b8aa8..38f1b66033 100644 --- a/epan/dissectors/packet-fc.c +++ b/epan/dissectors/packet-fc.c @@ -860,8 +860,7 @@ dissect_fc_helper (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean COPY_ADDRESS(&old_fced->s_id, &fchdr.s_id); COPY_ADDRESS(&old_fced->d_id, &fchdr.d_id); old_fced->first_exchange_frame=pinfo->fd->num; - old_fced->fc_time.nsecs = pinfo->fd->abs_usecs*1000; - old_fced->fc_time.secs = pinfo->fd->abs_secs; + old_fced->fc_time = pinfo->fd->abs_ts; g_hash_table_insert(fc_exchange_unmatched, old_fced, old_fced); fc_ex=old_fced; } else { @@ -901,15 +900,10 @@ dissect_fc_helper (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean proto_tree_add_uint(fc_tree, hf_fc_exchange_last_frame, tvb, 0, 0, fc_ex->last_exchange_frame); } if(fchdr.fctl&FC_FCTL_EXCHANGE_LAST){ - nstime_t delta_time; + nstime_t delta_ts; proto_tree_add_uint(fc_tree, hf_fc_exchange_first_frame, tvb, 0, 0, fc_ex->first_exchange_frame); - delta_time.secs = pinfo->fd->abs_secs - fc_ex->fc_time.secs; - delta_time.nsecs = pinfo->fd->abs_usecs*1000 - fc_ex->fc_time.nsecs; - if (delta_time.nsecs<0){ - delta_time.nsecs+=1000000000; - delta_time.secs--; - } - proto_tree_add_time(ti, hf_fc_time, tvb, 0, 0, &delta_time); + nstime_delta(&delta_ts, &pinfo->fd->abs_ts, &fc_ex->fc_time); + proto_tree_add_time(ti, hf_fc_time, tvb, 0, 0, &delta_ts); } } fchdr.fced=fc_ex; diff --git a/epan/dissectors/packet-fcp.c b/epan/dissectors/packet-fcp.c index f84a1474b3..df9604901d 100644 --- a/epan/dissectors/packet-fcp.c +++ b/epan/dissectors/packet-fcp.c @@ -84,8 +84,7 @@ typedef struct _fcp_conv_key { typedef struct _fcp_conv_data { guint32 fcp_dl; gint32 fcp_lun; - guint32 abs_secs; - guint32 abs_usecs; + nstime_t abs_ts; } fcp_conv_data_t; GHashTable *fcp_req_hash = NULL; @@ -276,8 +275,7 @@ dissect_fcp_cmnd (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) * req. */ cdata->fcp_dl = tvb_get_ntohl (tvb, offset+12+16+add_len); - cdata->abs_usecs = pinfo->fd->abs_usecs; - cdata->abs_secs = pinfo->fd->abs_secs; + cdata->abs_ts = pinfo->fd->abs_ts; } else { req_key = se_alloc (sizeof(fcp_conv_key_t)); @@ -285,8 +283,7 @@ dissect_fcp_cmnd (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) cdata = se_alloc (sizeof(fcp_conv_data_t)); cdata->fcp_dl = tvb_get_ntohl (tvb, offset+12+16+add_len); - cdata->abs_usecs = pinfo->fd->abs_usecs; - cdata->abs_secs = pinfo->fd->abs_secs; + cdata->abs_ts = pinfo->fd->abs_ts; g_hash_table_insert (fcp_req_hash, req_key, cdata); } @@ -434,8 +431,9 @@ dissect_fcp_rsp (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_uint_hidden (fcp_tree, hf_fcp_type, tvb, offset, 0, 0); if (cdata) { - del_usecs = (pinfo->fd->abs_secs - cdata->abs_secs)* 1000000 + - (pinfo->fd->abs_usecs - cdata->abs_usecs); + /* XXX - this is ugly and should be replaced by a "standard way" */ + del_usecs = (pinfo->fd->abs_ts.secs - cdata->abs_ts.secs)* 1000000 + + (pinfo->fd->abs_ts.nsecs - cdata->abs_ts.nsecs) / 1000; if (del_usecs > 1000) proto_tree_add_text (fcp_tree, tvb, offset, 0, "Cmd Response Time: %d msecs", @@ -538,8 +536,9 @@ dissect_fcp_xfer_rdy (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_uint_hidden (fcp_tree, hf_fcp_type, tvb, offset, 0, 0); if (cdata) { - del_usecs = (pinfo->fd->abs_secs - cdata->abs_secs)* 1000000 + - (pinfo->fd->abs_usecs - cdata->abs_usecs); + /* XXX - this is ugly and should be replaced by a "standard way" */ + del_usecs = (pinfo->fd->abs_ts.secs - cdata->abs_ts.secs)* 1000000 + + (pinfo->fd->abs_ts.nsecs - cdata->abs_ts.nsecs) / 1000; if (del_usecs > 1000) proto_tree_add_text (fcp_tree, tvb, offset, 0, "Cmd Response Time: %d msecs", diff --git a/epan/dissectors/packet-frame.c b/epan/dissectors/packet-frame.c index 233d97e005..9b581d8913 100644 --- a/epan/dissectors/packet-frame.c +++ b/epan/dissectors/packet-frame.c @@ -167,21 +167,18 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) proto_tree_add_item(fh_tree, hf_frame_ref_time, tvb, 0, 0, FALSE); } - ts.secs = pinfo->fd->abs_secs; - ts.nsecs = pinfo->fd->abs_usecs*1000; + ts = pinfo->fd->abs_ts; proto_tree_add_time(fh_tree, hf_frame_arrival_time, tvb, 0, 0, &ts); - ts.secs = pinfo->fd->del_secs; - ts.nsecs = pinfo->fd->del_usecs*1000; + ts = pinfo->fd->del_ts; item = proto_tree_add_time(fh_tree, hf_frame_time_delta, tvb, 0, 0, &ts); PROTO_ITEM_SET_GENERATED(item); - ts.secs = pinfo->fd->rel_secs; - ts.nsecs = pinfo->fd->rel_usecs*1000; + ts = pinfo->fd->rel_ts; item = proto_tree_add_time(fh_tree, hf_frame_time_relative, tvb, 0, 0, &ts); diff --git a/epan/dissectors/packet-h225.c b/epan/dissectors/packet-h225.c index 804028d459..9ec2b5c06d 100644 --- a/epan/dissectors/packet-h225.c +++ b/epan/dissectors/packet-h225.c @@ -12732,9 +12732,9 @@ static void ras_call_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre /* if end of list is reached, exit loop and decide if request is duplicate or not. */ if (h225ras_call->next_call == NULL) { if ( (pinfo->fd->num > h225ras_call->rsp_num && h225ras_call->rsp_num != 0 - && pinfo->fd->abs_secs > (guint) (h225ras_call->req_time.secs + THRESHOLD_REPEATED_RESPONDED_CALL) ) + && pinfo->fd->abs_ts.secs > (h225ras_call->req_time.secs + THRESHOLD_REPEATED_RESPONDED_CALL) ) ||(pinfo->fd->num > h225ras_call->req_num && h225ras_call->rsp_num == 0 - && pinfo->fd->abs_secs > (guint) (h225ras_call->req_time.secs + THRESHOLD_REPEATED_NOT_RESPONDED_CALL) ) ) + && pinfo->fd->abs_ts.secs > (h225ras_call->req_time.secs + THRESHOLD_REPEATED_NOT_RESPONDED_CALL) ) ) { /* if last request has been responded and this request appears after last response (has bigger frame number) @@ -12830,14 +12830,8 @@ static void ras_call_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre PROTO_ITEM_SET_GENERATED(ti); /* Calculate RAS Service Response Time */ - delta.secs= pinfo->fd->abs_secs-h225ras_call->req_time.secs; - delta.nsecs=pinfo->fd->abs_usecs*1000-h225ras_call->req_time.nsecs; - if(delta.nsecs<0){ - delta.nsecs+=1000000000; - delta.secs--; - } - pi->delta_time.secs = delta.secs; /* give it to tap */ - pi->delta_time.nsecs = delta.nsecs; + nstime_delta(&delta, &pinfo->fd->abs_ts, &h225ras_call->req_time); + pi->delta_time = delta; /* give it to tap */ /* display Ras Service Response Time and make it filterable */ ti = proto_tree_add_time(tree, hf_h225_ras_deltatime, tvb, 0, 0, &(pi->delta_time)); diff --git a/epan/dissectors/packet-iax2.c b/epan/dissectors/packet-iax2.c index 3efba06205..4d0135f585 100644 --- a/epan/dissectors/packet-iax2.c +++ b/epan/dissectors/packet-iax2.c @@ -817,8 +817,7 @@ static iax_call_data *iax_new_call( packet_info *pinfo, call -> n_forward_circuit_ids = 0; call -> n_reverse_circuit_ids = 0; call -> subdissector = NULL; - call -> start_time.secs = pinfo->fd->abs_secs; - call -> start_time.nsecs = (pinfo->fd->abs_usecs-1000) * 1000; + call -> start_time = pinfo->fd->abs_ts; iax2_new_circuit_for_call(circuit_id,pinfo->fd->num,call,FALSE); @@ -1308,11 +1307,11 @@ static void iax2_add_ts_fields(packet_info * pinfo, proto_tree * iax2_tree, iax_ if(iax_packet->abstime.secs == -1) { time_t start_secs = iax_packet->call_data->start_time.secs; - guint32 abs_secs = start_secs + longts/1000; + gint32 abs_secs = start_secs + longts/1000; /* deal with short timestamps by assuming that packets are never more than * 16 seconds late */ - while(abs_secs < pinfo->fd->abs_secs - 16) { + while(abs_secs < pinfo->fd->abs_ts.secs - 16) { longts += 32768; abs_secs = start_secs + longts/1000; } @@ -1328,9 +1327,8 @@ static void iax2_add_ts_fields(packet_info * pinfo, proto_tree * iax2_tree, iax_ item = proto_tree_add_time(iax2_tree, hf_iax2_absts, NULL, 0, 0, &iax_packet->abstime); PROTO_ITEM_SET_GENERATED(item); - ts.secs = pinfo->fd->abs_secs; - ts.nsecs = pinfo->fd->abs_usecs * 1000; - get_timedelta(&ts, &ts, &iax_packet->abstime); + ts = pinfo->fd->abs_ts; + nstime_delta(&ts, &ts, &iax_packet->abstime); item = proto_tree_add_time(iax2_tree, hf_iax2_lateness, NULL, 0, 0, &ts); PROTO_ITEM_SET_GENERATED(item); diff --git a/epan/dissectors/packet-iscsi.c b/epan/dissectors/packet-iscsi.c index d98ee25a18..60354a46f2 100644 --- a/epan/dissectors/packet-iscsi.c +++ b/epan/dissectors/packet-iscsi.c @@ -964,8 +964,7 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off cdata->data_in_frame=0; cdata->data_out_frame=0; cdata->response_frame=0; - cdata->req_time.nsecs = pinfo->fd->abs_usecs*1000; - cdata->req_time.secs = pinfo->fd->abs_secs; + cdata->req_time = pinfo->fd->abs_ts; g_hash_table_insert (iscsi_req_unmatched, cdata, cdata); } else { @@ -1608,14 +1607,8 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off if (cdata->request_frame){ nstime_t delta_time; proto_tree_add_uint(ti, hf_iscsi_request_frame, tvb, 0, 0, cdata->request_frame); - delta_time.secs = pinfo->fd->abs_secs - cdata->req_time.secs; - delta_time.nsecs = pinfo->fd->abs_usecs*1000 - cdata->req_time.nsecs; - if (delta_time.nsecs<0){ - delta_time.nsecs+=1000000000; - delta_time.secs--; - } + nstime_delta(&delta_time, &pinfo->fd->abs_ts, &cdata->req_time); proto_tree_add_time(ti, hf_iscsi_time, tvb, 0, 0, &delta_time); - } if (cdata->data_in_frame) proto_tree_add_uint(ti, hf_iscsi_data_in_frame, tvb, 0, 0, cdata->data_in_frame); @@ -1634,14 +1627,8 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off if (cdata->request_frame){ nstime_t delta_time; proto_tree_add_uint(ti, hf_iscsi_request_frame, tvb, 0, 0, cdata->request_frame); - delta_time.secs = pinfo->fd->abs_secs - cdata->req_time.secs; - delta_time.nsecs = pinfo->fd->abs_usecs*1000 - cdata->req_time.nsecs; - if (delta_time.nsecs<0){ - delta_time.nsecs+=1000000000; - delta_time.secs--; - } + nstime_delta(&delta_time, &pinfo->fd->abs_ts, &cdata->req_time); proto_tree_add_time(ti, hf_iscsi_time, tvb, 0, 0, &delta_time); - } } if (cdata->data_out_frame) diff --git a/epan/dissectors/packet-ldap.c b/epan/dissectors/packet-ldap.c index 9e4c6f37af..faaf6ef49f 100644 --- a/epan/dissectors/packet-ldap.c +++ b/epan/dissectors/packet-ldap.c @@ -2026,8 +2026,7 @@ ldap_match_call_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, ld } lcrp->messageId=messageId; lcrp->req_frame=pinfo->fd->num; - lcrp->req_time.secs=pinfo->fd->abs_secs; - lcrp->req_time.nsecs=pinfo->fd->abs_usecs*1000; + lcrp->req_time=pinfo->fd->abs_ts; lcrp->rep_frame=0; lcrp->protocolOpTag=protocolOpTag; lcrp->is_request=TRUE; @@ -2097,12 +2096,7 @@ ldap_match_call_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, ld } else { nstime_t ns; proto_tree_add_uint(tree, hf_ldap_response_to, tvb, 0, 0, lcrp->req_frame); - ns.secs=pinfo->fd->abs_secs-lcrp->req_time.secs; - ns.nsecs=pinfo->fd->abs_usecs*1000-lcrp->req_time.nsecs; - if(ns.nsecs<0){ - ns.nsecs+=1000000000; - ns.secs--; - } + nstime_delta(&ns, &pinfo->fd->abs_ts, &lcrp->req_time); proto_tree_add_time(tree, hf_ldap_time, tvb, 0, 0, &ns); } return lcrp; diff --git a/epan/dissectors/packet-ncp2222.inc b/epan/dissectors/packet-ncp2222.inc index b762269556..5feb405434 100644 --- a/epan/dissectors/packet-ncp2222.inc +++ b/epan/dissectors/packet-ncp2222.inc @@ -4521,8 +4521,7 @@ dissect_ncp_request(tvbuff_t *tvb, packet_info *pinfo, } request_value = ncp_hash_insert(conversation, sequence, ncp_rec); request_value->req_frame_num = pinfo->fd->num; - request_value->req_frame_time.secs=pinfo->fd->abs_secs; - request_value->req_frame_time.nsecs=pinfo->fd->abs_usecs*1000; + request_value->req_frame_time=pinfo->fd->abs_ts; /* If this is the first time we're examining the packet, * check to see if this NCP type uses a "request condition". @@ -4896,14 +4895,8 @@ dissect_ncp_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree_add_uint(ncp_tree, hf_ncp_req_frame_num, tvb, 0, 0, request_value->req_frame_num); - ns.secs=pinfo->fd->abs_secs-request_value->req_frame_time.secs; - ns.nsecs=pinfo->fd->abs_usecs*1000-request_value->req_frame_time.nsecs; - if(ns.nsecs<0){ - ns.nsecs+=1000000000; - ns.secs--; - } + nstime_delta(&ns, &pinfo->fd->abs_ts, &request_value->req_frame_time); proto_tree_add_time(ncp_tree, hf_ncp_req_frame_time, tvb, 0, 0, &ns); - } /* Put the func (and maybe subfunc) from the request packet @@ -8296,8 +8289,7 @@ dissect_nds_request(tvbuff_t *tvb, packet_info *pinfo, if (!pinfo->fd->flags.visited) { request_value = ncp_hash_insert(conversation, sequence, ncp_rec); request_value->req_frame_num = pinfo->fd->num; - request_value->req_frame_time.secs=pinfo->fd->abs_secs; - request_value->req_frame_time.nsecs=pinfo->fd->abs_usecs*1000; + request_value->req_frame_time=pinfo->fd->abs_ts; /* If this is the first time we're examining the packet, * check to see if this NCP type uses a "request condition". @@ -8576,8 +8568,7 @@ dissect_ping_req(tvbuff_t *tvb, packet_info *pinfo, request_value = ncp_hash_insert(conversation, sequence, ncp_rec); request_value->req_frame_num = pinfo->fd->num; - request_value->req_frame_time.secs=pinfo->fd->abs_secs; - request_value->req_frame_time.nsecs=pinfo->fd->abs_usecs*1000; + request_value->req_frame_time=pinfo->fd->abs_ts; /* If this is the first time we're examining the packet, * check to see if this NCP type uses a "request condition". diff --git a/epan/dissectors/packet-nlm.c b/epan/dissectors/packet-nlm.c index 5727c0622a..457dfae9cb 100644 --- a/epan/dissectors/packet-nlm.c +++ b/epan/dissectors/packet-nlm.c @@ -208,14 +208,8 @@ nlm_print_msgres_reply(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb) if(md){ nstime_t ns; proto_tree_add_uint(tree, hf_nlm_request_in, tvb, 0, 0, md->req_frame); - ns.secs= pinfo->fd->abs_secs-md->ns.secs; - ns.nsecs=pinfo->fd->abs_usecs*1000-md->ns.nsecs; - if(ns.nsecs<0){ - ns.nsecs+=1000000000; - ns.secs--; - } + nstime_delta(&ns, &pinfo->fd->abs_ts, &md->ns); proto_tree_add_time(tree, hf_nlm_time, tvb, 0, 0, &ns); - } } @@ -300,8 +294,7 @@ nlm_register_unmatched_msg(packet_info *pinfo, tvbuff_t *tvb, int offset) /* allocate and build the unmatched structure for this request */ umd=g_malloc(sizeof(nlm_msg_res_unmatched_data)); umd->req_frame=pinfo->fd->num; - umd->ns.secs=pinfo->fd->abs_secs; - umd->ns.nsecs=pinfo->fd->abs_usecs*1000; + umd->ns=pinfo->fd->abs_ts; umd->cookie_len=tvb_get_ntohl(tvb, offset); umd->cookie=tvb_memdup(tvb, offset+4, umd->cookie_len); diff --git a/epan/dissectors/packet-rlogin.c b/epan/dissectors/packet-rlogin.c index a0100bb013..ab672450b8 100644 --- a/epan/dissectors/packet-rlogin.c +++ b/epan/dissectors/packet-rlogin.c @@ -74,8 +74,7 @@ typedef struct { #define DONE 2 #define BAD 2 -static guint32 last_abs_sec = 0; -static guint32 last_abs_usec= 0; +static nstime_t last_abs_ts = { 0, 0 }; static void rlogin_init(void) @@ -83,9 +82,7 @@ rlogin_init(void) /* Routine to initialize rlogin protocol before each capture or filter pass. */ - last_abs_sec = 0; - last_abs_usec= 0; - + nstime_set_zero(&last_abs_ts); } @@ -110,13 +107,12 @@ rlogin_state_machine( rlogin_hash_entry_t *hash_info, tvbuff_t *tvb, return; /* test timestamp */ - if (( last_abs_sec > pinfo->fd->abs_secs) || - (( last_abs_sec == pinfo->fd->abs_secs) && - ( last_abs_usec >= pinfo->fd->abs_usecs))) + if (( last_abs_ts.secs > pinfo->fd->abs_ts.secs) || + (( last_abs_ts.secs == pinfo->fd->abs_ts.secs) && + ( last_abs_ts.nsecs >= pinfo->fd->abs_ts.nsecs))) return; - last_abs_sec = pinfo->fd->abs_secs; /* save timestamp */ - last_abs_usec = pinfo->fd->abs_usecs; + last_abs_ts = pinfo->fd->abs_ts; /* save timestamp */ length = tvb_length(tvb); if ( length == 0) /* exit if no data */ diff --git a/epan/dissectors/packet-rpc.c b/epan/dissectors/packet-rpc.c index 2ac43a24f8..3a2edc817b 100644 --- a/epan/dissectors/packet-rpc.c +++ b/epan/dissectors/packet-rpc.c @@ -1871,8 +1871,7 @@ dissect_rpc_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rpc_call->gss_proc = 0; rpc_call->gss_svc = 0; rpc_call->proc_info = value; - rpc_call->req_time.secs=pinfo->fd->abs_secs; - rpc_call->req_time.nsecs=pinfo->fd->abs_usecs*1000; + rpc_call->req_time = pinfo->fd->abs_ts; /* store it */ g_hash_table_insert(rpc_calls, new_rpc_call_key, rpc_call); @@ -2167,8 +2166,7 @@ dissect_rpc_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rpc_call->gss_proc = gss_proc; rpc_call->gss_svc = gss_svc; rpc_call->proc_info = value; - rpc_call->req_time.secs=pinfo->fd->abs_secs; - rpc_call->req_time.nsecs=pinfo->fd->abs_usecs*1000; + rpc_call->req_time = pinfo->fd->abs_ts; /* store it */ g_hash_table_insert(rpc_calls, new_rpc_call_key, @@ -2289,12 +2287,7 @@ dissect_rpc_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, tvb, 0, 0, rpc_call->req_num, "This is a reply to a request in frame %u", rpc_call->req_num); - ns.secs= pinfo->fd->abs_secs-rpc_call->req_time.secs; - ns.nsecs=pinfo->fd->abs_usecs*1000-rpc_call->req_time.nsecs; - if(ns.nsecs<0){ - ns.nsecs+=1000000000; - ns.secs--; - } + nstime_delta(&ns, &pinfo->fd->abs_ts, &rpc_call->req_time); proto_tree_add_time(rpc_tree, hf_rpc_time, tvb, offset, 0, &ns); diff --git a/epan/dissectors/packet-rtcp.c b/epan/dissectors/packet-rtcp.c index 4e7eb9364f..9e7e974d16 100644 --- a/epan/dissectors/packet-rtcp.c +++ b/epan/dissectors/packet-rtcp.c @@ -1551,8 +1551,7 @@ static void remember_outgoing_sr(packet_info *pinfo, long lsr) /* Update conversation data */ p_conv_data->last_received_set = TRUE; p_conv_data->last_received_frame_number = pinfo->fd->num; - p_conv_data->last_received_time_secs = pinfo->fd->abs_secs; - p_conv_data->last_received_time_usecs = pinfo->fd->abs_usecs; + p_conv_data->last_received_timestamp = pinfo->fd->abs_ts; p_conv_data->last_received_ts = lsr; @@ -1576,8 +1575,7 @@ static void remember_outgoing_sr(packet_info *pinfo, long lsr) /* Copy current conversation data into packet info */ p_packet_data->last_received_set = TRUE; p_packet_data->last_received_frame_number = p_conv_data->last_received_frame_number; - p_packet_data->last_received_time_secs = p_conv_data->last_received_time_secs; - p_packet_data->last_received_time_usecs = p_conv_data->last_received_time_usecs; + p_packet_data->last_received_timestamp = p_conv_data->last_received_timestamp; } @@ -1656,13 +1654,13 @@ static void calculate_roundtrip_delay(tvbuff_t *tvb, packet_info *pinfo, { /* Look at time of since original packet was sent */ gint seconds_between_packets = - pinfo->fd->abs_secs - p_conv_data->last_received_time_secs; - gint useconds_between_packets = - pinfo->fd->abs_usecs - p_conv_data->last_received_time_usecs; + pinfo->fd->abs_ts.secs - p_conv_data->last_received_timestamp.secs; + gint nseconds_between_packets = + pinfo->fd->abs_ts.nsecs - p_conv_data->last_received_timestamp.nsecs; gint total_gap = ((seconds_between_packets*1000000) + - useconds_between_packets) / 1000; + nseconds_between_packets) / 1000000; gint delay = total_gap - (int)(((double)dlsr/(double)65536) * 1000.0); /* No useful calculation can be done if dlsr not set... */ diff --git a/epan/dissectors/packet-rtcp.h b/epan/dissectors/packet-rtcp.h index 5523c4db57..d09f5fb8cc 100644 --- a/epan/dissectors/packet-rtcp.h +++ b/epan/dissectors/packet-rtcp.h @@ -41,8 +41,7 @@ struct _rtcp_conversation_info /* Info used for roundtrip calculations */ guchar last_received_set; guint32 last_received_frame_number; - guint32 last_received_time_secs; - guint32 last_received_time_usecs; + nstime_t last_received_timestamp; guint32 last_received_ts; /* Stored result of calculation (ms) */ diff --git a/epan/dissectors/packet-smb.c b/epan/dissectors/packet-smb.c index 460e2b7356..8d96725f21 100644 --- a/epan/dissectors/packet-smb.c +++ b/epan/dissectors/packet-smb.c @@ -15012,8 +15012,7 @@ dissect_smb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) sip = se_alloc(sizeof(smb_saved_info_t)); sip->frame_req = pinfo->fd->num; sip->frame_res = 0; - sip->req_time.secs=pinfo->fd->abs_secs; - sip->req_time.nsecs=pinfo->fd->abs_usecs*1000; + sip->req_time = pinfo->fd->abs_ts; sip->flags = 0; if(g_hash_table_lookup(si->ct->tid_service, GUINT_TO_POINTER(si->tid)) == (void *)TID_IPC) { @@ -15063,9 +15062,8 @@ dissect_smb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) if (sip->frame_req != 0) { tmp_item=proto_tree_add_uint(htree, hf_smb_response_to, tvb, 0, 0, sip->frame_req); PROTO_ITEM_SET_GENERATED(tmp_item); - t.secs = pinfo->fd->abs_secs; - t.nsecs = pinfo->fd->abs_usecs*1000; - get_timedelta(&deltat, &t, &sip->req_time); + t = pinfo->fd->abs_ts; + nstime_delta(&deltat, &t, &sip->req_time); tmp_item=proto_tree_add_time(htree, hf_smb_time, tvb, 0, 0, &deltat); PROTO_ITEM_SET_GENERATED(tmp_item); diff --git a/epan/dissectors/packet-tcp.c b/epan/dissectors/packet-tcp.c index 5cb1a94ea7..07a004e295 100644 --- a/epan/dissectors/packet-tcp.c +++ b/epan/dissectors/packet-tcp.c @@ -430,8 +430,7 @@ scan_for_next_pdu(tvbuff_t *tvb, proto_tree *tcp_tree, packet_info *pinfo, int o */ if(seq>tnp->seq && nxtseq<=tnp->nxtpdu){ tnp->last_frame=pinfo->fd->num; - tnp->last_frame_time.secs=pinfo->fd->abs_secs; - tnp->last_frame_time.nsecs=pinfo->fd->abs_usecs*1000; + tnp->last_frame_time=pinfo->fd->abs_ts; g_hash_table_insert(tcp_pdu_skipping_table, GINT_TO_POINTER(pinfo->fd->num), (void *)tnp); print_pdu_tracking_data(pinfo, tvb, tcp_tree, tnp); @@ -456,16 +455,10 @@ scan_for_next_pdu(tvbuff_t *tvb, proto_tree *tcp_tree, packet_info *pinfo, int o item=proto_tree_add_uint(tcp_tree, hf_tcp_pdu_last_frame, tvb, 0, 0, tnp->last_frame); PROTO_ITEM_SET_GENERATED(item); - ns.secs =tnp->last_frame_time.secs-pinfo->fd->abs_secs; - ns.nsecs=tnp->last_frame_time.nsecs-pinfo->fd->abs_usecs*1000; - if(ns.nsecs<0){ - ns.nsecs+=1000000000; - ns.secs--; - } + nstime_delta(&ns, &tnp->last_frame_time, &pinfo->fd->abs_ts); item = proto_tree_add_time(tcp_tree, hf_tcp_pdu_time, tvb, 0, 0, &ns); PROTO_ITEM_SET_GENERATED(item); - } /* check if this is a segment in the middle of a pdu */ @@ -502,8 +495,7 @@ pdu_store_sequencenumber_of_next_pdu(packet_info *pinfo, guint32 seq, guint32 nx tnp->seq=seq; tnp->first_frame=pinfo->fd->num; tnp->last_frame=pinfo->fd->num; - tnp->last_frame_time.secs=pinfo->fd->abs_secs; - tnp->last_frame_time.nsecs=pinfo->fd->abs_usecs*1000; + tnp->last_frame_time=pinfo->fd->abs_ts; /* check direction and get pdu start list */ direction=CMP_ADDRESS(&pinfo->src, &pinfo->dst); @@ -673,14 +665,12 @@ tcp_analyze_sequence_number(packet_info *pinfo, guint32 seq, guint32 ack, guint3 if(!ack2_frame){ ack2_frame=pinfo->fd->num; ack2=ack; - ack2_time->secs=pinfo->fd->abs_secs; - ack2_time->nsecs=pinfo->fd->abs_usecs*1000; + *ack2_time=pinfo->fd->abs_ts; num2_acks=0; } else if(GT_SEQ(ack, ack2)){ ack2_frame=pinfo->fd->num; ack2=ack; - ack2_time->secs=pinfo->fd->abs_secs; - ack2_time->nsecs=pinfo->fd->abs_usecs*1000; + *ack2_time=pinfo->fd->abs_ts; num2_acks=0; } } @@ -729,8 +719,7 @@ printf(" Frame:%d seq:%d nseq:%d time:%d.%09d ack:%d:%d\n",u->frame,u->seq,u->n num2_acks=0; ual1->seq=seq; ual1->nextseq=seq+1; - ual1->ts.secs=pinfo->fd->abs_secs; - ual1->ts.nsecs=pinfo->fd->abs_usecs*1000; + ual1->ts=pinfo->fd->abs_ts; ual1->window=window; ual1->flags=0; if(tcp_relative_seq){ @@ -754,8 +743,7 @@ printf(" Frame:%d seq:%d nseq:%d time:%d.%09d ack:%d:%d\n",u->frame,u->seq,u->n ual1->frame=pinfo->fd->num; ual1->seq=seq; ual1->nextseq=seq+seglen; - ual1->ts.secs=pinfo->fd->abs_secs; - ual1->ts.nsecs=pinfo->fd->abs_usecs*1000; + ual1->ts=pinfo->fd->abs_ts; ual1->window=window; ual1->flags=0; if(tcp_relative_seq){ @@ -781,8 +769,7 @@ printf(" Frame:%d seq:%d nseq:%d time:%d.%09d ack:%d:%d\n",u->frame,u->seq,u->n ual->frame=pinfo->fd->num; ual->seq=seq; ual->nextseq=seq+seglen; - ual->ts.secs=pinfo->fd->abs_secs; - ual->ts.nsecs=pinfo->fd->abs_usecs*1000; + ual->ts=pinfo->fd->abs_ts; ual->window=window; ual->flags=0; ual1=ual; @@ -840,8 +827,8 @@ printf(" Frame:%d seq:%d nseq:%d time:%d.%09d ack:%d:%d\n",u->frame,u->seq,u->n if( (num1_acks>=4) && (seq==ack1) ){ guint32 t; - t=(pinfo->fd->abs_secs-ack1_time->secs)*1000000000; - t=t+(pinfo->fd->abs_usecs*1000)-ack1_time->nsecs; + t=(pinfo->fd->abs_ts.secs-ack1_time->secs)*1000000000; + t=t+(pinfo->fd->abs_ts.nsecs)-ack1_time->nsecs; if(t<10000000){ /* has to be a retransmission then */ struct tcp_acked *ta; @@ -888,15 +875,15 @@ printf(" Frame:%d seq:%d nseq:%d time:%d.%09d ack:%d:%d\n",u->frame,u->seq,u->n } } if(ntu){ - if(pinfo->fd->abs_secs>(guint32)(ntu->ts.secs+2)){ + if(pinfo->fd->abs_ts.secs > ntu->ts.secs+2){ outoforder=FALSE; - } else if((pinfo->fd->abs_secs+2)<(guint32)ntu->ts.secs){ + } else if(pinfo->fd->abs_ts.secs+2 < ntu->ts.secs){ outoforder=FALSE; } else { guint32 t; - t=(ntu->ts.secs-pinfo->fd->abs_secs)*1000000000; - t=t+ntu->ts.nsecs-(pinfo->fd->abs_usecs*1000); + t=(ntu->ts.secs-pinfo->fd->abs_ts.secs)*1000000000; + t=t+ntu->ts.nsecs-(pinfo->fd->abs_ts.nsecs); if(t>4000000){ outoforder=FALSE; @@ -952,12 +939,7 @@ printf(" Frame:%d seq:%d nseq:%d time:%d.%09d ack:%d:%d\n",u->frame,u->seq,u->n * segment with an equal or lower sequence * number. */ - ta->rto_ts.secs=pinfo->fd->abs_secs-ntu->ts.secs; - ta->rto_ts.nsecs=pinfo->fd->abs_usecs*1000-ntu->ts.nsecs; - if(ta->rto_ts.nsecs<0){ - ta->rto_ts.nsecs+=1000000000; - ta->rto_ts.secs--; - } + nstime_delta(&ta->rto_ts, &pinfo->fd->abs_ts, &ntu->ts); ta->rto_frame=ntu->frame; } else { /* we didnt see any previous packet so we @@ -974,8 +956,7 @@ printf(" Frame:%d seq:%d nseq:%d time:%d.%09d ack:%d:%d\n",u->frame,u->seq,u->n if(GT_SEQ((seq+seglen), ual1->nextseq)){ ual1->nextseq=seq+seglen; ual1->frame=pinfo->fd->num; - ual1->ts.secs=pinfo->fd->abs_secs; - ual1->ts.nsecs=pinfo->fd->abs_usecs*1000; + ual1->ts=pinfo->fd->abs_ts; } } goto seq_finished; @@ -987,8 +968,7 @@ printf(" Frame:%d seq:%d nseq:%d time:%d.%09d ack:%d:%d\n",u->frame,u->seq,u->n ual->frame=pinfo->fd->num; ual->seq=seq; ual->nextseq=seq+seglen; - ual->ts.secs=pinfo->fd->abs_secs; - ual->ts.nsecs=pinfo->fd->abs_usecs*1000; + ual->ts=pinfo->fd->abs_ts; ual->window=window; ual->flags=0; ual1=ual; @@ -1043,12 +1023,7 @@ seq_finished: ta=tcp_analyze_get_acked_struct(pinfo->fd->num, TRUE); ta->frame_acked=ual2->frame; - ta->ts.secs=pinfo->fd->abs_secs-ual2->ts.secs; - ta->ts.nsecs=pinfo->fd->abs_usecs*1000-ual2->ts.nsecs; - if(ta->ts.nsecs<0){ - ta->ts.nsecs+=1000000000; - ta->ts.secs--; - } + nstime_delta(&ta->ts, &pinfo->fd->abs_ts, &ual2->ts); /* its all been ACKed so we dont need to keep them anymore */ for(ual=ual2;ual2;ual2=ual){ @@ -1076,12 +1051,7 @@ seq_finished: ta=tcp_analyze_get_acked_struct(pinfo->fd->num, TRUE); ta->frame_acked=ackedual->frame; - ta->ts.secs=pinfo->fd->abs_secs-ackedual->ts.secs; - ta->ts.nsecs=pinfo->fd->abs_usecs*1000-ackedual->ts.nsecs; - if(ta->ts.nsecs<0){ - ta->ts.nsecs+=1000000000; - ta->ts.secs--; - } + nstime_delta(&ta->ts, &pinfo->fd->abs_ts, &ackedual->ts); /* just delete all ACKed segments */ tmpual=ual->next; diff --git a/epan/frame_data.h b/epan/frame_data.h index 05c28859da..db6d5034a4 100644 --- a/epan/frame_data.h +++ b/epan/frame_data.h @@ -27,6 +27,7 @@ #include "column_info.h" #include "tvbuff.h" +#include <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 { diff --git a/epan/h225-persistentdata.c b/epan/h225-persistentdata.c index 38804ecf6a..f9ae7539a9 100644 --- a/epan/h225-persistentdata.c +++ b/epan/h225-persistentdata.c @@ -95,8 +95,7 @@ h225ras_call_t * new_h225ras_call(h225ras_call_info_key *h225ras_call_key, packe h225ras_call->requestSeqNum = h225ras_call_key->reqSeqNum; h225ras_call->responded = FALSE; h225ras_call->next_call = NULL; - h225ras_call->req_time.secs=pinfo->fd->abs_secs; - h225ras_call->req_time.nsecs=pinfo->fd->abs_usecs*1000; + h225ras_call->req_time=pinfo->fd->abs_ts; memcpy(h225ras_call->guid, guid,16); /* store it */ g_hash_table_insert(ras_calls[category], new_h225ras_call_key, h225ras_call); @@ -119,8 +118,7 @@ h225ras_call_t * append_h225ras_call(h225ras_call_t *prev_call, packet_info *pin h225ras_call->requestSeqNum = prev_call->requestSeqNum; h225ras_call->responded = FALSE; h225ras_call->next_call = NULL; - h225ras_call->req_time.secs=pinfo->fd->abs_secs; - h225ras_call->req_time.nsecs=pinfo->fd->abs_usecs*1000; + h225ras_call->req_time=pinfo->fd->abs_ts; memcpy(h225ras_call->guid, guid,16); prev_call->next_call = h225ras_call; diff --git a/epan/libethereal.def b/epan/libethereal.def index 6221d736e3..ea14571675 100644 --- a/epan/libethereal.def +++ b/epan/libethereal.def @@ -307,8 +307,6 @@ get_plugins_pers_dir get_systemfile_dir get_tcp_port get_tempfile_path -get_timedelta -get_timesum get_timestamp_setting get_udp_port gsm_a_bssmap_msg_strings DATA @@ -351,7 +349,12 @@ mtp3_addr_to_str_buf mtp3_service_indicator_code_short_vals DATA new_create_dissector_handle new_register_dissector +nstime_delta +nstime_is_zero +nstime_set_zero +nstime_sum nstime_to_msec +nstime_to_sec nt_cmd_vals DATA num_tap_filters DATA num_tree_types DATA diff --git a/epan/nstime.c b/epan/nstime.c index b5089bb97c..e20159afcf 100644 --- a/epan/nstime.c +++ b/epan/nstime.c @@ -25,6 +25,7 @@ * */ +#include <glib.h> #include "nstime.h" /* this is #defined so that we can clearly see that we have the right number of @@ -32,12 +33,30 @@ changing ;) */ #define NS_PER_S 1000000000 +/* set the given nstime_t to zero */ +void nstime_set_zero(nstime_t *nstime) +{ + nstime->secs = 0; + nstime->nsecs = 0; +} + +/* is the given nstime_t currently zero? */ +gboolean nstime_is_zero(nstime_t *nstime) +{ + if(nstime->secs == 0 && nstime->nsecs == 0) { + return TRUE; + } else { + return FALSE; + } +} + + /* - * function: get_timedelta + * function: nstime_delta * delta = b - a */ -void get_timedelta(nstime_t *delta, const nstime_t *b, const nstime_t *a ) +void nstime_delta(nstime_t *delta, const nstime_t *b, const nstime_t *a ) { if (b->secs == a->secs) { /* The seconds part of b is the same as the seconds part of a, so if @@ -74,11 +93,11 @@ void get_timedelta(nstime_t *delta, const nstime_t *b, const nstime_t *a ) } /* - * function: get_timesum + * function: nstime_sum * sum = a + b */ -void get_timesum(nstime_t *sum, const nstime_t *a, const nstime_t *b) +void nstime_sum(nstime_t *sum, const nstime_t *a, const nstime_t *b) { sum->secs = a->secs + b->secs; sum->nsecs = a->nsecs + b->nsecs; @@ -101,3 +120,13 @@ double nstime_to_msec(const nstime_t *time) return ((double)time->secs*1000 + (double)time->nsecs/1000000); } +/* + * function: nstime_to_sec + * converts nstime to double, time base is seconds + */ + +double nstime_to_sec(const nstime_t *time) +{ + return ((double)time->secs + (double)time->nsecs/1000000000); +} + diff --git a/epan/nstime.h b/epan/nstime.h index 25c10d6bef..60fec42e01 100644 --- a/epan/nstime.h +++ b/epan/nstime.h @@ -34,14 +34,20 @@ typedef struct { /* functions */ -/* calculate the delta between two times +/* set the given nstime_t to zero */ +extern void nstime_set_zero(nstime_t *nstime); + +/* is the given nstime_t currently zero? */ +extern gboolean nstime_is_zero(nstime_t *nstime); + +/* calculate the delta between two times (can be negative!) * * delta = b-a * * Note that it is acceptable for two or more of the arguments to point at the * same structure. */ -extern void get_timedelta(nstime_t *delta, const nstime_t *b, const nstime_t *a ); +extern void nstime_delta(nstime_t *delta, const nstime_t *b, const nstime_t *a ); /* calculate the sum of two times * @@ -50,12 +56,15 @@ extern void get_timedelta(nstime_t *delta, const nstime_t *b, const nstime_t *a * Note that it is acceptable for two or more of the arguments to point at the * same structure. */ -extern void get_timesum(nstime_t *sum, const nstime_t *b, const nstime_t *a ); +extern void nstime_sum(nstime_t *sum, const nstime_t *b, const nstime_t *a ); /* sum += a */ -#define addtime(sum, a) get_timesum(sum, sum, a) +#define nstime_add(sum, a) nstime_sum(sum, sum, a) -/* converts nstime to double, time base is milli seconds*/ +/* converts nstime to double, time base is milli seconds */ extern double nstime_to_msec(const nstime_t *time); +/* converts nstime to double, time base is seconds */ +extern double nstime_to_sec(const nstime_t *time); + #endif /* __NSTIME_H__ */ diff --git a/epan/stats_tree.c b/epan/stats_tree.c index cb36ba2d26..47c94c53c8 100644 --- a/epan/stats_tree.c +++ b/epan/stats_tree.c @@ -52,7 +52,7 @@ extern void stats_tree_get_strs_from_node(const stat_node* node, guint8* value, if (rate) { *rate = '\0'; if (node->st->elapsed > 0.0) { - f = ((float)node->counter) / node->st->elapsed; + f = ((float)node->counter) / (float)node->st->elapsed; g_snprintf(rate,NUM_BUF_SIZE,"%f",f); } } @@ -306,13 +306,13 @@ extern stats_tree* stats_tree_new(stats_tree_cfg* cfg, tree_pres* pr,char* filte /* will be the tap packet cb */ extern int stats_tree_packet(void* p, packet_info* pinfo, epan_dissect_t *edt, const void *pri) { stats_tree* st = p; - float now; + double now; if (st->highest_seen >= pinfo->fd->num) return 0; st->highest_seen = pinfo->fd->num; - - now = (((float)pinfo->fd->rel_secs) + (((float)pinfo->fd->rel_usecs)/1000000) ); + + now = nstime_to_msec(&pinfo->fd->rel_ts); if (st->start < 0.0) st->start = now; diff --git a/epan/stats_tree_priv.h b/epan/stats_tree_priv.h index a29ab8e5dc..7d36a3c7d9 100644 --- a/epan/stats_tree_priv.h +++ b/epan/stats_tree_priv.h @@ -85,8 +85,8 @@ struct _stats_tree { guint32 highest_seen; /* times */ - float start; - float elapsed; + double start; + double elapsed; /* used to lookup named parents: * key: parent node name |