aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-ppi-gps.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2014-09-05 08:48:37 -0400
committerAlexis La Goutte <alexis.lagoutte@gmail.com>2014-09-06 07:44:46 +0000
commitceef7eba755cbecf670653360f72d864949dac49 (patch)
tree2cc48ebd17a4e7dc714f1b00af21f4f92546c948 /epan/dissectors/packet-ppi-gps.c
parentf1ad9eb212a6f4c5e1b6b1963bccf5f3a4900293 (diff)
Eliminate proto_tree_add_text from some of the dissectors.
Other minor cleanups while in the area. Change-Id: I8ea59205cfe6fab643d8fe01b75ce91532004fd9 Reviewed-on: https://code.wireshark.org/review/4004 Reviewed-by: Michael Mann <mmann78@netscape.net> Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-ppi-gps.c')
-rw-r--r--epan/dissectors/packet-ppi-gps.c76
1 files changed, 39 insertions, 37 deletions
diff --git a/epan/dissectors/packet-ppi-gps.c b/epan/dissectors/packet-ppi-gps.c
index 9f1c2350cc..53f97653e9 100644
--- a/epan/dissectors/packet-ppi-gps.c
+++ b/epan/dissectors/packet-ppi-gps.c
@@ -27,6 +27,7 @@
#include <glib.h>
#include <epan/packet.h>
+#include <epan/expert.h>
#include "packet-ppi-geolocation-common.h"
enum ppi_geotagging_type {
@@ -119,6 +120,8 @@ static gint ett_ppi_gps = -1;
static gint ett_ppi_gps_present = -1;
static gint ett_ppi_gps_gpsflags_flags= -1;
+static expert_field ei_ppi_gps_present_bit = EI_INIT;
+
static void
dissect_ppi_gps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
/* These are locals used for processing the current tvb */
@@ -127,12 +130,28 @@ dissect_ppi_gps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
int offset = 0;
proto_tree *ppi_gps_tree = NULL;
- proto_tree *pt, *present_tree = NULL;
proto_tree *my_pt, *gpsflags_flags_tree = NULL; /* used for DeviceType bitmask stuff */
- proto_item *ti = NULL;
+ proto_item *ti = NULL, *pt;
proto_item *gps_line = NULL;
+ static const int * ppi_gps_present_flags[] = {
+ &hf_ppi_gps_present_gpsflags_flags,
+ &hf_ppi_gps_present_lat,
+ &hf_ppi_gps_present_lon,
+ &hf_ppi_gps_present_alt,
+ &hf_ppi_gps_present_alt_gnd,
+ &hf_ppi_gps_present_gpstime,
+ &hf_ppi_gps_present_fractime,
+ &hf_ppi_gps_present_eph,
+ &hf_ppi_gps_present_epv,
+ &hf_ppi_gps_present_ept,
+ &hf_ppi_gps_present_descr,
+ &hf_ppi_gps_present_appspecific_num,
+ &hf_ppi_gps_present_appspecific_data,
+ &hf_ppi_gps_present_ext,
+ NULL
+ };
/* bits */
int bit;
@@ -202,25 +221,8 @@ dissect_ppi_gps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
}
/* Subtree for the "present flags" bitfield. */
- if (tree) {
- pt = proto_tree_add_uint(ppi_gps_tree, hf_ppi_gps_present, tvb, offset + 4, 4, present);
- present_tree = proto_item_add_subtree(pt, ett_ppi_gps_present);
-
- proto_tree_add_item(present_tree, hf_ppi_gps_present_gpsflags_flags, tvb, 4, 4, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(present_tree, hf_ppi_gps_present_lat, tvb, 4, 4, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(present_tree, hf_ppi_gps_present_lon, tvb, 4, 4, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(present_tree, hf_ppi_gps_present_alt, tvb, 4, 4, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(present_tree, hf_ppi_gps_present_alt_gnd, tvb, 4, 4, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(present_tree, hf_ppi_gps_present_gpstime, tvb, 4, 4, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(present_tree, hf_ppi_gps_present_fractime, tvb, 4, 4, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(present_tree, hf_ppi_gps_present_eph, tvb, 4, 4, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(present_tree, hf_ppi_gps_present_epv, tvb, 4, 4, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(present_tree, hf_ppi_gps_present_ept, tvb, 4, 4, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(present_tree, hf_ppi_gps_present_descr, tvb, 4, 4, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(present_tree, hf_ppi_gps_present_appspecific_num, tvb, 4, 4, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(present_tree, hf_ppi_gps_present_appspecific_data, tvb, 4, 4, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(present_tree, hf_ppi_gps_present_ext, tvb, 4, 4, ENC_LITTLE_ENDIAN);
- }
+ pt = proto_tree_add_bitmask(ppi_gps_tree, tvb, offset + 4, hf_ppi_gps_present, ett_ppi_gps_present, ppi_gps_present_flags, ENC_LITTLE_ENDIAN);
+
offset += PPI_GEOBASE_MIN_HEADER_LEN;
length_remaining -= PPI_GEOBASE_MIN_HEADER_LEN;
@@ -322,9 +324,7 @@ dissect_ppi_gps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
already_processed_fractime = 1;
gps_time_size = 8;
}
- if (tree) {
- proto_tree_add_time(ppi_gps_tree, hf_ppi_gps_gpstime, tvb, offset, gps_time_size, &gps_timestamp);
- }
+ proto_tree_add_time(ppi_gps_tree, hf_ppi_gps_gpstime, tvb, offset, gps_time_size, &gps_timestamp);
offset += gps_time_size;
length_remaining -= gps_time_size;
break;
@@ -339,8 +339,7 @@ dissect_ppi_gps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
break;
t_herr = tvb_get_letohl(tvb, offset);
eph = ppi_fixed3_6_to_gdouble(t_herr);
- if (tree)
- proto_tree_add_double(ppi_gps_tree, hf_ppi_gps_eph, tvb, offset, 4, eph);
+ proto_tree_add_double(ppi_gps_tree, hf_ppi_gps_eph, tvb, offset, 4, eph);
offset+=4;
length_remaining-=4;
break;
@@ -349,8 +348,7 @@ dissect_ppi_gps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
break;
t_verr = tvb_get_letohl(tvb, offset);
epv = ppi_fixed3_6_to_gdouble(t_verr);
- if (tree)
- proto_tree_add_double(ppi_gps_tree, hf_ppi_gps_epv, tvb, offset, 4, epv);
+ proto_tree_add_double(ppi_gps_tree, hf_ppi_gps_epv, tvb, offset, 4, epv);
offset+=4;
length_remaining-=4;
break;
@@ -359,8 +357,7 @@ dissect_ppi_gps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
break;
t_terr = tvb_get_letohl(tvb, offset);
ept = ppi_ns_counter_to_gdouble(t_terr);
- if (tree)
- proto_tree_add_double(ppi_gps_tree, hf_ppi_gps_ept, tvb, offset, 4, ept);
+ proto_tree_add_double(ppi_gps_tree, hf_ppi_gps_ept, tvb, offset, 4, ept);
offset+=4;
length_remaining-=4;
break;
@@ -381,18 +378,14 @@ dissect_ppi_gps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
if (length_remaining < 4)
break;
t_appspecific_num = tvb_get_letohl(tvb, offset); /* application specific parsers may switch on this later */
- if (tree) {
- proto_tree_add_uint(ppi_gps_tree, hf_ppi_gps_appspecific_num, tvb, offset, 4, t_appspecific_num);
- }
+ proto_tree_add_uint(ppi_gps_tree, hf_ppi_gps_appspecific_num, tvb, offset, 4, t_appspecific_num);
offset+=4;
length_remaining-=4;
break;
case PPI_GEOTAG_APPDATA:
if (length_remaining < 60)
break;
- if (tree) {
- proto_tree_add_item(ppi_gps_tree, hf_ppi_gps_appspecific_data, tvb, offset, 60, ENC_NA);
- }
+ proto_tree_add_item(ppi_gps_tree, hf_ppi_gps_appspecific_data, tvb, offset, 60, ENC_NA);
offset+=60;
length_remaining-=60;
break;
@@ -402,7 +395,8 @@ dissect_ppi_gps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
*/
default:
next_present = 0; /* this will terminate the loop */
- proto_tree_add_text(ppi_gps_tree, tvb, offset, 0, "Error: PPI-GEOLOCATION-GPS: unknown bit (%d) set in present field.\n", bit);
+ expert_add_info_format(pinfo, pt, &ei_ppi_gps_present_bit,
+ "Error: PPI-GEOLOCATION-GPS: unknown bit (%d) set in present field.", bit);
continue;
} /* switch (bit) */
@@ -617,9 +611,17 @@ proto_register_ppi_gps(void) {
&ett_ppi_gps_gpsflags_flags
};
+ static ei_register_info ei[] = {
+ { &ei_ppi_gps_present_bit, { "ppi_gps.present.unknown_bit", PI_PROTOCOL, PI_WARN, "Error: PPI-GEOLOCATION-GPS: unknown bit set in present field.", EXPFILL }},
+ };
+
+ expert_module_t* expert_ppi_gps;
+
proto_ppi_gps = proto_register_protocol("PPI Geotagging GPS tag decoder", "PPI GPS Decoder", "ppi_gps");
proto_register_field_array(proto_ppi_gps, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
+ expert_ppi_gps = expert_register_protocol(proto_ppi_gps);
+ expert_register_field_array(expert_ppi_gps, ei, array_length(ei));
register_dissector("ppi_gps", dissect_ppi_gps, proto_ppi_gps);
}