* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
-#include <glib.h>
#include <epan/packet.h>
#include <epan/llcsaps.h>
static int proto_rpl = -1;
static int hf_rpl_type = -1;
+static int hf_rpl_len = -1;
static int hf_rpl_corrval = -1;
static int hf_rpl_respval = -1;
static int hf_rpl_maxframe = -1;
static gint ett_rpl_c014 = -1;
static gint ett_rpl_unkn = -1;
+static dissector_handle_t rpl_handle;
+
static const value_string rpl_type_vals[] = {
{ 1, "FIND Command" },
{ 2, "FOUND Frame" },
{ 0x0, NULL }
};
-static dissector_handle_t data_handle;
-
static void
dissect_rpl_container(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
gint length, reported_length;
len = tvb_get_ntohs(tvb, 0);
- proto_tree_add_text(tree, tvb, 0, 2, "Length: %u", len);
+ proto_tree_add_item(tree, hf_rpl_len, tvb, 0, 2, ENC_BIG_ENDIAN);
type = tvb_get_ntohs(tvb, 2);
- proto_tree_add_text(tree, tvb, 2, 2, "Type: %s",
- val_to_str_const(type, rpl_type_vals, "Unknown Type"));
+ proto_tree_add_item(tree, hf_rpl_type, tvb, 2, 2, ENC_BIG_ENDIAN);
offset = 4;
switch (type) {
val_to_str_const(subtyp,
rpl_type_vals,
"Unknown Type"));
- length = tvb_length_remaining(tvb, offset);
+ length = tvb_captured_length_remaining(tvb, offset);
if (length > sublen)
length = sublen;
reported_length = tvb_reported_length_remaining(tvb, offset);
if (reported_length > sublen)
reported_length = sublen;
if ( length > 0) {
- dissect_rpl_container(tvb_new_subset(tvb,
+ dissect_rpl_container(tvb_new_subset_length_caplen(tvb,
offset, length, reported_length),
pinfo, rpl_container_tree);
offset += reported_length;
break;
default:
- call_dissector(data_handle,
- tvb_new_subset_remaining(tvb, 4), pinfo,
+ call_data_dissector(tvb_new_subset_remaining(tvb, 4), pinfo,
tree);
break;
}
if (tvb_reported_length(tvb) > offset)
- call_dissector(data_handle,
- tvb_new_subset_remaining(tvb, offset), pinfo, tree);
+ call_data_dissector(tvb_new_subset_remaining(tvb, offset), pinfo, tree);
}
-static void
-dissect_rpl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+static int
+dissect_rpl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
guint16 rpl_len, rpl_type;
- proto_item *ti, *hidden_item;
+ proto_item *ti;
proto_tree *rpl_tree;
tvbuff_t *next_tvb;
col_set_str(pinfo->cinfo, COL_INFO,
val_to_str_const(rpl_type, rpl_type_vals, "Unknown Type"));
- if (tree) {
- ti = proto_tree_add_item(tree, proto_rpl, tvb, 0,
- rpl_len, ENC_NA);
- rpl_tree = proto_item_add_subtree(ti, ett_rpl);
- hidden_item = proto_tree_add_uint(rpl_tree, hf_rpl_type, tvb, 2, 2,
- rpl_type);
- PROTO_ITEM_SET_HIDDEN(hidden_item);
- next_tvb = tvb_new_subset_remaining(tvb, 0);
- set_actual_length(next_tvb, rpl_len);
- dissect_rpl_container(next_tvb, pinfo, rpl_tree);
-
- if (tvb_reported_length(tvb) > rpl_len)
- call_dissector(data_handle,
- tvb_new_subset_remaining(tvb, rpl_len), pinfo,
- tree);
- }
+ ti = proto_tree_add_item(tree, proto_rpl, tvb, 0,
+ rpl_len, ENC_NA);
+ rpl_tree = proto_item_add_subtree(ti, ett_rpl);
+ next_tvb = tvb_new_subset_remaining(tvb, 0);
+ set_actual_length(next_tvb, rpl_len);
+ dissect_rpl_container(next_tvb, pinfo, rpl_tree);
+
+ if (tvb_reported_length(tvb) > rpl_len)
+ call_data_dissector(tvb_new_subset_remaining(tvb, rpl_len), pinfo,
+ tree);
+
+ return tvb_captured_length(tvb);
}
void
static hf_register_info hf[] = {
{ &hf_rpl_type,
{ "Type", "rpl.type",
- FT_UINT16, BASE_DEC, NULL, 0x0,
+ FT_UINT16, BASE_DEC, VALS(rpl_type_vals), 0x0,
"RPL Packet Type", HFILL }},
+ { &hf_rpl_len,
+ { "Length", "rpl.len",
+ FT_UINT16, BASE_DEC, NULL, 0x0,
+ "RPL Packet Length", HFILL }},
{ &hf_rpl_corrval,
{ "Correlator Value", "rpl.corrval",
FT_UINT32, BASE_HEX, NULL, 0x0,
&ett_rpl_unkn
};
- proto_rpl = proto_register_protocol("Remote Program Load",
+ proto_rpl = proto_register_protocol("Remote Program Load",
"RPL", "rpl");
proto_register_field_array(proto_rpl, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
- register_dissector("rpl", dissect_rpl, proto_rpl);
+ rpl_handle = register_dissector("rpl", dissect_rpl, proto_rpl);
}
void
proto_reg_handoff_rpl(void)
{
- dissector_handle_t rpl_handle;
-
- data_handle = find_dissector("data");
- rpl_handle = find_dissector("rpl");
dissector_add_uint("llc.dsap", SAP_RPL, rpl_handle);
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */