diff options
Diffstat (limited to 'epan')
30 files changed, 214 insertions, 199 deletions
diff --git a/epan/Makefile.common b/epan/Makefile.common index e3dbdb8442..95a4b1cdea 100644 --- a/epan/Makefile.common +++ b/epan/Makefile.common @@ -226,6 +226,7 @@ LIBWIRESHARK_INCLUDES = \ tcap-persistentdata.h \ timestamp.h \ tfs.h \ + time_fmt.h \ to_str.h \ tvbparse.h \ tvbuff.h \ diff --git a/epan/dissectors/packet-ccsds.c b/epan/dissectors/packet-ccsds.c index 642dd1d564..b3ea7477b8 100644 --- a/epan/dissectors/packet-ccsds.c +++ b/epan/dissectors/packet-ccsds.c @@ -237,66 +237,13 @@ static const value_string ccsds_secondary_header_format_id[] = { -/* convert time from utc to julian values */ -void utc_to_julian ( int utc, int* year, int* julianday, int* hour, int* minute, int* second ) -{ - static int Days[2][13] = - { - { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, - { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } - }; - - int j, days_yr[2], left, secs; - - /* oops... */ - if ( ! year || ! julianday || ! hour || ! minute || ! second ) return; - - *year = 1970; - *julianday = 0; - *hour = 0; - *minute = 0; - *second = 0; - - days_yr[0] = days_yr[1] = 0; - - for ( j=1; j < 13; ++j ) - { - days_yr[0] += Days[0][j]; - days_yr[1] += Days[1][j]; - } - - left = utc; - secs = days_yr[Leap(*year)] * 24 * 60 * 60; - - while (left > secs) - { - ++(*year); - left -= secs; - secs = days_yr[Leap(*year)] * 24 * 60 * 60; - } - - *julianday = (left / (24 * 60 * 60)) + 1; - left = left % (24 * 60 * 60); - - *hour = left / (60 * 60); - left = left % (60 * 60); - - *minute = left / 60; - - *second = left % 60; - -} - - - /* convert ccsds embedded time to a human readable string - NOT THREAD SAFE */ static const char* embedded_time_to_string ( int coarse_time, int fine_time ) { - static const char* fmt = "%04d/%03d:%02d:%02d:%02d.%03d"; - static char juliantime[40]; static int utcdiff = 0; - - int utc, yr, year, julianday, hour, minute, second, fraction; + nstime_t t; + int yr; + int fraction; int multiplier = 1000; /* compute the static constant difference in seconds @@ -313,15 +260,11 @@ static const char* embedded_time_to_string ( int coarse_time, int fine_time ) utcdiff += 5 * 24 * 60 * 60; /* five days of January 1980 */ } - utc = coarse_time + utcdiff; - utc_to_julian ( utc, &year, &julianday, &hour, &minute, &second ); - + t.secs = coarse_time + utcdiff; fraction = ( multiplier * ( (int)fine_time & 0xff ) ) / 256; + t.nsecs = fraction*1000000; /* msecs to nsecs */ - g_snprintf ( juliantime, sizeof(juliantime), fmt, year, julianday, hour, minute, second, fraction ); - - return juliantime; - + return abs_time_to_str(&t, ABSOLUTE_TIME_DOY_UTC); } diff --git a/epan/dissectors/packet-collectd.c b/epan/dissectors/packet-collectd.c index dcdcc3bc90..c90fb879b7 100644 --- a/epan/dissectors/packet-collectd.c +++ b/epan/dissectors/packet-collectd.c @@ -1108,7 +1108,7 @@ dissect_collectd (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) pkt_errors++; else { - vdispatch.time_str = abs_time_secs_to_str ((time_t) vdispatch.time, FALSE); + vdispatch.time_str = abs_time_secs_to_str ((time_t) vdispatch.time, ABSOLUTE_TIME_LOCAL); ndispatch.time = vdispatch.time; ndispatch.time_str = vdispatch.time_str; diff --git a/epan/dissectors/packet-dhcp-failover.c b/epan/dissectors/packet-dhcp-failover.c index 1508ea6e37..19f6de062e 100644 --- a/epan/dissectors/packet-dhcp-failover.c +++ b/epan/dissectors/packet-dhcp-failover.c @@ -446,7 +446,7 @@ dissect_dhcpfo_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) timex.nsecs = 0; proto_tree_add_time_format_value(dhcpfo_tree, hf_dhcpfo_time, tvb, offset, 4, &timex, "%s", - abs_time_secs_to_str(timex.secs, FALSE)); + abs_time_secs_to_str(timex.secs, ABSOLUTE_TIME_LOCAL)); } offset += 4; @@ -669,7 +669,7 @@ dissect_dhcpfo_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) lease_expiration_time = tvb_get_ntohl(tvb, offset); lease_expiration_time_str = - abs_time_secs_to_str(lease_expiration_time, FALSE); + abs_time_secs_to_str(lease_expiration_time, ABSOLUTE_TIME_LOCAL); proto_item_append_text(oi, ", %s", lease_expiration_time_str); @@ -693,7 +693,7 @@ dissect_dhcpfo_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) tvb_get_ntohl(tvb, offset); potential_expiration_time_str = - abs_time_secs_to_str(potential_expiration_time, FALSE); + abs_time_secs_to_str(potential_expiration_time, ABSOLUTE_TIME_LOCAL); proto_item_append_text(oi, ", %s", potential_expiration_time_str); @@ -717,7 +717,7 @@ dissect_dhcpfo_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) tvb_get_ntohl(tvb, offset); grace_expiration_time_str = - abs_time_secs_to_str(grace_expiration_time, FALSE); + abs_time_secs_to_str(grace_expiration_time, ABSOLUTE_TIME_LOCAL); proto_item_append_text(oi, ", %s", grace_expiration_time_str); @@ -740,7 +740,7 @@ dissect_dhcpfo_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) client_last_transaction_time = tvb_get_ntohl(tvb, offset); client_last_transaction_time_str = - abs_time_secs_to_str(client_last_transaction_time, FALSE); + abs_time_secs_to_str(client_last_transaction_time, ABSOLUTE_TIME_LOCAL); proto_item_append_text(oi, ", %s", client_last_transaction_time_str); @@ -750,7 +750,7 @@ dissect_dhcpfo_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) offset, option_length, client_last_transaction_time, "%s", - abs_time_secs_to_str(client_last_transaction_time, FALSE)); + abs_time_secs_to_str(client_last_transaction_time, ABSOLUTE_TIME_LOCAL)); break; case DHCP_FO_PD_START_TIME_OF_STATE: @@ -763,7 +763,7 @@ dissect_dhcpfo_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) start_time_of_state = tvb_get_ntohl(tvb, offset); start_time_of_state_str = - abs_time_secs_to_str(start_time_of_state, FALSE); + abs_time_secs_to_str(start_time_of_state, ABSOLUTE_TIME_LOCAL); proto_item_append_text(oi, ", %s", start_time_of_state_str); @@ -773,7 +773,7 @@ dissect_dhcpfo_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) offset, option_length, start_time_of_state, "%s", - abs_time_secs_to_str(start_time_of_state, FALSE)); + abs_time_secs_to_str(start_time_of_state, ABSOLUTE_TIME_LOCAL)); break; case DHCP_FO_PD_SERVERSTATE: diff --git a/epan/dissectors/packet-dmp.c b/epan/dissectors/packet-dmp.c index 0a24ccd3c5..c6048ca2d4 100644 --- a/epan/dissectors/packet-dmp.c +++ b/epan/dissectors/packet-dmp.c @@ -2498,7 +2498,7 @@ static gint dissect_dmp_envelope (tvbuff_t *tvb, packet_info *pinfo, "Submission time: %s", (subm_time & 0x7FFF) >= 0x7FF8 ? "Reserved" : - abs_time_secs_to_str (dmp.subm_time, FALSE)); + abs_time_secs_to_str (dmp.subm_time, ABSOLUTE_TIME_LOCAL)); field_tree = proto_item_add_subtree (tf, ett_envelope_subm_time); proto_tree_add_item (field_tree, hf_envelope_time_diff_present, tvb, offset, 2, FALSE); @@ -3357,7 +3357,7 @@ static gint dissect_dmp_content (tvbuff_t *tvb, packet_info *pinfo, proto_item_append_text (tf, "Reserved (0x%2.2x)", exp_time); } else { proto_item_append_text (tf, "%s (%s)", time_secs_to_str (secs), - abs_time_secs_to_str (dmp.subm_time + secs, FALSE)); + abs_time_secs_to_str (dmp.subm_time + secs, ABSOLUTE_TIME_LOCAL)); } offset += 1; } @@ -3380,13 +3380,13 @@ static gint dissect_dmp_content (tvbuff_t *tvb, packet_info *pinfo, proto_item_append_text (tf, "0 minutes in the %s (%s)", (dtg & 0x80) ? dtg_sign.true_string : dtg_sign.false_string, - abs_time_secs_to_str (dmp.subm_time, FALSE)); + abs_time_secs_to_str (dmp.subm_time, ABSOLUTE_TIME_LOCAL)); } else { proto_item_append_text (tf, "%s in the %s (%s)", time_secs_to_str(secs), (dtg & 0x80) ? dtg_sign.true_string : dtg_sign.false_string, (dtg & 0x80) ? - abs_time_secs_to_str (dmp.subm_time + secs, FALSE) : - abs_time_secs_to_str (dmp.subm_time - secs, FALSE)); + abs_time_secs_to_str (dmp.subm_time + secs, ABSOLUTE_TIME_LOCAL) : + abs_time_secs_to_str (dmp.subm_time - secs, ABSOLUTE_TIME_LOCAL)); } offset += 1; } diff --git a/epan/dissectors/packet-dnp.c b/epan/dissectors/packet-dnp.c index ba3861f70f..634670e2d5 100644 --- a/epan/dissectors/packet-dnp.c +++ b/epan/dissectors/packet-dnp.c @@ -1569,7 +1569,7 @@ dnp3_al_process_object(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree data_pos += 6; al_bit = (al_ptflags & AL_OBJ_BI_FLAG7) >> 7; /* bit shift 1xxxxxxx -> xxxxxxx1 */ - proto_item_append_text(point_item, ", Value: %u, Timestamp: %s", al_bit, abs_time_to_str(&al_abstime, FALSE)); + proto_item_append_text(point_item, ", Value: %u, Timestamp: %s", al_bit, abs_time_to_str(&al_abstime, ABSOLUTE_TIME_LOCAL)); proto_item_set_len(point_item, data_pos - offset); offset = data_pos; @@ -1589,7 +1589,7 @@ dnp3_al_process_object(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree data_pos += 6; al_2bit = (al_ptflags >> 6) & 3; /* bit shift 11xxxxxx -> 00000011 */ - proto_item_append_text(point_item, ", Value: %u, Timestamp: %s", al_2bit, abs_time_to_str(&al_abstime, FALSE)); + proto_item_append_text(point_item, ", Value: %u, Timestamp: %s", al_2bit, abs_time_to_str(&al_abstime, ABSOLUTE_TIME_LOCAL)); proto_item_set_len(point_item, data_pos - offset); offset = data_pos; @@ -1612,7 +1612,7 @@ dnp3_al_process_object(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree data_pos += 2; al_bit = (al_ptflags & AL_OBJ_BI_FLAG7) >> 7; /* bit shift 1xxxxxxx -> xxxxxxx1 */ - proto_item_append_text(point_item, ", Value: %u, Timestamp: %s", al_bit, abs_time_to_str(&al_abstime, FALSE)); + proto_item_append_text(point_item, ", Value: %u, Timestamp: %s", al_bit, abs_time_to_str(&al_abstime, ABSOLUTE_TIME_LOCAL)); proto_item_set_len(point_item, data_pos - offset); offset = data_pos; @@ -1836,7 +1836,7 @@ dnp3_al_process_object(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree case AL_OBJ_FDCTRC_32T: case AL_OBJ_FDCTRC_16T: dnp3_al_get_timestamp(&al_abstime, tvb, data_pos); - proto_item_append_text(point_item, ", Timestamp: %s", abs_time_to_str(&al_abstime, FALSE)); + proto_item_append_text(point_item, ", Timestamp: %s", abs_time_to_str(&al_abstime, ABSOLUTE_TIME_LOCAL)); proto_tree_add_time(point_tree, hf_dnp3_al_timestamp, tvb, data_pos, 6, &al_abstime); data_pos += 6; break; @@ -1943,7 +1943,7 @@ dnp3_al_process_object(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree case AL_OBJ_AIFC_FLTT: case AL_OBJ_AIFC_DBLT: dnp3_al_get_timestamp(&al_abstime, tvb, data_pos); - proto_item_append_text(point_item, ", Timestamp: %s", abs_time_to_str(&al_abstime, FALSE)); + proto_item_append_text(point_item, ", Timestamp: %s", abs_time_to_str(&al_abstime, ABSOLUTE_TIME_LOCAL)); proto_tree_add_time(point_tree, hf_dnp3_al_timestamp, tvb, data_pos, 6, &al_abstime); data_pos += 6; break; diff --git a/epan/dissectors/packet-dns.c b/epan/dissectors/packet-dns.c index 93cb0c55ce..e84758f7fa 100644 --- a/epan/dissectors/packet-dns.c +++ b/epan/dissectors/packet-dns.c @@ -1543,7 +1543,7 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset, nstime.secs = tvb_get_ntohl(tvb, cur_offset); nstime.nsecs = 0; proto_tree_add_text(rr_tree, tvb, cur_offset, 4, "Signature expiration: %s", - abs_time_to_str(&nstime, FALSE)); + abs_time_to_str(&nstime, ABSOLUTE_TIME_LOCAL)); cur_offset += 4; rr_len -= 4; @@ -1552,7 +1552,7 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset, nstime.secs = tvb_get_ntohl(tvb, cur_offset); nstime.nsecs = 0; proto_tree_add_text(rr_tree, tvb, cur_offset, 4, "Time signed: %s", - abs_time_to_str(&nstime, FALSE)); + abs_time_to_str(&nstime, ABSOLUTE_TIME_LOCAL)); cur_offset += 4; rr_len -= 4; @@ -2187,7 +2187,7 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset, nstime.secs = tvb_get_ntohl(tvb, cur_offset); nstime.nsecs = 0; proto_tree_add_text(rr_tree, tvb, cur_offset, 4, "Signature inception: %s", - abs_time_to_str(&nstime, FALSE)); + abs_time_to_str(&nstime, ABSOLUTE_TIME_LOCAL)); cur_offset += 4; rr_len -= 4; @@ -2196,7 +2196,7 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset, nstime.secs = tvb_get_ntohl(tvb, cur_offset); nstime.nsecs = 0; proto_tree_add_text(rr_tree, tvb, cur_offset, 4, "Signature expiration: %s", - abs_time_to_str(&nstime, FALSE)); + abs_time_to_str(&nstime, ABSOLUTE_TIME_LOCAL)); cur_offset += 4; rr_len -= 4; @@ -2314,7 +2314,7 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset, nstime.secs = tsig_timelo; nstime.nsecs = 0; proto_tree_add_text(rr_tree, tvb, cur_offset, 6, "Time signed: %s%s", - abs_time_to_str(&nstime, FALSE), tsig_timehi == 0 ? "" : "(high bits set)"); + abs_time_to_str(&nstime, ABSOLUTE_TIME_LOCAL), tsig_timehi == 0 ? "" : "(high bits set)"); cur_offset += 6; rr_len -= 6; diff --git a/epan/dissectors/packet-dtn.c b/epan/dissectors/packet-dtn.c index 431a26c4ae..0a5f7704ad 100644 --- a/epan/dissectors/packet-dtn.c +++ b/epan/dissectors/packet-dtn.c @@ -1285,7 +1285,7 @@ dissect_version_5_primary_header(packet_info *pinfo, return 0; } time_since_2000 = (time_t) (timestamp + 946684800); - time_string = abs_time_secs_to_str(time_since_2000, FALSE); + time_string = abs_time_secs_to_str(time_since_2000, ABSOLUTE_TIME_LOCAL); proto_item_set_text(timestamp_item, "Timestamp: 0x%x [%s]", timestamp, time_string); offset += sdnv_length; @@ -2090,7 +2090,7 @@ add_dtn_time_to_tree(proto_tree *tree, tvbuff_t *tvb, int offset, char *field_id return 0; } time_since_2000 = (time_t) (sdnv_value + 946684800); - time_string = abs_time_secs_to_str(time_since_2000, FALSE); + time_string = abs_time_secs_to_str(time_since_2000, ABSOLUTE_TIME_LOCAL); proto_tree_add_text(tree, tvb, offset, sdnv_length, "%s (sec): %d [%s]", field_id, sdnv_value, time_string); offset += sdnv_length; @@ -2121,7 +2121,7 @@ add_sdnv_time_to_tree(proto_tree *tree, tvbuff_t *tvb, int offset, char *field_i return 0; } time_since_2000 = (time_t) (sdnv_value + 946684800); - time_string = abs_time_secs_to_str(time_since_2000, FALSE); + time_string = abs_time_secs_to_str(time_since_2000, ABSOLUTE_TIME_LOCAL); proto_tree_add_text(tree, tvb, offset, sdnv_length, "%s: %d [%s]", field_id, sdnv_value, time_string); return sdnv_length; diff --git a/epan/dissectors/packet-goose.c b/epan/dissectors/packet-goose.c index 4e0ceed2ab..9cac6d702f 100644 --- a/epan/dissectors/packet-goose.c +++ b/epan/dissectors/packet-goose.c @@ -507,7 +507,7 @@ dissect_goose_UtcTime(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _ ts.secs = seconds; ts.nsecs = nanoseconds; - ptime = abs_time_to_str(&ts, TRUE); + ptime = abs_time_to_str(&ts, ABSOLUTE_TIME_UTC); if(hf_index >= 0) { diff --git a/epan/dissectors/packet-icq.c b/epan/dissectors/packet-icq.c index 73c28cc088..1d4aadd2f6 100644 --- a/epan/dissectors/packet-icq.c +++ b/epan/dissectors/packet-icq.c @@ -956,7 +956,7 @@ icqv5_cmd_login(proto_tree* tree, tvbuff_t *tvb, int offset, int size) ti = proto_tree_add_text(tree, tvb, offset, size, "Body"); subtree = proto_item_add_subtree(ti, ett_icq_body); theTime = tvb_get_letohl(tvb, offset + CMD_LOGIN_TIME); - aTime = abs_time_secs_to_str(theTime, FALSE); + aTime = abs_time_secs_to_str(theTime, ABSOLUTE_TIME_LOCAL); proto_tree_add_text(subtree, tvb, offset + CMD_LOGIN_TIME, 4, "Time: %ld = %s", (long)theTime, aTime); port = tvb_get_letohl(tvb, offset + CMD_LOGIN_PORT); diff --git a/epan/dissectors/packet-ipmi.c b/epan/dissectors/packet-ipmi.c index 2e7a8e09fd..5e02b9056d 100644 --- a/epan/dissectors/packet-ipmi.c +++ b/epan/dissectors/packet-ipmi.c @@ -781,7 +781,7 @@ ipmi_add_timestamp(proto_tree *tree, gint hf, tvbuff_t *tvb, guint offset) time_secs_to_str_unsigned(ts)); } else { proto_tree_add_uint_format_value(tree, hf, tvb, offset, 4, - ts, "%s", abs_time_secs_to_str(ts, TRUE)); + ts, "%s", abs_time_secs_to_str(ts, ABSOLUTE_TIME_UTC)); } } diff --git a/epan/dissectors/packet-ipp.c b/epan/dissectors/packet-ipp.c index 4e90490198..b25f50857c 100644 --- a/epan/dissectors/packet-ipp.c +++ b/epan/dissectors/packet-ipp.c @@ -507,7 +507,7 @@ add_integer_tree(proto_tree *tree, tvbuff_t *tvb, int offset, 1 + 2 + name_length + 2 + value_length, "%s: %s", format_text(name_val, name_length), - abs_time_secs_to_str(tvb_get_ntohl(tvb, offset + 1 + 2 + name_length + 2), FALSE)); + abs_time_secs_to_str(tvb_get_ntohl(tvb, offset + 1 + 2 + name_length + 2), ABSOLUTE_TIME_LOCAL)); } else if((name_length > 5) && name_val && !tvb_memeql(tvb, offset + 1 + 2, "printer-state", 13)){ diff --git a/epan/dissectors/packet-kink.c b/epan/dissectors/packet-kink.c index 531a2dc7a6..bd193e370b 100644 --- a/epan/dissectors/packet-kink.c +++ b/epan/dissectors/packet-kink.c @@ -357,7 +357,7 @@ dissect_payload_kink_ap_req(packet_info *pinfo, tvbuff_t *tvb, int offset, proto /* Show time as UTC, not local time. */ timer = tvb_get_ntohl(tvb, offset); proto_tree_add_text(payload_kink_ap_req_tree, tvb, offset, 4, "EPOCH: %s", - abs_time_secs_to_str(timer, TRUE)); + abs_time_secs_to_str(timer, ABSOLUTE_TIME_UTC)); offset += 4; if(payload_length > PAYLOAD_HEADER){ @@ -419,7 +419,7 @@ dissect_payload_kink_ap_rep(packet_info *pinfo, tvbuff_t *tvb, int offset, proto /* Show time as UTC, not local time. */ timer = tvb_get_ntohl(tvb, offset); proto_tree_add_text(payload_kink_ap_rep_tree, tvb, offset, 4, "EPOCH: %s", - abs_time_secs_to_str(timer, TRUE)); + abs_time_secs_to_str(timer, ABSOLUTE_TIME_UTC)); offset += 4; if(payload_length > PAYLOAD_HEADER){ diff --git a/epan/dissectors/packet-kismet.c b/epan/dissectors/packet-kismet.c index e3b4bcf874..792c176c59 100644 --- a/epan/dissectors/packet-kismet.c +++ b/epan/dissectors/packet-kismet.c @@ -249,7 +249,7 @@ dissect_kismet(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) /* * Format ascii representaion of time */ - ptr = abs_time_secs_to_str(t, FALSE); + ptr = abs_time_secs_to_str(t, ABSOLUTE_TIME_LOCAL); proto_tree_add_text(reqresp_tree, tvb, offset, tokenlen, "Time: %s", ptr); } diff --git a/epan/dissectors/packet-mms.c b/epan/dissectors/packet-mms.c index 57c9975e1d..223dc8eb98 100644 --- a/epan/dissectors/packet-mms.c +++ b/epan/dissectors/packet-mms.c @@ -1868,7 +1868,7 @@ dissect_mms_TimeOfDay(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _ ts.secs = (days + 5113) * 86400 + milliseconds / 1000; ts.nsecs = (milliseconds % 1000) * G_GINT64_CONSTANT(1000000U); - ptime = abs_time_to_str(&ts, TRUE); + ptime = abs_time_to_str(&ts, ABSOLUTE_TIME_UTC); if(hf_index >= 0) { proto_tree_add_string(tree, hf_index, tvb, offset, len, ptime); @@ -1951,7 +1951,7 @@ dissect_mms_UtcTime(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_ ts.secs = seconds; ts.nsecs = nanoseconds; - ptime = abs_time_to_str(&ts, TRUE); + ptime = abs_time_to_str(&ts, ABSOLUTE_TIME_UTC); if(hf_index >= 0) { diff --git a/epan/dissectors/packet-mmse.c b/epan/dissectors/packet-mmse.c index f057005860..f021302eac 100644 --- a/epan/dissectors/packet-mmse.c +++ b/epan/dissectors/packet-mmse.c @@ -1207,7 +1207,7 @@ dissect_mmse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint8 pdut, &count2); tmptime.secs = tval; tmptime.nsecs = 0; - strval = abs_time_to_str(&tmptime, FALSE); + strval = abs_time_to_str(&tmptime, ABSOLUTE_TIME_LOCAL); /* Now render the fields */ tvb_ensure_bytes_exist(tvb, offset - 1, length + count + 1); tii = proto_tree_add_string_format(mmse_tree, diff --git a/epan/dissectors/packet-ncp2222.inc b/epan/dissectors/packet-ncp2222.inc index 959dbe56fb..44349c9217 100644 --- a/epan/dissectors/packet-ncp2222.inc +++ b/epan/dissectors/packet-ncp2222.inc @@ -3363,7 +3363,7 @@ print_nds_values(proto_tree *vtree, tvbuff_t *tvb, guint32 syntax_type, nds_val voffset = voffset+4; ns.secs = tvb_get_letohl(tvb, voffset); ns.nsecs = 0; - proto_tree_add_time_format(nvtree, hf_nds_ds_time, tvb, voffset, 4, &ns, "Timestamp: %s", abs_time_secs_to_str(ns.secs, FALSE)); + proto_tree_add_time_format(nvtree, hf_nds_ds_time, tvb, voffset, 4, &ns, "Timestamp: %s", abs_time_secs_to_str(ns.secs, ABSOLUTE_TIME_LOCAL)); voffset = voffset + 4; rnum = tvb_get_letohs(tvb, voffset); /* replica number */ proto_tree_add_uint_format(nvtree, hf_nds_rnum, tvb, voffset, @@ -3397,7 +3397,7 @@ print_nds_values(proto_tree *vtree, tvbuff_t *tvb, guint32 syntax_type, nds_val voffset += 4; /* This is the length of the time data no need to decode, always 4 bytes */ ns.secs = tvb_get_letohl(tvb, voffset); ns.nsecs = 0; - proto_tree_add_time_format(nvtree, hf_nds_ds_time, tvb, voffset, 4, &ns, "Time: %s", abs_time_secs_to_str(ns.secs, FALSE)); + proto_tree_add_time_format(nvtree, hf_nds_ds_time, tvb, voffset, 4, &ns, "Time: %s", abs_time_secs_to_str(ns.secs, ABSOLUTE_TIME_LOCAL)); voffset = voffset + 4; break; case 0x00000019: /* Typed Name */ @@ -3612,7 +3612,7 @@ print_es_type(proto_tree *estree, tvbuff_t *tvb, nds_val *values, guint32 vtype, ns.secs = tvb_get_letohl(tvb, ioffset); /* Seconds */ ns.nsecs = 0; proto_tree_add_time_format(nestree, hf_es_seconds, tvb, ioffset, - 4, &ns, "Timestamp: %s", abs_time_secs_to_str(ns.secs, FALSE)); + 4, &ns, "Timestamp: %s", abs_time_secs_to_str(ns.secs, ABSOLUTE_TIME_LOCAL)); ioffset = ioffset + 4; replica_num = tvb_get_letohs(tvb, ioffset); /* Replica */ proto_tree_add_item(nestree, hf_nds_replica_num, tvb, ioffset, @@ -3697,7 +3697,7 @@ print_es_type(proto_tree *estree, tvbuff_t *tvb, nds_val *values, guint32 vtype, ns.secs = tvb_get_letohl(tvb, ioffset); /* Seconds */ ns.nsecs = 0; proto_tree_add_time_format(estree, hf_es_seconds, tvb, ioffset, - 4, &ns, "Timestamp: %s", abs_time_secs_to_str(ns.secs, FALSE)); + 4, &ns, "Timestamp: %s", abs_time_secs_to_str(ns.secs, ABSOLUTE_TIME_LOCAL)); ioffset = ioffset + 4; replica_num = tvb_get_letohs(tvb, ioffset); /* Replica */ proto_tree_add_item(estree, hf_nds_replica_num, tvb, ioffset, @@ -3844,7 +3844,7 @@ print_es_type(proto_tree *estree, tvbuff_t *tvb, nds_val *values, guint32 vtype, ns.secs = tvb_get_letohl(tvb, ioffset); /* Seconds */ ns.nsecs = 0; proto_tree_add_time_format(estree, hf_es_seconds, tvb, ioffset, - 4, &ns, "Timestamp: %s", abs_time_secs_to_str(ns.secs, FALSE)); + 4, &ns, "Timestamp: %s", abs_time_secs_to_str(ns.secs, ABSOLUTE_TIME_LOCAL)); ioffset = ioffset + 4; replica_num = tvb_get_letohs(tvb, ioffset); /* Replica */ proto_tree_add_item(estree, hf_nds_replica_num, tvb, ioffset, @@ -3895,7 +3895,7 @@ print_es_type(proto_tree *estree, tvbuff_t *tvb, nds_val *values, guint32 vtype, ns.secs = tvb_get_letohl(tvb, ioffset); /* Seconds */ ns.nsecs = 0; proto_tree_add_time_format(sub2tree, hf_es_seconds, tvb, ioffset, - 4, &ns, "Timestamp: %s", abs_time_secs_to_str(ns.secs, FALSE)); + 4, &ns, "Timestamp: %s", abs_time_secs_to_str(ns.secs, ABSOLUTE_TIME_LOCAL)); ioffset = ioffset + 4; replica_num = tvb_get_letohs(tvb, ioffset); /* Replica */ proto_tree_add_item(sub2tree, hf_nds_replica_num, tvb, ioffset, @@ -4443,14 +4443,14 @@ process_entry_info(proto_tree *it_tree, tvbuff_t *tvb, nds_val *values) ns.secs = tvb_get_letohl(tvb, ioffset); /* Seconds */ ns.nsecs = 0; proto_tree_add_time_format(it_tree, hf_es_seconds, tvb, ioffset, - 4, &ns, "Modification Time: %s", abs_time_secs_to_str(ns.secs, FALSE)); + 4, &ns, "Modification Time: %s", abs_time_secs_to_str(ns.secs, ABSOLUTE_TIME_LOCAL)); ioffset = ioffset + 4; } if (iter_flags & DSI_MODIFICATION_TIMESTAMP) { /* Modification Timestamp */ ns.secs = tvb_get_letohl(tvb, ioffset); /* Seconds */ ns.nsecs = 0; proto_tree_add_time_format(it_tree, hf_es_seconds, tvb, ioffset, - 4, &ns, "Modification Timestamp: %s", abs_time_secs_to_str(ns.secs, FALSE)); + 4, &ns, "Modification Timestamp: %s", abs_time_secs_to_str(ns.secs, ABSOLUTE_TIME_LOCAL)); ioffset = ioffset + 4; replica_num = tvb_get_letohs(tvb, ioffset); /* Replica */ proto_tree_add_item(it_tree, hf_nds_replica_num, tvb, ioffset, @@ -4465,7 +4465,7 @@ process_entry_info(proto_tree *it_tree, tvbuff_t *tvb, nds_val *values) ns.secs = tvb_get_letohl(tvb, ioffset); /* Seconds */ ns.nsecs = 0; proto_tree_add_time_format(it_tree, hf_es_seconds, tvb, ioffset, - 4, &ns, "Creation Timestamp: %s", abs_time_secs_to_str(ns.secs, FALSE)); + 4, &ns, "Creation Timestamp: %s", abs_time_secs_to_str(ns.secs, ABSOLUTE_TIME_LOCAL)); ioffset = ioffset + 4; replica_num = tvb_get_letohs(tvb, ioffset); /* Replica */ proto_tree_add_item(it_tree, hf_nds_replica_num, tvb, ioffset, @@ -4567,7 +4567,7 @@ process_entry_info(proto_tree *it_tree, tvbuff_t *tvb, nds_val *values) ns.secs = tvb_get_letohl(tvb, ioffset); /* Seconds */ ns.nsecs = 0; proto_tree_add_time_format(it_tree, hf_nds_purge, tvb, ioffset, - 4, &ns, "Purge Time: %s", abs_time_secs_to_str(ns.secs, FALSE)); + 4, &ns, "Purge Time: %s", abs_time_secs_to_str(ns.secs, ABSOLUTE_TIME_LOCAL)); ioffset = ioffset + 4; } if (iter_flags & DSI_DEREFERENCED_BASE_CLASS) { /* Dereference Base Class */ @@ -5178,7 +5178,7 @@ process_multivalues(proto_tree *ncp_tree, tvbuff_t *tvb, packet_info *pinfo, nds ns.secs = tvb_get_letohl(tvb, ioffset); /* Seconds */ ns.nsecs = 0; proto_tree_add_time_format(atree, hf_es_seconds, tvb, ioffset, - 4, &ns, "Timestamp: %s", abs_time_secs_to_str(ns.secs, FALSE)); + 4, &ns, "Timestamp: %s", abs_time_secs_to_str(ns.secs, ABSOLUTE_TIME_LOCAL)); ioffset = ioffset + 4; replica_num = tvb_get_letohs(tvb, ioffset); /* Replica */ proto_tree_add_item(atree, hf_nds_replica_num, tvb, ioffset, @@ -5270,7 +5270,7 @@ process_multivalues(proto_tree *ncp_tree, tvbuff_t *tvb, packet_info *pinfo, nds ns.secs = tvb_get_letohl(tvb, ioffset); /* Seconds */ ns.nsecs = 0; proto_tree_add_time_format(ntree, hf_es_seconds, tvb, ioffset, - 4, &ns, "Creation Time: %s", abs_time_secs_to_str(ns.secs, FALSE)); + 4, &ns, "Creation Time: %s", abs_time_secs_to_str(ns.secs, ABSOLUTE_TIME_LOCAL)); ioffset = ioffset + 4; replica_num = tvb_get_letohs(tvb, ioffset); /* Replica */ proto_tree_add_item(ntree, hf_nds_replica_num, tvb, ioffset, @@ -5412,7 +5412,7 @@ process_multivalues(proto_tree *ncp_tree, tvbuff_t *tvb, packet_info *pinfo, nds ns.secs = tvb_get_letohl(tvb, ioffset); /* Seconds */ ns.nsecs = 0; proto_tree_add_time_format(ntree, hf_es_seconds, tvb, ioffset, - 4, &ns, "Modification Timestamp: %s", abs_time_secs_to_str(ns.secs, FALSE)); + 4, &ns, "Modification Timestamp: %s", abs_time_secs_to_str(ns.secs, ABSOLUTE_TIME_LOCAL)); ioffset = ioffset + 4; replica_num = tvb_get_letohs(tvb, ioffset); /* Replica */ proto_tree_add_item(ntree, hf_nds_replica_num, tvb, ioffset, @@ -5427,7 +5427,7 @@ process_multivalues(proto_tree *ncp_tree, tvbuff_t *tvb, packet_info *pinfo, nds ns.secs = tvb_get_letohl(tvb, ioffset); /* Seconds */ ns.nsecs = 0; proto_tree_add_time_format(ntree, hf_nds_purge, tvb, ioffset, - 4, &ns, "Purge Time: %s", abs_time_secs_to_str(ns.secs, FALSE)); + 4, &ns, "Purge Time: %s", abs_time_secs_to_str(ns.secs, ABSOLUTE_TIME_LOCAL)); ioffset = ioffset + 4; break; case 0x00000020: /*p3values.bit6 = "Local Partition ID"*/ @@ -5887,14 +5887,14 @@ process_multivalues(proto_tree *ncp_tree, tvbuff_t *tvb, packet_info *pinfo, nds ns.secs = tvb_get_letohl(tvb, ioffset); /* Seconds */ ns.nsecs = 0; proto_tree_add_time_format(ntree, hf_es_seconds, tvb, ioffset, - 4, &ns, "Modification Time: %s", abs_time_secs_to_str(ns.secs, FALSE)); + 4, &ns, "Modification Time: %s", abs_time_secs_to_str(ns.secs, ABSOLUTE_TIME_LOCAL)); ioffset = ioffset + 4; break; case 0x0000020: /* Modification Timestamp */ ns.secs = tvb_get_letohl(tvb, ioffset); /* Seconds */ ns.nsecs = 0; proto_tree_add_time_format(ntree, hf_es_seconds, tvb, ioffset, - 4, &ns, "Modification Timestamp: %s", abs_time_secs_to_str(ns.secs, FALSE)); + 4, &ns, "Modification Timestamp: %s", abs_time_secs_to_str(ns.secs, ABSOLUTE_TIME_LOCAL)); ioffset = ioffset + 4; replica_num = tvb_get_letohs(tvb, ioffset); /* Replica */ proto_tree_add_item(ntree, hf_nds_replica_num, tvb, ioffset, @@ -5909,7 +5909,7 @@ process_multivalues(proto_tree *ncp_tree, tvbuff_t *tvb, packet_info *pinfo, nds ns.secs = tvb_get_letohl(tvb, ioffset); /* Seconds */ ns.nsecs = 0; proto_tree_add_time_format(ntree, hf_es_seconds, tvb, ioffset, - 4, &ns, "Creation Timestamp: %s", abs_time_secs_to_str(ns.secs, FALSE)); + 4, &ns, "Creation Timestamp: %s", abs_time_secs_to_str(ns.secs, ABSOLUTE_TIME_LOCAL)); ioffset = ioffset + 4; replica_num = tvb_get_letohs(tvb, ioffset); /* Replica */ proto_tree_add_item(ntree, hf_nds_replica_num, tvb, ioffset, @@ -6002,7 +6002,7 @@ process_multivalues(proto_tree *ncp_tree, tvbuff_t *tvb, packet_info *pinfo, nds ns.secs = tvb_get_letohl(tvb, ioffset); /* Seconds */ ns.nsecs = 0; proto_tree_add_time_format(ntree, hf_es_seconds, tvb, ioffset, - 4, &ns, "Purge Time: %s", abs_time_secs_to_str(ns.secs, FALSE)); + 4, &ns, "Purge Time: %s", abs_time_secs_to_str(ns.secs, ABSOLUTE_TIME_LOCAL)); ioffset = ioffset + 4; break; case 0x00020000: /* Dereference Base Class */ @@ -6266,7 +6266,7 @@ process_multivalues(proto_tree *ncp_tree, tvbuff_t *tvb, packet_info *pinfo, nds ns.secs = tvb_get_letohl(tvb, ioffset); /* Seconds */ ns.nsecs = 0; proto_tree_add_time_format(sub1tree, hf_es_seconds, tvb, ioffset, - 4, &ns, "Creation Timestamp: %s", abs_time_secs_to_str(ns.secs, FALSE)); + 4, &ns, "Creation Timestamp: %s", abs_time_secs_to_str(ns.secs, ABSOLUTE_TIME_LOCAL)); ioffset = ioffset + 4; replica_num = tvb_get_letohs(tvb, ioffset); /* Replica */ proto_tree_add_item(sub1tree, hf_nds_replica_num, tvb, ioffset, @@ -6279,7 +6279,7 @@ process_multivalues(proto_tree *ncp_tree, tvbuff_t *tvb, packet_info *pinfo, nds ns.secs = tvb_get_letohl(tvb, ioffset); /* Seconds */ ns.nsecs = 0; proto_tree_add_time_format(sub1tree, hf_es_seconds, tvb, ioffset, - 4, &ns, "Modification Timestamp: %s", abs_time_secs_to_str(ns.secs, FALSE)); + 4, &ns, "Modification Timestamp: %s", abs_time_secs_to_str(ns.secs, ABSOLUTE_TIME_LOCAL)); ioffset = ioffset + 4; replica_num = tvb_get_letohs(tvb, ioffset); /* Replica */ proto_tree_add_item(sub1tree, hf_nds_replica_num, tvb, ioffset, @@ -6499,7 +6499,7 @@ process_multivalues(proto_tree *ncp_tree, tvbuff_t *tvb, packet_info *pinfo, nds ns.secs = tvb_get_letohl(tvb, ioffset); /* Seconds */ ns.nsecs = 0; proto_tree_add_time_format(ntree, hf_es_seconds, tvb, ioffset, - 4, &ns, "Creation Timestamp: %s", abs_time_secs_to_str(ns.secs, FALSE)); + 4, &ns, "Creation Timestamp: %s", abs_time_secs_to_str(ns.secs, ABSOLUTE_TIME_LOCAL)); ioffset += 4; replica_num = tvb_get_letohs(tvb, ioffset); /* Replica */ proto_tree_add_item(ntree, hf_nds_replica_num, tvb, ioffset, @@ -6535,7 +6535,7 @@ process_multivalues(proto_tree *ncp_tree, tvbuff_t *tvb, packet_info *pinfo, nds ns.secs = tvb_get_letohl(tvb, ioffset); /* Seconds */ ns.nsecs = 0; proto_tree_add_time_format(sub2tree, hf_es_seconds, tvb, ioffset, - 4, &ns, "Timestamp: %s", abs_time_secs_to_str(ns.secs, FALSE)); + 4, &ns, "Timestamp: %s", abs_time_secs_to_str(ns.secs, ABSOLUTE_TIME_LOCAL)); ioffset += 4; replica_num = tvb_get_letohs(tvb, ioffset); /* Replica */ proto_tree_add_item(sub2tree, hf_nds_replica_num, tvb, ioffset, diff --git a/epan/dissectors/packet-pktc.c b/epan/dissectors/packet-pktc.c index 60a544613e..ee2460984a 100644 --- a/epan/dissectors/packet-pktc.c +++ b/epan/dissectors/packet-pktc.c @@ -517,7 +517,7 @@ dissect_pktc_mtafqdn_krbsafeuserdata(packet_info *pinfo, tvbuff_t *tvb, proto_tr proto_tree_add_time_format(tree, hf_pktc_mtafqdn_manu_cert_revoked, tvb, offset, 4, &ts, "%s: %s", proto_registrar_get_name(hf_pktc_mtafqdn_manu_cert_revoked), - (bignum==0) ? "not revoked" : abs_time_secs_to_str(bignum, FALSE)); + (bignum==0) ? "not revoked" : abs_time_secs_to_str(bignum, ABSOLUTE_TIME_LOCAL)); break; case PKTC_MTAFQDN_REP: diff --git a/epan/dissectors/packet-radius.c b/epan/dissectors/packet-radius.c index e10f0c0270..5245e5e79c 100644 --- a/epan/dissectors/packet-radius.c +++ b/epan/dissectors/packet-radius.c @@ -709,7 +709,7 @@ void radius_date(radius_attr_info_t* a, proto_tree* tree, packet_info *pinfo _U_ time_ptr.nsecs = 0; proto_tree_add_time(tree, a->hf, tvb, offset, len, &time_ptr); - proto_item_append_text(avp_item, "%s", abs_time_to_str(&time_ptr, FALSE)); + proto_item_append_text(avp_item, "%s", abs_time_to_str(&time_ptr, ABSOLUTE_TIME_LOCAL)); } void radius_abinary(radius_attr_info_t* a, proto_tree* tree, packet_info *pinfo _U_, tvbuff_t* tvb, int offset, int len, proto_item* avp_item) { diff --git a/epan/dissectors/packet-snmp.c b/epan/dissectors/packet-snmp.c index 751d14aa63..4326cbdc8f 100644 --- a/epan/dissectors/packet-snmp.c +++ b/epan/dissectors/packet-snmp.c @@ -1100,7 +1100,7 @@ int dissect_snmp_engineid(proto_tree *tree, tvbuff_t *tvb, int offset, int len) ts.nsecs = 0; proto_tree_add_time_format_value(tree, hf_snmp_engineid_time, tvb, offset+4, 4, &ts, "%s", - abs_time_secs_to_str(seconds, FALSE)); + abs_time_secs_to_str(seconds, ABSOLUTE_TIME_LOCAL)); offset+=8; len_remain=0; } diff --git a/epan/dissectors/packet-time.c b/epan/dissectors/packet-time.c index ee25df4f43..771b3965e9 100644 --- a/epan/dissectors/packet-time.c +++ b/epan/dissectors/packet-time.c @@ -65,7 +65,7 @@ dissect_time(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) guint32 delta_seconds = tvb_get_ntohl(tvb, 0); proto_tree_add_uint_format(time_tree, hf_time_time, tvb, 0, 4, delta_seconds, "%s", - abs_time_secs_to_str(delta_seconds-2208988800U, FALSE)); + abs_time_secs_to_str(delta_seconds-2208988800U, ABSOLUTE_TIME_LOCAL)); } } } diff --git a/epan/dissectors/packet-vcdu.c b/epan/dissectors/packet-vcdu.c index 346726dfb1..1f838a0530 100644 --- a/epan/dissectors/packet-vcdu.c +++ b/epan/dissectors/packet-vcdu.c @@ -150,19 +150,14 @@ static const value_string smex_data_class[] = { -/* prototype of utc to julian time conversion function - see packet-ccsds.c for the full source code */ -extern void utc_to_julian ( int utc, int* year, int* julianday, int* hour, int* minute, int* second ); - - /* convert smex PB5 header time to a human readable string - NOT THREAD SAFE * * note: this is not true PB5 time either, but a tsi specific version, although it is similar */ static const char* smex_time_to_string ( int pb5_days_since_midnight_9_10_oct_1995, int pb5_seconds, int pb5_milliseconds ) { - static const char* fmt = "%04d/%03d:%02d:%02d:%02d.%03d"; - static char juliantime[40]; static int utcdiff = 0; + nstime_t t; static int Days[2][13] = { @@ -170,7 +165,7 @@ static const char* smex_time_to_string ( int pb5_days_since_midnight_9_10_oct_19 { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } }; - int utc, yr, year, julianday, hour, minute, second; + int yr; int ix, days, month; /* compute the static constant difference in seconds @@ -197,13 +192,10 @@ static const char* smex_time_to_string ( int pb5_days_since_midnight_9_10_oct_19 utcdiff += days * 24 * 60 * 60; /* add days in 1995 prior to October 10 */ } - utc = ( pb5_days_since_midnight_9_10_oct_1995 * 86400 ) + pb5_seconds + utcdiff; - utc_to_julian ( utc, &year, &julianday, &hour, &minute, &second ); - - g_snprintf ( juliantime, sizeof(juliantime), fmt, year, julianday, hour, minute, second, pb5_milliseconds ); - - return juliantime; + t.secs = ( pb5_days_since_midnight_9_10_oct_1995 * 86400 ) + pb5_seconds + utcdiff; + t.nsecs = pb5_milliseconds*1000000; /* msecs to nsecs */ + return abs_time_to_str(&t, ABSOLUTE_TIME_DOY_UTC); } diff --git a/epan/dissectors/packet-wsp.c b/epan/dissectors/packet-wsp.c index 68bc82db11..7a270687ff 100644 --- a/epan/dissectors/packet-wsp.c +++ b/epan/dissectors/packet-wsp.c @@ -1798,7 +1798,7 @@ add_headers (proto_tree *tree, tvbuff_t *tvb, int hf, packet_info *pinfo) tvb, hdr_start, hdr_len + val_len, "Requesting Time Of Day"); } else { - val_str = abs_time_secs_to_str(val, FALSE); + val_str = abs_time_secs_to_str(val, ABSOLUTE_TIME_LOCAL); ti = proto_tree_add_string (wsp_headers, hf_hdr_x_wap_tod, tvb, hdr_start, hdr_len + val_len, val_str); @@ -2833,7 +2833,7 @@ wkh_ ## underscored(proto_tree *tree, tvbuff_t *tvb, guint32 hdr_start, packet_i if (val_id <= 4) { /* Length field already parsed by macro! */ \ get_date_value(val, tvb, off, len, ok); \ if (ok) { \ - str = abs_time_secs_to_str(val, FALSE); \ + str = abs_time_secs_to_str(val, ABSOLUTE_TIME_LOCAL); \ tvb_ensure_bytes_exist(tvb, hdr_start, offset - hdr_start); \ ti = proto_tree_add_string(tree, hf_hdr_ ## underscored, \ tvb, hdr_start, offset - hdr_start, str); \ @@ -2868,7 +2868,7 @@ wkh_ ## underscored(proto_tree *tree, tvbuff_t *tvb, guint32 hdr_start, packet_i if (val_id <= 4) { /* Length field already parsed by macro! */ \ get_date_value(val, tvb, off, len, ok); \ if (ok) { \ - str = abs_time_secs_to_str(val, FALSE); \ + str = abs_time_secs_to_str(val, ABSOLUTE_TIME_LOCAL); \ tvb_ensure_bytes_exist(tvb, hdr_start, offset - hdr_start); \ ti = proto_tree_add_string(tree, hf_hdr_ ## underscored, \ tvb, hdr_start, offset - hdr_start, str); \ @@ -2921,7 +2921,7 @@ wkh_ ## underscored(proto_tree *tree, tvbuff_t *tvb, guint32 hdr_start, packet_i tvb, hdr_start, offset - hdr_start, \ "Requesting Time Of Day"); \ } else { \ - str = abs_time_secs_to_str(val, FALSE); \ + str = abs_time_secs_to_str(val, ABSOLUTE_TIME_LOCAL); \ tvb_ensure_bytes_exist(tvb, hdr_start, offset - hdr_start); \ ti = proto_tree_add_string(tree, hf_hdr_ ## underscored, \ tvb, hdr_start, offset - hdr_start, str); \ @@ -3591,7 +3591,7 @@ wkh_profile_warning(proto_tree *tree, tvbuff_t *tvb, guint32 hdr_start, packet_i get_date_value(val, tvb, off, len, ok); if (ok) { /* Valid warn-text string */ off += len; - val_str = abs_time_secs_to_str(val, FALSE); + val_str = abs_time_secs_to_str(val, ABSOLUTE_TIME_LOCAL); str = g_strdup_printf("; date=%s", val_str); proto_item_append_string(ti, str); g_free(str); /* proto_XXX creates a copy */ diff --git a/epan/ftypes/ftype-time.c b/epan/ftypes/ftype-time.c index 155bac9599..75436cbb35 100644 --- a/epan/ftypes/ftype-time.c +++ b/epan/ftypes/ftype-time.c @@ -319,14 +319,14 @@ absolute_val_repr_len(fvalue_t *fv, ftrepr_t rtype _U_) { gchar *rep; - rep = abs_time_to_str(&fv->value.time, FALSE); + rep = abs_time_to_str(&fv->value.time, ABSOLUTE_TIME_LOCAL); return (int)strlen(rep) + 2; /* 2 for opening and closing quotes */ } static void absolute_val_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, char *buf) { - sprintf(buf, "\"%s\"", abs_time_to_str(&fv->value.time, FALSE)); + sprintf(buf, "\"%s\"", abs_time_to_str(&fv->value.time, ABSOLUTE_TIME_LOCAL)); } static int diff --git a/epan/proto.c b/epan/proto.c index 5c904b47eb..5c6a8f370b 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -3336,7 +3336,7 @@ proto_custom_set(proto_tree* tree, int field_id, case FT_ABSOLUTE_TIME: g_strlcpy(result, - abs_time_to_str(fvalue_get(&finfo->value), (hfinfo->display == ABSOLUTE_TIME_UTC)), + abs_time_to_str(fvalue_get(&finfo->value), hfinfo->display), size); break; @@ -4229,7 +4229,8 @@ static void tmp_fld_check_assert(header_field_info *hfinfo) { case FT_ABSOLUTE_TIME: DISSECTOR_ASSERT(hfinfo->display == ABSOLUTE_TIME_LOCAL || - hfinfo->display == ABSOLUTE_TIME_UTC); + hfinfo->display == ABSOLUTE_TIME_UTC || + hfinfo->display == ABSOLUTE_TIME_DOY_UTC); DISSECTOR_ASSERT(hfinfo->bitmask == 0); DISSECTOR_ASSERT(hfinfo->strings == NULL); break; @@ -4471,7 +4472,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str) case FT_ABSOLUTE_TIME: g_snprintf(label_str, ITEM_LABEL_LENGTH, "%s: %s", hfinfo->name, - abs_time_to_str(fvalue_get(&fi->value), (hfinfo->display == ABSOLUTE_TIME_UTC))); + abs_time_to_str(fvalue_get(&fi->value), hfinfo->display)); break; case FT_RELATIVE_TIME: diff --git a/epan/proto.h b/epan/proto.h index fec48db587..59556aea0b 100644 --- a/epan/proto.h +++ b/epan/proto.h @@ -47,6 +47,7 @@ #include "ipv4.h" #include "nstime.h" +#include "time_fmt.h" #include "tvbuff.h" #include "ftypes/ftypes.h" #include "register.h" @@ -166,14 +167,8 @@ typedef enum { /* BASE_ values that cause the field value to be displayed twice */ #define IS_BASE_DUAL(b) ((b)==BASE_DEC_HEX||(b)==BASE_HEX_DEC) -/* For FT_ABSOLUTE_TIME, the display format is ABSOLUTE_TIME_LOCAL if - * the time is to be displayed as local time in our time zone or - * ABSOLUTE_TIME_UTC if the time is to be displayed as UTC. */ - -typedef enum { - ABSOLUTE_TIME_LOCAL, - ABSOLUTE_TIME_UTC -} absolute_time_display_e; +/* For FT_ABSOLUTE_TIME, the display format is an absolute_time_display_e + * as per time_fmt.h. */ typedef enum { HF_REF_TYPE_NONE, /**< Field is not referenced */ diff --git a/epan/time_fmt.h b/epan/time_fmt.h new file mode 100644 index 0000000000..a7b1d57d09 --- /dev/null +++ b/epan/time_fmt.h @@ -0,0 +1,49 @@ +/* time_fmt.h + * Definitions for various time display formats. + * + * $Id: to_str.h 31967 2010-02-23 19:28:38Z etxrab $ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __TIME_FMT_H__ +#define __TIME_FMT_H__ + +/* + * Resolution of a time stamp. + */ +typedef enum { + TO_STR_TIME_RES_T_SECS, /* seconds */ + TO_STR_TIME_RES_T_DSECS, /* deciseconds */ + TO_STR_TIME_RES_T_CSECS, /* centiseconds */ + TO_STR_TIME_RES_T_MSECS, /* milliseconds */ + TO_STR_TIME_RES_T_USECS, /* microseconds */ + TO_STR_TIME_RES_T_NSECS /* nanoseconds */ +} to_str_time_res_t; + +/* + * Display format of an absolute-time time stamp. + */ +typedef enum { + ABSOLUTE_TIME_LOCAL, /* local time in our time zone, with month and day */ + ABSOLUTE_TIME_UTC, /* UTC, with month and day */ + ABSOLUTE_TIME_DOY_UTC /* UTC, with 1-origin day-of-year */ +} absolute_time_display_e; + +#endif /* __TIME_FMT_H__ */ diff --git a/epan/to_str.c b/epan/to_str.c index ec5599aedb..63d3fa91ca 100644 --- a/epan/to_str.c +++ b/epan/to_str.c @@ -504,11 +504,11 @@ static const char *mon_names[12] = { }; gchar * -abs_time_to_str(nstime_t *abs_time, gboolean show_as_utc) +abs_time_to_str(nstime_t *abs_time, absolute_time_display_e fmt) { - struct tm *tmp; + struct tm *tmp = NULL; const char *zonename; - gchar *buf; + gchar *buf = NULL; #ifdef _MSC_VER /* calling localtime() on MSVC 2005 with huge values causes it to crash */ @@ -518,10 +518,15 @@ abs_time_to_str(nstime_t *abs_time, gboolean show_as_utc) tmp = NULL; } else #endif - if (show_as_utc) { + switch (fmt) { + + case ABSOLUTE_TIME_UTC: + case ABSOLUTE_TIME_DOY_UTC: tmp = gmtime(&abs_time->secs); zonename = "UTC"; - } else { + break; + + case ABSOLUTE_TIME_LOCAL: tmp = localtime(&abs_time->secs); if (tmp) { #if defined(HAVE_TM_ZONE) @@ -535,28 +540,46 @@ abs_time_to_str(nstime_t *abs_time, gboolean show_as_utc) #endif } else zonename = NULL; + break; } if (tmp) { - buf = ep_strdup_printf("%s %2d, %d %02d:%02d:%02d.%09ld %s", - mon_names[tmp->tm_mon], - tmp->tm_mday, - tmp->tm_year + 1900, - tmp->tm_hour, - tmp->tm_min, - tmp->tm_sec, - (long)abs_time->nsecs, - zonename); + switch (fmt) { + + case ABSOLUTE_TIME_DOY_UTC: + buf = ep_strdup_printf("%04d/%03d:%02d:%02d:%02d.%09ld %s", + tmp->tm_year + 1900, + tmp->tm_yday, + tmp->tm_hour, + tmp->tm_min, + tmp->tm_sec, + (long)abs_time->nsecs, + zonename); + break; + + case ABSOLUTE_TIME_UTC: + case ABSOLUTE_TIME_LOCAL: + buf = ep_strdup_printf("%s %2d, %d %02d:%02d:%02d.%09ld %s", + mon_names[tmp->tm_mon], + tmp->tm_mday, + tmp->tm_year + 1900, + tmp->tm_hour, + tmp->tm_min, + tmp->tm_sec, + (long)abs_time->nsecs, + zonename); + break; + } } else buf = ep_strdup("Not representable"); return buf; } gchar * -abs_time_secs_to_str(time_t abs_time, gboolean show_as_utc) +abs_time_secs_to_str(time_t abs_time, absolute_time_display_e fmt) { - struct tm *tmp; + struct tm *tmp = NULL; const char *zonename; - gchar *buf; + gchar *buf = NULL; #ifdef _MSC_VER /* calling localtime() on MSVC 2005 with huge values causes it to crash */ @@ -566,10 +589,15 @@ abs_time_secs_to_str(time_t abs_time, gboolean show_as_utc) tmp = NULL; } else #endif - if (show_as_utc) { + switch (fmt) { + + case ABSOLUTE_TIME_UTC: + case ABSOLUTE_TIME_DOY_UTC: tmp = gmtime(&abs_time); zonename = "UTC"; - } else { + break; + + case ABSOLUTE_TIME_LOCAL: tmp = localtime(&abs_time); if (tmp) { #if defined(HAVE_TM_ZONE) @@ -583,16 +611,33 @@ abs_time_secs_to_str(time_t abs_time, gboolean show_as_utc) #endif } else zonename = NULL; + break; } if (tmp) { - buf = ep_strdup_printf("%s %2d, %d %02d:%02d:%02d %s", - mon_names[tmp->tm_mon], - tmp->tm_mday, - tmp->tm_year + 1900, - tmp->tm_hour, - tmp->tm_min, - tmp->tm_sec, - zonename); + switch (fmt) { + + case ABSOLUTE_TIME_DOY_UTC: + buf = ep_strdup_printf("%04d/%03d:%02d:%02d:%02d %s", + tmp->tm_year + 1900, + tmp->tm_yday, + tmp->tm_hour, + tmp->tm_min, + tmp->tm_sec, + zonename); + break; + + case ABSOLUTE_TIME_UTC: + case ABSOLUTE_TIME_LOCAL: + buf = ep_strdup_printf("%s %2d, %d %02d:%02d:%02d %s", + mon_names[tmp->tm_mon], + tmp->tm_mday, + tmp->tm_year + 1900, + tmp->tm_hour, + tmp->tm_min, + tmp->tm_sec, + zonename); + break; + } } else buf = ep_strdup("Not representable"); return buf; diff --git a/epan/to_str.h b/epan/to_str.h index 86e487b036..7f139f46c1 100644 --- a/epan/to_str.h +++ b/epan/to_str.h @@ -28,6 +28,7 @@ #include <glib.h> #include "nstime.h" +#include "time_fmt.h" #include <epan/packet_info.h> #define GUID_STR_LEN 37 @@ -35,18 +36,6 @@ #define MAX_ADDR_STR_LEN 256 /* - * Resolution of a time stamp. - */ -typedef enum { - TO_STR_TIME_RES_T_SECS, /* seconds */ - TO_STR_TIME_RES_T_DSECS, /* deciseconds */ - TO_STR_TIME_RES_T_CSECS, /* centiseconds */ - TO_STR_TIME_RES_T_MSECS, /* milliseconds */ - TO_STR_TIME_RES_T_USECS, /* microseconds */ - TO_STR_TIME_RES_T_NSECS /* nanoseconds */ -} to_str_time_res_t; - -/* * These are utility functions which convert various types to strings, * but for which no more specific module applies. */ @@ -73,8 +62,8 @@ extern gchar* vines_addr_to_str(const guint8 *addrp); extern gchar* time_secs_to_str(gint32); extern gchar* time_secs_to_str_unsigned(guint32); extern gchar* time_msecs_to_str(gint32); -extern gchar* abs_time_to_str(nstime_t*, gboolean); -extern gchar* abs_time_secs_to_str(time_t, gboolean); +extern gchar* abs_time_to_str(nstime_t*, absolute_time_display_e fmt); +extern gchar* abs_time_secs_to_str(time_t, absolute_time_display_e fmt); extern void display_signed_time(gchar *, int, gint32, gint32, to_str_time_res_t); extern void display_epoch_time(gchar *, int, time_t, gint32, to_str_time_res_t); diff --git a/epan/wslua/wslua_util.c b/epan/wslua/wslua_util.c index 8ab47cf300..5e52a9fa93 100644 --- a/epan/wslua/wslua_util.c +++ b/epan/wslua/wslua_util.c @@ -64,7 +64,7 @@ WSLUA_FUNCTION wslua_format_date(lua_State* LS) { /* Formats an absolute timesta then.secs = (guint32)floor(timestamp); then.nsecs = (guint32) ( (timestamp-(double)(then.secs))*1000000000); - str = abs_time_to_str(&then, FALSE); + str = abs_time_to_str(&then, ABSOLUTE_TIME_LOCAL); lua_pushstring(LS,str); WSLUA_RETURN(1); /* A string with the formated date */ |