aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-ppi-vector.c
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 /epan/dissectors/packet-ppi-vector.c
parent8748a047bf684fbdf2c9859b6b17aa18b9a761d7 (diff)
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>
Diffstat (limited to 'epan/dissectors/packet-ppi-vector.c')
-rw-r--r--epan/dissectors/packet-ppi-vector.c40
1 files changed, 20 insertions, 20 deletions
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);
}