3 * Jochen Friedrich <jochen@scram.de>
5 * $Id: packet-rpl.c,v 1.5 2003/03/02 21:52:19 guy Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #include <epan/packet.h>
34 #include "packet-llc.h"
36 static int proto_rpl = -1;
38 static int hf_rpl_type = -1;
39 static int hf_rpl_corrval = -1;
40 static int hf_rpl_respval = -1;
41 static int hf_rpl_maxframe = -1;
42 static int hf_rpl_connclass = -1;
43 static int hf_rpl_lmac = -1;
44 static int hf_rpl_smac = -1;
45 static int hf_rpl_sap = -1;
46 static int hf_rpl_equipment = -1;
47 static int hf_rpl_memsize = -1;
48 static int hf_rpl_bsmversion = -1;
49 static int hf_rpl_adapterid = -1;
50 static int hf_rpl_shortname = -1;
51 static int hf_rpl_laddress = -1;
52 static int hf_rpl_xaddress = -1;
53 static int hf_rpl_sequence = -1;
54 static int hf_rpl_config = -1;
55 static int hf_rpl_flags = -1;
56 static int hf_rpl_data = -1;
57 static int hf_rpl_ec = -1;
59 static gint ett_rpl = -1;
60 static gint ett_rpl_0004 = -1;
61 static gint ett_rpl_0008 = -1;
62 static gint ett_rpl_4003 = -1;
63 static gint ett_rpl_4006 = -1;
64 static gint ett_rpl_4007 = -1;
65 static gint ett_rpl_4009 = -1;
66 static gint ett_rpl_400a = -1;
67 static gint ett_rpl_400b = -1;
68 static gint ett_rpl_400c = -1;
69 static gint ett_rpl_4011 = -1;
70 static gint ett_rpl_4018 = -1;
71 static gint ett_rpl_c005 = -1;
72 static gint ett_rpl_c014 = -1;
73 static gint ett_rpl_unkn = -1;
75 static const value_string rpl_type_vals[] = {
76 { 1, "FIND Command" },
78 { 4, "Search Vector" },
79 { 8, "Connect Info Vector" },
80 { 0x10, "Send File Request" },
81 { 0x20, "File Data Response" },
82 { 0x4003, "Correlator Vector" },
83 { 0x4006, "Loader Address Vector" },
84 { 0x4007, "Loader SAP Vector" },
85 { 0x4009, "Frame Size Sub-Vector" },
86 { 0x400a, "Connect Class Sub-Vector" },
87 { 0x400b, "Response Correlator" },
88 { 0x400c, "Set Address Vector" },
89 { 0x4011, "Sequence Header" },
90 { 0x4018, "File Data Vector" },
91 { 0xc005, "Loader Info Sub-Vector" },
92 { 0xc014, "Loader Header" },
96 static dissector_handle_t data_handle;
99 dissect_rpl_container(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
101 guint16 len, type, sublen, subtyp;
103 proto_tree *rpl_container_tree;
107 len = tvb_get_ntohs(tvb, 0);
108 proto_tree_add_text(tree, tvb, 0, 2, "Length: %u", len);
110 type = tvb_get_ntohs(tvb, 2);
111 proto_tree_add_text(tree, tvb, 2, 2, "Type: %s",
112 val_to_str(type, rpl_type_vals, "Unknown Type"));
122 while (len >= offset+4) {
123 sublen = tvb_get_ntohs(tvb, offset);
124 subtyp = tvb_get_ntohs(tvb, offset+2);
125 ett_type = ett_rpl_unkn;
126 if(subtyp == 0x0004) ett_type = ett_rpl_0004;
127 if(subtyp == 0x0008) ett_type = ett_rpl_0008;
128 if(subtyp == 0x4003) ett_type = ett_rpl_4003;
129 if(subtyp == 0x4006) ett_type = ett_rpl_4006;
130 if(subtyp == 0x4007) ett_type = ett_rpl_4007;
131 if(subtyp == 0x4009) ett_type = ett_rpl_4009;
132 if(subtyp == 0x400a) ett_type = ett_rpl_400a;
133 if(subtyp == 0x400b) ett_type = ett_rpl_400b;
134 if(subtyp == 0x400c) ett_type = ett_rpl_400c;
135 if(subtyp == 0x4011) ett_type = ett_rpl_4011;
136 if(subtyp == 0x4018) ett_type = ett_rpl_4018;
137 if(subtyp == 0xc005) ett_type = ett_rpl_c005;
138 if(subtyp == 0xc014) ett_type = ett_rpl_c014;
139 ti = proto_tree_add_text(tree, tvb,
140 offset, sublen, val_to_str(subtyp,
141 rpl_type_vals, "Unknown Type"));
142 rpl_container_tree = proto_item_add_subtree(ti,
144 dissect_rpl_container(tvb_new_subset(tvb,
145 offset, sublen, -1), pinfo,
153 proto_tree_add_item(tree, hf_rpl_corrval,
154 tvb, offset, 4, FALSE);
159 proto_tree_add_item(tree, hf_rpl_lmac,
160 tvb, offset, 6, FALSE);
165 proto_tree_add_item(tree, hf_rpl_sap,
166 tvb, offset, 1, FALSE);
171 proto_tree_add_item(tree, hf_rpl_maxframe,
172 tvb, offset, 2, FALSE);
177 proto_tree_add_item(tree, hf_rpl_connclass,
178 tvb, offset, 2, FALSE);
183 proto_tree_add_item(tree, hf_rpl_respval,
184 tvb, offset, 1, FALSE);
189 proto_tree_add_item(tree, hf_rpl_smac,
190 tvb, offset, 6, FALSE);
195 proto_tree_add_item(tree, hf_rpl_sequence,
196 tvb, offset, 4, FALSE);
201 proto_tree_add_item(tree, hf_rpl_data,
202 tvb, offset, len-4, FALSE);
207 proto_tree_add_item(tree, hf_rpl_config,
208 tvb, offset, 8, FALSE);
210 proto_tree_add_item(tree, hf_rpl_equipment,
211 tvb, offset, 2, FALSE);
213 proto_tree_add_item(tree, hf_rpl_memsize,
214 tvb, offset, 2, FALSE);
216 proto_tree_add_item(tree, hf_rpl_bsmversion,
217 tvb, offset, 2, FALSE);
219 proto_tree_add_item(tree, hf_rpl_ec,
220 tvb, offset, 6, FALSE);
222 proto_tree_add_item(tree, hf_rpl_adapterid,
223 tvb, offset, 2, FALSE);
225 proto_tree_add_item(tree, hf_rpl_shortname,
226 tvb, offset, 10, FALSE);
231 proto_tree_add_item(tree, hf_rpl_laddress,
232 tvb, offset, 4, FALSE);
234 proto_tree_add_item(tree, hf_rpl_xaddress,
235 tvb, offset, 4, FALSE);
237 proto_tree_add_item(tree, hf_rpl_flags,
238 tvb, offset, 1, FALSE);
243 call_dissector(data_handle,
244 tvb_new_subset(tvb, 4, -1, -1), pinfo,
248 if (tvb_reported_length(tvb) > offset)
249 call_dissector(data_handle,
250 tvb_new_subset(tvb, offset, -1, -1), pinfo, tree);
254 dissect_rpl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
256 guint16 rpl_len, rpl_type;
258 proto_tree *rpl_tree;
260 if (check_col(pinfo->cinfo, COL_PROTOCOL))
261 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RPL");
263 rpl_len = tvb_get_ntohs(tvb, 0);
264 rpl_type = tvb_get_ntohs(tvb, 2);
266 if (check_col(pinfo->cinfo, COL_INFO)) {
267 col_set_str(pinfo->cinfo, COL_INFO,
268 val_to_str(rpl_type, rpl_type_vals, "Unknown Type"));
271 ti = proto_tree_add_item(tree, proto_rpl, tvb, 0,
273 rpl_tree = proto_item_add_subtree(ti, ett_rpl);
274 proto_tree_add_uint_hidden(rpl_tree, hf_rpl_type, tvb, 2, 2,
276 dissect_rpl_container(tvb_new_subset(tvb, 0, rpl_len, -1),
279 if (tvb_reported_length(tvb) > rpl_len)
280 call_dissector(data_handle,
281 tvb_new_subset(tvb, rpl_len, -1, -1), pinfo,
287 proto_register_rpl(void)
289 static hf_register_info hf[] = {
291 { "Type", "rpl.type",
292 FT_UINT16, BASE_DEC, NULL, 0x0,
293 "RPL Packet Type", HFILL }},
295 { "Correlator Value", "rpl.corrval",
296 FT_UINT32, BASE_HEX, NULL, 0x0,
297 "RPL Correlator Value", HFILL }},
299 { "Response Code", "rpl.respval",
300 FT_UINT8, BASE_DEC, NULL, 0x0,
301 "RPL Response Code", HFILL }},
303 { "Maximum Frame Size", "rpl.maxframe",
304 FT_UINT16, BASE_DEC, NULL, 0x0,
305 "RPL Maximum Frame Size", HFILL }},
307 { "Connection Class", "rpl.connclass",
308 FT_UINT16, BASE_HEX, NULL, 0x0,
309 "RPL Connection Class", HFILL }},
311 { "Loader MAC Address", "rpl.lmac",
312 FT_ETHER, BASE_NONE, NULL, 0x0,
313 "RPL Loader MAC Address", HFILL }},
315 { "Set MAC Address", "rpl.smac",
316 FT_ETHER, BASE_NONE, NULL, 0x0,
317 "RPL Set MAC Address", HFILL }},
320 FT_UINT8, BASE_HEX, VALS(sap_vals), 0x0,
323 { "Equipment", "rpl.equipment",
324 FT_UINT16, BASE_HEX, NULL, 0x0,
325 "RPL Equipment - AX from INT 11h", HFILL }},
327 { "Memory Size", "rpl.memsize",
328 FT_UINT16, BASE_DEC, NULL, 0x0,
329 "RPL Memory Size - AX from INT 12h MINUS 32k"
330 " MINUS the Boot ROM Size", HFILL }},
331 { &hf_rpl_bsmversion,
332 { "BSM Version", "rpl.bsmversion",
333 FT_UINT16, BASE_HEX, NULL, 0x0,
334 "RPL Version of BSM.obj", HFILL }},
336 { "Adapter ID", "rpl.adapterid",
337 FT_UINT16, BASE_HEX, NULL, 0x0,
338 "RPL Adapter ID", HFILL }},
340 { "Short Name", "rpl.shortname",
341 FT_BYTES, BASE_HEX, NULL, 0x0,
342 "RPL BSM Short Name", HFILL }},
344 { "Locate Address", "rpl.laddress",
345 FT_UINT32, BASE_HEX, NULL, 0x0,
346 "RPL Locate Address", HFILL }},
348 { "XFER Address", "rpl.xaddress",
349 FT_UINT32, BASE_HEX, NULL, 0x0,
350 "RPL Transfer Control Address", HFILL }},
352 { "Sequence Number", "rpl.sequence",
353 FT_UINT32, BASE_HEX, NULL, 0x0,
354 "RPL Sequence Number", HFILL }},
356 { "Configuration", "rpl.config",
357 FT_BYTES, BASE_HEX, NULL, 0x0,
358 "RPL Configuration", HFILL }},
360 { "Flags", "rpl.flags",
361 FT_UINT8, BASE_HEX, NULL, 0x0,
362 "RPL Bit Significant Option Flags", HFILL }},
364 { "Data", "rpl.data",
365 FT_BYTES, BASE_HEX, NULL, 0x0,
366 "RPL Binary File Data", HFILL }},
369 FT_BYTES, BASE_HEX, NULL, 0x0,
373 static gint *ett[] = {
391 proto_rpl = proto_register_protocol("Remote Program Load",
393 proto_register_field_array(proto_rpl, hf, array_length(hf));
394 proto_register_subtree_array(ett, array_length(ett));
395 register_dissector("rpl", dissect_rpl, proto_rpl);
399 proto_reg_handoff_rpl(void)
401 dissector_handle_t rpl_handle;
403 data_handle = find_dissector("data");
404 rpl_handle = find_dissector("rpl");
405 dissector_add("llc.dsap", SAP_RPL, rpl_handle);