Skip to content

Commit

Permalink
EVERYTHING IN THE BUILDBOT IS GOING TO BE RED!!! Sorry!
Browse files Browse the repository at this point in the history
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...

svn path=/trunk/; revision=15520
  • Loading branch information
ulflulfl committed Aug 24, 2005
1 parent ef81f7d commit 6f43fbb
Show file tree
Hide file tree
Showing 88 changed files with 462 additions and 610 deletions.
6 changes: 3 additions & 3 deletions capinfos.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions cfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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 *);
Expand Down
12 changes: 6 additions & 6 deletions epan/column-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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';
}
Expand All @@ -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]);
Expand All @@ -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]);
Expand All @@ -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';
}
Expand Down
11 changes: 4 additions & 7 deletions epan/dissectors/packet-afp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

Expand Down
14 changes: 4 additions & 10 deletions epan/dissectors/packet-afs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}


Expand Down
14 changes: 4 additions & 10 deletions epan/dissectors/packet-aoe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -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 {
Expand Down
50 changes: 14 additions & 36 deletions epan/dissectors/packet-dcerpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -3636,21 +3630,16 @@ 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);
parent_pi = proto_tree_get_parent(dcerpc_tree);
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);
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -4573,21 +4561,16 @@ 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);
parent_pi = proto_tree_get_parent(dcerpc_tree);
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);
Expand All @@ -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);
Expand All @@ -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);
/* }*/
}
Expand Down
14 changes: 4 additions & 10 deletions epan/dissectors/packet-fc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
19 changes: 9 additions & 10 deletions epan/dissectors/packet-fcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -276,17 +275,15 @@ 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));
req_key->conv_idx = conversation->index;

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);
}
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Loading

0 comments on commit 6f43fbb

Please sign in to comment.