1 /* packet-usbdfu.c
2 * Routines for USB DFU dissection
3 *
4 * Copyright 2014, Michal Labedzki for Tieto Corporation
5 *
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
9 *
10 * SPDX-License-Identifier: GPL-2.0-or-later
11 */
12
13 #include "config.h"
14
15 #include <epan/packet.h>
16 #include <epan/prefs.h>
17 #include <epan/expert.h>
18 #include "packet-usb.h"
19
20 static int proto_usb_dfu = -1;
21
22 static gint hf_setup_command = -1;
23 static gint hf_setup_unused = -1;
24 static gint hf_setup_interface = -1;
25 static gint hf_setup_length = -1;
26 static gint hf_setup_timeout = -1;
27 static gint hf_setup_block_number = -1;
28 static gint hf_response = -1;
29 static gint hf_command_in_frame = -1;
30 static gint hf_state = -1;
31 static gint hf_status = -1;
32 static gint hf_poll_timeout = -1;
33 static gint hf_iString = -1;
34 static gint hf_data = -1;
35 static gint hf_usb_dfu_descriptor = -1;
36 static gint hf_usb_dfu_descriptor_bmAttributes_reserved = -1;
37 static gint hf_usb_dfu_descriptor_bmAttributes_WillDetach = -1;
38 static gint hf_usb_dfu_descriptor_bmAttributes_ManifestationTolerant = -1;
39 static gint hf_usb_dfu_descriptor_bmAttributes_CanUpload = -1;
40 static gint hf_usb_dfu_descriptor_bmAttributes_CanDownload = -1;
41 static gint hf_usb_dfu_descriptor_wDetachTimeOut = -1;
42 static gint hf_usb_dfu_descriptor_wTransferSize = -1;
43 static gint hf_usb_dfu_descriptor_bcdDFUVersion = -1;
44
45 static gint ett_usb_dfu = -1;
46 static gint ett_usb_dfu_descriptor = -1;
47 static gint ett_command = -1;
48
49 static expert_field ei_unexpected_response = EI_INIT;
50 static expert_field ei_unknown_data = EI_INIT;
51 static expert_field ei_unexpected_data = EI_INIT;
52 static expert_field ei_descriptor_invalid_length = EI_INIT;
53 static expert_field ei_invalid_command_for_request_type = EI_INIT;
54
55 static dissector_handle_t usb_dfu_handle;
56
57 static wmem_tree_t *command_info = NULL;
58
59 typedef struct _command_data {
60 guint32 bus_id;
61 guint32 device_address;
62
63 guint16 interface;
64 guint8 command;
65 guint32 command_frame_number;
66 gint32 block_number;
67 } command_data_t;
68
69
70 static const value_string command_vals[] = {
71 { 0x00, "Detach" },
72 { 0x01, "Download" },
73 { 0x02, "Upload" },
74 { 0x03, "Get Status" },
75 { 0x04, "Clear Status" },
76 { 0x05, "Get State" },
77 { 0x06, "Abort" },
78 { 0x00, NULL }
79 };
80 static value_string_ext(command_vals_ext) = VALUE_STRING_EXT_INIT(command_vals);
81
82 static const value_string state_vals[] = {
83 { 0, "appIdle" },
84 { 1, "appDetach" },
85 { 2, "dfuIdle" },
86 { 3, "dfuDownloadSync" },
87 { 4, "dfuDownloadBusy" },
88 { 5, "dfuDownloadIdle" },
89 { 6, "dfuManifestSync" },
90 { 7, "dfuManifest" },
91 { 8, "dfuManifestWaitReset" },
92 { 9, "dfuUploadIdle" },
93 { 10, "dfuError" },
94 { 0x00, NULL }
95 };
96 static value_string_ext(state_vals_ext) = VALUE_STRING_EXT_INIT(state_vals);
97
98 static const value_string status_vals[] = {
99 { 0x00, "OK" },
100 { 0x01, "errTarget" },
101 { 0x02, "errFile" },
102 { 0x03, "errWrite" },
103 { 0x04, "errErase" },
104 { 0x05, "errCheckErased" },
105 { 0x06, "errProg" },
106 { 0x07, "errVerify" },
107 { 0x08, "errAddress" },
108 { 0x09, "errNotDone" },
109 { 0x0A, "errFirmware" },
110 { 0x0B, "errVendor" },
111 { 0x0C, "errUsbReset" },
112 { 0x0D, "errPowerOnReset" },
113 { 0x0E, "errUnknown" },
114 { 0x0F, "errStalledPkt" },
115 { 0x00, NULL }
116 };
117 static value_string_ext(status_vals_ext) = VALUE_STRING_EXT_INIT(status_vals);
118
119 static const value_string descriptor_type_vals[] = {
120 { 0x21, "DFU FUNCTIONAL" },
121 { 0x00, NULL }
122 };
123 static value_string_ext(descriptor_type_vals_ext) = VALUE_STRING_EXT_INIT(descriptor_type_vals);
124
125 void proto_register_usb_dfu(void);
126 void proto_reg_handoff_usb_dfu(void);
127
128
129 static gint
dissect_usb_dfu_descriptor(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,void * data)130 dissect_usb_dfu_descriptor(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
131 {
132 proto_item *main_item;
133 proto_tree *main_tree;
134 proto_item *length_item;
135 gint offset = 0;
136 guint8 descriptor_length;
137 guint8 descriptor_type;
138 usb_conv_info_t *usb_conv_info = (usb_conv_info_t *) data;
139
140 if (!usb_conv_info) return offset;
141
142 if (!(usb_conv_info->interfaceClass == IF_CLASS_APPLICATION_SPECIFIC &&
143 usb_conv_info->interfaceSubclass == 0x01)) return offset;
144
145 descriptor_length = tvb_get_guint8(tvb, offset);
146 descriptor_type = tvb_get_guint8(tvb, offset + 1);
147
148 switch (descriptor_type) {
149 case 0x21:
150 main_item = proto_tree_add_item(tree, hf_usb_dfu_descriptor, tvb, offset, -1, ENC_NA);
151 main_tree = proto_item_add_subtree(main_item, ett_usb_dfu_descriptor);
152
153 proto_item_append_text(main_item, ": %s", val_to_str_ext_const(descriptor_type, &descriptor_type_vals_ext, "Unknown"));
154
155 length_item = dissect_usb_descriptor_header(main_tree, tvb, offset, &descriptor_type_vals_ext);
156 if (descriptor_length != 7 && descriptor_length != 9)
157 expert_add_info(pinfo, length_item, &ei_descriptor_invalid_length);
158 offset += 2;
159
160 proto_tree_add_item(main_tree, hf_usb_dfu_descriptor_bmAttributes_reserved, tvb, offset, 1, ENC_LITTLE_ENDIAN);
161 proto_tree_add_item(main_tree, hf_usb_dfu_descriptor_bmAttributes_WillDetach, tvb, offset, 1, ENC_NA);
162 proto_tree_add_item(main_tree, hf_usb_dfu_descriptor_bmAttributes_ManifestationTolerant, tvb, offset, 1, ENC_NA);
163 proto_tree_add_item(main_tree, hf_usb_dfu_descriptor_bmAttributes_CanUpload, tvb, offset, 1, ENC_NA);
164 proto_tree_add_item(main_tree, hf_usb_dfu_descriptor_bmAttributes_CanDownload, tvb, offset, 1, ENC_NA);
165 offset += 1;
166
167 proto_tree_add_item(main_tree, hf_usb_dfu_descriptor_wDetachTimeOut, tvb, offset, 2, ENC_LITTLE_ENDIAN);
168 offset += 2;
169
170 proto_tree_add_item(main_tree, hf_usb_dfu_descriptor_wTransferSize, tvb, offset, 2, ENC_LITTLE_ENDIAN);
171 offset += 2;
172
173 if (descriptor_length > 7) {
174 proto_tree_add_item(main_tree, hf_usb_dfu_descriptor_bcdDFUVersion, tvb, offset, 2, ENC_LITTLE_ENDIAN);
175 offset += 2;
176 }
177
178 break;
179 }
180
181 return offset;
182 }
183
184 static gint
dissect_usb_dfu(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,void * data)185 dissect_usb_dfu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
186 {
187 proto_item *main_item;
188 proto_tree *main_tree;
189 proto_item *command_item;
190 proto_item *sub_item;
191 proto_tree *command_tree;
192 gint offset = 0;
193 gint p2p_dir_save;
194 guint8 command;
195 gint16 command_response = -1;
196 command_data_t *command_data = NULL;
197 wmem_tree_t *wmem_tree;
198 wmem_tree_key_t key[5];
199 guint32 bus_id;
200 guint32 device_address;
201 guint32 k_bus_id;
202 guint32 k_device_address;
203 guint32 k_frame_number;
204 gint32 block_number = -1;
205 usb_conv_info_t *usb_conv_info = (usb_conv_info_t *)data;
206
207 if (!usb_conv_info) return offset;
208
209 bus_id = usb_conv_info->bus_id;
210 device_address = usb_conv_info->device_address;
211
212 k_bus_id = bus_id;
213 k_device_address = device_address;
214 k_frame_number = pinfo->num;
215
216 key[0].length = 1;
217 key[0].key = &k_bus_id;
218 key[1].length = 1;
219 key[1].key = &k_device_address;
220
221 main_item = proto_tree_add_item(tree, proto_usb_dfu, tvb, offset, -1, ENC_NA);
222 main_tree = proto_item_add_subtree(main_item, ett_usb_dfu);
223
224 col_set_str(pinfo->cinfo, COL_PROTOCOL, "USB DFU");
225
226 p2p_dir_save = pinfo->p2p_dir;
227 pinfo->p2p_dir = (usb_conv_info->is_request) ? P2P_DIR_SENT : P2P_DIR_RECV;
228
229 switch (pinfo->p2p_dir) {
230
231 case P2P_DIR_SENT:
232 col_set_str(pinfo->cinfo, COL_INFO, "Sent ");
233 break;
234
235 case P2P_DIR_RECV:
236 col_set_str(pinfo->cinfo, COL_INFO, "Rcvd ");
237 break;
238
239 default:
240 col_add_fstr(pinfo->cinfo, COL_INFO, "Unknown direction ");
241 break;
242 }
243
244 if (usb_conv_info->is_setup) {
245 guint16 interface;
246
247 command_item = proto_tree_add_item(main_tree, hf_setup_command, tvb, offset, 1, ENC_LITTLE_ENDIAN);
248 command = tvb_get_guint8(tvb, offset);
249
250 if (!((usb_conv_info->setup_requesttype == 0x21 && (command == 0x00 || command == 0x01 || command == 0x04 || command == 0x06)) ||
251 (usb_conv_info->setup_requesttype == 0xa1 && (command == 0x02 || command == 0x03 || command == 0x05))))
252 expert_add_info(pinfo, command_item, &ei_invalid_command_for_request_type);
253 offset += 1;
254
255 col_append_fstr(pinfo->cinfo, COL_INFO, "Command: %s",
256 val_to_str_ext_const(command, &command_vals_ext, "Unknown"));
257
258 if (command == 0x00) { /* Detach */
259 proto_tree_add_item(main_tree, hf_setup_timeout, tvb, offset, 2, ENC_LITTLE_ENDIAN);
260 col_append_fstr(pinfo->cinfo, COL_INFO, " Timeout=%u", tvb_get_letohs(tvb, offset));
261 } else if (command == 0x01 || command == 0x02) { /* Download || Upload */
262 proto_tree_add_item(main_tree, hf_setup_block_number, tvb, offset, 2, ENC_LITTLE_ENDIAN);
263 col_append_fstr(pinfo->cinfo, COL_INFO, " Block Number=%u", tvb_get_letohs(tvb, offset));
264 block_number = tvb_get_letohs(tvb, offset);
265 } else {
266 proto_tree_add_item(main_tree, hf_setup_unused, tvb, offset, 2, ENC_LITTLE_ENDIAN);
267 }
268 offset += 2;
269
270 proto_tree_add_item(main_tree, hf_setup_interface, tvb, offset, 2, ENC_LITTLE_ENDIAN);
271 interface = tvb_get_letohs(tvb, offset);
272 offset += 2;
273
274 proto_tree_add_item(main_tree, hf_setup_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
275 offset += 2;
276
277 if (command == 0x01) { /* Download */
278 proto_tree_add_item(main_tree, hf_data, tvb, offset, -1, ENC_NA);
279 offset = tvb_captured_length(tvb);
280 }
281
282 if (tvb_reported_length_remaining(tvb, offset) > 0) {
283 proto_tree_add_expert(main_tree, pinfo, &ei_unexpected_data, tvb, offset, tvb_captured_length_remaining(tvb, offset));
284 offset = tvb_captured_length(tvb);
285 }
286
287 /* Save request info (command_data) */
288 if (!pinfo->fd->visited && command != 21) {
289 key[2].length = 1;
290 key[2].key = &k_frame_number;
291 key[3].length = 0;
292 key[3].key = NULL;
293
294 command_data = wmem_new(wmem_file_scope(), command_data_t);
295 command_data->bus_id = bus_id;
296 command_data->device_address = device_address;
297
298 command_data->command = command;
299 command_data->interface = interface;
300 command_data->command_frame_number = pinfo->num;
301 command_data->block_number = block_number;
302
303 wmem_tree_insert32_array(command_info, key, command_data);
304 }
305
306 pinfo->p2p_dir = p2p_dir_save;
307
308 return offset;
309 }
310
311 /* Get request info (command_data) */
312 key[2].length = 0;
313 key[2].key = NULL;
314
315 wmem_tree = (wmem_tree_t *) wmem_tree_lookup32_array(command_info, key);
316 if (wmem_tree) {
317 command_data = (command_data_t *) wmem_tree_lookup32_le(wmem_tree, pinfo->num);
318 if (command_data) {
319 command_response = command_data->command;
320 block_number = command_data->block_number;
321 }
322 }
323
324 if (!command_data) {
325 col_append_str(pinfo->cinfo, COL_INFO, "Response: Unknown");
326
327 proto_tree_add_expert(main_tree, pinfo, &ei_unknown_data, tvb, offset, tvb_captured_length_remaining(tvb, offset));
328
329 pinfo->p2p_dir = p2p_dir_save;
330
331 return tvb_captured_length(tvb);
332 }
333
334 col_append_fstr(pinfo->cinfo, COL_INFO, "Response: %s",
335 val_to_str_ext_const(command_response, &command_vals_ext, "Unknown"));
336
337 command_item = proto_tree_add_uint(main_tree, hf_response, tvb, offset, 0, command_response);
338 command_tree = proto_item_add_subtree(command_item, ett_command);
339 proto_item_set_generated(command_item);
340
341 command_item = proto_tree_add_uint(main_tree, hf_setup_interface, tvb, offset, 0, command_data->interface);
342 proto_item_set_generated(command_item);
343
344 command_item = proto_tree_add_uint(main_tree, hf_command_in_frame, tvb, offset, 0, command_data->command_frame_number);
345 proto_item_set_generated(command_item);
346
347 switch (command_response) {
348 case 0x02: /* Upload */
349 if (block_number != -1) {
350 sub_item = proto_tree_add_uint(main_tree, hf_setup_block_number, tvb, offset, 0, block_number);
351 proto_item_set_generated(sub_item);
352 col_append_fstr(pinfo->cinfo, COL_INFO, " Block Number=%u", block_number);
353 }
354
355 proto_tree_add_item(main_tree, hf_data, tvb, offset, -1, ENC_NA);
356 offset = tvb_captured_length(tvb);
357
358 break;
359 case 0x03: /* Get Status */
360 col_append_fstr(pinfo->cinfo, COL_INFO, " = Status: %s, PollTimeout: %u ms, State: %s",
361 val_to_str_ext_const(tvb_get_guint8(tvb, offset), &status_vals_ext, "Unknown"),
362 tvb_get_letoh24(tvb, offset + 1),
363 val_to_str_ext_const(tvb_get_guint8(tvb, offset + 4), &state_vals_ext, "Unknown"));
364
365 proto_tree_add_item(main_tree, hf_status, tvb, offset, 1, ENC_LITTLE_ENDIAN);
366 offset += 1;
367
368 proto_tree_add_item(main_tree, hf_poll_timeout, tvb, offset, 3, ENC_LITTLE_ENDIAN);
369 offset += 3;
370
371 proto_tree_add_item(main_tree, hf_state, tvb, offset, 1, ENC_LITTLE_ENDIAN);
372 offset += 1;
373
374 proto_tree_add_item(main_tree, hf_iString, tvb, offset, 1, ENC_LITTLE_ENDIAN);
375 offset += 1;
376
377 break;
378 case 0x05: /* Get State */
379 proto_tree_add_item(main_tree, hf_state, tvb, offset, 1, ENC_LITTLE_ENDIAN);
380
381 col_append_fstr(pinfo->cinfo, COL_INFO, " = %s",
382 val_to_str_ext_const(tvb_get_guint8(tvb, offset), &state_vals_ext, "Unknown"));
383
384 offset += 1;
385
386 break;
387 case 0x00: /* Detach */
388 case 0x01: /* Download */
389 case 0x04: /* Clear Status */
390 case 0x06: /* Abort */
391 default:
392 proto_tree_add_expert(command_tree, pinfo, &ei_unexpected_response, tvb, offset, 0);
393 if (tvb_reported_length_remaining(tvb, offset) > 0) {
394 proto_tree_add_expert(main_tree, pinfo, &ei_unknown_data, tvb, offset, -1);
395 offset = tvb_captured_length(tvb);
396 }
397 }
398
399 pinfo->p2p_dir = p2p_dir_save;
400
401 return offset;
402 }
403
404 void
proto_register_usb_dfu(void)405 proto_register_usb_dfu(void)
406 {
407 module_t *module;
408 expert_module_t *expert_module;
409
410 static hf_register_info hf[] = {
411
412 { &hf_setup_command,
413 { "Command", "usbdfu.command",
414 FT_UINT8, BASE_DEC | BASE_EXT_STRING, &command_vals_ext, 0x0,
415 NULL, HFILL }
416 },
417 { &hf_response,
418 { "Response", "usbdfu.response",
419 FT_UINT8, BASE_DEC | BASE_EXT_STRING, &command_vals_ext, 0x0,
420 NULL, HFILL }
421 },
422 { &hf_command_in_frame,
423 { "Command Frame", "usbdfu.command_frame",
424 FT_FRAMENUM, BASE_NONE, NULL, 0x0,
425 NULL, HFILL }
426 },
427 { &hf_setup_unused,
428 { "Unused", "usbdfu.unused",
429 FT_UINT16, BASE_HEX, NULL, 0x0,
430 NULL, HFILL }
431 },
432 { &hf_setup_interface,
433 { "Interface", "usbdfu.interface",
434 FT_UINT16, BASE_DEC, NULL, 0x0,
435 NULL, HFILL }
436 },
437 { &hf_setup_length,
438 { "Length", "usbdfu.length",
439 FT_UINT16, BASE_DEC, NULL, 0x0,
440 NULL, HFILL }
441 },
442 { &hf_setup_block_number,
443 { "Block Number", "usbdfu.block_number",
444 FT_UINT16, BASE_DEC, NULL, 0x0,
445 NULL, HFILL }
446 },
447 { &hf_setup_timeout,
448 { "Timeout", "usbdfu.timeout",
449 FT_UINT16, BASE_DEC, NULL, 0x0,
450 NULL, HFILL }
451 },
452 { &hf_state,
453 { "State", "usbdfu.state",
454 FT_UINT8, BASE_DEC | BASE_EXT_STRING, &state_vals_ext, 0x0,
455 NULL, HFILL }
456 },
457 { &hf_status,
458 { "Status", "usbdfu.status",
459 FT_UINT8, BASE_HEX | BASE_EXT_STRING, &status_vals_ext, 0x0,
460 NULL, HFILL }
461 },
462 { &hf_iString,
463 { "iString", "usbdfu.iString",
464 FT_INT8, BASE_DEC, NULL, 0x0,
465 NULL, HFILL }
466 },
467 { &hf_poll_timeout,
468 { "Poll Timeout", "usbdfu.poll_timeout",
469 FT_UINT24, BASE_DEC, NULL, 0x0,
470 NULL, HFILL }
471 },
472 { &hf_data,
473 { "Data", "usbdfu.data",
474 FT_NONE, BASE_NONE, NULL, 0x0,
475 NULL, HFILL }
476 },
477 { &hf_usb_dfu_descriptor,
478 { "DFU Descriptor", "usbdfu.descriptor",
479 FT_NONE, BASE_NONE, NULL, 0x0,
480 NULL, HFILL }
481 },
482 { &hf_usb_dfu_descriptor_bmAttributes_reserved,
483 { "Reserved", "usbdfu.descriptor.bmAttributes.reserved",
484 FT_UINT8, BASE_HEX, NULL, 0xF0,
485 NULL, HFILL }
486 },
487 { &hf_usb_dfu_descriptor_bmAttributes_WillDetach,
488 { "Will Detach", "usbdfu.descriptor.bmAttributes.WillDetach",
489 FT_BOOLEAN, 8, NULL, 0x08,
490 NULL, HFILL }
491 },
492 { &hf_usb_dfu_descriptor_bmAttributes_ManifestationTolerant,
493 { "Manifestation Tolerant", "usbdfu.descriptor.bmAttributes.ManifestationTolerant",
494 FT_BOOLEAN, 8, NULL, 0x04,
495 NULL, HFILL }
496 },
497 { &hf_usb_dfu_descriptor_bmAttributes_CanUpload,
498 { "Can Upload", "usbdfu.descriptor.bmAttributes.CanUpload",
499 FT_BOOLEAN, 8, NULL, 0x02,
500 NULL, HFILL }
501 },
502 { &hf_usb_dfu_descriptor_bmAttributes_CanDownload,
503 { "Can Download", "usbdfu.descriptor.bmAttributes.CanDownload",
504 FT_BOOLEAN, 8, NULL, 0x01,
505 NULL, HFILL }
506 },
507 { &hf_usb_dfu_descriptor_wDetachTimeOut,
508 { "wDetachTimeOut", "usbdfu.descriptor.wDetachTimeOut",
509 FT_UINT16, BASE_DEC, NULL, 0x0,
510 NULL, HFILL }
511 },
512 { &hf_usb_dfu_descriptor_wTransferSize,
513 { "wTransferSize", "usbdfu.descriptor.wTransferSize",
514 FT_UINT16, BASE_DEC, NULL, 0x0,
515 NULL, HFILL }
516 },
517 { &hf_usb_dfu_descriptor_bcdDFUVersion,
518 { "bcdDFUVersion", "usbdfu.descriptor.bcdDFUVersion",
519 FT_UINT16, BASE_HEX, NULL, 0x0,
520 NULL, HFILL }
521 }
522 };
523
524 static ei_register_info ei[] = {
525 { &ei_unexpected_response, { "usb_dfu.unexpected_response", PI_PROTOCOL, PI_ERROR, "Unexpected response for this command", EXPFILL }},
526 { &ei_unknown_data, { "usb_dfu.unknown_data", PI_PROTOCOL, PI_NOTE, "Unknown data", EXPFILL }},
527 { &ei_unexpected_data, { "usb_dfu.unexpected_data", PI_PROTOCOL, PI_WARN, "Unexpected data", EXPFILL }},
528 { &ei_invalid_command_for_request_type, { "usb_dfu.invalid_command_for_request_type", PI_PROTOCOL, PI_WARN, "Invalid command for this Request Type", EXPFILL }},
529 { &ei_descriptor_invalid_length, { "usb_dfu.descriptor.invalid_length", PI_PROTOCOL, PI_WARN, "Invalid Length", EXPFILL }},
530 };
531
532 static gint *ett[] = {
533 &ett_usb_dfu,
534 &ett_usb_dfu_descriptor,
535 &ett_command
536 };
537
538 command_info = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
539
540 proto_usb_dfu = proto_register_protocol("USB Device Firmware Upgrade ", "USB DFU", "usbdfu");
541 proto_register_field_array(proto_usb_dfu, hf, array_length(hf));
542 proto_register_subtree_array(ett, array_length(ett));
543 usb_dfu_handle = register_dissector("usb_dfu", dissect_usb_dfu, proto_usb_dfu);
544
545 expert_module = expert_register_protocol(proto_usb_dfu);
546 expert_register_field_array(expert_module, ei, array_length(ei));
547
548 module = prefs_register_protocol(proto_usb_dfu, NULL);
549 prefs_register_static_text_preference(module, "version",
550 "USB DFU Specification 1.1",
551 "Version of protocol supported by this dissector.");
552 }
553
554 void
proto_reg_handoff_usb_dfu(void)555 proto_reg_handoff_usb_dfu(void)
556 {
557 dissector_handle_t usf_dfu_descriptor_handle;
558
559 usf_dfu_descriptor_handle = create_dissector_handle(dissect_usb_dfu_descriptor, proto_usb_dfu);
560 dissector_add_uint("usb.descriptor", IF_CLASS_APPLICATION_SPECIFIC, usf_dfu_descriptor_handle);
561
562 dissector_add_uint("usb.product", (0x1d50 << 16) | 0x1db5, usb_dfu_handle); /* IDBG in DFU mode */
563 dissector_add_uint("usb.product", (0x1d50 << 16) | 0x6001, usb_dfu_handle); /* Ubertooth Zero DFU */
564 dissector_add_uint("usb.product", (0x1d50 << 16) | 0x6003, usb_dfu_handle); /* Ubertooth One DFU */
565 dissector_add_uint("usb.product", (0x1d50 << 16) | 0x600f, usb_dfu_handle); /* Paparazzi Lisa/M (DFU) */
566 dissector_add_uint("usb.product", (0x1d50 << 16) | 0x6011, usb_dfu_handle); /* LeoLipo (DFU) */
567 dissector_add_uint("usb.product", (0x1d50 << 16) | 0x6017, usb_dfu_handle); /* Black Magic Debug Probe (DFU) */
568 dissector_add_uint("usb.product", (0x1d50 << 16) | 0x6044, usb_dfu_handle); /* Open Source USB CANBUS converter (DFU Mode) */
569 dissector_add_uint("usb.product", (0x1d50 << 16) | 0x6064, usb_dfu_handle); /* CPC FPGA (DFU) */
570 dissector_add_uint("usb.product", (0x1d50 << 16) | 0x6069, usb_dfu_handle); /* xser (DFU mode) */
571 dissector_add_uint("usb.product", (0x1d50 << 16) | 0x6082, usb_dfu_handle); /* Facecandy *USB DFU loader */
572 dissector_add_uint("usb.product", (0x1d50 << 16) | 0x6084, usb_dfu_handle); /* arcin arcade controller (USB DFU loader) */
573
574 dissector_add_for_decode_as("usb.device", usb_dfu_handle);
575 dissector_add_for_decode_as("usb.protocol", usb_dfu_handle);
576 }
577
578 /*
579 * Editor modelines - https://www.wireshark.org/tools/modelines.html
580 *
581 * Local variables:
582 * c-basic-offset: 4
583 * tab-width: 8
584 * indent-tabs-mode: nil
585 * End:
586 *
587 * vi: set shiftwidth=4 tabstop=8 expandtab:
588 * :indentSize=4:tabSize=8:noTabs=true:
589 */
590