-
Notifications
You must be signed in to change notification settings - Fork 0
/
proto_t6.c
1034 lines (938 loc) · 43.1 KB
/
proto_t6.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* proto_t6.c - Wireshark dissector for MCT's Trigger 6 protocol.
* Copyright (C) 2023 Forest Crossman <cyrozap@gmail.com>
*
* 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, see <https://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <epan/dissectors/packet-usb.h>
#include <epan/packet.h>
#include <epan/proto.h>
#include <epan/reassemble.h>
#include "proto_t6.h"
static const int CTRL_BREQ_OFFSET = 0;
static const int CTRL_WVAL_OFFSET = 1;
static const int CTRL_WIDX_OFFSET = 3;
static const int CTRL_WLEN_OFFSET = 5;
static const int CTRL_SETUP_DATA_OFFSET = 7;
typedef enum {
SELECTOR,
FRAGMENT,
} frame_type;
typedef struct selector_info_s {
guint32 frame_num;
uint32_t session_num;
uint32_t payload_len;
uint32_t dest_addr;
uint32_t frag_len;
uint32_t frag_offset;
} selector_info_t;
typedef struct frame_info_s {
frame_type type;
selector_info_t * selector_info;
uint32_t payload_len_remaining;
uint32_t frag_len_remaining;
} frame_info_t;
typedef struct session_conv_info_s {
frame_info_t * last_frame;
} session_conv_info_t;
typedef struct bulk_conv_info_s {
frame_info_t * last_frame;
wmem_map_t * session_conv_info_by_session_num;
wmem_map_t * frame_info_by_frame_num;
} bulk_conv_info_t;
typedef struct bigger_range_s {
guint nranges;
range_admin_t ranges[2];
} bigger_range_t;
static const uint32_t MCT_USB_VID = 0x0711;
static const uint32_t INSIGNIA_USB_VID = 0x19FF;
static bigger_range_t MCT_USB_PID_RANGE = {
.nranges = 2,
.ranges = {
{ .low = (MCT_USB_VID << 16) | 0x5600, .high = (MCT_USB_VID << 16) | 0x561F },
{ .low = (INSIGNIA_USB_VID << 16) | 0x5600, .high = (INSIGNIA_USB_VID << 16) | 0x561F },
},
};
static const value_string SESSIONS[] = {
{ 0, "Video" },
{ 3, "Audio" },
{ 5, "Firmware update" },
{ 0, NULL },
};
static const value_string INFO_FIELDS[] = {
{ 0, "Hardware Platform" },
{ 1, "Boot Code Version" },
{ 2, "Image Code Version" },
{ 3, "Project Code" },
{ 4, "Vendor Command Version" },
{ 5, "Serial Number" },
{ 0, NULL },
};
static const value_string CONTROL_REQS[] = {
{ 0x12, "Set video mode?" },
{ 0x80, "Get EDID block" },
{ 0x87, "Get connector status?" },
{ 0x89, "Get video modes" },
{ 0xa5, "Get audio descriptor?" },
{ 0xb0, "Get adapter info field" },
{ 0xb1, "Get adapter session info?" },
{ 0xb3, "Get adapter config blob?" },
{ 0, NULL },
};
static const value_string CONF_TYPES[] = {
{ 0x4C414855, "UHAL" },
{ 0x50534944, "DISP" },
{ 0x5F445541, "AUD_" },
{ 0x4F495047, "GPIO" },
{ 0, NULL },
};
static const value_string VIDEO_TYPES[] = {
{ 3, "Type 3" },
{ 4, "Type 4" },
{ 7, "Type 7" },
{ 0, NULL },
};
static const value_string IMAGE_FORMATS[] = {
{ 0x06, "NV12" },
{ 0x09, "BGR24" },
{ 0x0d, "JPEG" },
{ 0, NULL },
};
static dissector_handle_t T6_HANDLE = NULL;
static dissector_handle_t T6_VIDEO_HANDLE = NULL;
static reassembly_table T6_REASSEMBLY_TABLE = { 0 };
static int PROTO_T6 = -1;
static int PROTO_T6_VIDEO = -1;
static int HF_T6_CONTROL_REQ = -1;
static int HF_T6_CONTROL_REQ_WVAL = -1;
static int HF_T6_CONTROL_REQ_WIDX = -1;
static int HF_T6_CONTROL_REQ_WLEN = -1;
static int HF_T6_CONTROL_REQ_UNKNOWN_DATA = -1;
static int HF_T6_CONTROL_REQ_VIDEO_CONN_IDX = -1;
static int HF_T6_CONTROL_REQ_EDID_BYTE_OFFSET = -1;
static int HF_T6_CONTROL_REQ_EDID_BLOCK_DATA = -1;
static int HF_T6_CONTROL_REQ_VIDEO_MODES_BYTE_OFFSET = -1;
static int HF_T6_CONTROL_REQ_VIDEO_MODES_DATA = -1;
static int HF_T6_CONTROL_REQ_VIDEO_MODE = -1;
static int HF_T6_CONTROL_REQ_VIDEO_MODE_PIXEL_CLK_KHZ = -1;
static int HF_T6_CONTROL_REQ_VIDEO_MODE_REFRESH_RATE_HZ = -1;
static int HF_T6_CONTROL_REQ_VIDEO_MODE_LINE_TOTAL_PIXELS = -1;
static int HF_T6_CONTROL_REQ_VIDEO_MODE_LINE_ACTIVE_PIXELS = -1;
static int HF_T6_CONTROL_REQ_VIDEO_MODE_LINE_ACTIVE_PLUS_FRONT_PORCH_PIXELS = -1;
static int HF_T6_CONTROL_REQ_VIDEO_MODE_LINE_SYNC_WIDTH = -1;
static int HF_T6_CONTROL_REQ_VIDEO_MODE_FRAME_TOTAL_LINES = -1;
static int HF_T6_CONTROL_REQ_VIDEO_MODE_FRAME_ACTIVE_LINES = -1;
static int HF_T6_CONTROL_REQ_VIDEO_MODE_FRAME_ACTIVE_PLUS_FRONT_PORCH_LINES = -1;
static int HF_T6_CONTROL_REQ_VIDEO_MODE_FRAME_SYNC_WIDTH = -1;
static int HF_T6_CONTROL_REQ_VIDEO_MODE_UNK_8 = -1;
static int HF_T6_CONTROL_REQ_VIDEO_MODE_UNK_9 = -1;
static int HF_T6_CONTROL_REQ_VIDEO_MODE_UNK_10 = -1;
static int HF_T6_CONTROL_REQ_VIDEO_MODE_SYNC_POLARITY_0 = -1;
static int HF_T6_CONTROL_REQ_VIDEO_MODE_SYNC_POLARITY_1 = -1;
static int HF_T6_CONTROL_REQ_VIDEO_MODE_UNK_11 = -1;
static int HF_T6_CONTROL_REQ_INFO_FIELD_IDX = -1;
static int HF_T6_CONTROL_REQ_INFO_FIELD_HW_PLAT = -1;
static int HF_T6_CONTROL_REQ_INFO_FIELD_BOOT_CODE = -1;
static int HF_T6_CONTROL_REQ_INFO_FIELD_IMAGE_CODE = -1;
static int HF_T6_CONTROL_REQ_INFO_FIELD_PROJECT_CODE = -1;
static int HF_T6_CONTROL_REQ_INFO_FIELD_VENDOR_CMD_VER = -1;
static int HF_T6_CONTROL_REQ_INFO_FIELD_SERIAL = -1;
static int HF_T6_CONTROL_REQ_SESSION_INFO_NUM = -1;
static int HF_T6_CONTROL_REQ_SESSION_INFO_VDEV_VID = -1;
static int HF_T6_CONTROL_REQ_SESSION_INFO_VDEV_PID = -1;
static int HF_T6_CONTROL_REQ_SESSION_INFO_VDEV_NAME = -1;
static int HF_T6_CONTROL_REQ_CONF_INFO_TYPE = -1;
static int HF_T6_CONTROL_REQ_CONF_INFO_SIZE = -1;
static int HF_T6_CONTROL_REQ_CONF_INFO_VDEV_VID = -1;
static int HF_T6_CONTROL_REQ_CONF_INFO_VDEV_PID = -1;
static int HF_T6_CONTROL_REQ_CONF_INFO_VDEV_NAME = -1;
static hf_register_info HF_T6_CONTROL[] = {
{ &HF_T6_CONTROL_REQ,
{ "Request type", "trigger6.control.request",
FT_UINT8, BASE_HEX, VALS(CONTROL_REQS), 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_WVAL,
{ "wValue", "trigger6.control.wValue",
FT_UINT16, BASE_DEC_HEX, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_WIDX,
{ "wIndex", "trigger6.control.wIndex",
FT_UINT16, BASE_DEC_HEX, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_WLEN,
{ "wLength", "trigger6.control.wLength",
FT_UINT16, BASE_DEC_HEX, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_UNKNOWN_DATA,
{ "Unknown data", "trigger6.control.unknown_data",
FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_VIDEO_CONN_IDX,
{ "Video connector index", "trigger6.control.video_connector",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_EDID_BYTE_OFFSET,
{ "EDID byte offset", "trigger6.control.edid.byte_offset",
FT_UINT16, BASE_DEC_HEX, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_EDID_BLOCK_DATA,
{ "EDID block data", "trigger6.control.edid.block_data",
FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_VIDEO_MODES_BYTE_OFFSET,
{ "Video modes byte offset", "trigger6.control.video_modes.byte_offset",
FT_UINT16, BASE_DEC_HEX, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_VIDEO_MODES_DATA,
{ "Video modes data", "trigger6.control.video_modes.data",
FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_VIDEO_MODE,
{ "Video mode data", "trigger6.control.video_modes.video_mode",
FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_PIXEL_CLK_KHZ,
{ "Pixel clock (kHz)", "trigger6.control.video_modes.video_mode.pixel_clk_khz",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_REFRESH_RATE_HZ,
{ "Refresh rate (HZ)", "trigger6.control.video_modes.video_mode.refresh_rate_hz",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_LINE_TOTAL_PIXELS,
{ "Line total pixels", "trigger6.control.video_modes.video_mode.line_total_pixels",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_LINE_ACTIVE_PIXELS,
{ "Line active pixels", "trigger6.control.video_modes.video_mode.line_active_pixels",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_LINE_ACTIVE_PLUS_FRONT_PORCH_PIXELS,
{ "Line active plus front porch pixels", "trigger6.control.video_modes.video_mode.line_active_plus_front_porch_pixels",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_LINE_SYNC_WIDTH,
{ "Line sync width", "trigger6.control.video_modes.video_mode.line_sync_width",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_FRAME_TOTAL_LINES,
{ "Frame total lines", "trigger6.control.video_modes.video_mode.frame_total_lines",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_FRAME_ACTIVE_LINES,
{ "Frame active lines", "trigger6.control.video_modes.video_mode.frame_active_lines",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_FRAME_ACTIVE_PLUS_FRONT_PORCH_LINES,
{ "Frame active plus front porch lines", "trigger6.control.video_modes.video_mode.frame_active_plus_front_porch_lines",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_FRAME_SYNC_WIDTH,
{ "Frame sync width", "trigger6.control.video_modes.video_mode.frame_sync_width",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_UNK_8,
{ "Unknown 8", "trigger6.control.video_modes.video_mode.unk8",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_UNK_9,
{ "Unknown 9", "trigger6.control.video_modes.video_mode.unk9",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_UNK_10,
{ "Unknown 10", "trigger6.control.video_modes.video_mode.unk10",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_SYNC_POLARITY_0,
{ "Sync polarity 0", "trigger6.control.video_modes.video_mode.sync_polarity_0",
FT_BOOLEAN, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_SYNC_POLARITY_1,
{ "Sync polarity 1", "trigger6.control.video_modes.video_mode.sync_polarity_1",
FT_BOOLEAN, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_UNK_11,
{ "Unknown 11", "trigger6.control.video_modes.video_mode.unk11",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_INFO_FIELD_IDX,
{ "Info field", "trigger6.control.info_field.index",
FT_UINT16, BASE_HEX, VALS(INFO_FIELDS), 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_INFO_FIELD_HW_PLAT,
{ "Hardware Platform", "trigger6.control.info_field.hw_plat",
FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_INFO_FIELD_BOOT_CODE,
{ "Boot Code Version", "trigger6.control.info_field.boot_code",
FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_INFO_FIELD_IMAGE_CODE,
{ "Image Code Version", "trigger6.control.info_field.image_code",
FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_INFO_FIELD_PROJECT_CODE,
{ "Project Code", "trigger6.control.info_field.project_code",
FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_INFO_FIELD_VENDOR_CMD_VER,
{ "Vendor Command Version", "trigger6.control.info_field.vendor_cmd_ver",
FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_INFO_FIELD_SERIAL,
{ "Serial Number", "trigger6.control.info_field.serial",
FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_SESSION_INFO_NUM,
{ "Session number", "trigger6.control.session_info.num",
FT_UINT16, BASE_DEC_HEX, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_SESSION_INFO_VDEV_VID,
{ "Virtual device vendor ID", "trigger6.control.session_info.vid",
FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_SESSION_INFO_VDEV_PID,
{ "Virtual device product ID", "trigger6.control.session_info.pid",
FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_SESSION_INFO_VDEV_NAME,
{ "Virtual device name", "trigger6.control.session_info.name",
FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_CONF_INFO_TYPE,
{ "Configuration type", "trigger6.control.conf_info.type",
FT_UINT32, BASE_HEX, VALS(CONF_TYPES), 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_CONF_INFO_SIZE,
{ "Configuration size", "trigger6.control.conf_info.size",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_CONF_INFO_VDEV_VID,
{ "Virtual device vendor ID", "trigger6.control.conf_info.disp.vid",
FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_CONF_INFO_VDEV_PID,
{ "Virtual device product ID", "trigger6.control.conf_info.disp.pid",
FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_CONTROL_REQ_CONF_INFO_VDEV_NAME,
{ "Virtual device name", "trigger6.control.conf_info.disp.name",
FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
};
static int HF_T6_BULK_SESSION_SELECTOR = -1;
static int HF_T6_BULK_SESSION_NUM = -1;
static int HF_T6_BULK_SESSION_PAYLOAD_LEN = -1;
static int HF_T6_BULK_SESSION_PAYLOAD_DEST_ADDR = -1;
static int HF_T6_BULK_SESSION_PAYLOAD_FRAGMENT_LENGTH = -1;
static int HF_T6_BULK_SESSION_PAYLOAD_FRAGMENT_OFFSET = -1;
static int HF_T6_BULK_SESSION_PAYLOAD_DATA = -1;
static hf_register_info HF_T6_BULK[] = {
{ &HF_T6_BULK_SESSION_SELECTOR,
{ "Session selector in", "trigger6.bulk.session.selector_in",
FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_REQUEST), 0x0, NULL, HFILL }
},
{ &HF_T6_BULK_SESSION_NUM,
{ "Session number", "trigger6.bulk.session.num",
FT_UINT32, BASE_DEC, VALS(SESSIONS), 0x0, NULL, HFILL }
},
{ &HF_T6_BULK_SESSION_PAYLOAD_LEN,
{ "Session payload length", "trigger6.bulk.session.payload.len",
FT_UINT32, BASE_DEC_HEX, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_BULK_SESSION_PAYLOAD_DEST_ADDR,
{ "Session payload destination address", "trigger6.bulk.session.payload.dest_addr",
FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_BULK_SESSION_PAYLOAD_FRAGMENT_LENGTH,
{ "Session payload fragment length", "trigger6.bulk.session.payload.frag_len",
FT_UINT32, BASE_DEC_HEX, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_BULK_SESSION_PAYLOAD_FRAGMENT_OFFSET,
{ "Session payload fragment offset", "trigger6.bulk.session.payload.frag_offset",
FT_UINT32, BASE_DEC_HEX, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_BULK_SESSION_PAYLOAD_DATA,
{ "Session payload data", "trigger6.bulk.session.payload.data",
FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
};
static int HF_T6_BULK_FRAGMENTS = -1;
static int HF_T6_BULK_FRAGMENT = -1;
static int HF_T6_BULK_FRAGMENT_OVERLAP = -1;
static int HF_T6_BULK_FRAGMENT_OVERLAP_CONFLICTS = -1;
static int HF_T6_BULK_FRAGMENT_MULTIPLE_TAILS = -1;
static int HF_T6_BULK_FRAGMENT_TOO_LONG_FRAGMENT = -1;
static int HF_T6_BULK_FRAGMENT_ERROR = -1;
static int HF_T6_BULK_FRAGMENT_COUNT = -1;
static int HF_T6_BULK_REASSEMBLED_IN = -1;
static int HF_T6_BULK_REASSEMBLED_LENGTH = -1;
static int ETT_T6_BULK_FRAGMENT = -1;
static int ETT_T6_BULK_FRAGMENTS = -1;
static const fragment_items T6_BULK_FRAG_ITEMS = {
&ETT_T6_BULK_FRAGMENT,
&ETT_T6_BULK_FRAGMENTS,
&HF_T6_BULK_FRAGMENTS,
&HF_T6_BULK_FRAGMENT,
&HF_T6_BULK_FRAGMENT_OVERLAP,
&HF_T6_BULK_FRAGMENT_OVERLAP_CONFLICTS,
&HF_T6_BULK_FRAGMENT_MULTIPLE_TAILS,
&HF_T6_BULK_FRAGMENT_TOO_LONG_FRAGMENT,
&HF_T6_BULK_FRAGMENT_ERROR,
&HF_T6_BULK_FRAGMENT_COUNT,
&HF_T6_BULK_REASSEMBLED_IN,
&HF_T6_BULK_REASSEMBLED_LENGTH,
NULL,
"Payload fragments",
};
static hf_register_info HF_T6_BULK_FRAG[] = {
{ &HF_T6_BULK_FRAGMENTS,
{ "Payload fragments", "trigger6.bulk.session.payload.fragments",
FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL }
},
{ &HF_T6_BULK_FRAGMENT,
{ "Payload fragment", "trigger6.bulk.session.payload.fragment",
FT_FRAMENUM, BASE_NONE, NULL, 0x00, NULL, HFILL }
},
{ &HF_T6_BULK_FRAGMENT_OVERLAP,
{ "Payload fragment overlap", "trigger6.bulk.session.payload.fragment.overlap",
FT_BOOLEAN, 0, NULL, 0x00, NULL, HFILL }
},
{ &HF_T6_BULK_FRAGMENT_OVERLAP_CONFLICTS,
{ "Payload fragment overlapping with conflicting data", "trigger6.bulk.session.payload.fragment.overlap.conflicts",
FT_BOOLEAN, 0, NULL, 0x00, NULL, HFILL }
},
{ &HF_T6_BULK_FRAGMENT_MULTIPLE_TAILS,
{ "Payload has multiple tail fragments", "trigger6.bulk.session.payload.fragment.multiple_tails",
FT_BOOLEAN, 0, NULL, 0x00, NULL, HFILL }
},
{ &HF_T6_BULK_FRAGMENT_TOO_LONG_FRAGMENT,
{ "Payload fragment too long", "trigger6.bulk.session.payload.fragment.too_long_fragment",
FT_BOOLEAN, 0, NULL, 0x00, NULL, HFILL }
},
{ &HF_T6_BULK_FRAGMENT_ERROR,
{ "Payload defragmentation error", "trigger6.bulk.session.payload.fragment.error",
FT_FRAMENUM, BASE_NONE, NULL, 0x00, NULL, HFILL }
},
{ &HF_T6_BULK_FRAGMENT_COUNT,
{ "Payload fragment count", "trigger6.bulk.session.payload.fragment.count",
FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }
},
{ &HF_T6_BULK_REASSEMBLED_IN,
{ "Reassembled in", "trigger6.bulk.session.payload.reassembled.in",
FT_FRAMENUM, BASE_NONE, NULL, 0x00, NULL, HFILL }
},
{ &HF_T6_BULK_REASSEMBLED_LENGTH,
{ "Reassembled length", "trigger6.bulk.session.payload.reassembled.length",
FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }
},
};
static int HF_T6_VIDEO_TYPE = -1;
static int HF_T6_VIDEO_DATA_LEN = -1;
static int HF_T6_VIDEO_SEQ = -1;
static int HF_T6_VIDEO_UNK_3 = -1;
static int HF_T6_VIDEO_UNK_4_0 = -1;
static int HF_T6_VIDEO_UNK_4_1 = -1;
static int HF_T6_VIDEO_UNK_4_2 = -1;
static int HF_T6_VIDEO_UNK_4_3 = -1;
static int HF_T6_VIDEO_UNK_5 = -1;
static int HF_T6_VIDEO_UNK_6 = -1;
static int HF_T6_VIDEO_UNK_7 = -1;
static int HF_T6_VIDEO_IMAGE_FORMAT = -1;
static int HF_T6_VIDEO_UNK_9 = -1;
static int HF_T6_VIDEO_UNK_10 = -1;
static int HF_T6_VIDEO_UNK_11 = -1;
static int HF_T6_VIDEO_DATA = -1;
static hf_register_info HF_T6_VIDEO[] = {
{ &HF_T6_VIDEO_TYPE,
{ "Type", "trigger6.video.type",
FT_UINT32, BASE_DEC, VALS(VIDEO_TYPES), 0x0, NULL, HFILL }
},
{ &HF_T6_VIDEO_DATA_LEN,
{ "Data length", "trigger6.video.data_len",
FT_UINT32, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_VIDEO_SEQ,
{ "Sequence number", "trigger6.video.seq",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_VIDEO_UNK_3,
{ "Unknown 3", "trigger6.video.unk3",
FT_UINT32, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_VIDEO_UNK_4_0,
{ "Top-right corner X", "trigger6.video.type7.x",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_VIDEO_UNK_4_1,
{ "Top-right corner Y", "trigger6.video.type7.y",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_VIDEO_UNK_4_2,
{ "Unknown 4-2", "trigger6.video.unk42",
FT_UINT16, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_VIDEO_UNK_4_3,
{ "Unknown 4-3", "trigger6.video.unk43",
FT_UINT16, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_VIDEO_UNK_5,
{ "Unknown 5", "trigger6.video.unk5",
FT_UINT32, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_VIDEO_UNK_6,
{ "Unknown 6", "trigger6.video.unk6",
FT_UINT32, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_VIDEO_UNK_7,
{ "Unknown 7", "trigger6.video.unk7",
FT_UINT32, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_VIDEO_IMAGE_FORMAT,
{ "Image format", "trigger6.video.format",
FT_UINT32, BASE_HEX_DEC, VALS(IMAGE_FORMATS), 0x0, NULL, HFILL }
},
{ &HF_T6_VIDEO_UNK_9,
{ "Unknown 9", "trigger6.video.unk9",
FT_UINT32, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_VIDEO_UNK_10,
{ "Unknown 10", "trigger6.video.unk10",
FT_UINT32, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_VIDEO_UNK_11,
{ "Unknown 11", "trigger6.video.unk11",
FT_UINT32, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }
},
{ &HF_T6_VIDEO_DATA,
{ "Data", "trigger6.video.data",
FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
};
typedef struct field_sizes_s {
int * hf;
int size;
} field_sizes_t;
static const field_sizes_t video_mode_fields[] = {
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_PIXEL_CLK_KHZ, 4 },
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_REFRESH_RATE_HZ, 2 },
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_LINE_TOTAL_PIXELS, 2 },
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_LINE_ACTIVE_PIXELS, 2 },
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_LINE_ACTIVE_PLUS_FRONT_PORCH_PIXELS, 2 },
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_LINE_SYNC_WIDTH, 2 },
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_FRAME_TOTAL_LINES, 2 },
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_FRAME_ACTIVE_LINES, 2 },
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_FRAME_ACTIVE_PLUS_FRONT_PORCH_LINES, 2 },
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_FRAME_SYNC_WIDTH, 2 },
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_UNK_8, 2 },
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_UNK_9, 2 },
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_UNK_10, 2 },
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_SYNC_POLARITY_0, 1 },
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_SYNC_POLARITY_1, 1 },
{ &HF_T6_CONTROL_REQ_VIDEO_MODE_UNK_11, 2 },
};
static const field_sizes_t video_fields_common[] = {
{ &HF_T6_VIDEO_TYPE, 4 },
{ &HF_T6_VIDEO_DATA_LEN, 4 },
{ &HF_T6_VIDEO_SEQ, 4 },
{ &HF_T6_VIDEO_UNK_3, 4 },
};
static const field_sizes_t video_fields_types34[] = {
{ &HF_T6_VIDEO_UNK_4_2, 2 },
{ &HF_T6_VIDEO_UNK_4_3, 2 },
{ &HF_T6_VIDEO_UNK_5, 4 },
{ &HF_T6_VIDEO_UNK_6, 4 },
{ &HF_T6_VIDEO_UNK_7, 4 },
{ &HF_T6_VIDEO_IMAGE_FORMAT, 4 },
{ &HF_T6_VIDEO_UNK_9, 4 },
{ &HF_T6_VIDEO_UNK_10, 4 },
{ &HF_T6_VIDEO_UNK_11, 4 },
};
static const field_sizes_t video_fields_type7[] = {
{ &HF_T6_VIDEO_UNK_4_0, 2 },
{ &HF_T6_VIDEO_UNK_4_1, 2 },
{ &HF_T6_VIDEO_UNK_4_2, 2 },
{ &HF_T6_VIDEO_UNK_4_3, 2 },
{ &HF_T6_VIDEO_UNK_5, 4 },
{ &HF_T6_VIDEO_UNK_6, 4 },
{ &HF_T6_VIDEO_UNK_7, 4 },
{ &HF_T6_VIDEO_IMAGE_FORMAT, 4 },
{ &HF_T6_VIDEO_UNK_9, 4 },
// { &HF_T6_VIDEO_UNK_10, 4 },
{ &HF_T6_VIDEO_UNK_11, 4 },
};
static int ETT_T6 = -1;
static int ETT_T6_VIDEO_MODES = -1;
static int ETT_T6_VIDEO_MODE = -1;
static int ETT_T6_VIDEO = -1;
static int * const ETT[] = {
&ETT_T6,
&ETT_T6_VIDEO_MODES,
&ETT_T6_VIDEO_MODE,
&ETT_T6_BULK_FRAGMENT,
&ETT_T6_BULK_FRAGMENTS,
&ETT_T6_VIDEO,
};
static int dissect_t6_video(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) {
proto_item * video_tree_item = proto_tree_add_item(tree, PROTO_T6_VIDEO, tvb, 0, -1, ENC_NA);
proto_tree * video_tree = proto_item_add_subtree(video_tree_item, ETT_T6_VIDEO);
int field_offset = 0;
for (int i = 0; i < array_length(video_fields_common); i++) {
proto_tree_add_item(video_tree, *video_fields_common[i].hf, tvb, field_offset, video_fields_common[i].size, ENC_LITTLE_ENDIAN);
field_offset += video_fields_common[i].size;
}
uint32_t type = tvb_get_letohl(tvb, 0);
switch (type) {
case 3:
case 4:
{
for (int i = 0; i < array_length(video_fields_types34); i++) {
proto_tree_add_item(video_tree, *video_fields_types34[i].hf, tvb, field_offset, video_fields_types34[i].size, ENC_LITTLE_ENDIAN);
field_offset += video_fields_types34[i].size;
}
}
break;
case 7:
{
for (int i = 0; i < array_length(video_fields_type7); i++) {
proto_tree_add_item(video_tree, *video_fields_type7[i].hf, tvb, field_offset, video_fields_type7[i].size, ENC_LITTLE_ENDIAN);
field_offset += video_fields_type7[i].size;
}
}
break;
default:
break;
}
uint32_t length = tvb_get_letohl(tvb, 4);
proto_tree_add_item(video_tree, HF_T6_VIDEO_DATA, tvb, 0x30, length, ENC_NA);
return tvb_captured_length(tvb);
}
static int handle_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, usb_conv_info_t *usb_conv_info) {
gboolean in_not_out = usb_conv_info->direction != 0;
gboolean setup_not_completion = usb_conv_info->is_setup;
uint8_t bRequest = usb_conv_info->usb_trans_info->setup.request;
uint16_t wValue = usb_conv_info->usb_trans_info->setup.wValue;
uint16_t wIndex = usb_conv_info->usb_trans_info->setup.wIndex;
uint16_t wLength = usb_conv_info->usb_trans_info->setup.wLength;
if (!in_not_out && !setup_not_completion) {
/* We don't care about completions for OUT requests */
return 0;
}
if (setup_not_completion) {
proto_tree_add_item(tree, HF_T6_CONTROL_REQ, tvb, CTRL_BREQ_OFFSET, 1, ENC_LITTLE_ENDIAN);
} else {
proto_item * it = proto_tree_add_uint(tree, HF_T6_CONTROL_REQ, tvb, 0, 0, bRequest);
proto_item_set_generated(it);
}
switch (bRequest) {
case 0x80:
if (setup_not_completion) {
proto_tree_add_item(tree, HF_T6_CONTROL_REQ_EDID_BYTE_OFFSET, tvb, CTRL_WVAL_OFFSET, 2, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, HF_T6_CONTROL_REQ_VIDEO_CONN_IDX, tvb, CTRL_WIDX_OFFSET, 2, ENC_LITTLE_ENDIAN);
} else {
proto_item_set_generated(proto_tree_add_uint(tree, HF_T6_CONTROL_REQ_EDID_BYTE_OFFSET, tvb, 0, 0, wValue));
proto_item_set_generated(proto_tree_add_uint(tree, HF_T6_CONTROL_REQ_VIDEO_CONN_IDX, tvb, 0, 0, wIndex));
}
break;
case 0x89:
if (setup_not_completion) {
proto_tree_add_item(tree, HF_T6_CONTROL_REQ_VIDEO_CONN_IDX, tvb, CTRL_WVAL_OFFSET, 2, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, HF_T6_CONTROL_REQ_VIDEO_MODES_BYTE_OFFSET, tvb, CTRL_WIDX_OFFSET, 2, ENC_LITTLE_ENDIAN);
} else {
proto_item_set_generated(proto_tree_add_uint(tree, HF_T6_CONTROL_REQ_VIDEO_CONN_IDX, tvb, 0, 0, wValue));
proto_item_set_generated(proto_tree_add_uint(tree, HF_T6_CONTROL_REQ_VIDEO_MODES_BYTE_OFFSET, tvb, 0, 0, wIndex));
}
break;
case 0xb0:
if (setup_not_completion) {
proto_tree_add_item(tree, HF_T6_CONTROL_REQ_INFO_FIELD_IDX, tvb, CTRL_WIDX_OFFSET, 2, ENC_LITTLE_ENDIAN);
} else {
proto_item_set_generated(proto_tree_add_uint(tree, HF_T6_CONTROL_REQ_INFO_FIELD_IDX, tvb, 0, 0, wIndex));
}
break;
case 0xb1:
if (setup_not_completion) {
proto_tree_add_item(tree, HF_T6_CONTROL_REQ_SESSION_INFO_NUM, tvb, CTRL_WIDX_OFFSET, 2, ENC_LITTLE_ENDIAN);
} else {
proto_item_set_generated(proto_tree_add_uint(tree, HF_T6_CONTROL_REQ_SESSION_INFO_NUM, tvb, 0, 0, wIndex));
}
break;
default:
if (setup_not_completion) {
proto_tree_add_item(tree, HF_T6_CONTROL_REQ_WVAL, tvb, CTRL_WVAL_OFFSET, 2, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, HF_T6_CONTROL_REQ_WIDX, tvb, CTRL_WIDX_OFFSET, 2, ENC_LITTLE_ENDIAN);
} else {
proto_item_set_generated(proto_tree_add_uint(tree, HF_T6_CONTROL_REQ_WVAL, tvb, 0, 0, wValue));
proto_item_set_generated(proto_tree_add_uint(tree, HF_T6_CONTROL_REQ_WIDX, tvb, 0, 0, wIndex));
}
break;
}
if (setup_not_completion) {
proto_tree_add_item(tree, HF_T6_CONTROL_REQ_WLEN, tvb, CTRL_WLEN_OFFSET, 2, ENC_LITTLE_ENDIAN);
} else {
proto_item_set_generated(proto_tree_add_uint(tree, HF_T6_CONTROL_REQ_WLEN, tvb, 0, 0, wLength));
}
if (!in_not_out && setup_not_completion) {
/* OUT Setup */
// printf("CONTROL OUT: 0x%02x\n", bRequest);
switch (bRequest) {
case 0x12:
{
int field_offset = 0;
for (int i = 0; i < array_length(video_mode_fields); i++) {
proto_tree_add_item(tree, *video_mode_fields[i].hf, tvb, CTRL_SETUP_DATA_OFFSET+field_offset, video_mode_fields[i].size, ENC_LITTLE_ENDIAN);
field_offset += video_mode_fields[i].size;
}
}
break;
}
} else if (in_not_out && !setup_not_completion) {
/* IN Completion */
switch (bRequest) {
case 0x80:
proto_tree_add_item(tree, HF_T6_CONTROL_REQ_EDID_BLOCK_DATA, tvb, 0, 128, ENC_NA);
break;
case 0x89:
{
proto_item * video_modes_item = proto_tree_add_item(tree, HF_T6_CONTROL_REQ_VIDEO_MODES_DATA, tvb, 0, -1, ENC_NA);
proto_tree * video_modes_tree = proto_item_add_subtree(video_modes_item, ETT_T6_VIDEO_MODES);
for (int offset = 0; offset < tvb_reported_length(tvb); offset += 32) {
proto_item * video_mode_item = proto_tree_add_item(video_modes_tree, HF_T6_CONTROL_REQ_VIDEO_MODE, tvb, offset, 32, ENC_NA);
proto_tree * video_mode_tree = proto_item_add_subtree(video_mode_item, ETT_T6_VIDEO_MODE);
int field_offset = 0;
for (int i = 0; i < array_length(video_mode_fields); i++) {
proto_tree_add_item(video_mode_tree, *video_mode_fields[i].hf, tvb, offset+field_offset, video_mode_fields[i].size, ENC_LITTLE_ENDIAN);
field_offset += video_mode_fields[i].size;
}
}
}
break;
case 0xb0:
switch (wIndex) {
case 0:
proto_tree_add_item(tree, HF_T6_CONTROL_REQ_INFO_FIELD_HW_PLAT, tvb, 0, 4, ENC_LITTLE_ENDIAN);
break;
case 1:
proto_tree_add_item(tree, HF_T6_CONTROL_REQ_INFO_FIELD_BOOT_CODE, tvb, 0, 4, ENC_LITTLE_ENDIAN);
break;
case 2:
proto_tree_add_item(tree, HF_T6_CONTROL_REQ_INFO_FIELD_IMAGE_CODE, tvb, 0, 4, ENC_LITTLE_ENDIAN);
break;
case 3:
proto_tree_add_item(tree, HF_T6_CONTROL_REQ_INFO_FIELD_PROJECT_CODE, tvb, 0, -1, ENC_ASCII);
break;
case 4:
proto_tree_add_item(tree, HF_T6_CONTROL_REQ_INFO_FIELD_VENDOR_CMD_VER, tvb, 0, 4, ENC_LITTLE_ENDIAN);
break;
case 5:
proto_tree_add_item(tree, HF_T6_CONTROL_REQ_INFO_FIELD_SERIAL, tvb, 0, -1, ENC_NA);
break;
default:
proto_tree_add_item(tree, HF_T6_CONTROL_REQ_UNKNOWN_DATA, tvb, 0, -1, ENC_NA);
break;
}
break;
case 0xb1:
proto_tree_add_item(tree, HF_T6_CONTROL_REQ_SESSION_INFO_VDEV_VID, tvb, 0, 2, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, HF_T6_CONTROL_REQ_SESSION_INFO_VDEV_PID, tvb, 2, 2, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, HF_T6_CONTROL_REQ_SESSION_INFO_VDEV_NAME, tvb, 4, 64, ENC_UTF_16 | ENC_LITTLE_ENDIAN);
break;
case 0xb3:
{
uint32_t conf_type = 0;
proto_tree_add_item_ret_uint(tree, HF_T6_CONTROL_REQ_CONF_INFO_TYPE, tvb, 0, 4, ENC_LITTLE_ENDIAN, &conf_type);
proto_tree_add_item(tree, HF_T6_CONTROL_REQ_CONF_INFO_SIZE, tvb, 4, 4, ENC_LITTLE_ENDIAN);
switch (conf_type) {
case 0x50534944:
proto_tree_add_item(tree, HF_T6_CONTROL_REQ_CONF_INFO_VDEV_VID, tvb, 12, 2, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, HF_T6_CONTROL_REQ_CONF_INFO_VDEV_PID, tvb, 14, 2, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, HF_T6_CONTROL_REQ_CONF_INFO_VDEV_NAME, tvb, 16, 64, ENC_UTF_16 | ENC_LITTLE_ENDIAN);
break;
}
}
break;
default:
proto_tree_add_item(tree, HF_T6_CONTROL_REQ_UNKNOWN_DATA, tvb, 0, -1, ENC_NA);
break;
}
}
return tvb_captured_length(tvb);
}
static int handle_bulk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_tree *parent_tree, usb_conv_info_t *usb_conv_info) {
if (usb_conv_info->endpoint == 1 && usb_conv_info->direction) {
/* BULK 1 IN */
} else if (usb_conv_info->endpoint == 2 && !usb_conv_info->direction) {
/* BULK 2 OUT */
conversation_t * conversation = find_or_create_conversation(pinfo);
bulk_conv_info_t * bulk_conv_info = (bulk_conv_info_t *)conversation_get_proto_data(conversation, PROTO_T6);
if (!bulk_conv_info) {
bulk_conv_info = wmem_new(wmem_file_scope(), bulk_conv_info_t);
bulk_conv_info->last_frame = NULL;
bulk_conv_info->session_conv_info_by_session_num = wmem_map_new(wmem_file_scope(), g_direct_hash, g_direct_equal);
bulk_conv_info->frame_info_by_frame_num = wmem_map_new(wmem_file_scope(), g_direct_hash, g_direct_equal);
conversation_add_proto_data(conversation, PROTO_T6, bulk_conv_info);
}
frame_info_t * frame_info = NULL;
if (!PINFO_FD_VISITED(pinfo)) {
if ((bulk_conv_info->last_frame == NULL) || (bulk_conv_info->last_frame->frag_len_remaining == 0)) {
/* Selector */
/* Create new selector info */
selector_info_t * selector_info = wmem_new(wmem_file_scope(), selector_info_t);
selector_info->frame_num = pinfo->num;
selector_info->session_num = tvb_get_letohl(tvb, 0);
selector_info->payload_len = tvb_get_letohl(tvb, 4);
selector_info->dest_addr = tvb_get_letohl(tvb, 8);
selector_info->frag_len = tvb_get_letohl(tvb, 12);
selector_info->frag_offset = tvb_get_letohl(tvb, 16);
/* Create new frame info */
frame_info = wmem_new(wmem_file_scope(), frame_info_t);
frame_info->type = SELECTOR;
frame_info->selector_info = selector_info;
frame_info->payload_len_remaining = selector_info->payload_len - selector_info->frag_offset;
frame_info->frag_len_remaining = selector_info->frag_len;
bulk_conv_info->last_frame = frame_info;
session_conv_info_t * session_conv_info = wmem_map_lookup(bulk_conv_info->session_conv_info_by_session_num, GUINT_TO_POINTER(selector_info->session_num));
if (!session_conv_info) {
session_conv_info = wmem_new(wmem_file_scope(), session_conv_info_t);
}
session_conv_info->last_frame = frame_info;
wmem_map_insert(bulk_conv_info->session_conv_info_by_session_num, GUINT_TO_POINTER(selector_info->session_num), session_conv_info);
wmem_map_insert(bulk_conv_info->frame_info_by_frame_num, GUINT_TO_POINTER(pinfo->num), frame_info);
} else {
/* Fragment */
selector_info_t * selector_info = bulk_conv_info->last_frame->selector_info;
session_conv_info_t * session_conv_info = wmem_map_lookup(bulk_conv_info->session_conv_info_by_session_num, GUINT_TO_POINTER(selector_info->session_num));
if (session_conv_info) {
frame_info_t * last_frame_in_session = session_conv_info->last_frame;
/* Create new frame info */
frame_info = wmem_new(wmem_file_scope(), frame_info_t);
frame_info->type = FRAGMENT;
frame_info->selector_info = selector_info;
frame_info->payload_len_remaining = last_frame_in_session->payload_len_remaining - tvb_reported_length(tvb);
frame_info->frag_len_remaining = last_frame_in_session->frag_len_remaining - tvb_reported_length(tvb);
bulk_conv_info->last_frame = frame_info;
session_conv_info->last_frame = frame_info;
wmem_map_insert(bulk_conv_info->frame_info_by_frame_num, GUINT_TO_POINTER(pinfo->num), frame_info);
}
}
} else {
frame_info = wmem_map_lookup(bulk_conv_info->frame_info_by_frame_num, GUINT_TO_POINTER(pinfo->num));
}
if (!frame_info) {
return 0;
}
if (frame_info->type == SELECTOR) {
/* Selector */
proto_tree_add_item(tree, HF_T6_BULK_SESSION_NUM, tvb, 0, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, HF_T6_BULK_SESSION_PAYLOAD_LEN, tvb, 4, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, HF_T6_BULK_SESSION_PAYLOAD_DEST_ADDR, tvb, 8, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, HF_T6_BULK_SESSION_PAYLOAD_FRAGMENT_LENGTH, tvb, 12, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, HF_T6_BULK_SESSION_PAYLOAD_FRAGMENT_OFFSET, tvb, 16, 4, ENC_LITTLE_ENDIAN);
} else {
/* Fragment */
selector_info_t * selector_info = frame_info->selector_info;
proto_item_set_generated(proto_tree_add_uint(tree, HF_T6_BULK_SESSION_SELECTOR, tvb, 0, 0, selector_info->frame_num));
proto_item_set_generated(proto_tree_add_uint(tree, HF_T6_BULK_SESSION_NUM, tvb, 0, 0, selector_info->session_num));
proto_item_set_generated(proto_tree_add_uint(tree, HF_T6_BULK_SESSION_PAYLOAD_LEN, tvb, 0, 0, selector_info->payload_len));
proto_item_set_generated(proto_tree_add_uint(tree, HF_T6_BULK_SESSION_PAYLOAD_DEST_ADDR, tvb, 0, 0, selector_info->dest_addr));
proto_item_set_generated(proto_tree_add_uint(tree, HF_T6_BULK_SESSION_PAYLOAD_FRAGMENT_LENGTH, tvb, 0, 0, selector_info->frag_len));
proto_item_set_generated(proto_tree_add_uint(tree, HF_T6_BULK_SESSION_PAYLOAD_FRAGMENT_OFFSET, tvb, 0, 0, selector_info->frag_offset));
tvbuff_t * next_tvb = NULL;
if ((selector_info->payload_len > selector_info->frag_len) || (selector_info->frag_len > tvb_reported_length(tvb))) {
/* Fragmented */
pinfo->fragmented = true;
uint32_t calc_frag_offset = selector_info->payload_len - frame_info->payload_len_remaining - tvb_reported_length(tvb);
gboolean more_frags = frame_info->payload_len_remaining > 0;
fragment_head * frag_head = fragment_add_check(&T6_REASSEMBLY_TABLE,
tvb, 0, pinfo, selector_info->session_num, NULL,
calc_frag_offset, tvb_captured_length(tvb), more_frags);
next_tvb = process_reassembled_data(tvb, 0, pinfo, "Reassembled Payload", frag_head, &T6_BULK_FRAG_ITEMS, NULL, tree);
if (frag_head) {
/* Reassembled */
col_append_str(pinfo->cinfo, COL_INFO, " (Payload Reassembled)");
} else {
/* Failed to reassemble. This can happen when a packet captures less data than was reported, which
* seems to be common with captured firmware updates. */
col_append_fstr(pinfo->cinfo, COL_INFO, " (Fragment offset %u)", calc_frag_offset);
}
} else {
/* Not fragmented */
next_tvb = tvb;
}
if (next_tvb) {
switch (selector_info->session_num) {
case 0:
call_dissector(T6_VIDEO_HANDLE, next_tvb, pinfo, parent_tree);
break;
default:
proto_tree_add_item(tree, HF_T6_BULK_SESSION_PAYLOAD_DATA, next_tvb, 0, -1, ENC_NA);
break;
}
}
}
} else {
return 0;
}
return tvb_captured_length(tvb);
}
static int handle_interrupt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, usb_conv_info_t *usb_conv_info) {
/* INTERRUPT IN */
return tvb_captured_length(tvb);
}
static int dissect_t6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) {
usb_conv_info_t * usb_conv_info = (usb_conv_info_t *)data;
proto_item * t6_tree_item = proto_tree_add_item(tree, PROTO_T6, tvb, 0, -1, ENC_NA);
proto_tree * t6_tree = proto_item_add_subtree(t6_tree_item, ETT_T6);
col_set_str(pinfo->cinfo, COL_PROTOCOL, "Trigger 6");
switch (usb_conv_info->endpoint) {
case 0:
return handle_control(tvb, pinfo, t6_tree, usb_conv_info);
case 1:
case 2:
return handle_bulk(tvb, pinfo, t6_tree, tree, usb_conv_info);
case 3:
if (!usb_conv_info->direction) {
return 0;
}
return handle_interrupt(tvb, pinfo, t6_tree, usb_conv_info);
default:
return 0;
};