diff options
author | AndersBroman <anders.broman@ericsson.com> | 2015-03-10 10:53:41 +0100 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2015-03-10 09:57:13 +0000 |
commit | 1e3840e40cd47426678836a3d71b9e242735be18 (patch) | |
tree | 180ae2d7689e0a1fc141f497a3e1df62a95b13fa | |
parent | e9a40106302b331db4ccf683c9155e544d2d128c (diff) |
[GTPv2] Dissect ULI Timestamp.
Change-Id: If257831315423e5654cbbc3f6af99703cfad7f90
Reviewed-on: https://code.wireshark.org/review/7614
Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r-- | epan/dissectors/packet-gtpv2.c | 29 | ||||
-rw-r--r-- | epan/dissectors/packet-ntp.c | 40 | ||||
-rw-r--r-- | epan/dissectors/packet-ntp.h | 1 |
3 files changed, 63 insertions, 7 deletions
diff --git a/epan/dissectors/packet-gtpv2.c b/epan/dissectors/packet-gtpv2.c index cbc3a2e572..1a2ff7cce9 100644 --- a/epan/dissectors/packet-gtpv2.c +++ b/epan/dissectors/packet-gtpv2.c @@ -408,6 +408,7 @@ static int hf_gtpv2_ip4cp_ipv4 = -1; static int hf_gtpv2_change_report_flags_sncr = -1; static int hf_gtpv2_change_report_flags_tzcr = -1; static int hf_gtpv2_action_indication_val = -1; +static int hf_gtpv2_uli_timestamp = -1; static int hf_gtpv2_mbms_session_duration_days = -1; static int hf_gtpv2_mbms_session_duration_secs = -1; static int hf_gtpv2_node_features_prn = -1; @@ -5280,7 +5281,16 @@ 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_) { - proto_tree_add_expert(tree, pinfo, &ei_gtpv2_ie_data_not_dissected, tvb, 0, length); + const gchar *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, 8, time_str); + proto_item_append_text(item, "%s", time_str); + } /* * 8.102 MBMS Flags @@ -7504,12 +7514,17 @@ void proto_register_gtpv2(void) FT_UINT8, BASE_DEC|BASE_EXT_STRING, >pv2_action_indication_vals_ext, 0x07, 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, - NULL, HFILL} - }, - { &hf_gtpv2_mbms_session_duration_days, + { &hf_gtpv2_uli_timestamp, + { "ULI Timestamp", "gtpv2.uli_timestamp", + FT_STRING, BASE_NONE, 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, + NULL, HFILL } + }, + { &hf_gtpv2_mbms_session_duration_days, {"MBMS Session Duration (days)", "gtpv2.mbms_session_duration_days", FT_UINT24, BASE_DEC, NULL, 0x00007F, NULL, HFILL} diff --git a/epan/dissectors/packet-ntp.c b/epan/dissectors/packet-ntp.c index f338b9eb58..0d139ee2ab 100644 --- a/epan/dissectors/packet-ntp.c +++ b/epan/dissectors/packet-ntp.c @@ -704,6 +704,46 @@ tvb_ntp_fmt_ts(tvbuff_t *tvb, gint offset) 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 +* dissection of the next packet occurs. +*/ +const char * +tvb_ntp_fmt_ts_sec(tvbuff_t *tvb, gint offset) +{ + guint32 tempstmp; + time_t temptime; + struct tm *bd; + char *buff; + + tempstmp = tvb_get_ntohl(tvb, offset); + if (tempstmp == 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"; + } + + buff = (char *)wmem_alloc(wmem_packet_scope(), NTP_TS_SIZE); + g_snprintf(buff, NTP_TS_SIZE, + "%s %2d, %d %02d:%02d:%02d UTC", + mon_names[bd->tm_mon], + bd->tm_mday, + bd->tm_year + 1900, + bd->tm_hour, + bd->tm_min, + bd->tm_sec); + return buff; +} + void ntp_to_nstime(tvbuff_t *tvb, gint offset, nstime_t *nstime) { diff --git a/epan/dissectors/packet-ntp.h b/epan/dissectors/packet-ntp.h index 0723e5cf44..b465d54c03 100644 --- a/epan/dissectors/packet-ntp.h +++ b/epan/dissectors/packet-ntp.h @@ -24,6 +24,7 @@ #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); |