3 * Jochen Friedrich <jochen@scram.de>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include <epan/packet.h>
28 #include <epan/llcsaps.h>
29 #include "packet-llc.h"
31 void proto_register_rpl(void);
32 void proto_reg_handoff_rpl(void);
34 static int proto_rpl = -1;
36 static int hf_rpl_type = -1;
37 static int hf_rpl_len = -1;
38 static int hf_rpl_corrval = -1;
39 static int hf_rpl_respval = -1;
40 static int hf_rpl_maxframe = -1;
41 static int hf_rpl_connclass = -1;
42 static int hf_rpl_lmac = -1;
43 static int hf_rpl_smac = -1;
44 static int hf_rpl_sap = -1;
45 static int hf_rpl_equipment = -1;
46 static int hf_rpl_memsize = -1;
47 static int hf_rpl_bsmversion = -1;
48 static int hf_rpl_adapterid = -1;
49 static int hf_rpl_shortname = -1;
50 static int hf_rpl_laddress = -1;
51 static int hf_rpl_xaddress = -1;
52 static int hf_rpl_sequence = -1;
53 static int hf_rpl_config = -1;
54 static int hf_rpl_flags = -1;
55 static int hf_rpl_data = -1;
56 static int hf_rpl_ec = -1;
58 static gint ett_rpl = -1;
59 static gint ett_rpl_0004 = -1;
60 static gint ett_rpl_0008 = -1;
61 static gint ett_rpl_4003 = -1;
62 static gint ett_rpl_4006 = -1;
63 static gint ett_rpl_4007 = -1;
64 static gint ett_rpl_4009 = -1;
65 static gint ett_rpl_400a = -1;
66 static gint ett_rpl_400b = -1;
67 static gint ett_rpl_400c = -1;
68 static gint ett_rpl_4011 = -1;
69 static gint ett_rpl_4018 = -1;
70 static gint ett_rpl_c005 = -1;
71 static gint ett_rpl_c014 = -1;
72 static gint ett_rpl_unkn = -1;
74 static const value_string rpl_type_vals[] = {
75 { 1, "FIND Command" },
77 { 4, "Search Vector" },
78 { 8, "Connect Info Vector" },
79 { 0x10, "Send File Request" },
80 { 0x20, "File Data Response" },
81 { 0x4003, "Correlator Vector" },
82 { 0x4006, "Loader Address Vector" },
83 { 0x4007, "Loader SAP Vector" },
84 { 0x4009, "Frame Size Sub-Vector" },
85 { 0x400a, "Connect Class Sub-Vector" },
86 { 0x400b, "Response Correlator" },
87 { 0x400c, "Set Address Vector" },
88 { 0x4011, "Sequence Header" },
89 { 0x4018, "File Data Vector" },
90 { 0xc005, "Loader Info Sub-Vector" },
91 { 0xc014, "Loader Header" },
95 static dissector_handle_t data_handle;
98 dissect_rpl_container(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
100 guint16 len, type, sublen, subtyp;
101 proto_tree *rpl_container_tree;
104 gint length, reported_length;
106 len = tvb_get_ntohs(tvb, 0);
107 proto_tree_add_item(tree, hf_rpl_len, tvb, 0, 2, ENC_BIG_ENDIAN);
109 type = tvb_get_ntohs(tvb, 2);
110 proto_tree_add_item(tree, hf_rpl_type, tvb, 2, 2, ENC_BIG_ENDIAN);
120 while (len >= offset+4) {
121 sublen = tvb_get_ntohs(tvb, offset);
122 subtyp = tvb_get_ntohs(tvb, offset+2);
123 ett_type = ett_rpl_unkn;
124 if(subtyp == 0x0004) ett_type = ett_rpl_0004;
125 if(subtyp == 0x0008) ett_type = ett_rpl_0008;
126 if(subtyp == 0x4003) ett_type = ett_rpl_4003;
127 if(subtyp == 0x4006) ett_type = ett_rpl_4006;
128 if(subtyp == 0x4007) ett_type = ett_rpl_4007;
129 if(subtyp == 0x4009) ett_type = ett_rpl_4009;
130 if(subtyp == 0x400a) ett_type = ett_rpl_400a;
131 if(subtyp == 0x400b) ett_type = ett_rpl_400b;
132 if(subtyp == 0x400c) ett_type = ett_rpl_400c;
133 if(subtyp == 0x4011) ett_type = ett_rpl_4011;
134 if(subtyp == 0x4018) ett_type = ett_rpl_4018;
135 if(subtyp == 0xc005) ett_type = ett_rpl_c005;
136 if(subtyp == 0xc014) ett_type = ett_rpl_c014;
137 rpl_container_tree = proto_tree_add_subtree(tree, tvb,
138 offset, sublen, ett_type, NULL,
139 val_to_str_const(subtyp,
142 length = tvb_length_remaining(tvb, offset);
145 reported_length = tvb_reported_length_remaining(tvb, offset);
146 if (reported_length > sublen)
147 reported_length = sublen;
149 dissect_rpl_container(tvb_new_subset(tvb,
150 offset, length, reported_length),
151 pinfo, rpl_container_tree);
152 offset += reported_length;
154 /* no more data, exit the loop */
155 offset += reported_length;
162 proto_tree_add_item(tree, hf_rpl_corrval,
163 tvb, offset, 4, ENC_BIG_ENDIAN);
168 proto_tree_add_item(tree, hf_rpl_lmac,
169 tvb, offset, 6, ENC_NA);
174 proto_tree_add_item(tree, hf_rpl_sap,
175 tvb, offset, 1, ENC_BIG_ENDIAN);
180 proto_tree_add_item(tree, hf_rpl_maxframe,
181 tvb, offset, 2, ENC_BIG_ENDIAN);
186 proto_tree_add_item(tree, hf_rpl_connclass,
187 tvb, offset, 2, ENC_BIG_ENDIAN);
192 proto_tree_add_item(tree, hf_rpl_respval,
193 tvb, offset, 1, ENC_BIG_ENDIAN);
198 proto_tree_add_item(tree, hf_rpl_smac,
199 tvb, offset, 6, ENC_NA);
204 proto_tree_add_item(tree, hf_rpl_sequence,
205 tvb, offset, 4, ENC_BIG_ENDIAN);
210 proto_tree_add_item(tree, hf_rpl_data,
211 tvb, offset, len-4, ENC_NA);
216 proto_tree_add_item(tree, hf_rpl_config,
217 tvb, offset, 8, ENC_NA);
219 proto_tree_add_item(tree, hf_rpl_equipment,
220 tvb, offset, 2, ENC_BIG_ENDIAN);
222 proto_tree_add_item(tree, hf_rpl_memsize,
223 tvb, offset, 2, ENC_BIG_ENDIAN);
225 proto_tree_add_item(tree, hf_rpl_bsmversion,
226 tvb, offset, 2, ENC_BIG_ENDIAN);
228 proto_tree_add_item(tree, hf_rpl_ec,
229 tvb, offset, 6, ENC_NA);
231 proto_tree_add_item(tree, hf_rpl_adapterid,
232 tvb, offset, 2, ENC_BIG_ENDIAN);
234 proto_tree_add_item(tree, hf_rpl_shortname,
235 tvb, offset, 10, ENC_NA);
240 proto_tree_add_item(tree, hf_rpl_laddress,
241 tvb, offset, 4, ENC_BIG_ENDIAN);
243 proto_tree_add_item(tree, hf_rpl_xaddress,
244 tvb, offset, 4, ENC_BIG_ENDIAN);
246 proto_tree_add_item(tree, hf_rpl_flags,
247 tvb, offset, 1, ENC_BIG_ENDIAN);
252 call_dissector(data_handle,
253 tvb_new_subset_remaining(tvb, 4), pinfo,
257 if (tvb_reported_length(tvb) > offset)
258 call_dissector(data_handle,
259 tvb_new_subset_remaining(tvb, offset), pinfo, tree);
263 dissect_rpl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
265 guint16 rpl_len, rpl_type;
267 proto_tree *rpl_tree;
270 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RPL");
272 rpl_len = tvb_get_ntohs(tvb, 0);
273 rpl_type = tvb_get_ntohs(tvb, 2);
275 col_set_str(pinfo->cinfo, COL_INFO,
276 val_to_str_const(rpl_type, rpl_type_vals, "Unknown Type"));
278 ti = proto_tree_add_item(tree, proto_rpl, tvb, 0,
280 rpl_tree = proto_item_add_subtree(ti, ett_rpl);
281 next_tvb = tvb_new_subset_remaining(tvb, 0);
282 set_actual_length(next_tvb, rpl_len);
283 dissect_rpl_container(next_tvb, pinfo, rpl_tree);
285 if (tvb_reported_length(tvb) > rpl_len)
286 call_dissector(data_handle,
287 tvb_new_subset_remaining(tvb, rpl_len), pinfo,
292 proto_register_rpl(void)
294 static hf_register_info hf[] = {
296 { "Type", "rpl.type",
297 FT_UINT16, BASE_DEC, VALS(rpl_type_vals), 0x0,
298 "RPL Packet Type", HFILL }},
300 { "Length", "rpl.len",
301 FT_UINT16, BASE_DEC, NULL, 0x0,
302 "RPL Packet Length", HFILL }},
304 { "Correlator Value", "rpl.corrval",
305 FT_UINT32, BASE_HEX, NULL, 0x0,
306 "RPL Correlator Value", HFILL }},
308 { "Response Code", "rpl.respval",
309 FT_UINT8, BASE_DEC, NULL, 0x0,
310 "RPL Response Code", HFILL }},
312 { "Maximum Frame Size", "rpl.maxframe",
313 FT_UINT16, BASE_DEC, NULL, 0x0,
314 "RPL Maximum Frame Size", HFILL }},
316 { "Connection Class", "rpl.connclass",
317 FT_UINT16, BASE_HEX, NULL, 0x0,
318 "RPL Connection Class", HFILL }},
320 { "Loader MAC Address", "rpl.lmac",
321 FT_ETHER, BASE_NONE, NULL, 0x0,
322 "RPL Loader MAC Address", HFILL }},
324 { "Set MAC Address", "rpl.smac",
325 FT_ETHER, BASE_NONE, NULL, 0x0,
326 "RPL Set MAC Address", HFILL }},
329 FT_UINT8, BASE_HEX, VALS(sap_vals), 0x0,
332 { "Equipment", "rpl.equipment",
333 FT_UINT16, BASE_HEX, NULL, 0x0,
334 "RPL Equipment - AX from INT 11h", HFILL }},
336 { "Memory Size", "rpl.memsize",
337 FT_UINT16, BASE_DEC, NULL, 0x0,
338 "RPL Memory Size - AX from INT 12h MINUS 32k MINUS the Boot ROM Size", HFILL }},
339 { &hf_rpl_bsmversion,
340 { "BSM Version", "rpl.bsmversion",
341 FT_UINT16, BASE_HEX, NULL, 0x0,
342 "RPL Version of BSM.obj", HFILL }},
344 { "Adapter ID", "rpl.adapterid",
345 FT_UINT16, BASE_HEX, NULL, 0x0,
346 "RPL Adapter ID", HFILL }},
348 { "Short Name", "rpl.shortname",
349 FT_BYTES, BASE_NONE, NULL, 0x0,
350 "RPL BSM Short Name", HFILL }},
352 { "Locate Address", "rpl.laddress",
353 FT_UINT32, BASE_HEX, NULL, 0x0,
354 "RPL Locate Address", HFILL }},
356 { "XFER Address", "rpl.xaddress",
357 FT_UINT32, BASE_HEX, NULL, 0x0,
358 "RPL Transfer Control Address", HFILL }},
360 { "Sequence Number", "rpl.sequence",
361 FT_UINT32, BASE_HEX, NULL, 0x0,
362 "RPL Sequence Number", HFILL }},
364 { "Configuration", "rpl.config",
365 FT_BYTES, BASE_NONE, NULL, 0x0,
366 "RPL Configuration", HFILL }},
368 { "Flags", "rpl.flags",
369 FT_UINT8, BASE_HEX, NULL, 0x0,
370 "RPL Bit Significant Option Flags", HFILL }},
372 { "Data", "rpl.data",
373 FT_BYTES, BASE_NONE, NULL, 0x0,
374 "RPL Binary File Data", HFILL }},
377 FT_BYTES, BASE_NONE, NULL, 0x0,
381 static gint *ett[] = {
399 proto_rpl = proto_register_protocol("Remote Program Load",
401 proto_register_field_array(proto_rpl, hf, array_length(hf));
402 proto_register_subtree_array(ett, array_length(ett));
403 register_dissector("rpl", dissect_rpl, proto_rpl);
407 proto_reg_handoff_rpl(void)
409 dissector_handle_t rpl_handle;
411 data_handle = find_dissector("data");
412 rpl_handle = find_dissector("rpl");
413 dissector_add_uint("llc.dsap", SAP_RPL, rpl_handle);
417 * Editor modelines - http://www.wireshark.org/tools/modelines.html
422 * indent-tabs-mode: t
425 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
426 * :indentSize=8:tabSize=8:noTabs=false: