-
Notifications
You must be signed in to change notification settings - Fork 16
/
USBAnalyzerResults.cpp
1609 lines (1476 loc) · 53.4 KB
/
USBAnalyzerResults.cpp
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
#include <iostream>
#include <fstream>
#include <algorithm>
#include <stdio.h>
#include <AnalyzerHelpers.h>
#include "USBAnalyzerResults.h"
#include "USBAnalyzer.h"
#include "USBAnalyzerSettings.h"
#include "USBLookupTables.h"
std::string GetCollectionData( U8 data )
{
switch( data )
{
case 0x00:
return "Physical";
case 0x01:
return "Application";
case 0x02:
return "Logical";
case 0x03:
return "Report";
case 0x04:
return "Named Array";
case 0x05:
return "Usage Switch";
case 0x06:
return "Usage Modifier";
}
if( data >= 0x07 && data <= 0x7F )
return "Reserved";
return "Vendor-defined";
}
std::string GetInputData( U8 data1, U8 data2 )
{
std::string retVal;
retVal += data1 & 0x01 ? "Constant" : "Data";
retVal += ',';
retVal += data1 & 0x02 ? "Variable" : "Array";
retVal += ',';
retVal += data1 & 0x04 ? "Relative" : "Absolute";
retVal += ',';
retVal += data1 & 0x08 ? "Wrap" : "No wrap";
retVal += ',';
retVal += data1 & 0x10 ? "Non Linear" : "Linear";
retVal += ',';
retVal += data1 & 0x20 ? "No Preferred" : "Preferred State";
retVal += ',';
retVal += data1 & 0x40 ? "Null State" : "No Null position";
retVal += ',';
retVal += data2 & 0x01 ? "Buffered Bytes" : "Bit Field";
return retVal;
}
std::string GetOutputAndFeatureData( U8 data1, U8 data2 )
{
std::string retVal;
retVal += data1 & 0x01 ? "Constant" : "Data";
retVal += ',';
retVal += data1 & 0x02 ? "Variable" : "Array";
retVal += ',';
retVal += data1 & 0x04 ? "Relative" : "Absolute";
retVal += ',';
retVal += data1 & 0x08 ? "Wrap" : "No wrap";
retVal += ',';
retVal += data1 & 0x10 ? "Non Linear" : "Linear";
retVal += ',';
retVal += data1 & 0x20 ? "No Preferred" : "Preferred State";
retVal += ',';
retVal += data1 & 0x40 ? "Null State" : "No Null position";
retVal += ',';
retVal += data1 & 0x80 ? "Volatile" : "Non Volatile";
retVal += ',';
retVal += data2 & 0x01 ? "Buffered Bytes" : "Bit Field";
return retVal;
}
std::string GetHIDItemUsage( U16 usagePage, const U8* pItem )
{
// do we have an extended usage?
if( GetNumHIDItemDataBytes( *pItem ) == 4 )
{
U16 usagePage = *( U16* )( pItem + 3 );
U16 usageID = *( U16* )( pItem + 1 );
return GetHIDUsageName( usagePage, usageID );
}
return GetHIDUsageName( usagePage, *( U16* )( pItem + 1 ) );
}
std::string GetSignedDataValue( const U8* pItem, DisplayBase display_base )
{
int numBytes = GetNumHIDItemDataBytes( pItem[ 0 ] ); // number of data bytes
if( numBytes == 0 )
return "0";
int sVal;
U64 uVal;
if( numBytes == 1 )
{
sVal = S8( pItem[ 1 ] );
uVal = pItem[ 1 ];
}
else if( numBytes == 2 )
{
sVal = *( S16* )( pItem + 1 );
uVal = *( U16* )( pItem + 1 );
}
else
{
sVal = *( S32* )( pItem + 1 );
uVal = *( U32* )( pItem + 1 );
}
std::string retVal;
if( display_base == Decimal )
{
// we can't use AnalyzerHelpers::GetNumberString because we need signed values
char buff[ 32 ];
sprintf( buff, "%i", sVal );
retVal = buff;
}
else
{
retVal = int2str_sal( uVal, display_base, numBytes * 8 );
}
return retVal;
}
std::string GetUnitExponent( U8 data )
{
if( data > 0xF0 )
return "undefined";
const char* results[] = { "0", "1", "2", "3", "4", "5", "6", "7", "-8", "-7", "-6", "-5", "-4", "-3", "-2", "-1" };
return results[ data ];
}
std::string GetUnit( const U8* pItem )
{
U32 val = *( U32* )( pItem + 1 );
U8 firstNibble = val & 0x0f;
// branch by quality measures
if( val & 0x000000f0 ) // Length
{
switch( firstNibble )
{
case 1:
return "Centimeter";
case 2:
return "Radian";
case 3:
return "Inch";
case 4:
return "Degree";
}
}
else if( val & 0x00000f00 )
{ // Mass
if( firstNibble == 1 || firstNibble == 2 )
return "Gram";
else if( firstNibble == 3 || firstNibble == 4 )
return "Slug";
}
else if( val & 0x0000f000 )
{ // Time
if( firstNibble >= 1 || firstNibble <= 4 )
return "Second";
}
else if( val & 0x000f0000 )
{ // Temperature
if( firstNibble == 1 || firstNibble == 2 )
return "Kelvin";
else if( firstNibble == 3 || firstNibble == 4 )
return "Fahrenheit";
}
else if( val & 0x00f00000 )
{ // Current
if( firstNibble >= 1 || firstNibble <= 4 )
return "Ampere";
}
else if( val & 0x0f000000 )
{ // Luminosity
if( firstNibble >= 1 || firstNibble <= 4 )
return "Candela";
}
return "Undefined Unit";
}
USBAnalyzerResults::USBAnalyzerResults( USBAnalyzer* analyzer, USBAnalyzerSettings* settings )
: mSettings( settings ), mAnalyzer( analyzer )
{
}
USBAnalyzerResults::~USBAnalyzerResults()
{
}
double USBAnalyzerResults::GetSampleTime( S64 sample ) const
{
return ( sample - mAnalyzer->GetTriggerSample() ) / double( mAnalyzer->GetSampleRate() );
}
std::string USBAnalyzerResults::GetSampleTimeStr( S64 sample ) const
{
char time_str[ 128 ];
AnalyzerHelpers::GetTimeString( sample, mAnalyzer->GetTriggerSample(), mAnalyzer->GetSampleRate(), time_str, sizeof( time_str ) );
// remove trailing zeros
char* pEnd = strchr( time_str, 0 ) - 1;
while( pEnd > time_str && *pEnd == '0' )
{
*pEnd = '\0';
--pEnd;
}
return time_str;
}
void GetHIDReportDescriptorItemFrameDesc( const Frame& frm, DisplayBase display_base, std::vector<std::string>& results )
{
if( ( frm.mFlags & 0x3F ) == FF_FieldIncomplete )
{
results.push_back( "<item incomplete - see next packet>" );
results.push_back( "<item incomplete>" );
results.push_back( "<incomplete>" );
return;
}
const USBHidRepDescItemFrame& f( static_cast<const USBHidRepDescItemFrame&>( frm ) );
std::string indent( f.GetIndentLevel() * 4, ' ' );
const U8* pItem = f.GetItem();
U8 itemSize = GetNumHIDItemDataBytes( pItem[ 0 ] ) + 1;
// make the raw values (always HEX)
std::string rawVal;
for( int cnt = 0; cnt < itemSize; cnt++ )
{
if( cnt )
rawVal += ' ';
rawVal += int2str_sal( pItem[ cnt ], Hexadecimal, 8 );
}
size_t padding_chars;
if( rawVal.size() >= 15 )
padding_chars = 1;
else
padding_chars = 16 - rawVal.size();
std::string padding( padding_chars, ' ' );
std::string desc;
const U8 firstByte = *pItem;
const U8 tagType = ( firstByte & 0xfc );
const U8 bType = ( firstByte >> 2 ) & 0x03;
const U8 bTag = firstByte >> 4;
if( bType == 0 ) // Main items
{
if( bTag == 0x0A )
desc = "Collection (" + GetCollectionData( pItem[ 1 ] ) + ")";
else if( bTag == 0x0C )
desc = "End Collection";
else if( bTag == 0x08 )
desc = "Input (" + GetInputData( pItem[ 1 ], pItem[ 2 ] ) + ")";
else if( bTag == 0x09 )
desc = "Output (" + GetOutputAndFeatureData( pItem[ 1 ], pItem[ 2 ] ) + ")";
else if( bTag == 0x0B )
desc = "Feature (" + GetOutputAndFeatureData( pItem[ 1 ], pItem[ 2 ] ) + ")";
else
desc = "Unknown Main item. bTag=" + int2str_sal( bTag, display_base, 4 );
}
else if( bType == 1 )
{ // Global
if( bTag == 0x00 )
desc = "Usage Page (" + GetHIDUsagePageName( ( pItem[ 2 ] << 8 ) | pItem[ 1 ] ) + ")";
else if( bTag == 0x01 )
desc = "Logical Minimum (" + GetSignedDataValue( pItem, display_base ) + ")";
else if( bTag == 0x02 )
desc = "Logical Maximum (" + GetSignedDataValue( pItem, display_base ) + ")";
else if( bTag == 0x03 )
desc = "Physical Minimum (" + GetSignedDataValue( pItem, display_base ) + ")";
else if( bTag == 0x04 )
desc = "Physical Maximum (" + GetSignedDataValue( pItem, display_base ) + ")";
else if( bTag == 0x05 )
desc = "Unit Exponent (" + GetUnitExponent( pItem[ 1 ] ) + ")";
else if( bTag == 0x06 )
desc = "Unit (" + GetUnit( pItem ) + ")";
else if( bTag == 0x07 )
desc = "Report Size (" + int2str_sal( pItem[ 1 ], display_base, 8 ) + ")";
else if( bTag == 0x08 )
desc = "Report ID (" + int2str_sal( pItem[ 1 ], display_base, 8 ) + ")";
else if( bTag == 0x09 )
desc = "Report Count (" + int2str_sal( pItem[ 1 ], display_base, 8 ) + ")";
else if( bTag == 0x0A )
desc = "Push";
else if( bTag == 0x0B )
desc = "Pop";
else
desc = "Unknown Global item bTag=" + int2str_sal( bTag, display_base, 4 );
}
else if( bType == 2 )
{ // Local
if( bTag == 0 )
desc = "Usage (" + GetHIDItemUsage( f.GetUsagePage(), pItem ) + ")";
else if( bTag == 1 )
desc = "Usage Minimum (" + GetHIDItemUsage( f.GetUsagePage(), pItem ) + ")";
else if( bTag == 2 )
desc = "Usage Maximum (" + GetHIDItemUsage( f.GetUsagePage(), pItem ) + ")";
else if( bTag == 3 )
desc = "Designator Index (" + int2str_sal( pItem[ 1 ], display_base, 8 ) + ")";
else if( bTag == 4 )
desc = "Designator Minimum (" + int2str_sal( pItem[ 1 ], display_base, 8 ) + ")";
else if( bTag == 5 )
desc = "Designator Maximum (" + int2str_sal( pItem[ 1 ], display_base, 8 ) + ")";
else if( bTag == 7 )
desc = "String Index (" + int2str_sal( pItem[ 1 ], display_base, 8 ) + ")";
else if( bTag == 8 )
desc = "String Minimum (" + int2str_sal( pItem[ 1 ], display_base, 8 ) + ")";
else if( bTag == 9 )
desc = "String Maximum (" + int2str_sal( pItem[ 1 ], display_base, 8 ) + ")";
else if( bTag == 10 )
desc = "Delimiter (" + int2str_sal( pItem[ 1 ], display_base, 8 ) + ")";
else
desc = "Unknown Local item bTag=" + int2str_sal( bTag, display_base, 4 );
}
else
{
desc = "Unknown item type (" + int2str_sal( tagType, Hexadecimal, 8 ) + ")";
}
results.push_back( rawVal + padding + indent + desc );
results.push_back( desc );
results.push_back( rawVal + desc );
results.push_back( rawVal );
}
void GetCtrlTransFrameDesc( const Frame& frm, DisplayBase display_base, std::vector<std::string>& results,
const USBAnalyzerResults::USBStringContainer& stringDescriptors )
{
const USBCtrlTransFieldFrame& f( static_cast<const USBCtrlTransFieldFrame&>( frm ) );
// create value string for the general case
U16 bcnt = f.GetNumBytes();
U32 val = f.GetData();
std::string val_str = int2str_sal( val, display_base, bcnt * 8 );
// handle details for specific fields
std::string desc;
USBCtrlTransFieldType formatter = f.GetFormatter();
if( formatter == Fld_bRequest_Standard )
{
desc = " ";
desc += GetRequestName( val );
}
else if( formatter == Fld_bRequest_Class )
{
desc = " (Class request)";
}
else if( formatter == Fld_bRequest_HID )
{
desc = " ";
desc += GetHIDRequestName( val );
desc += " (HID class)";
}
else if( formatter == Fld_bRequest_CDC )
{
desc = " ";
desc += GetCDCRequestName( val );
desc += " (CDC class)";
}
else if( formatter == Fld_bRequest_Vendor )
{
desc = " (Vendor request)";
}
else if( formatter == Fld_bmRequestType || formatter == Fld_bmRequestType_NoData )
{
desc = " Data direction=";
if( formatter == Fld_bmRequestType_NoData )
desc += "No data";
else
desc += ( val & 0x80 ) ? "Device to host" : "Host to device";
desc += ", Type=";
switch( ( val & 0x60 ) >> 5 )
{
case 0:
desc += "Standard";
break;
case 1:
desc += "Class";
break;
case 2:
desc += "Vendor";
break;
case 3:
desc += "Reserved";
break;
}
desc += ", Recipient=";
switch( val & 0x1f )
{
case 0:
desc += "Device";
break;
case 1:
desc += "Interface";
break;
case 2:
desc += "Endpoint";
break;
case 3:
desc += "Other";
break;
default:
desc += "Reserved";
break;
}
}
else if( formatter == Fld_wValue_Address )
{
desc += " Address=" + int2str_sal( val, display_base, 8 );
}
else if( formatter == Fld_wValue_Descriptor )
{
U8 descriptor = ( val >> 8 ) & 0xff;
U8 index = val & 0xff;
desc = " Descriptor=";
desc += GetDescriptorName( descriptor );
desc += ", Index=" + int2str_sal( index, display_base, 8 );
}
else if( formatter == Fld_wValue_HIDSetIdle )
{
U8 duration = ( val >> 8 ) & 0xff;
U8 reportID = val & 0xff;
desc = " Duration=";
if( duration == 0 )
desc += "Indefinite";
else
desc += int2str( duration ) + "ms";
desc += ", Report ID=" + int2str_sal( reportID, display_base, 8 );
}
else if( formatter == Fld_wValue_HIDGetIdle )
{
desc = " Report ID=" + int2str_sal( val & 0xff, display_base, 8 );
}
else if( formatter == Fld_wValue_HIDSetProtocol )
{
desc = " Protocol=";
if( val == 0 )
desc += "Boot protocol";
else if( val == 1 )
desc += "Report protocol";
else
desc += "<unknown>";
}
else if( formatter == Fld_wValue_HIDGetSetReport )
{
U8 reportType = ( val >> 8 ) & 0xff;
U8 reportID = val & 0xff;
desc = " Report type=";
if( reportType == 1 )
desc += "Input";
else if( reportType == 2 )
desc += "Output";
else if( reportType == 3 )
desc += "Feature";
else
desc += "Reserved";
desc += ", Report ID=" + int2str_sal( reportID, display_base, 8 );
}
else if( formatter == Fld_bDescriptorType )
{
desc = " ";
desc += GetDescriptorName( val & 0xff );
}
else if( formatter == Fld_bDescriptorType_Other )
{
desc = " <unknown>";
}
else if( formatter == Fld_Wchar )
{
desc = std::string( " char='" ) + char( val & 0xff ) + '\'';
}
else if( formatter == Fld_wLANGID )
{
desc = " Language=" + std::string( GetLangName( val ) );
}
else if( formatter == Fld_wVendorId )
{
desc = " Vendor=" + std::string( GetVendorName( val ) );
}
else if( formatter == Fld_bMaxPower )
{
desc += " " + int2str( val * 2 ) + "mA";
}
else if( formatter == Fld_bmAttributes_Endpoint )
{
desc = " ";
switch( val & 0x03 )
{
case 0:
desc += "Control";
break;
case 1:
desc += "Isochronous";
break;
case 2:
desc += "Bulk";
break;
case 3:
desc += "Interrupt";
break;
}
if( ( val & 0x03 ) == 1 ) // if isochronous
{
desc += ", ";
switch( ( val >> 2 ) & 0x03 )
{
case 0:
desc += "No Synchronization";
break;
case 1:
desc += "Asynchronous";
break;
case 2:
desc += "Adaptive";
break;
case 3:
desc += "Synchronous";
break;
}
desc += ", ";
switch( ( val >> 4 ) & 0x03 )
{
case 0:
desc += "Data endpoint";
break;
case 1:
desc += "Feedback endpoint";
break;
case 2:
desc += "Implicit feedback Data endpoint";
break;
case 3:
desc += "Reserved";
break;
}
}
}
else if( formatter == Fld_bmAttributes_Config )
{
desc = ( val & 0x40 ) ? " Self powered" : " Bus powered";
desc += ", Remote wakeup ";
desc += ( val & 0x20 ) ? "supported" : "unsupported";
}
else if( formatter == Fld_bEndpointAddress || formatter == Fld_wIndex_Endpoint )
{
desc = " Endpoint=" + int2str( val & 0x0F );
desc += ", Direction=";
desc += ( val & 0x80 ) == 0 ? "OUT" : "IN";
}
else if( formatter == Fld_BCD )
{
desc = " ";
if( val & 0xf000 )
desc += int2str( val >> 12 );
desc += int2str( ( val >> 8 ) & 0x0f );
desc += ".";
desc += int2str( ( val >> 4 ) & 0x0f );
desc += int2str( val & 0x0f );
}
else if( formatter == Fld_ClassCode )
{
desc = " ";
desc += GetUSBClassName( ( U8 )val );
}
else if( formatter == Fld_HIDSubClass )
{
if( val == 0 )
desc = " None";
else if( val == 1 )
desc = " Boot Interface";
else
desc = " Reserved";
}
else if( formatter == Fld_HIDProtocol )
{
if( val == 0 )
desc = " None";
else if( val == 1 )
desc = " Keyboard";
else if( val == 2 )
desc = " Mouse";
else
desc = " Reserved";
}
else if( formatter == Fld_wIndex_InterfaceNum )
{
desc = " Interface=" + int2str_sal( val & 0xff, display_base, 8 );
}
else if( formatter == Fld_HID_bCountryCode )
{
desc = " Country=";
desc += GetHIDCountryName( ( U8 )val );
}
else if( formatter == Fld_String )
{
if( val != 0 )
{
USBAnalyzerResults::USBStringContainer::const_iterator srch(
stringDescriptors.find( std::make_pair( f.GetAddress(), ( int )val ) ) );
if( srch != stringDescriptors.end() )
desc = " " + srch->second;
}
}
else if( formatter == Fld_CDC_wValue_CommFeatureSelector )
{
if( val == 0 )
desc = " RESERVED";
else if( val == 1 )
desc = " ABSTRACT_STATE";
else if( val == 2 )
desc = " COUNTRY_SETTING";
}
else if( formatter == Fld_CDC_wValue_DisconnectConnect )
{
if( val == 0 )
desc = " Disconnect";
else if( val == 1 )
desc = " Connect";
}
else if( formatter == Fld_CDC_wValue_RelayConfig )
{
if( val == 0 )
desc = " ON_HOOK";
else if( val == 1 )
desc = " OFF_HOOK";
else if( val == 2 )
desc = " SNOOPING";
}
else if( formatter == Fld_CDC_wValue_EnableDisable )
{
if( val == 0xffff )
desc = " Disengage the holding circuit";
else
desc = " Prepare for a pulse-dialing cycle";
}
else if( formatter == Fld_CDC_wValue_Cycles )
{
desc = " Number of cycles";
}
else if( formatter == Fld_CDC_wValue_Timing )
{
U8 hi = ( val >> 8 ) & 0xff;
U8 lo = val & 0xff;
desc = " Break time=" + int2str( hi ) + "ms, make time=" + int2str( lo );
}
else if( formatter == Fld_CDC_wValue_NumberOfRings )
{
desc = " Number of rings";
}
else if( formatter == Fld_CDC_wValue_ControlSignalBitmap )
{
desc = ( val & 2 ) ? " Activate carrier" : " Deactivate carrier";
desc += ( val & 1 ) ? ", DTE Present" : ", DTE Not Present";
}
else if( formatter == Fld_CDC_wValue_DurationOfBreak )
{
if( val == 0xffff )
desc = " Break until receive SEND_BREAK with wValue of 0";
else
desc = " Duration of break " + int2str( val ) + "ms";
}
else if( formatter == Fld_CDC_wValue_OperationParms || formatter == Fld_CDC_OperationMode )
{
if( val == 0 )
desc = " Simple Mode";
else if( val == 1 )
desc = " Standalone Mode";
else if( val == 2 )
desc = " Host Centric Mode";
}
else if( formatter == Fld_CDC_wValue_LineStateChange )
{
if( val == 0 )
desc = " Drop the active call on the line.";
else if( val == 1 )
desc = " Start a new call on the line.";
else if( val == 2 )
desc = " Apply ringing to the line.";
else if( val == 3 )
desc = " Remove ringing from the line.";
else if( val == 4 )
desc = " Switch to a specific call on the line.";
}
else if( formatter == Fld_CDC_wValue_UnitParameterStructure )
{
desc = " bEntityId=" + int2str_sal( val & 0xff, display_base, 8 );
desc += ", bParameterIndex=" + int2str_sal( val >> 8, display_base, 8 );
}
else if( formatter == Fld_CDC_wValue_NumberOfFilters )
{
desc = " Number of filters";
}
else if( formatter == Fld_CDC_wValue_FilterNumber )
{
desc = " Filter number";
}
else if( formatter == Fld_CDC_wValue_PacketFilterBitmap )
{
desc = " PACKET_TYPE_MULTICAST=";
desc += ( ( val & 0x10 ) ? "1" : "0" );
desc += ", PACKET_TYPE_BROADCAST=";
desc += ( ( val & 0x08 ) ? "1" : "0" );
desc += ", PACKET_TYPE_DIRECTED=";
desc += ( ( val & 0x04 ) ? "1" : "0" );
desc += ", PACKET_TYPE_ALL_MULTICAST=";
desc += ( ( val & 0x02 ) ? "1" : "0" );
desc += ", PACKET_TYPE_PROMISCUOUS=";
desc += ( ( val & 0x01 ) ? "1" : "0" );
}
else if( formatter == Fld_CDC_wValue_EthFeatureSelector )
{
desc = " ";
desc += GetCDCEthFeatureSelectorName( val );
}
else if( formatter == Fld_CDC_wValue_ATMDataFormat )
{
if( val == 1 )
desc = " Concatenated ATM cells";
else if( val == 2 )
desc = " ATM header template + concatenated ATM cell payloads";
else if( val == 3 )
desc = " AAL 5 SDU";
}
else if( formatter == Fld_CDC_wValue_ATMFeatureSelector )
{
desc = " ";
desc += GetCDCATMFeatureSelectorName( val );
}
else if( formatter == Fld_CDC_wValue_ATMVCFeatureSelector )
{
if( val == 1 )
desc = " VC_US_CELLS_SENT";
else if( val == 2 )
desc = " VC_DS_CELLS_RECEIVED";
}
else if( formatter == Fld_CDC_DescriptorSubtype )
{
desc = " ";
desc += GetCDCDescriptorSubtypeName( val );
}
else if( formatter == Fld_CDC_bmCapabilities_Call )
{
desc = ( val & 0x02 ) ? " Call management over a Data Class interface" : " Call management only over the Comm Class interface";
desc += ", ";
desc += ( val & 0x01 ) ? "Device handles call management itself" : "Device doesn't handle call management itself";
}
else if( formatter == Fld_CDC_bmCapabilities_AbstractCtrl )
{
desc = " Network_Connection notification ";
desc += ( val & 0x08 ) ? "supported" : "not supported";
desc += "; Send_Break request ";
desc += ( val & 0x04 ) ? "supported" : "not supported";
desc += "; Set_Line_Coding, Set_Control_Line_State, Get_Line_Coding and the notification Serial_State ";
desc += ( val & 0x02 ) ? "supported" : "not supported";
desc += "; Set_Comm_Feature, Clear_Comm_Feature and Get_Comm_Feature ";
desc += ( val & 0x01 ) ? "supported" : "not supported";
}
else if( formatter == Fld_CDC_bmCapabilities_DataLine )
{
if( val & 0x04 )
desc = "Device requires extra Pulse_Setup request during pulse dialing sequence to disengage holding circuit";
if( val & 0x02 )
desc +=
( desc.empty() ? "" : "; " ) +
std::string(
"Device supports the request combination of Set_Aux_Line_State, Ring_Aux_Jack, and notification Aux_Jack_Hook_State" );
if( val & 0x01 )
desc += ( desc.empty() ? "" : "; " ) +
std::string( "Device supports the request combination of Pulse_Setup, Send_Pulse, and Set_Pulse_Time" );
if( !desc.empty() )
desc = " " + desc;
}
else if( formatter == Fld_CDC_bRingerVolSteps )
{
desc = " ";
if( val == 0 )
desc += "256 discrete volume steps";
else
desc = int2str( val ) + " discrete volume steps";
}
else if( formatter == Fld_CDC_bmCapabilities_TelOpModes )
{
desc = ( val & 0x04 ) ? " Supports Computer Centric mode" : " Does not support Computer Centric mode";
desc += "; ";
desc += ( val & 0x02 ) ? "Supports Standalone mode" : "Does not support Standalone mode";
desc += "; ";
desc += ( val & 0x01 ) ? "Supports Simple mode" : "Does not support Simple mode";
}
else if( formatter == Fld_CDC_bmCapabilities_TelCallStateRep )
{
desc = ( val & 0x20 ) ? " Supports line state change notification." : " Does not support line state change notification";
desc += "; ";
desc = ( val & 0x10 ) ? "Can report DTMF digits input remotely over the telephone line"
: "Cannot report DTMF digits input remotely over the telephone line";
desc += "; ";
desc = ( val & 0x08 ) ? "Reports only incoming ringing" : "Reports incoming distinctive ringing patterns";
desc += "; ";
desc += ( val & 0x04 ) ? "Reports caller ID information" : "Does not report caller ID";
desc += "; ";
desc += ( val & 0x02 ) ? "Reports ringback, busy, and fast busy states." : "Reports only dialing state";
desc += "; ";
desc += ( val & 0x01 ) ? "Reports interrupted dialtone in addition to normal dialtone" : "Reports only dialtone";
}
else if( formatter == Fld_CDC_bmOptions )
{
desc = ( val & 0x01 ) ? " Wrapper used" : " No wrapper used";
}
else if( formatter == Fld_CDC_bPhysicalInterface )
{
if( val == 0 )
desc = " None";
else if( val == 1 )
desc = " ISDN";
else if( val >= 2 && val <= 200 )
desc = " RESERVED";
else
desc = " Vendor specific";
}
else if( formatter == Fld_CDC_bProtocol )
{
if( val == 0x00 )
desc = " No class specific protocol required";
else if( val == 0x30 )
desc = " Physical interface protocol for ISDN BRI";
else if( val == 0x31 )
desc = " HDLC";
else if( val == 0x32 )
desc = " Transparent";
else if( val == 0x50 )
desc = " Management protocol for Q.921 data link protocol";
else if( val == 0x51 )
desc = " Data link protocol for Q.931";
else if( val == 0x52 )
desc = " TEI-multiplexor for Q.921 data link protocol";
else if( val == 0x90 )
desc = " Data compression procedures";
else if( val == 0x91 )
desc = " Euro-ISDN protocol control";
else if( val == 0x92 )
desc = " V.24 rate adaptation to ISDN";
else if( val == 0x93 )
desc = " CAPI Commands";
else if( val == 0xfd )
desc = " Host based driver";
else if( val == 0xfe )
desc = " The protocol(s) are described using a Protocol Unit Functional Descriptors on Communication Class Interface.";
else if( val == 0xff )
desc = " Vendor-specific";
else
desc = " RESERVED";
}
else if( formatter == Fld_CDC_bmCapabilities_MultiChannel )
{
if( val & 0x04 )
desc = "Device supports the request Set_Unit_Parameter";
if( val & 0x02 )
desc += ( desc.empty() ? "" : "; " ) + std::string( "Device supports the request Clear_Unit_Parameter" );
if( val & 0x01 )
desc += ( desc.empty() ? "" : "; " ) + std::string( "Device stores Unit parameters in non-volatile memory" );
if( !desc.empty() )
desc = " " + desc;
}
else if( formatter == Fld_CDC_bmCapabilities_CAPIControl )
{
if( val & 0x01 )
desc = " Device is an Intelligent CAPI device";
else
desc = " Device is an Simple CAPI device";
}
else if( formatter == Fld_CDC_bmEthernetStatistics )
{
if( val & 0x00000001 )
desc = "XMIT_OK";
if( val & 0x00000002 )
desc += ( desc.empty() ? "" : ", " ) + std::string( "RVC_OK" );
if( val & 0x00000004 )
desc += ( desc.empty() ? "" : ", " ) + std::string( "XMIT_ERROR" );
if( val & 0x00000008 )
desc += ( desc.empty() ? "" : ", " ) + std::string( "RCV_ERROR" );
if( val & 0x00000010 )
desc += ( desc.empty() ? "" : ", " ) + std::string( "RCV_NO_BUFFER" );
if( val & 0x00000020 )
desc += ( desc.empty() ? "" : ", " ) + std::string( "DIRECTED_BYTES_XMIT" );
if( val & 0x00000040 )
desc += ( desc.empty() ? "" : ", " ) + std::string( "DIRECTED_FRAMES_XMIT" );
if( val & 0x00000080 )
desc += ( desc.empty() ? "" : ", " ) + std::string( "MULTICAST_BYTES_XMIT" );
if( val & 0x00000100 )
desc += ( desc.empty() ? "" : ", " ) + std::string( "MULTICAST_FRAMES_XMIT" );
if( val & 0x00000200 )
desc += ( desc.empty() ? "" : ", " ) + std::string( "BROADCAST_BYTES_XMIT" );
if( val & 0x00000400 )
desc += ( desc.empty() ? "" : ", " ) + std::string( "BROADCAST_FRAMES_XMIT" );
if( val & 0x00000800 )
desc += ( desc.empty() ? "" : ", " ) + std::string( "DIRECTED_BYTES_RCV" );
if( val & 0x00001000 )
desc += ( desc.empty() ? "" : ", " ) + std::string( "DIRECTED_FRAMES_RCV" );
if( val & 0x00002000 )
desc += ( desc.empty() ? "" : ", " ) + std::string( "MULTICAST_BYTES_RCV" );
if( val & 0x00004000 )
desc += ( desc.empty() ? "" : ", " ) + std::string( "MULTICAST_FRAMES_RCV" );
if( val & 0x00008000 )
desc += ( desc.empty() ? "" : ", " ) + std::string( "BROADCAST_BYTES_RCV" );
if( val & 0x00010000 )
desc += ( desc.empty() ? "" : ", " ) + std::string( "BROADCAST_FRAMES_RCV" );
if( val & 0x00020000 )
desc += ( desc.empty() ? "" : ", " ) + std::string( "RCV_CRC_ERROR" );
if( val & 0x00040000 )
desc += ( desc.empty() ? "" : ", " ) + std::string( "TRANSMIT_QUEUE_LENGTH" );
if( val & 0x00080000 )
desc += ( desc.empty() ? "" : ", " ) + std::string( "RCV_ERROR_ALIGNMENT" );
if( val & 0x00100000 )
desc += ( desc.empty() ? "" : ", " ) + std::string( "XMIT_ONE_COLLISION" );
if( val & 0x00200000 )
desc += ( desc.empty() ? "" : ", " ) + std::string( "XMIT_MORE_COLLISIONS" );
if( val & 0x00400000 )
desc += ( desc.empty() ? "" : ", " ) + std::string( "XMIT_DEFERRED" );
if( val & 0x00800000 )
desc += ( desc.empty() ? "" : ", " ) + std::string( "XMIT_MAX_COLLISIONS" );
if( val & 0x01000000 )
desc += ( desc.empty() ? "" : ", " ) + std::string( "RCV_OVERRUN" );
if( val & 0x02000000 )
desc += ( desc.empty() ? "" : ", " ) + std::string( "XMIT_UNDERRUN" );
if( val & 0x04000000 )
desc += ( desc.empty() ? "" : ", " ) + std::string( "XMIT_HEARTBEAT_FAILURE" );
if( val & 0x08000000 )
desc += ( desc.empty() ? "" : ", " ) + std::string( "XMIT_TIMES_CRS_LOST" );
if( val & 0x10000000 )
desc += ( desc.empty() ? "" : ", " ) + std::string( "XMIT_LATE_COLLISIONS" );
if( !desc.empty() )
desc = " " + desc;
}
else if( formatter == Fld_CDC_wNumberMCFilters )
{
desc = " Number of multicase filters=" + int2str( val & 0x7fff ) + "; ";
if( val & 0x8000 )
desc += "The device uses imperfect multicast address filtering (hashing)";
else
desc += "The device performs perfect multicast address filtering (no hashing)";
}
else if( formatter == Fld_CDC_bmDataCapabilities )
{
if( val & 0x08 )
desc = "Type 3 - AAL5 SDU";
if( val & 0x04 )