diff options
author | Michael Mann <mmann78@netscape.net> | 2019-08-28 15:04:32 -0400 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2019-08-29 13:31:48 +0000 |
commit | 01d7793976cca50519c6609dc2a4ba391946f07b (patch) | |
tree | bbe7e8a2c863904dcac33459226b24882e7828f1 /epan | |
parent | 862e2acdd94ca38e9310f4ec9509a1108346f2bc (diff) |
Add proto_tree_add_item_ret_time_string
A few dissectors need the functionality of adding a time field to a proto_tree
while also needing the "time to string" value (typically to show on a tree above).
The functionality to do "get value from tvb and convert to string" was being done
in packet-ntp.c.
Instead proto_tree_add_item_ret_time_string can be used with various encoding to
get the necessary functionality with less code duplication.
ENC_TIME_MIP6 was added as a result of the refactoring.
ABSOLUTE_TIME_NTP_UTC was added as another potential "base" type for time fields.
Change-Id: Ie460c33370b0af59ef60bdab893ce9d6eb23b94f
Reviewed-on: https://code.wireshark.org/review/34390
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dissectors/asn1/m3ap/m3ap.cnf | 7 | ||||
-rw-r--r-- | epan/dissectors/asn1/m3ap/packet-m3ap-template.c | 3 | ||||
-rw-r--r-- | epan/dissectors/packet-diameter_3gpp.c | 7 | ||||
-rw-r--r-- | epan/dissectors/packet-gtpv2.c | 40 | ||||
-rw-r--r-- | epan/dissectors/packet-m3ap.c | 66 | ||||
-rw-r--r-- | epan/dissectors/packet-mip6.c | 7 | ||||
-rw-r--r-- | epan/dissectors/packet-ntp.c | 99 | ||||
-rw-r--r-- | epan/dissectors/packet-ntp.h | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-pfcp.c | 64 | ||||
-rw-r--r-- | epan/dissectors/packet-rtcp.c | 9 | ||||
-rw-r--r-- | epan/proto.c | 113 | ||||
-rw-r--r-- | epan/proto.h | 24 | ||||
-rw-r--r-- | epan/time_fmt.h | 3 | ||||
-rw-r--r-- | epan/to_str.c | 14 |
14 files changed, 236 insertions, 222 deletions
diff --git a/epan/dissectors/asn1/m3ap/m3ap.cnf b/epan/dissectors/asn1/m3ap/m3ap.cnf index aa26d0d38b..c1f1afc404 100644 --- a/epan/dissectors/asn1/m3ap/m3ap.cnf +++ b/epan/dissectors/asn1/m3ap/m3ap.cnf @@ -148,18 +148,13 @@ ProtocolIE-Field/value ie_field_value #.FN_BODY Absolute-Time-ofMBMS-Data VAL_PTR = ¶meter_tvb tvbuff_t *parameter_tvb=NULL; - const gchar *time_str; - gint tvb_len; %(DEFAULT_BODY)s if (!parameter_tvb) return offset; - tvb_len = tvb_reported_length(parameter_tvb); - - time_str = tvb_ntp_fmt_ts(parameter_tvb, 0); - proto_tree_add_string(tree, hf_m3ap_Absolute_Time_ofMBMS_Data_value, parameter_tvb, 0, tvb_len, time_str); + proto_tree_add_item(tree, hf_m3ap_Absolute_Time_ofMBMS_Data_value, parameter_tvb, 0, 8, ENC_TIME_NTP|ENC_BIG_ENDIAN); #.END #.TYPE_ATTR diff --git a/epan/dissectors/asn1/m3ap/packet-m3ap-template.c b/epan/dissectors/asn1/m3ap/packet-m3ap-template.c index f3661cc780..dd460d7d5d 100644 --- a/epan/dissectors/asn1/m3ap/packet-m3ap-template.c +++ b/epan/dissectors/asn1/m3ap/packet-m3ap-template.c @@ -23,7 +23,6 @@ #include "packet-per.h" #include "packet-e212.h" #include "packet-gtpv2.h" -#include "packet-ntp.h" #define PNAME "M3 Application Protocol" #define PSNAME "M3AP" @@ -135,7 +134,7 @@ void proto_register_m3ap(void) { static hf_register_info hf[] = { { &hf_m3ap_Absolute_Time_ofMBMS_Data_value, { "Absolute-Time-ofMBMS-Data-value", "m3ap.Absolute_Time_ofMBMS_Data_value", - FT_STRING, BASE_NONE, NULL, 0, + FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC, NULL, 0, NULL, HFILL } }, { &hf_m3ap_IPAddress_v4, diff --git a/epan/dissectors/packet-diameter_3gpp.c b/epan/dissectors/packet-diameter_3gpp.c index fd50f37c4a..f4c3621c37 100644 --- a/epan/dissectors/packet-diameter_3gpp.c +++ b/epan/dissectors/packet-diameter_3gpp.c @@ -26,7 +26,6 @@ #include "packet-gtpv2.h" #include "packet-e164.h" #include "packet-e212.h" -#include "packet-ntp.h" #include "packet-s1ap.h" #include "packet-sip.h" #include "packet-lcsap.h" @@ -1417,10 +1416,8 @@ static int dissect_diameter_3gpp_mbms_abs_time_ofmbms_data_tfer(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_) { int offset = 0; - const gchar *time_str; - time_str = tvb_ntp_fmt_ts(tvb, offset); - proto_tree_add_string(tree, hf_diameter_3gpp_mbms_abs_time_ofmbms_data_tfer, tvb, offset, 8, time_str); + proto_tree_add_item(tree, hf_diameter_3gpp_mbms_abs_time_ofmbms_data_tfer, tvb, offset, 8, ENC_TIME_NTP | ENC_BIG_ENDIAN); offset+=8; return offset; @@ -4675,7 +4672,7 @@ proto_register_diameter_3gpp(void) }, { &hf_diameter_3gpp_mbms_abs_time_ofmbms_data_tfer, { "Absolute Time of MBMS Data Transfer", "diameter.3gpp.mbms_abs_time_ofmbms_data_tfer", - FT_STRING, BASE_NONE, NULL, 0x0, + FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC, NULL, 0x0, NULL, HFILL } }, { &hf_diameter_3gpp_udp_port , diff --git a/epan/dissectors/packet-gtpv2.c b/epan/dissectors/packet-gtpv2.c index 0909805b41..c54123bfbe 100644 --- a/epan/dissectors/packet-gtpv2.c +++ b/epan/dissectors/packet-gtpv2.c @@ -6442,13 +6442,12 @@ dissect_gtpv2_apco(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, prot /* 8.95 Absolute Time of MBMS Data Transfer */ static void -dissect_gtpv2_abs_mbms_data_tf_time(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_, session_args_t * args _U_) +dissect_gtpv2_abs_mbms_data_tf_time(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length, guint8 message_type _U_, guint8 instance _U_, session_args_t * args _U_) { int offset = 0; - const gchar *time_str; + char *time_str; - time_str = tvb_ntp_fmt_ts(tvb, offset); - proto_tree_add_string(tree, hf_gtpv2_abs_time_mbms_data, tvb, offset, 8, time_str); + proto_tree_add_item_ret_time_string(tree, hf_gtpv2_abs_time_mbms_data, tvb, offset, 8, ENC_TIME_NTP | ENC_BIG_ENDIAN, wmem_packet_scope(), &time_str); proto_item_append_text(item, "%s", time_str); offset += 8; @@ -6657,14 +6656,13 @@ dissect_gtpv2_twan_identifier(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree static void dissect_gtpv2_uli_timestamp(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_, session_args_t * args _U_) { - const gchar *time_str; + char *time_str; /* Octets 5 to 8 are encoded in the same format as the first four octets of the 64-bit timestamp * format as defined in section 6 of IETF RFC 5905 */ - time_str = tvb_ntp_fmt_ts_sec(tvb, 0); - proto_tree_add_string(tree, hf_gtpv2_uli_timestamp, tvb, 0, 4, time_str); + proto_tree_add_item_ret_time_string(tree, hf_gtpv2_uli_timestamp, tvb, 0, 4, ENC_TIME_NTP|ENC_BIG_ENDIAN, wmem_packet_scope(), &time_str); proto_item_append_text(item, "%s", time_str); } @@ -7060,15 +7058,14 @@ dissect_gtpv2_pres_rep_area_information(tvbuff_t *tvb, packet_info *pinfo _U_, p static void dissect_gtpv2_twan_identifier_timestamp(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_, session_args_t * args _U_) { - const gchar *time_str; + char *time_str; /* TWAN Identifier Timestamp value */ /* Octets 5 to 8 are encoded in the same format as the first four octets of the 64-bit timestamp * format as defined in section 6 of IETF RFC 5905 */ - time_str = tvb_ntp_fmt_ts_sec(tvb, 0); - proto_tree_add_string(tree, hf_gtpv2_twan_id_ts, tvb, 0, 4, time_str); + proto_tree_add_item_ret_time_string(tree, hf_gtpv2_twan_id_ts, tvb, 0, 4, ENC_TIME_NTP | ENC_BIG_ENDIAN, wmem_packet_scope(), &time_str); proto_item_append_text(item, "%s", time_str); } @@ -7354,7 +7351,6 @@ dissect_gtpv2_serv_plmn_rate_control(tvbuff_t *tvb, packet_info *pinfo _U_, prot static void dissect_gtpv2_counter(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_, session_args_t * args _U_) { - const gchar *time_str; int offset = 0; /* Timestamp value */ @@ -7362,8 +7358,7 @@ dissect_gtpv2_counter(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, p *format as defined in section 6 of IETF RFC 5905 */ - time_str = tvb_ntp_fmt_ts_sec(tvb, 0); - proto_tree_add_string(tree, hf_gtpv2_timestamp_value, tvb, offset, 4, time_str); + proto_tree_add_item(tree, hf_gtpv2_timestamp_value, tvb, offset, 4, ENC_TIME_NTP | ENC_BIG_ENDIAN); offset += 4; proto_tree_add_item(tree, hf_gtpv2_counter_value, tvb, offset, 1, ENC_BIG_ENDIAN); } @@ -7394,7 +7389,6 @@ static void dissect_gtpv2_secondary_rat_usage_data_report(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_, session_args_t * args _U_) { int offset = 0; - const gchar *time_str; static const int *secondary_rat_usage_data_report_flags[] = { &hf_gtpv2_secondary_rat_usage_data_report_spare_bits, &hf_gtpv2_secondary_rat_usage_data_report_bit2, @@ -7429,13 +7423,11 @@ dissect_gtpv2_secondary_rat_usage_data_report(tvbuff_t *tvb, packet_info *pinfo, */ /* Octets 8 to 11 Start timestamp */ - time_str = tvb_ntp_fmt_ts_sec(tvb, offset); - proto_tree_add_string(tree, hf_gtpv2_secondary_rat_usage_data_report_start_timestamp, tvb, offset, 4, time_str); + proto_tree_add_item(tree, hf_gtpv2_secondary_rat_usage_data_report_start_timestamp, tvb, offset, 4, ENC_TIME_NTP | ENC_BIG_ENDIAN); offset += 4; /* Octets 12 to 15 End timestamp */ - time_str = tvb_ntp_fmt_ts_sec(tvb, offset); - proto_tree_add_string(tree, hf_gtpv2_secondary_rat_usage_data_report_end_timestamp, tvb, offset, 4, time_str); + proto_tree_add_item(tree, hf_gtpv2_secondary_rat_usage_data_report_end_timestamp, tvb, offset, 4, ENC_TIME_NTP | ENC_BIG_ENDIAN); offset += 4; /* 16 to 23 Usage Data DL */ @@ -10445,12 +10437,12 @@ void proto_register_gtpv2(void) }, { &hf_gtpv2_uli_timestamp, { "ULI Timestamp", "gtpv2.uli_timestamp", - FT_STRING, BASE_NONE, NULL, 0, + FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC, NULL, 0, NULL, HFILL } }, { &hf_gtpv2_abs_time_mbms_data, { "Absolute Time of MBMS Data Transfer", "gtpv2.abs_time_mbms_data", - FT_STRING, BASE_NONE, NULL, 0, + FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC, NULL, 0, NULL, HFILL } }, { &hf_gtpv2_mbms_session_duration_days, @@ -10766,7 +10758,7 @@ void proto_register_gtpv2(void) { &hf_gtpv2_fq_csid_node_id, { "Node-ID", "gtpv2.fq_csid_node_id", FT_UINT32, BASE_DEC, NULL, 0x00000FFF, NULL, HFILL }}, { &hf_gtpv2_fq_csid_mcc_mnc, { "MCC+MNC", "gtpv2.fq_csid_mcc_mnc", FT_UINT32, BASE_DEC, NULL, 0xFFFFF000, NULL, HFILL }}, - { &hf_gtpv2_twan_id_ts, { "TWAN Identifier Timestamp", "gtpv2.twan.id_ts", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } }, + { &hf_gtpv2_twan_id_ts, { "TWAN Identifier Timestamp", "gtpv2.twan.id_ts", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC, NULL, 0, NULL, HFILL } }, { &hf_gtpv2_twan_flags,{ "Flags", "gtpv2.twan_id.flags", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } }, { &hf_gtpv2_twan_bssidi,{ "BSSIDI", "gtpv2.twan_id.bssidi", FT_BOOLEAN, 8, TFS(&tfs_present_not_present), 0x01, NULL, HFILL } }, { &hf_gtpv2_twan_civai,{ "CIVAI", "gtpv2.twan_id.civai", FT_BOOLEAN, 8, TFS(&tfs_present_not_present), 0x02, NULL, HFILL } }, @@ -10912,7 +10904,7 @@ void proto_register_gtpv2(void) }, { &hf_gtpv2_timestamp_value, { "Timestamp value", "gtpv2.timestamp_value", - FT_STRING, BASE_NONE, NULL, 0x0, + FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC, NULL, 0x0, NULL, HFILL } }, { &hf_gtpv2_counter_value, @@ -10957,12 +10949,12 @@ void proto_register_gtpv2(void) }, { &hf_gtpv2_secondary_rat_usage_data_report_start_timestamp, { "Start timestamp", "gtpv2.secondary_rat_usage_data_report.start_timestamp", - FT_STRING, BASE_NONE, NULL, 0x0, + FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC, NULL, 0x0, NULL, HFILL } }, { &hf_gtpv2_secondary_rat_usage_data_report_end_timestamp, { "End timestamp", "gtpv2.secondary_rat_usage_data_report.end_timestamp", - FT_STRING, BASE_NONE, NULL, 0x0, + FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC, NULL, 0x0, NULL, HFILL } }, { &hf_gtpv2_secondary_rat_usage_data_report_usage_data_dl, diff --git a/epan/dissectors/packet-m3ap.c b/epan/dissectors/packet-m3ap.c index 687e2d29bf..3afb0fe1de 100644 --- a/epan/dissectors/packet-m3ap.c +++ b/epan/dissectors/packet-m3ap.c @@ -31,7 +31,6 @@ #include "packet-per.h" #include "packet-e212.h" #include "packet-gtpv2.h" -#include "packet-ntp.h" #define PNAME "M3 Application Protocol" #define PSNAME "M3AP" @@ -96,7 +95,7 @@ typedef enum _ProtocolIE_ID_enum { } ProtocolIE_ID_enum; /*--- End of included file: packet-m3ap-val.h ---*/ -#line 40 "./asn1/m3ap/packet-m3ap-template.c" +#line 39 "./asn1/m3ap/packet-m3ap-template.c" /* Initialize the protocol and registered fields */ static int proto_m3ap = -1; @@ -209,7 +208,7 @@ static int hf_m3ap_successfulOutcome_value = -1; /* SuccessfulOutcome_value */ static int hf_m3ap_unsuccessfulOutcome_value = -1; /* UnsuccessfulOutcome_value */ /*--- End of included file: packet-m3ap-hf.c ---*/ -#line 49 "./asn1/m3ap/packet-m3ap-template.c" +#line 48 "./asn1/m3ap/packet-m3ap-template.c" /* Initialize the subtree pointers */ static int ett_m3ap = -1; @@ -265,7 +264,7 @@ static gint ett_m3ap_SuccessfulOutcome = -1; static gint ett_m3ap_UnsuccessfulOutcome = -1; /*--- End of included file: packet-m3ap-ett.c ---*/ -#line 54 "./asn1/m3ap/packet-m3ap-template.c" +#line 53 "./asn1/m3ap/packet-m3ap-template.c" static expert_field ei_m3ap_invalid_ip_address_len = EI_INIT; @@ -576,8 +575,6 @@ static int dissect_m3ap_Absolute_Time_ofMBMS_Data(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { #line 150 "./asn1/m3ap/m3ap.cnf" tvbuff_t *parameter_tvb=NULL; - const gchar *time_str; - gint tvb_len; offset = dissect_per_bit_string(tvb, offset, actx, tree, hf_index, 64, 64, FALSE, NULL, 0, ¶meter_tvb, NULL); @@ -586,10 +583,7 @@ dissect_m3ap_Absolute_Time_ofMBMS_Data(tvbuff_t *tvb _U_, int offset _U_, asn1_c if (!parameter_tvb) return offset; - tvb_len = tvb_reported_length(parameter_tvb); - - time_str = tvb_ntp_fmt_ts(parameter_tvb, 0); - proto_tree_add_string(tree, hf_m3ap_Absolute_Time_ofMBMS_Data_value, parameter_tvb, 0, tvb_len, time_str); + proto_tree_add_item(tree, hf_m3ap_Absolute_Time_ofMBMS_Data_value, parameter_tvb, 0, 8, ENC_TIME_NTP|ENC_BIG_ENDIAN); return offset; @@ -1090,7 +1084,7 @@ dissect_m3ap_MBMSServiceArea1(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *act static int dissect_m3ap_MBMS_Service_Area(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 169 "./asn1/m3ap/m3ap.cnf" +#line 164 "./asn1/m3ap/m3ap.cnf" tvbuff_t *parameter_tvb=NULL; guint16 tvb_len; @@ -1113,7 +1107,7 @@ dissect_m3ap_MBMS_Service_Area(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *ac static int dissect_m3ap_MBMS_Session_Duration(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 183 "./asn1/m3ap/m3ap.cnf" +#line 178 "./asn1/m3ap/m3ap.cnf" tvbuff_t *parameter_tvb=NULL; guint16 tvb_len; @@ -1156,7 +1150,7 @@ dissect_m3ap_MCEname(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, pr static int dissect_m3ap_MinimumTimeToMBMSDataTransfer(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 199 "./asn1/m3ap/m3ap.cnf" +#line 194 "./asn1/m3ap/m3ap.cnf" tvbuff_t *parameter_tvb=NULL; guint16 tvb_len; @@ -1260,7 +1254,7 @@ static const per_sequence_t MBMSSessionStartRequest_sequence[] = { static int dissect_m3ap_MBMSSessionStartRequest(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 213 "./asn1/m3ap/m3ap.cnf" +#line 208 "./asn1/m3ap/m3ap.cnf" col_set_str(actx->pinfo->cinfo, COL_INFO,"MBMS Session Start Request "); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, @@ -1277,7 +1271,7 @@ static const per_sequence_t MBMSSessionStartResponse_sequence[] = { static int dissect_m3ap_MBMSSessionStartResponse(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 215 "./asn1/m3ap/m3ap.cnf" +#line 210 "./asn1/m3ap/m3ap.cnf" col_set_str(actx->pinfo->cinfo, COL_INFO,"MBMS Session Start Response "); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, @@ -1294,7 +1288,7 @@ static const per_sequence_t MBMSSessionStartFailure_sequence[] = { static int dissect_m3ap_MBMSSessionStartFailure(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 217 "./asn1/m3ap/m3ap.cnf" +#line 212 "./asn1/m3ap/m3ap.cnf" col_set_str(actx->pinfo->cinfo, COL_INFO,"MBMS Session Start Failure "); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, @@ -1311,7 +1305,7 @@ static const per_sequence_t MBMSSessionStopRequest_sequence[] = { static int dissect_m3ap_MBMSSessionStopRequest(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 219 "./asn1/m3ap/m3ap.cnf" +#line 214 "./asn1/m3ap/m3ap.cnf" col_set_str(actx->pinfo->cinfo, COL_INFO,"MBMS Session Stop Request "); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, @@ -1328,7 +1322,7 @@ static const per_sequence_t MBMSSessionStopResponse_sequence[] = { static int dissect_m3ap_MBMSSessionStopResponse(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 221 "./asn1/m3ap/m3ap.cnf" +#line 216 "./asn1/m3ap/m3ap.cnf" col_set_str(actx->pinfo->cinfo, COL_INFO,"MBMS Session Stop Response "); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, @@ -1345,7 +1339,7 @@ static const per_sequence_t MBMSSessionUpdateRequest_sequence[] = { static int dissect_m3ap_MBMSSessionUpdateRequest(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 223 "./asn1/m3ap/m3ap.cnf" +#line 218 "./asn1/m3ap/m3ap.cnf" col_set_str(actx->pinfo->cinfo, COL_INFO,"MBMS Session Update Request "); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, @@ -1362,7 +1356,7 @@ static const per_sequence_t MBMSSessionUpdateResponse_sequence[] = { static int dissect_m3ap_MBMSSessionUpdateResponse(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 225 "./asn1/m3ap/m3ap.cnf" +#line 220 "./asn1/m3ap/m3ap.cnf" col_set_str(actx->pinfo->cinfo, COL_INFO,"MBMS Session Update Response "); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, @@ -1379,7 +1373,7 @@ static const per_sequence_t MBMSSessionUpdateFailure_sequence[] = { static int dissect_m3ap_MBMSSessionUpdateFailure(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 227 "./asn1/m3ap/m3ap.cnf" +#line 222 "./asn1/m3ap/m3ap.cnf" col_set_str(actx->pinfo->cinfo, COL_INFO,"MBMS Session Update Failure "); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, @@ -1396,7 +1390,7 @@ static const per_sequence_t ErrorIndication_sequence[] = { static int dissect_m3ap_ErrorIndication(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 229 "./asn1/m3ap/m3ap.cnf" +#line 224 "./asn1/m3ap/m3ap.cnf" col_set_str(actx->pinfo->cinfo, COL_INFO,"Error Indication "); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, @@ -1413,7 +1407,7 @@ static const per_sequence_t Reset_sequence[] = { static int dissect_m3ap_Reset(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 231 "./asn1/m3ap/m3ap.cnf" +#line 226 "./asn1/m3ap/m3ap.cnf" col_set_str(actx->pinfo->cinfo, COL_INFO,"Reset "); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, @@ -1481,7 +1475,7 @@ static const per_sequence_t ResetAcknowledge_sequence[] = { static int dissect_m3ap_ResetAcknowledge(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 233 "./asn1/m3ap/m3ap.cnf" +#line 228 "./asn1/m3ap/m3ap.cnf" col_set_str(actx->pinfo->cinfo, COL_INFO,"Reset Acknowledge "); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, @@ -1512,7 +1506,7 @@ static const per_sequence_t PrivateMessage_sequence[] = { static int dissect_m3ap_PrivateMessage(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 235 "./asn1/m3ap/m3ap.cnf" +#line 230 "./asn1/m3ap/m3ap.cnf" col_set_str(actx->pinfo->cinfo, COL_INFO,"Private Message "); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, @@ -1529,7 +1523,7 @@ static const per_sequence_t M3SetupRequest_sequence[] = { static int dissect_m3ap_M3SetupRequest(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 243 "./asn1/m3ap/m3ap.cnf" +#line 238 "./asn1/m3ap/m3ap.cnf" col_set_str(actx->pinfo->cinfo, COL_INFO,"M3 Setup Request "); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, @@ -1560,7 +1554,7 @@ static const per_sequence_t M3SetupResponse_sequence[] = { static int dissect_m3ap_M3SetupResponse(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 245 "./asn1/m3ap/m3ap.cnf" +#line 240 "./asn1/m3ap/m3ap.cnf" col_set_str(actx->pinfo->cinfo, COL_INFO,"M3 Setup Response "); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, @@ -1577,7 +1571,7 @@ static const per_sequence_t M3SetupFailure_sequence[] = { static int dissect_m3ap_M3SetupFailure(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 247 "./asn1/m3ap/m3ap.cnf" +#line 242 "./asn1/m3ap/m3ap.cnf" col_set_str(actx->pinfo->cinfo, COL_INFO,"M3 Setup Failure "); @@ -1596,7 +1590,7 @@ static const per_sequence_t MCEConfigurationUpdate_sequence[] = { static int dissect_m3ap_MCEConfigurationUpdate(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 237 "./asn1/m3ap/m3ap.cnf" +#line 232 "./asn1/m3ap/m3ap.cnf" col_set_str(actx->pinfo->cinfo, COL_INFO,"MCE Configuration Update "); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, @@ -1613,7 +1607,7 @@ static const per_sequence_t MCEConfigurationUpdateAcknowledge_sequence[] = { static int dissect_m3ap_MCEConfigurationUpdateAcknowledge(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 239 "./asn1/m3ap/m3ap.cnf" +#line 234 "./asn1/m3ap/m3ap.cnf" col_set_str(actx->pinfo->cinfo, COL_INFO,"MCE Configuration Update Acknowledge "); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, @@ -1630,7 +1624,7 @@ static const per_sequence_t MCEConfigurationUpdateFailure_sequence[] = { static int dissect_m3ap_MCEConfigurationUpdateFailure(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 241 "./asn1/m3ap/m3ap.cnf" +#line 236 "./asn1/m3ap/m3ap.cnf" col_set_str(actx->pinfo->cinfo, COL_INFO,"MCE Configuration Update Failure "); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, @@ -2087,7 +2081,7 @@ static int dissect_M3AP_PDU_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto /*--- End of included file: packet-m3ap-fn.c ---*/ -#line 84 "./asn1/m3ap/packet-m3ap-template.c" +#line 83 "./asn1/m3ap/packet-m3ap-template.c" static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { @@ -2142,7 +2136,7 @@ void proto_register_m3ap(void) { static hf_register_info hf[] = { { &hf_m3ap_Absolute_Time_ofMBMS_Data_value, { "Absolute-Time-ofMBMS-Data-value", "m3ap.Absolute_Time_ofMBMS_Data_value", - FT_STRING, BASE_NONE, NULL, 0, + FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC, NULL, 0, NULL, HFILL } }, { &hf_m3ap_IPAddress_v4, @@ -2557,7 +2551,7 @@ void proto_register_m3ap(void) { "UnsuccessfulOutcome_value", HFILL }}, /*--- End of included file: packet-m3ap-hfarr.c ---*/ -#line 153 "./asn1/m3ap/packet-m3ap-template.c" +#line 152 "./asn1/m3ap/packet-m3ap-template.c" }; /* List of subtrees */ @@ -2615,7 +2609,7 @@ void proto_register_m3ap(void) { &ett_m3ap_UnsuccessfulOutcome, /*--- End of included file: packet-m3ap-ettarr.c ---*/ -#line 160 "./asn1/m3ap/packet-m3ap-template.c" +#line 159 "./asn1/m3ap/packet-m3ap-template.c" }; expert_module_t* expert_m3ap; @@ -2701,7 +2695,7 @@ proto_reg_handoff_m3ap(void) /*--- End of included file: packet-m3ap-dis-tab.c ---*/ -#line 198 "./asn1/m3ap/packet-m3ap-template.c" +#line 197 "./asn1/m3ap/packet-m3ap-template.c" dissector_add_uint("m3ap.extension", 17, create_dissector_handle(dissect_AllocationAndRetentionPriority_PDU, proto_m3ap)); } else { diff --git a/epan/dissectors/packet-mip6.c b/epan/dissectors/packet-mip6.c index c0fdf99f61..55df45d015 100644 --- a/epan/dissectors/packet-mip6.c +++ b/epan/dissectors/packet-mip6.c @@ -2747,12 +2747,11 @@ dissect_pmip6_opt_ts(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void * proto_item* ti; int option_len = tvb_reported_length(tvb)-2; int offset = 2; - const gchar *str; + char *str; opt_tree = mip6_fixed_option_header(tree, pinfo, tvb, proto_mip6_option_ts, ett_pmip6_opt_ts, &ti, option_len, PMIP6_TS_LEN); - str = tvb_mip6_fmt_ts(tvb,offset); - proto_tree_add_string(opt_tree, hf_pmip6_timestamp, tvb, offset, 8, str); + proto_tree_add_item_ret_time_string(opt_tree, hf_pmip6_timestamp, tvb, offset, 8, ENC_TIME_MIP6|ENC_BIG_ENDIAN, wmem_packet_scope(), &str); proto_item_append_text(ti, ": %s", str); return tvb_captured_length(tvb); @@ -4519,7 +4518,7 @@ proto_register_mip6(void) }, { &hf_pmip6_timestamp, { "Timestamp", "mip6.timestamp_tmp", - FT_STRING, BASE_NONE, NULL, 0, + FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0, NULL, HFILL } }, { &hf_pmip6_opt_lila_lla, diff --git a/epan/dissectors/packet-ntp.c b/epan/dissectors/packet-ntp.c index 57b6033d64..68762e50e3 100644 --- a/epan/dissectors/packet-ntp.c +++ b/epan/dissectors/packet-ntp.c @@ -1016,95 +1016,6 @@ static tvbparse_wanted_t *want_ignore; #define NTP_FLOAT_DENOM 4294967296.0 #define NTP_TS_SIZE 100 -/* Modified tvb_ntp_fmt_ts - * tvb_mip6_fmt_ts - converts MIP6 timestamp to human readable string. - * Timestamp - * - * A 64-bit unsigned integer field containing a timestamp. The - * value indicates the number of seconds since January 1, 1970, - * 00:00 UTC, by using a fixed point format. In this format, the - * integer number of seconds is contained in the first 48 bits of - * the field, and the remaining 16 bits indicate the number of - * 1/65536 fractions of a second. - * - * TVB and an offset (IN). - * returns pointer to filled buffer. This buffer will be freed automatically once - * dissection of the next packet occurs. - */ -const char * -tvb_mip6_fmt_ts(tvbuff_t *tvb, gint offset) -{ - guint64 tempstmp; - guint32 tempfrac; - time_t temptime; - struct tm *bd; - double fractime; - - tempstmp = tvb_get_ntoh48(tvb, offset); - tempfrac = tvb_get_ntohs(tvb, offset+6); - tempfrac <<= 16; - if ((tempstmp == 0) && (tempfrac == 0)) { - return "NULL"; - } - - temptime = (time_t)(tempstmp /*- NTP_BASETIME*/); - bd = gmtime(&temptime); - if(!bd){ - return "Not representable"; - } - - fractime = bd->tm_sec + tempfrac / NTP_FLOAT_DENOM; - return wmem_strdup_printf(wmem_packet_scope(), "%s %2d, %d %02d:%02d:%07.4f UTC", - mon_names[bd->tm_mon], - bd->tm_mday, - bd->tm_year + 1900, - bd->tm_hour, - bd->tm_min, - fractime); -} -/* tvb_ntp_fmt_ts - converts NTP timestamp to human readable string. - * TVB and an offset (IN). - * returns pointer to filled buffer. This buffer will be freed automatically once - * dissection of the next packet occurs. - */ -const char * -tvb_ntp_fmt_ts(tvbuff_t *tvb, gint offset) -{ - guint32 tempstmp, tempfrac; - time_t temptime; - struct tm *bd; - double fractime; - char *buff; - - tempstmp = tvb_get_ntohl(tvb, offset); - tempfrac = tvb_get_ntohl(tvb, offset+4); - if ((tempstmp == 0) && (tempfrac == 0)) { - return "NULL"; - } - - /* We need a temporary variable here so the unsigned math - * works correctly (for years > 2036 according to RFC 2030 - * chapter 3). - */ - temptime = (time_t)(tempstmp - NTP_BASETIME); - bd = gmtime(&temptime); - if(!bd){ - return "Not representable"; - } - - fractime = bd->tm_sec + tempfrac / NTP_FLOAT_DENOM; - buff=(char *)wmem_alloc(wmem_packet_scope(), NTP_TS_SIZE); - g_snprintf(buff, NTP_TS_SIZE, - "%s %2d, %d %02d:%02d:%09.6f UTC", - mon_names[bd->tm_mon], - bd->tm_mday, - bd->tm_year + 1900, - bd->tm_hour, - bd->tm_min, - fractime); - return buff; -} - /* tvb_ntp_fmt_ts_sec - converts an NTP timestamps second part (32bits) to an human readable string. * TVB and an offset (IN). * returns pointer to filled buffer. This buffer will be freed automatically once @@ -2753,16 +2664,16 @@ proto_register_ntp(void) "Reference ID", "ntp.refid", FT_BYTES, BASE_NONE, NULL, 0, "Particular server or reference clock being used", HFILL }}, { &hf_ntp_reftime, { - "Reference Timestamp", "ntp.reftime", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, + "Reference Timestamp", "ntp.reftime", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC, NULL, 0, "Time when the system clock was last set or corrected", HFILL }}, { &hf_ntp_org, { - "Origin Timestamp", "ntp.org", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, + "Origin Timestamp", "ntp.org", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC, NULL, 0, "Time at the client when the request departed for the server", HFILL }}, { &hf_ntp_rec, { - "Receive Timestamp", "ntp.rec", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, + "Receive Timestamp", "ntp.rec", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC, NULL, 0, "Time at the server when the request arrived from the client", HFILL }}, { &hf_ntp_xmt, { - "Transmit Timestamp", "ntp.xmt", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, + "Transmit Timestamp", "ntp.xmt", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC, NULL, 0, "Time at the server when the response left for the client", HFILL }}, { &hf_ntp_keyid, { "Key ID", "ntp.keyid", FT_BYTES, BASE_NONE, @@ -3011,7 +2922,7 @@ proto_register_ntp(void) "ipv6 local addr", "ntp.priv.monlist.daddr6", FT_IPv6, BASE_NONE, NULL, 0, NULL, HFILL }}, { &hf_ntppriv_tstamp, { - "Authentication timestamp", "ntp.priv.tstamp", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, + "Authentication timestamp", "ntp.priv.tstamp", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC, NULL, 0, NULL, HFILL }}, { &hf_ntppriv_mode7_addr, { "Address", "ntp.priv.mode7.address", FT_IPv4, BASE_NONE, diff --git a/epan/dissectors/packet-ntp.h b/epan/dissectors/packet-ntp.h index 389b5f57d0..12879190ae 100644 --- a/epan/dissectors/packet-ntp.h +++ b/epan/dissectors/packet-ntp.h @@ -11,9 +11,7 @@ #ifndef PACKET_NTP_H #define PACKET_NTP_H -extern const char *tvb_ntp_fmt_ts(tvbuff_t *tvb, gint offset); extern const char *tvb_ntp_fmt_ts_sec(tvbuff_t *tvb, gint offset); -extern const char *tvb_mip6_fmt_ts(tvbuff_t *tvb, gint offset); extern void ntp_to_nstime(tvbuff_t *tvb, gint offset, nstime_t *nstime); #endif diff --git a/epan/dissectors/packet-pfcp.c b/epan/dissectors/packet-pfcp.c index ef07d31fae..3e6e88abef 100644 --- a/epan/dissectors/packet-pfcp.c +++ b/epan/dissectors/packet-pfcp.c @@ -22,7 +22,6 @@ #include <epan/addr_resolv.h> /* Needed for BASE_ENTERPRISES */ #include "packet-e164.h" #include "packet-e212.h" -#include "packet-ntp.h" void proto_register_pfcp(void); void proto_reg_handoff_pfcp(void); @@ -1921,15 +1920,14 @@ dissect_pfcp_time_threshold(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, static void dissect_pfcp_monitoring_time(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 length, guint8 message_type _U_, pfcp_session_args_t *args _U_) { - const gchar *time_str; + char *time_str; int offset = 0; /* The Monitoring Time field shall indicate the monitoring time in UTC time. * Octets 5 to 8 shall be encoded in the same format as the first four octets * of the 64-bit timestamp format as defined in section 6 of IETF RFC 5905. */ - time_str = tvb_ntp_fmt_ts_sec(tvb, 0); - proto_tree_add_string(tree, hf_pfcp_monitoring_time, tvb, offset, 4, time_str); + proto_tree_add_item_ret_time_string(tree, hf_pfcp_monitoring_time, tvb, offset, 4, ENC_TIME_NTP | ENC_BIG_ENDIAN, wmem_packet_scope(), &time_str); proto_item_append_text(item, "%s", time_str); offset += 4; @@ -3171,14 +3169,13 @@ static void dissect_pfcp_time_of_first_packet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 length, guint8 message_type _U_, pfcp_session_args_t *args _U_) { int offset = 0; - const gchar *time_str; + char *time_str; /* Octets 5 to 8 shall be encoded in the same format as the first four octets of the 64-bit timestamp * format as defined in section 6 of IETF RFC 5905 */ - time_str = tvb_ntp_fmt_ts_sec(tvb, 0); - proto_tree_add_string(tree, hf_pfcp_time_of_first_packet, tvb, offset, 4, time_str); + proto_tree_add_item_ret_time_string(tree, hf_pfcp_time_of_first_packet, tvb, offset, 4, ENC_TIME_NTP | ENC_BIG_ENDIAN, wmem_packet_scope(), &time_str); proto_item_append_text(item, "%s", time_str); offset += 4; @@ -3193,14 +3190,13 @@ static void dissect_pfcp_time_of_last_packet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 length, guint8 message_type _U_, pfcp_session_args_t *args _U_) { int offset = 0; - const gchar *time_str; + char *time_str; /* Octets 5 to 8 shall be encoded in the same format as the first four octets of the 64-bit timestamp * format as defined in section 6 of IETF RFC 5905 */ - time_str = tvb_ntp_fmt_ts_sec(tvb, 0); - proto_tree_add_string(tree, hf_pfcp_time_of_last_packet, tvb, offset, 4, time_str); + proto_tree_add_item_ret_time_string(tree, hf_pfcp_time_of_last_packet, tvb, offset, 4, ENC_TIME_NTP | ENC_BIG_ENDIAN, wmem_packet_scope(), &time_str); proto_item_append_text(item, "%s", time_str); offset += 4; @@ -3346,14 +3342,13 @@ dissect_pfcp_time_quota(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, pro static void dissect_pfcp_start_time(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 length, guint8 message_type _U_, pfcp_session_args_t *args _U_) { - const gchar *time_str; + char *time_str; int offset = 0; /* The Start Time field shall contain a UTC time. Octets 5 to 8 are encoded in the same format as * the first four octets of the 64-bit timestamp format as defined in section 6 of IETF RFC 5905 [26]. */ - time_str = tvb_ntp_fmt_ts_sec(tvb, 0); - proto_tree_add_string(tree, hf_pfcp_start_time, tvb, offset, 4, time_str); + proto_tree_add_item_ret_time_string(tree, hf_pfcp_start_time, tvb, offset, 4, ENC_TIME_NTP | ENC_BIG_ENDIAN, wmem_packet_scope(), &time_str); proto_item_append_text(item, "%s", time_str); offset += 4; @@ -3368,14 +3363,13 @@ dissect_pfcp_start_time(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, pro static void dissect_pfcp_end_time(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 length, guint8 message_type _U_, pfcp_session_args_t *args _U_) { - const gchar *time_str; + char *time_str; int offset = 0; /* The End Time field shall contain a UTC time. Octets 5 to 8 are encoded in the same format as * the first four octets of the 64-bit timestamp format as defined in section 6 of IETF RFC 5905 [26]. */ - time_str = tvb_ntp_fmt_ts_sec(tvb, 0); - proto_tree_add_string(tree, hf_pfcp_end_time, tvb, offset, 4, time_str); + proto_tree_add_item_ret_time_string(tree, hf_pfcp_end_time, tvb, offset, 4, ENC_TIME_NTP | ENC_BIG_ENDIAN, wmem_packet_scope(), &time_str); proto_item_append_text(item, "%s", time_str); offset += 4; @@ -3825,14 +3819,13 @@ dissect_pfcp_outer_hdr_rem(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tr static void dissect_pfcp_recovery_time_stamp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 length, guint8 message_type _U_, pfcp_session_args_t *args _U_) { - const gchar *time_str; + char *time_str; int offset = 0; /* indicates the UTC time when the node started. Octets 5 to 8 are encoded in the same format as * the first four octets of the 64-bit timestamp format as defined in section 6 of IETF RFC 5905 [26]. */ - time_str = tvb_ntp_fmt_ts_sec(tvb, 0); - proto_tree_add_string(tree, hf_pfcp_recovery_time_stamp, tvb, offset, 4, time_str); + proto_tree_add_item_ret_time_string(tree, hf_pfcp_recovery_time_stamp, tvb, offset, 4, ENC_TIME_NTP | ENC_BIG_ENDIAN, wmem_packet_scope(), &time_str); proto_item_append_text(item, "%s", time_str); offset += 4; @@ -5240,15 +5233,14 @@ dissect_pfcp_event_threshold(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree * static void dissect_pfcp_event_time_stamp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 length, guint8 message_type _U_, pfcp_session_args_t *args _U_) { - const gchar *time_str; + char *time_str; int offset = 0; /* The Event Time Stamp field shall contain a UTC time. * Octets 5 to 8 shall be encoded in the same format as the first four octets * of the 64-bit timestamp format as defined in section 6 of IETF RFC 5905. */ - time_str = tvb_ntp_fmt_ts_sec(tvb, 0); - proto_tree_add_string(tree, hf_pfcp_event_time_stamp, tvb, offset, 4, time_str); + proto_tree_add_item_ret_time_string(tree, hf_pfcp_event_time_stamp, tvb, offset, 4, ENC_TIME_NTP | ENC_BIG_ENDIAN, wmem_packet_scope(), &time_str); proto_item_append_text(item, "%s", time_str); offset += 4; @@ -5420,14 +5412,13 @@ static void dissect_pfcp_activation_time(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 length, guint8 message_type _U_, pfcp_session_args_t *args _U_) { int offset = 0; - const gchar *time_str; + char *time_str; /* Octets 5 to 8 shall be encoded in the same format as the first four octets of the 64-bit timestamp * format as defined in section 6 of IETF RFC 5905 */ - time_str = tvb_ntp_fmt_ts_sec(tvb, 0); - proto_tree_add_string(tree, hf_pfcp_activation_time, tvb, offset, 4, time_str); + proto_tree_add_item_ret_time_string(tree, hf_pfcp_activation_time, tvb, offset, 4, ENC_TIME_NTP | ENC_BIG_ENDIAN, wmem_packet_scope(), &time_str); proto_item_append_text(item, "%s", time_str); offset += 4; @@ -5443,14 +5434,13 @@ static void dissect_pfcp_deactivation_time(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 length, guint8 message_type _U_, pfcp_session_args_t *args _U_) { int offset = 0; - const gchar *time_str; + char *time_str; /* Octets 5 to 8 shall be encoded in the same format as the first four octets of the 64-bit timestamp * format as defined in section 6 of IETF RFC 5905 */ - time_str = tvb_ntp_fmt_ts_sec(tvb, 0); - proto_tree_add_string(tree, hf_pfcp_deactivation_time, tvb, offset, 4, time_str); + proto_tree_add_item_ret_time_string(tree, hf_pfcp_deactivation_time, tvb, offset, 4, ENC_TIME_NTP | ENC_BIG_ENDIAN, wmem_packet_scope(), &time_str); proto_item_append_text(item, "%s", time_str); offset += 4; @@ -6784,7 +6774,7 @@ proto_register_pfcp(void) }, { &hf_pfcp_recovery_time_stamp, { "Recovery Time Stamp", "pfcp.recovery_time_stamp", - FT_STRING, BASE_NONE, NULL, 0, + FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC, NULL, 0, NULL, HFILL } }, { &hf_pfcp2_cause, @@ -7190,12 +7180,12 @@ proto_register_pfcp(void) }, { &hf_pfcp_time_of_first_packet, { "Time of First Packet", "pfcp.time_of_first_packet", - FT_STRING, BASE_NONE, NULL, 0, + FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC, NULL, 0, NULL, HFILL } }, { &hf_pfcp_time_of_last_packet, { "Time of Last Packet", "pfcp.time_of_last_packet", - FT_STRING, BASE_NONE, NULL, 0, + FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC, NULL, 0, NULL, HFILL } }, { &hf_pfcp_dst_interface, @@ -7305,7 +7295,7 @@ proto_register_pfcp(void) }, { &hf_pfcp_monitoring_time, { "Monitoring Time", "pfcp.monitoring_time", - FT_STRING, BASE_NONE, NULL, 0, + FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC, NULL, 0, NULL, HFILL } }, { &hf_pfcp_reporting_triggers_o5_b0_perio, @@ -7577,12 +7567,12 @@ proto_register_pfcp(void) }, { &hf_pfcp_start_time, { "Start Time", "pfcp.start_time", - FT_STRING, BASE_NONE, NULL, 0, + FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC, NULL, 0, NULL, HFILL } }, { &hf_pfcp_end_time, { "End Time", "pfcp.start_time", - FT_STRING, BASE_NONE, NULL, 0, + FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC, NULL, 0, NULL, HFILL } }, { &hf_pfcp_quota_holding_time, @@ -8713,7 +8703,7 @@ proto_register_pfcp(void) { &hf_pfcp_event_time_stamp, { "Event Time Stamp", "pfcp.event_time_stamp", - FT_STRING, BASE_NONE, NULL, 0, + FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC, NULL, 0, NULL, HFILL } }, @@ -8763,12 +8753,12 @@ proto_register_pfcp(void) { &hf_pfcp_activation_time, { "Activation Time", "pfcp.activation_time", - FT_STRING, BASE_NONE, NULL, 0, + FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC, NULL, 0, NULL, HFILL } }, { &hf_pfcp_deactivation_time, { "Dectivation Time", "pfcp.deactivation_time", - FT_STRING, BASE_NONE, NULL, 0, + FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC, NULL, 0, NULL, HFILL } }, diff --git a/epan/dissectors/packet-rtcp.c b/epan/dissectors/packet-rtcp.c index bcee25f56c..d662069440 100644 --- a/epan/dissectors/packet-rtcp.c +++ b/epan/dissectors/packet-rtcp.c @@ -60,7 +60,6 @@ #include "packet-rtcp.h" #include "packet-rtp.h" -#include "packet-ntp.h" #include <epan/conversation.h> #include <epan/prefs.h> @@ -1803,7 +1802,7 @@ dissect_rtcp_app( tvbuff_t *tvb,packet_info *pinfo, int offset, proto_tree *tree /* Request timestamp (optional) */ if (code == 103) { - const gchar *buff; + char *buff; item_len = tvb_get_guint8(tvb, offset); offset += 1; @@ -1811,9 +1810,7 @@ dissect_rtcp_app( tvbuff_t *tvb,packet_info *pinfo, int offset, proto_tree *tree if (item_len != 8) /* SHALL be 8 */ return offset; - proto_tree_add_item(PoC1_tree, hf_rtcp_app_poc1_request_ts, - tvb, offset, 8, ENC_TIME_NTP|ENC_BIG_ENDIAN); - buff = tvb_ntp_fmt_ts(tvb, offset); + proto_tree_add_item_ret_time_string(PoC1_tree, hf_rtcp_app_poc1_request_ts, tvb, offset, 8, ENC_TIME_NTP|ENC_BIG_ENDIAN, wmem_packet_scope(), &buff); offset += 8; packet_len -= 8; @@ -4396,7 +4393,7 @@ proto_register_rtcp(void) "Talk Burst Request Timestamp", "rtcp.app.poc1.request.ts", FT_ABSOLUTE_TIME, - ABSOLUTE_TIME_UTC, + ABSOLUTE_TIME_NTP_UTC, NULL, 0x0, NULL, HFILL diff --git a/epan/proto.c b/epan/proto.c index 7b03d256a2..29d8e223d7 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -1794,6 +1794,7 @@ get_time_value(proto_tree *tree, tvbuff_t *tvb, const gint start, const gboolean is_relative) { guint32 tmpsecs; + guint64 tmp64secs; guint64 todsecs; switch (encoding) { @@ -1911,10 +1912,18 @@ get_time_value(proto_tree *tree, tvbuff_t *tvb, const gint start, * Convert 1/2^32s of a second to nanoseconds. */ time_stamp->nsecs = (int)(1000000000*(tvb_get_ntohl(tvb, start+4)/4294967296.0)); + if ((time_stamp->nsecs == 0) && (tmpsecs == 0)) { + //This is "NULL" time + time_stamp->secs = 0; + } } else if (length == 4) { /* * Backwards compatibility. */ + if (tmpsecs == 0) { + //This is "NULL" time + time_stamp->secs = 0; + } time_stamp->nsecs = 0; } else { time_stamp->secs = 0; @@ -1950,10 +1959,18 @@ get_time_value(proto_tree *tree, tvbuff_t *tvb, const gint start, * Convert 1/2^32s of a second to nanoseconds. */ time_stamp->nsecs = (int)(1000000000*(tvb_get_letohl(tvb, start+4)/4294967296.0)); + if ((time_stamp->nsecs == 0) && (tmpsecs == 0)) { + //This is "NULL" time + time_stamp->secs = 0; + } } else if (length == 4) { /* * Backwards compatibility. */ + if (tmpsecs == 0) { + //This is "NULL" time + time_stamp->secs = 0; + } time_stamp->nsecs = 0; } else { time_stamp->secs = 0; @@ -2049,6 +2066,43 @@ get_time_value(proto_tree *tree, tvbuff_t *tvb, const gint start, } break; + case ENC_TIME_MIP6 | ENC_BIG_ENDIAN: + /* + * MIP6 time stamp, big-endian. + * A 64-bit unsigned integer field containing a timestamp. The + * value indicates the number of seconds since January 1, 1970, + * 00:00 UTC, by using a fixed point format. In this format, the + * integer number of seconds is contained in the first 48 bits of + * the field, and the remaining 16 bits indicate the number of + * 1/65536 fractions of a second. + + * Only supported for absolute times. + */ + DISSECTOR_ASSERT(!is_relative); + + if (length == 8) { + /* We need a temporary variable here so the casting and fractions + * of a second work correctly. + */ + tmp64secs = tvb_get_ntoh48(tvb, start); + tmpsecs = tvb_get_ntohs(tvb, start + 6); + tmpsecs <<= 16; + + if ((tmp64secs == 0) && (tmpsecs == 0)) { + //This is "NULL" time + time_stamp->secs = 0; + time_stamp->nsecs = 0; + } else { + time_stamp->secs = (time_t)tmp64secs; + time_stamp->nsecs = (int)((tmpsecs / 4294967296.0) * 1000000000); + } + } else { + time_stamp->secs = 0; + time_stamp->nsecs = 0; + report_type_length_mismatch(tree, "an NTP time stamp", length, (length != 8)); + } + break; + case ENC_TIME_SECS_USECS|ENC_BIG_ENDIAN: /* * 4-byte seconds, followed by 4-byte fractional @@ -3430,19 +3484,19 @@ proto_tree_add_item_ret_display_string_and_length(proto_tree *tree, int hfindex, switch (hfinfo->type) { case FT_STRING: value = get_string_value(scope, tvb, start, length, lenretval, encoding); - *retval = hfinfo_format_text(scope, hfinfo, value);; + *retval = hfinfo_format_text(scope, hfinfo, value); break; case FT_STRINGZ: value = get_stringz_value(scope, tree, tvb, start, length, lenretval, encoding); - *retval = hfinfo_format_text(scope, hfinfo, value);; + *retval = hfinfo_format_text(scope, hfinfo, value); break; case FT_UINT_STRING: value = get_uint_string_value(scope, tree, tvb, start, length, lenretval, encoding); - *retval = hfinfo_format_text(scope, hfinfo, value);; + *retval = hfinfo_format_text(scope, hfinfo, value); break; case FT_STRINGZPAD: value = get_stringzpad_value(scope, tvb, start, length, lenretval, encoding); - *retval = hfinfo_format_text(scope, hfinfo, value);; + *retval = hfinfo_format_text(scope, hfinfo, value); break; case FT_BYTES: value = tvb_get_ptr(tvb, start, length); @@ -3522,6 +3576,56 @@ proto_tree_add_item_ret_display_string(proto_tree *tree, int hfindex, tvb, start, length, encoding, scope, retval, &length); } +proto_item * +proto_tree_add_item_ret_time_string(proto_tree *tree, int hfindex, + tvbuff_t *tvb, + const gint start, gint length, const guint encoding, + wmem_allocator_t *scope, char **retval) +{ + proto_item *pi; + header_field_info *hfinfo = proto_registrar_get_nth(hfindex); + field_info *new_fi; + nstime_t time_stamp; + + DISSECTOR_ASSERT_HINT(hfinfo != NULL, "Not passed hfi!"); + + switch (hfinfo->type) { + case FT_ABSOLUTE_TIME: + get_time_value(tree, tvb, start, length, encoding, &time_stamp, FALSE); + *retval = abs_time_to_str(scope, &time_stamp, (absolute_time_display_e)hfinfo->display, TRUE); + break; + case FT_RELATIVE_TIME: + get_time_value(tree, tvb, start, length, encoding, &time_stamp, TRUE); + *retval = rel_time_to_secs_str(scope, &time_stamp); + break; + default: + REPORT_DISSECTOR_BUG("field %s is not of type FT_ABSOLUTE_TIME or FT_RELATIVE_TIME", + hfinfo->abbrev); + } + + CHECK_FOR_NULL_TREE(tree); + + TRY_TO_FAKE_THIS_ITEM(tree, hfinfo->id, hfinfo); + + new_fi = new_field_info(tree, hfinfo, tvb, start, length); + + switch (hfinfo->type) { + + case FT_ABSOLUTE_TIME: + case FT_RELATIVE_TIME: + proto_tree_set_time(new_fi, &time_stamp); + break; + default: + g_assert_not_reached(); + } + + new_fi->flags |= (encoding & ENC_LITTLE_ENDIAN) ? FI_LITTLE_ENDIAN : FI_BIG_ENDIAN; + + pi = proto_tree_add_node(tree, new_fi); + + return pi; +} + /* Gets data from tvbuff, adds it to proto_tree, increments offset, and returns proto_item* */ proto_item * @@ -8037,6 +8141,7 @@ tmp_fld_check_assert(header_field_info *hfinfo) case FT_ABSOLUTE_TIME: if (!(hfinfo->display == ABSOLUTE_TIME_LOCAL || hfinfo->display == ABSOLUTE_TIME_UTC || + hfinfo->display == ABSOLUTE_TIME_NTP_UTC || hfinfo->display == ABSOLUTE_TIME_DOY_UTC)) { tmp_str = val_to_str_wmem(NULL, hfinfo->display, hf_display, "(Bit count: %d)"); g_error("Field '%s' (%s) is a %s but is being displayed as %s instead of as a time\n", diff --git a/epan/proto.h b/epan/proto.h index 787348b5fb..b6f5ef37b0 100644 --- a/epan/proto.h +++ b/epan/proto.h @@ -413,6 +413,7 @@ void proto_report_dissector_bug(const char *format, ...) #define ENC_TIME_SECS_NTP 0x00000018 #define ENC_TIME_RFC_3971 0x00000020 #define ENC_TIME_MSEC_NTP 0x00000022 +#define ENC_TIME_MIP6 0x00000024 /* * This is a modifier for FT_UINT_STRING and FT_UINT_BYTES values; @@ -1307,13 +1308,13 @@ text label registered to that item. This provides a string that is a display representation of the value, similar to what proto_tree_add_item_ret_string() does. -@param scope the wmem scope to use to allocate the string @param tree the tree to append this item to @param hfindex field @param tvb the tv buffer of the current data @param start start of data in tvb (cannot be negative) @param length length of data in tvb (for strings can be -1 for remaining) @param encoding data encoding (e.g, ENC_ASCII, ENC_UTF_8, etc.) +@param scope the wmem scope to use to allocate the string @param[out] retval points to a guint8 * that will be set to point to the string value @return the newly created item, *retval is set to the display string @@ -1324,6 +1325,27 @@ proto_tree_add_item_ret_display_string(proto_tree *tree, int hfindex, const gint start, gint length, const guint encoding, wmem_allocator_t *scope, char **retval); +/** Add a time item to a proto_tree, using thetext label registered to that item. + +This provides a string that is a display representation of the time value + +@param tree the tree to append this item to +@param hfindex field +@param tvb the tv buffer of the current data +@param start start of data in tvb (cannot be negative) +@param length length of data in tvb (for strings can be -1 for remaining) +@param encoding data encoding (e.g, ENC_ASCII, ENC_UTF_8, etc.) +@param scope the wmem scope to use to allocate the string +@param[out] retval points to a guint8 * that will be set to point to the +string value +@return the newly created item, *retval is set to the display string +*/ +WS_DLL_PUBLIC proto_item * +proto_tree_add_item_ret_time_string(proto_tree *tree, int hfindex, + tvbuff_t *tvb, + const gint start, gint length, const guint encoding, + wmem_allocator_t *scope, char **retval); + /** (INTERNAL USE ONLY) Add a text-only node to a proto_tree. @param tree the tree to append this item to @param tvb the tv buffer of the current data diff --git a/epan/time_fmt.h b/epan/time_fmt.h index 65ddb3e027..f31571150d 100644 --- a/epan/time_fmt.h +++ b/epan/time_fmt.h @@ -30,7 +30,8 @@ typedef enum { /* Start at 1000 to avoid duplicating the values used in field_display_e */ ABSOLUTE_TIME_LOCAL = 1000, /* 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_DOY_UTC, /* UTC, with 1-origin day-of-year */ + ABSOLUTE_TIME_NTP_UTC /* UTC, with "NULL" when timestamp is all zeros */ } absolute_time_display_e; #endif /* __TIME_FMT_H__ */ diff --git a/epan/to_str.c b/epan/to_str.c index 62841b4273..fd37f8c6bb 100644 --- a/epan/to_str.c +++ b/epan/to_str.c @@ -439,6 +439,7 @@ abs_time_to_str(wmem_allocator_t *scope, const nstime_t *abs_time, const absolut case ABSOLUTE_TIME_UTC: case ABSOLUTE_TIME_DOY_UTC: + case ABSOLUTE_TIME_NTP_UTC: tmp = gmtime(&abs_time->secs); zonename = "UTC"; break; @@ -475,6 +476,12 @@ abs_time_to_str(wmem_allocator_t *scope, const nstime_t *abs_time, const absolut (long)abs_time->nsecs); } break; + case ABSOLUTE_TIME_NTP_UTC: + if ((abs_time->secs == 0) && (abs_time->nsecs == 0)) { + buf = wmem_strdup(scope, "NULL"); + break; + } + /* FALLTHROUGH */ case ABSOLUTE_TIME_UTC: case ABSOLUTE_TIME_LOCAL: @@ -519,6 +526,7 @@ abs_time_secs_to_str(wmem_allocator_t *scope, const time_t abs_time, const absol case ABSOLUTE_TIME_UTC: case ABSOLUTE_TIME_DOY_UTC: + case ABSOLUTE_TIME_NTP_UTC: tmp = gmtime(&abs_time); zonename = "UTC"; break; @@ -554,6 +562,12 @@ abs_time_secs_to_str(wmem_allocator_t *scope, const time_t abs_time, const absol } break; + case ABSOLUTE_TIME_NTP_UTC: + if (abs_time == 0) { + buf = wmem_strdup(scope, "NULL"); + break; + } + /* FALLTHROUGH */ case ABSOLUTE_TIME_UTC: case ABSOLUTE_TIME_LOCAL: if (show_zone) { |