summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2015-11-24 00:18:24 -0500
committerMichael Mann <mmann78@netscape.net>2015-11-24 11:47:50 +0000
commite30c8f230222aea11dc729cb840affcf49fa8a21 (patch)
treea7c3348bdb89b4396e5ab2d8dfe5b879e60fe860
parent8748a047bf684fbdf2c9859b6b17aa18b9a761d7 (diff)
downloadwireshark-e30c8f230222aea11dc729cb840affcf49fa8a21.tar.gz
Convert PPI dissectors to "new style".
Also add some expert info and don't stop dissection based on version. Change-Id: Ia471cb3d517008a486ec9ad8aaf11d06fa55a72d Reviewed-on: https://code.wireshark.org/review/12082 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
-rw-r--r--epan/dissectors/packet-ppi-antenna.c86
-rw-r--r--epan/dissectors/packet-ppi-gps.c75
-rw-r--r--epan/dissectors/packet-ppi-sensor.c54
-rw-r--r--epan/dissectors/packet-ppi-vector.c40
-rw-r--r--epan/dissectors/packet-ppi.c17
5 files changed, 127 insertions, 145 deletions
diff --git a/epan/dissectors/packet-ppi-antenna.c b/epan/dissectors/packet-ppi-antenna.c
index 2a0ed72b9b..54a56624e2 100644
--- a/epan/dissectors/packet-ppi-antenna.c
+++ b/epan/dissectors/packet-ppi-antenna.c
@@ -99,19 +99,19 @@ static gint ett_ppi_antenna_present = -1;
static gint ett_ppi_antennaflags= -1;
static expert_field ei_ppi_antenna_present_bit = EI_INIT;
+static expert_field ei_ppi_antenna_version = EI_INIT;
+static expert_field ei_ppi_antenna_length = EI_INIT;
-static void
-dissect_ppi_antenna(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
+static int
+dissect_ppi_antenna(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) {
/* The fixed values up front */
guint32 version;
guint length;
gint length_remaining;
- proto_tree *ppi_antenna_tree = NULL;
- proto_tree *antennaflags_tree = NULL;
- proto_tree *pt, *my_pt;
- proto_item *ti = NULL;
- proto_item *antenna_line = NULL;
+ proto_tree *ppi_antenna_tree;
+ proto_tree *pt;
+ proto_item *antenna_line, *version_item, *length_item;
/* bits */
@@ -122,7 +122,6 @@ dissect_ppi_antenna(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
guint16 beamid;
guint32 t_hbw, t_vbw, t_pgain, t_appspecific_num; /* temporary conversions */
gdouble horizbw, vertbw, pgain;
- guint32 flags;
gchar *curr_str;
int offset = 0;
@@ -142,6 +141,17 @@ dissect_ppi_antenna(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
NULL
};
+ static const int * ppi_antenna_ant_flags[] = {
+ &hf_ppi_antennaflags_mimo,
+ &hf_ppi_antennaflags_horizpol,
+ &hf_ppi_antennaflags_vertpol,
+ &hf_ppi_antennaflags_circpol_l,
+ &hf_ppi_antennaflags_circpol_r,
+ &hf_ppi_antennaflags_steer_elec,
+ &hf_ppi_antennaflags_steer_mech,
+ NULL
+ };
+
/* Clear out stuff in the info column */
col_clear(pinfo->cinfo,COL_INFO);
@@ -156,24 +166,19 @@ dissect_ppi_antenna(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
/* Create the basic dissection tree*/
- if (tree) {
- ti = proto_tree_add_protocol_format(tree, proto_ppi_antenna,
- tvb, 0, length, "Antenna: ");
- antenna_line = ti; /* save this for later, we will fill it in with more detail */
-
- ppi_antenna_tree= proto_item_add_subtree(ti, ett_ppi_antenna);
- proto_tree_add_uint(ppi_antenna_tree, hf_ppi_antenna_version,
- tvb, offset, 1, version);
- proto_tree_add_item(ppi_antenna_tree, hf_ppi_antenna_pad,
- tvb, offset + 1, 1, ENC_LITTLE_ENDIAN);
- ti = proto_tree_add_uint(ppi_antenna_tree, hf_ppi_antenna_length,
- tvb, offset + 2, 2, length);
- }
+ antenna_line = proto_tree_add_protocol_format(tree, proto_ppi_antenna,
+ tvb, 0, length, "Antenna: ");
+ ppi_antenna_tree = proto_item_add_subtree(antenna_line, ett_ppi_antenna);
+ version_item = proto_tree_add_uint(ppi_antenna_tree, hf_ppi_antenna_version,
+ tvb, offset, 1, version);
+ proto_tree_add_item(ppi_antenna_tree, hf_ppi_antenna_pad,
+ tvb, offset + 1, 1, ENC_LITTLE_ENDIAN);
+ length_item = proto_tree_add_uint(ppi_antenna_tree, hf_ppi_antenna_length,
+ tvb, offset + 2, 2, length);
+
/* We support v1 and v2 of Antenna tags (identical) */
if (! (version == 1 || version == 2) ) {
- if (tree)
- proto_item_append_text(ti, "invalid version (got %d, expected 1 or 2)", version);
- return;
+ expert_add_info_format(pinfo, version_item, &ei_ppi_antenna_version, "Invalid version (got %d, expected 1 or 2)", version);
}
length_remaining = length;
@@ -183,15 +188,15 @@ dissect_ppi_antenna(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
* Base-geotag-header (Radiotap lookalike) is shorter than the fixed-length portion
* plus one "present" bitset.
*/
- proto_item_append_text(ti, " (invalid - minimum length is 8)");
- return;
+ expert_add_info_format(pinfo, length_item, &ei_ppi_antenna_length, "Invalid PPI-Antenna length - minimum length is 8");
+ return 2;
}
/* perform max length sanity checking */
if (length > PPI_ANTENNA_MAXTAGLEN ) {
- proto_item_append_text(ti, "Invalid PPI-Antenna length (got %d, %d max\n)", length, PPI_ANTENNA_MAXTAGLEN);
- return;
+ expert_add_info_format(pinfo, length_item, &ei_ppi_antenna_length, "Invalid PPI-Antenna length (got %d, %d max\n)", length, PPI_ANTENNA_MAXTAGLEN);
+ return 2;
}
/* Subtree for the "present flags" bitfield. */
@@ -210,27 +215,14 @@ dissect_ppi_antenna(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
case PPI_ANTENNA_ANTFLAGS:
if (length_remaining < 4)
break;
- flags = tvb_get_letohl(tvb, offset);
- if (tree) {
- my_pt = proto_tree_add_uint(ppi_antenna_tree, hf_ppi_antenna_flags, tvb, offset , 4, flags);
- /*Add antenna_flags bitfields here */
- antennaflags_tree= proto_item_add_subtree(my_pt, ett_ppi_antennaflags);
-
- proto_tree_add_item(antennaflags_tree, hf_ppi_antennaflags_mimo, tvb, offset, 4, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(antennaflags_tree, hf_ppi_antennaflags_horizpol, tvb, offset, 4, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(antennaflags_tree, hf_ppi_antennaflags_vertpol, tvb, offset, 4, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(antennaflags_tree, hf_ppi_antennaflags_circpol_l, tvb, offset, 4, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(antennaflags_tree, hf_ppi_antennaflags_circpol_r, tvb, offset, 4, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(antennaflags_tree, hf_ppi_antennaflags_steer_elec, tvb, offset, 4, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(antennaflags_tree, hf_ppi_antennaflags_steer_mech, tvb, offset, 4, ENC_LITTLE_ENDIAN);
- }
+ proto_tree_add_bitmask(ppi_antenna_tree, tvb, offset, hf_ppi_antenna_flags, ett_ppi_antennaflags, ppi_antenna_ant_flags, ENC_LITTLE_ENDIAN);
offset+=4;
length_remaining-=4;
break;
case PPI_ANTENNA_GAINDB:
if (length_remaining < 1)
break;
- gaindb= tvb_get_guint8(tvb, offset);
+ gaindb = tvb_get_guint8(tvb, offset);
if (tree) {
proto_tree_add_uint(ppi_antenna_tree, hf_ppi_antenna_gaindb, tvb, offset, 1, gaindb);
proto_item_append_text(antenna_line, " Gain: %d", gaindb);
@@ -335,8 +327,8 @@ dissect_ppi_antenna(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
continue;
}
- };
- return;
+ }
+ return tvb_captured_length(tvb);
}
void
@@ -527,6 +519,8 @@ proto_register_ppi_antenna(void) {
static ei_register_info ei[] = {
{ &ei_ppi_antenna_present_bit, { "ppi_antenna.present.unknown_bit", PI_PROTOCOL, PI_WARN, "Error: PPI-ANTENNA: unknown bit set in present field.", EXPFILL }},
+ { &ei_ppi_antenna_version, { "ppi_antenna.version.unsupported", PI_PROTOCOL, PI_WARN, "Invalid version", EXPFILL }},
+ { &ei_ppi_antenna_length, { "ppi_antenna.length.invalid", PI_MALFORMED, PI_ERROR, "Invalid length", EXPFILL }},
};
expert_module_t* expert_ppi_antenna;
@@ -536,7 +530,7 @@ proto_register_ppi_antenna(void) {
proto_register_subtree_array(ett, array_length(ett));
expert_ppi_antenna = expert_register_protocol(proto_ppi_antenna);
expert_register_field_array(expert_ppi_antenna, ei, array_length(ei));
- register_dissector("ppi_antenna", dissect_ppi_antenna, proto_ppi_antenna);
+ new_register_dissector("ppi_antenna", dissect_ppi_antenna, proto_ppi_antenna);
}
diff --git a/epan/dissectors/packet-ppi-gps.c b/epan/dissectors/packet-ppi-gps.c
index 203cd69d91..d1de54bc48 100644
--- a/epan/dissectors/packet-ppi-gps.c
+++ b/epan/dissectors/packet-ppi-gps.c
@@ -120,18 +120,19 @@ 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 expert_field ei_ppi_gps_version = EI_INIT;
+static expert_field ei_ppi_gps_length = EI_INIT;
-static void
-dissect_ppi_gps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
+static int
+dissect_ppi_gps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) {
/* These are locals used for processing the current tvb */
guint length;
gint length_remaining;
int offset = 0;
proto_tree *ppi_gps_tree = NULL;
- proto_tree *my_pt, *gpsflags_flags_tree = NULL; /* used for DeviceType bitmask stuff */
- proto_item *ti = NULL, *pt;
+ proto_item *version_item, *length_item, *pt;
proto_item *gps_line = NULL;
static const int * ppi_gps_present_flags[] = {
@@ -152,11 +153,24 @@ dissect_ppi_gps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
NULL
};
+ static const int * ppi_antenna_gps_flags[] = {
+ &hf_ppi_gps_gpsflags_flag0_nofix,
+ &hf_ppi_gps_gpsflags_flag1_gpsfix,
+ &hf_ppi_gps_gpsflags_flag2_diffgps,
+ &hf_ppi_gps_gpsflags_flag3_PPS,
+ &hf_ppi_gps_gpsflags_flag4_RTK,
+ &hf_ppi_gps_gpsflags_flag5_floatRTK,
+ &hf_ppi_gps_gpsflags_flag6_dead_reck,
+ &hf_ppi_gps_gpsflags_flag7_manual,
+ &hf_ppi_gps_gpsflags_flag8_sim,
+ NULL
+ };
+
/* bits */
int bit;
guint32 present, next_present;
/* values actually read out, for displaying */
- guint32 version, gpsflags_flags;
+ guint32 version;
gdouble lat, lon, alt, alt_gnd;
nstime_t gps_timestamp;
int gps_time_size, already_processed_fractime; /* we use this internally to track if this is a 4 or 8 byte wide timestamp */
@@ -183,20 +197,15 @@ dissect_ppi_gps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
col_add_fstr(pinfo->cinfo, COL_INFO, "PPI_GPS Capture v%u, Length %u", version, length);
/* Create the basic dissection tree*/
- if (tree) {
- ti = proto_tree_add_protocol_format(tree, proto_ppi_gps, tvb, 0, length, "GPS:");
- gps_line = ti; /*we will make this more useful if we hit lon/lat later */
- ppi_gps_tree= proto_item_add_subtree(ti, ett_ppi_gps);
- proto_tree_add_uint(ppi_gps_tree, hf_ppi_gps_version, tvb, offset, 1, version);
- proto_tree_add_item(ppi_gps_tree, hf_ppi_gps_pad, tvb, offset + 1, 1, ENC_LITTLE_ENDIAN);
- ti = proto_tree_add_uint(ppi_gps_tree, hf_ppi_gps_length, tvb, offset + 2, 2, length);
- }
+ gps_line = proto_tree_add_protocol_format(tree, proto_ppi_gps, tvb, 0, length, "GPS:");
+ ppi_gps_tree = proto_item_add_subtree(gps_line, ett_ppi_gps);
+ version_item = proto_tree_add_uint(ppi_gps_tree, hf_ppi_gps_version, tvb, offset, 1, version);
+ proto_tree_add_item(ppi_gps_tree, hf_ppi_gps_pad, tvb, offset + 1, 1, ENC_LITTLE_ENDIAN);
+ length_item = proto_tree_add_uint(ppi_gps_tree, hf_ppi_gps_length, tvb, offset + 2, 2, length);
/* We support v1 and v2 of GPS tags (identical) */
if (! (version == 1 || version == 2) ) {
- if (tree)
- proto_item_append_text(ti, "invalid version (got %d, expected 1 or 2)", version);
- return;
+ expert_add_info_format(pinfo, version_item, &ei_ppi_gps_version, "Invalid version (got %d, expected 1 or 2)", version);
}
/* initialize the length of the actual tag contents */
@@ -207,16 +216,14 @@ dissect_ppi_gps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
* Base-geotag-header (Radiotap lookalike) is shorter than the fixed-length portion
* plus one "present" bitset.
*/
- if (tree)
- proto_item_append_text(ti, " (invalid - minimum length is 8)");
- return;
+ expert_add_info_format(pinfo, length_item, &ei_ppi_gps_length, "Invalid PPI-GPS length - minimum length is 8");
+ return 2;
}
/* perform tag-specific max length sanity checking */
if (length > PPI_GPS_MAXTAGLEN ) {
- if (tree)
- proto_item_append_text(ti, "Invalid PPI-GPS length (got %d, %d max\n)", length, PPI_GPS_MAXTAGLEN);
- return;
+ expert_add_info_format(pinfo, length_item, &ei_ppi_gps_length, "Invalid PPI-GPS length (got %d, %d max\n)", length, PPI_GPS_MAXTAGLEN);
+ return 2;
}
/* Subtree for the "present flags" bitfield. */
@@ -235,23 +242,7 @@ dissect_ppi_gps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
case PPI_GEOTAG_GPSFLAGS:
if (length_remaining < 4)
break;
- gpsflags_flags = tvb_get_letohl(tvb, offset); /* retrieve 32-bit gpsflags bitmask (-not- present bitmask) */
- if (tree) {
- /* first we add the hex flags line */
- my_pt = proto_tree_add_uint(ppi_gps_tree, hf_ppi_gps_gpsflags_flags, tvb, offset , 4, gpsflags_flags);
- /* then we add a subtree */
- gpsflags_flags_tree = proto_item_add_subtree(my_pt, ett_ppi_gps_gpsflags_flags);
- /* to pin the individual bits on */
- proto_tree_add_item(gpsflags_flags_tree, hf_ppi_gps_gpsflags_flag0_nofix, tvb, offset, 4, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(gpsflags_flags_tree, hf_ppi_gps_gpsflags_flag1_gpsfix, tvb, offset, 4, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(gpsflags_flags_tree, hf_ppi_gps_gpsflags_flag2_diffgps, tvb, offset, 4, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(gpsflags_flags_tree, hf_ppi_gps_gpsflags_flag3_PPS, tvb, offset, 4, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(gpsflags_flags_tree, hf_ppi_gps_gpsflags_flag4_RTK, tvb, offset, 4, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(gpsflags_flags_tree, hf_ppi_gps_gpsflags_flag5_floatRTK, tvb, offset, 4, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(gpsflags_flags_tree, hf_ppi_gps_gpsflags_flag6_dead_reck, tvb, offset, 4, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(gpsflags_flags_tree, hf_ppi_gps_gpsflags_flag7_manual, tvb, offset, 4, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(gpsflags_flags_tree, hf_ppi_gps_gpsflags_flag8_sim, tvb, offset, 4, ENC_LITTLE_ENDIAN);
- }
+ proto_tree_add_bitmask(ppi_gps_tree, tvb, offset, hf_ppi_gps_gpsflags_flags, ett_ppi_gps_gpsflags_flags, ppi_antenna_gps_flags, ENC_LITTLE_ENDIAN);
offset+=4;
length_remaining-=4;
break;
@@ -402,7 +393,7 @@ dissect_ppi_gps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
} /* (for present..)*/
/* If there was any post processing of the elements, it could happen here. */
- return;
+ return tvb_captured_length(tvb);
}
void
@@ -612,6 +603,8 @@ proto_register_ppi_gps(void) {
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 }},
+ { &ei_ppi_gps_version, { "ppi_gps.version.unsupported", PI_PROTOCOL, PI_WARN, "Invalid version", EXPFILL }},
+ { &ei_ppi_gps_length, { "ppi_gps.length.invalid", PI_MALFORMED, PI_ERROR, "Invalid length", EXPFILL }},
};
expert_module_t* expert_ppi_gps;
@@ -621,7 +614,7 @@ proto_register_ppi_gps(void) {
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);
+ new_register_dissector("ppi_gps", dissect_ppi_gps, proto_ppi_gps);
}
/*
diff --git a/epan/dissectors/packet-ppi-sensor.c b/epan/dissectors/packet-ppi-sensor.c
index 3b2548f083..af86f0b9e0 100644
--- a/epan/dissectors/packet-ppi-sensor.c
+++ b/epan/dissectors/packet-ppi-sensor.c
@@ -129,6 +129,8 @@ static gint ett_ppi_sensor = -1;
static gint ett_ppi_sensor_present = -1;
static expert_field ei_ppi_sensor_present_bit = EI_INIT;
+static expert_field ei_ppi_sensor_version = EI_INIT;
+static expert_field ei_ppi_sensor_length = EI_INIT;
/* used with ScaleFactor */
static gdouble
@@ -157,8 +159,8 @@ base_10_expt(int power)
return (1.0/ret);
}
-static void
-dissect_ppi_sensor(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
+static int
+dissect_ppi_sensor(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) {
/* The fixed values up front */
guint32 version;
guint length;
@@ -166,8 +168,8 @@ dissect_ppi_sensor(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
proto_tree *ppi_sensor_tree = NULL;
proto_tree *pt, *my_pt;
- proto_item *ti = NULL;
- proto_item *sensor_line = NULL;
+ proto_item *version_item, *length_item;
+ proto_tree *sensor_line;
/* sensor type in english */
const gchar *type_str = "Unknown sensor";
const gchar *unit_str = "Unknown unit";
@@ -216,27 +218,21 @@ dissect_ppi_sensor(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
version, length);
/* Create the basic dissection tree*/
- if (tree) {
- ti = proto_tree_add_protocol_format(tree, proto_ppi_sensor,
- tvb, 0, length, "PPI Sensor Header v%u, Length %u", version, length);
- sensor_line = ti; /* we will almost definitely overwrite this in the field processing below */
-
- /*Add in the fixed ppi-geotagging-header fields: ver, pad, len */
- ppi_sensor_tree= proto_item_add_subtree(ti, ett_ppi_sensor);
- proto_tree_add_uint(ppi_sensor_tree, hf_ppi_sensor_version,
- tvb, offset, 1, version);
- proto_tree_add_item(ppi_sensor_tree, hf_ppi_sensor_pad,
- tvb, offset + 1, 1, ENC_BIG_ENDIAN);
- ti = proto_tree_add_uint(ppi_sensor_tree, hf_ppi_sensor_length,
- tvb, offset + 2, 2, length);
- /*fixed ppi-geotagging-header fields finished, move onto the fields marked present*/
- }
+ sensor_line = proto_tree_add_protocol_format(tree, proto_ppi_sensor,
+ tvb, 0, length, "PPI Sensor Header v%u, Length %u", version, length);
+ /*Add in the fixed ppi-geotagging-header fields: ver, pad, len */
+ ppi_sensor_tree = proto_item_add_subtree(sensor_line, ett_ppi_sensor);
+ version_item = proto_tree_add_uint(ppi_sensor_tree, hf_ppi_sensor_version,
+ tvb, offset, 1, version);
+ proto_tree_add_item(ppi_sensor_tree, hf_ppi_sensor_pad,
+ tvb, offset + 1, 1, ENC_BIG_ENDIAN);
+ length_item = proto_tree_add_uint(ppi_sensor_tree, hf_ppi_sensor_length,
+ tvb, offset + 2, 2, length);
+ /*fixed ppi-geotagging-header fields finished, move onto the fields marked present*/
/* We support v1 and v2 of Sensor tags (identical) */
if (! (version == 1 || version == 2) ) {
- if (tree)
- proto_item_append_text(ti, "invalid version (got %d, expected 1 or 2)", version);
- return;
+ expert_add_info_format(pinfo, version_item, &ei_ppi_sensor_version, "Invalid version (got %d, expected 1 or 2)", version);
}
length_remaining = length;
@@ -246,14 +242,14 @@ dissect_ppi_sensor(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
* Base-geotag-header (Radiotap lookalike) is shorter than the fixed-length portion
* plus one "present" bitset.
*/
- proto_item_append_text(ti, " (invalid - minimum length is 8)");
- return;
+ expert_add_info_format(pinfo, length_item, &ei_ppi_sensor_length, "Invalid PPI-Sensor length - minimum length is 8");
+ return 2;
}
/* perform max length sanity checking */
if (length > PPI_SENSOR_MAXTAGLEN ) {
- proto_item_append_text(ti, "Invalid PPI-Sensor length (got %d, %d max\n)", length, PPI_SENSOR_MAXTAGLEN);
- return;
+ expert_add_info_format(pinfo, length_item, &ei_ppi_sensor_length, "Invalid PPI-Sensor length (got %d, %d max\n)", length, PPI_SENSOR_MAXTAGLEN);
+ return 2;
}
/* Subtree for the "present flags" bitfield. */
@@ -401,7 +397,7 @@ dissect_ppi_sensor(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
}
};
- return;
+ return tvb_captured_length(tvb);
}
void
@@ -540,6 +536,8 @@ proto_register_ppi_sensor(void) {
static ei_register_info ei[] = {
{ &ei_ppi_sensor_present_bit, { "ppi_sensor.present.unknown_bit", PI_PROTOCOL, PI_WARN, "Error: PPI-ANTENNA: unknown bit set in present field.", EXPFILL }},
+ { &ei_ppi_sensor_version, { "ppi_sensor.version.unsupported", PI_PROTOCOL, PI_WARN, "Invalid version", EXPFILL }},
+ { &ei_ppi_sensor_length, { "ppi_sensor.length.invalid", PI_MALFORMED, PI_ERROR, "Invalid length", EXPFILL }},
};
expert_module_t* expert_ppi_sensor;
@@ -549,7 +547,7 @@ proto_register_ppi_sensor(void) {
proto_register_subtree_array(ett, array_length(ett));
expert_ppi_sensor = expert_register_protocol(proto_ppi_sensor);
expert_register_field_array(expert_ppi_sensor, ei, array_length(ei));
- register_dissector("ppi_sensor", dissect_ppi_sensor, proto_ppi_sensor);
+ new_register_dissector("ppi_sensor", dissect_ppi_sensor, proto_ppi_sensor);
}
diff --git a/epan/dissectors/packet-ppi-vector.c b/epan/dissectors/packet-ppi-vector.c
index 78b4f27425..f56cfd0855 100644
--- a/epan/dissectors/packet-ppi-vector.c
+++ b/epan/dissectors/packet-ppi-vector.c
@@ -266,6 +266,7 @@ static gint ett_ppi_vectorflags= -1;
static gint ett_ppi_vectorchars= -1;
static expert_field ei_ppi_vector_present_bit = EI_INIT;
+static expert_field ei_ppi_vector_length = EI_INIT;
/* We want to abbreviate this field into a single line. Does so without any string maniuplation */
@@ -948,12 +949,11 @@ dissect_ppi_vector_v2(tvbuff_t *tvb, packet_info *pinfo, int offset, gint length
proto_item_append_text (vector_line, " RelativeTo: %s", relativeto_str);
}
-static void
-dissect_ppi_vector(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+static int
+dissect_ppi_vector(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
- proto_tree *ppi_vector_tree = NULL;
- proto_item *ti = NULL;
- proto_item *vector_line = NULL;
+ proto_tree *ppi_vector_tree;
+ proto_item *ti, *vector_line;
gint length_remaining;
int offset = 0;
@@ -973,16 +973,14 @@ dissect_ppi_vector(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
version, length);
/* Create the basic dissection tree*/
- if (tree) {
- vector_line = proto_tree_add_protocol_format(tree, proto_ppi_vector, tvb, 0, length, "Vector:");
- ppi_vector_tree= proto_item_add_subtree(vector_line, ett_ppi_vector);
- proto_tree_add_uint(ppi_vector_tree, hf_ppi_vector_version,
- tvb, offset, 1, version);
- proto_tree_add_item(ppi_vector_tree, hf_ppi_vector_pad,
- tvb, offset + 1, 1, ENC_LITTLE_ENDIAN);
- ti = proto_tree_add_uint(ppi_vector_tree, hf_ppi_vector_length,
- tvb, offset + 2, 2, length);
- }
+ vector_line = proto_tree_add_protocol_format(tree, proto_ppi_vector, tvb, 0, length, "Vector:");
+ ppi_vector_tree = proto_item_add_subtree(vector_line, ett_ppi_vector);
+ proto_tree_add_uint(ppi_vector_tree, hf_ppi_vector_version,
+ tvb, offset, 1, version);
+ proto_tree_add_item(ppi_vector_tree, hf_ppi_vector_pad,
+ tvb, offset + 1, 1, ENC_LITTLE_ENDIAN);
+ ti = proto_tree_add_uint(ppi_vector_tree, hf_ppi_vector_length,
+ tvb, offset + 2, 2, length);
/* initialize remaining length */
length_remaining = length;
@@ -992,8 +990,8 @@ dissect_ppi_vector(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
* Base-geotag-header (Radiotap lookalike) is shorter than the fixed-length portion
* plus one "present" bitset.
*/
- proto_item_append_text(ti, " (invalid - minimum length is %d)", PPI_GEOBASE_MIN_HEADER_LEN);
- return;
+ expert_add_info_format(pinfo, ti, &ei_ppi_vector_length, "Invalid PPI-Vector length - minimum length is %d", PPI_GEOBASE_MIN_HEADER_LEN);
+ return 2;
}
switch (version) {
@@ -1005,8 +1003,8 @@ dissect_ppi_vector(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
case 2:
/* perform max length sanity checking */
if (length > PPI_VECTOR_MAXTAGLEN ) {
- proto_item_append_text(ti, " (invalid - maximum length is %d\n)", PPI_VECTOR_MAXTAGLEN);
- return;
+ expert_add_info_format(pinfo, ti, &ei_ppi_vector_length, "Invalid PPI-Vector length (got %d, %d max\n)", length, PPI_VECTOR_MAXTAGLEN);
+ return 2;
}
dissect_ppi_vector_v2(tvb, pinfo, offset, length_remaining, ppi_vector_tree, vector_line);
break;
@@ -1015,6 +1013,7 @@ dissect_ppi_vector(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
proto_tree_add_item(ppi_vector_tree, hf_ppi_vector_unknown_data, tvb, offset + 4, -1, ENC_NA);
break;
}
+ return tvb_captured_length(tvb);
}
void
@@ -1383,6 +1382,7 @@ proto_register_ppi_vector(void)
static ei_register_info ei[] = {
{ &ei_ppi_vector_present_bit, { "ppi_vector.present.unknown_bit", PI_PROTOCOL, PI_WARN, "Error: PPI-VECTOR: unknown bit set in present field.", EXPFILL }},
+ { &ei_ppi_vector_length, { "ppi_vector.length.invalid", PI_MALFORMED, PI_ERROR, "Invalid length", EXPFILL }},
};
expert_module_t* expert_ppi_vector;
@@ -1392,7 +1392,7 @@ proto_register_ppi_vector(void)
proto_register_subtree_array(ett, array_length(ett));
expert_ppi_vector = expert_register_protocol(proto_ppi_vector);
expert_register_field_array(expert_ppi_vector, ei, array_length(ei));
- register_dissector("ppi_vector", dissect_ppi_vector, proto_ppi_vector);
+ new_register_dissector("ppi_vector", dissect_ppi_vector, proto_ppi_vector);
}
diff --git a/epan/dissectors/packet-ppi.c b/epan/dissectors/packet-ppi.c
index 53a929c3fe..ee31a2464f 100644
--- a/epan/dissectors/packet-ppi.c
+++ b/epan/dissectors/packet-ppi.c
@@ -836,8 +836,8 @@ dissect_8023_extension(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
if (tree) \
proto_tree_add_item(ppi_tree, hf_tag, tvb, offset, data_len, ENC_NA)
-static void
-dissect_ppi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+static int
+dissect_ppi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
proto_tree *ppi_tree = NULL, *ppi_flags_tree = NULL, *seg_tree = NULL, *ampdu_tree = NULL;
proto_tree *agg_tree = NULL;
@@ -1036,12 +1036,8 @@ dissect_ppi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
fd_head = fd_head->next;
}
if (ampdu_len > AGGREGATE_MAX) {
- if (tree) {
- proto_tree_add_expert_format(ppi_tree, pinfo, &ei_ppi_invalid_length, tvb, offset, -1, "Aggregate length greater than maximum (%u)", AGGREGATE_MAX);
- THROW(ReportedBoundsError);
- } else {
- return;
- }
+ proto_tree_add_expert_format(ppi_tree, pinfo, &ei_ppi_invalid_length, tvb, offset, -1, "Aggregate length greater than maximum (%u)", AGGREGATE_MAX);
+ return offset;
}
/*
@@ -1117,7 +1113,7 @@ dissect_ppi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
col_set_str(pinfo->cinfo, COL_INFO, "Unreassembled A-MPDU data");
call_dissector(data_handle, next_tvb, pinfo, tree);
}
- return;
+ return tvb_captured_length(tvb);
}
next_tvb = tvb_new_subset_remaining(tvb, offset);
@@ -1140,6 +1136,7 @@ dissect_ppi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
dissector_try_uint(wtap_encap_dissector_table,
wtap_pcap_encap_to_wtap_encap(dlt), next_tvb, pinfo, tree);
}
+ return tvb_captured_length(tvb);
}
/* Establish our beachead */
@@ -1496,7 +1493,7 @@ proto_register_ppi(void)
expert_ppi = expert_register_protocol(proto_ppi);
expert_register_field_array(expert_ppi, ei, array_length(ei));
- ppi_handle = register_dissector("ppi", dissect_ppi, proto_ppi);
+ ppi_handle = new_register_dissector("ppi", dissect_ppi, proto_ppi);
register_init_routine(ampdu_reassemble_init);
register_cleanup_routine(ampdu_reassemble_cleanup);