From a16ac8f306adca88308c74c5b4ab3e2ff8fd5215 Mon Sep 17 00:00:00 2001 From: Sylvain Munaut Date: Fri, 2 Jan 2015 14:38:25 +0100 Subject: gmr1_rach: Use FT_INT24 instead of FT_UINT24 for latitude/longitude No need to do sign extension manually, the core code now supports signed integers with bitmask and it will do the sign extension. Not sure if that was always the code, but it works now. This also have the advantage that the real value 'seen' by wireshark when applying filters is the real signed value. Change-Id: I47e2357e5556160a00110ad63e3342879769a0b9 Signed-off-by: Sylvain Munaut Reviewed-on: https://code.wireshark.org/review/6288 Reviewed-by: Pascal Quantin --- epan/dissectors/packet-gmr1_rach.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'epan') diff --git a/epan/dissectors/packet-gmr1_rach.c b/epan/dissectors/packet-gmr1_rach.c index 641a294628..292e1c03a1 100644 --- a/epan/dissectors/packet-gmr1_rach.c +++ b/epan/dissectors/packet-gmr1_rach.c @@ -223,12 +223,7 @@ static const value_string rach_gps_pos_cpi_vals[] = { static void rach_gps_pos_lat_fmt(gchar *s, guint32 v) { - gint32 sv; - - if (v & (1<<18)) - v |= 0xfff80000; - - sv = v; + gint32 sv = v; g_snprintf(s, ITEM_LABEL_LENGTH, "%.5f %s (%d)", abs(sv) / 2912.7f, sv < 0 ? "S" : "N", sv); @@ -237,12 +232,7 @@ rach_gps_pos_lat_fmt(gchar *s, guint32 v) static void rach_gps_pos_long_fmt(gchar *s, guint32 v) { - gint32 sv; - - if (v & (1<<19)) - v |= 0xfff00000; - - sv = v; + gint32 sv = v; g_snprintf(s, ITEM_LABEL_LENGTH, "%.5f %s (%d)", abs(sv) / 2912.70555f, sv < 0 ? "W" : "E", sv); @@ -260,7 +250,7 @@ dissect_gmr1_rach_gps_pos(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, pro /* Check for NULL */ lat = (tvb_get_ntohl(tvb, offset) >> 4) & 0x7ffff; if (lat == 0x40000) { - proto_tree_add_uint_format(tree, hf_rach_gps_pos_lat, tvb, offset, 5, 0x40000, "NULL GPS Position"); + proto_tree_add_int_format(tree, hf_rach_gps_pos_lat, tvb, offset, 5, 0x40000, "NULL GPS Position"); return; } @@ -593,12 +583,12 @@ proto_register_gmr1_rach(void) }, { &hf_rach_gps_pos_lat, { "Latitude", "gmr1.rach.gps_pos.latitude", - FT_UINT24, BASE_CUSTOM, rach_gps_pos_lat_fmt, 0x7ffff0, + FT_INT24, BASE_CUSTOM, rach_gps_pos_lat_fmt, 0x7ffff0, NULL, HFILL } }, { &hf_rach_gps_pos_long, { "Longitude", "gmr1.rach.gps_pos.longitude", - FT_UINT24, BASE_CUSTOM, rach_gps_pos_long_fmt, 0x0fffff, + FT_INT24, BASE_CUSTOM, rach_gps_pos_long_fmt, 0x0fffff, NULL, HFILL } }, { &hf_rach_mes_pwr_class, -- cgit v1.2.3