usbconfig(8): Sync with FreeBSD (decodes bDeviceClass/bInterfaceClass).
authorSascha Wildner <saw@online.de>
Wed, 31 Dec 2014 03:46:11 +0000 (04:46 +0100)
committerSascha Wildner <saw@online.de>
Wed, 31 Dec 2014 03:48:05 +0000 (04:48 +0100)
usr.sbin/usbconfig/dump.c

index b62697c..a207d22 100644 (file)
@@ -1,4 +1,4 @@
-/* $FreeBSD: head/usr.sbin/usbconfig/dump.c 246789 2013-02-14 12:22:40Z hselasky $ */
+/* $FreeBSD: head/usr.sbin/usbconfig/dump.c 274435 2014-11-12 14:52:44Z hselasky $ */
 /*-
  * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
  *
@@ -110,7 +110,6 @@ dump_field(struct libusb20_device *pdev, const char *plevel,
                                printf(" <OUT>\n");
                        return;
                }
-
                if (strcmp(field, "bmAttributes") == 0) {
                        switch (value & 0x03) {
                        case 0:
@@ -142,7 +141,6 @@ dump_field(struct libusb20_device *pdev, const char *plevel,
                        return;
                }
        }
-
        if ((field[0] == 'i') && (field[1] != 'd')) {
                /* Indirect String Descriptor */
                if (value == 0) {
@@ -157,7 +155,84 @@ dump_field(struct libusb20_device *pdev, const char *plevel,
                printf(" <%s>\n", temp_string);
                return;
        }
+       if (strlen(plevel) == 2 || strlen(plevel) == 6) {
+
+               /* Device and Interface Descriptor class codes */
+
+               if (strcmp(field, "bInterfaceClass") == 0 ||
+                   strcmp(field, "bDeviceClass") == 0) {
 
+                       switch (value) {
+                       case 0x00:
+                               printf(" <Probed by interface class>\n");
+                               break;
+                       case 0x01:
+                               printf(" <Audio device>\n");
+                               break;
+                       case 0x02:
+                               printf(" <Communication device>\n");
+                               break;
+                       case 0x03:
+                               printf(" <HID device>\n");
+                               break;
+                       case 0x05:
+                               printf(" <Physical device>\n");
+                               break;
+                       case 0x06:
+                               printf(" <Still imaging>\n");
+                               break;
+                       case 0x07:
+                               printf(" <Printer device>\n");
+                               break;
+                       case 0x08:
+                               printf(" <Mass storage>\n");
+                               break;
+                       case 0x09:
+                               printf(" <HUB>\n");
+                               break;
+                       case 0x0A:
+                               printf(" <CDC-data>\n");
+                               break;
+                       case 0x0B:
+                               printf(" <Smart card>\n");
+                               break;
+                       case 0x0D:
+                               printf(" <Content security>\n");
+                               break;
+                       case 0x0E:
+                               printf(" <Video device>\n");
+                               break;
+                       case 0x0F:
+                               printf(" <Personal healthcare>\n");
+                               break;
+                       case 0x10:
+                               printf(" <Audio and video device>\n");
+                               break;
+                       case 0x11:
+                               printf(" <Billboard device>\n");
+                               break;
+                       case 0xDC:
+                               printf(" <Diagnostic device>\n");
+                               break;
+                       case 0xE0:
+                               printf(" <Wireless controller>\n");
+                               break;
+                       case 0xEF:
+                               printf(" <Miscellaneous device>\n");
+                               break;
+                       case 0xFE:
+                               printf(" <Application specific>\n");
+                               break;
+                       case 0xFF:
+                               printf(" <Vendor specific>\n");
+                               break;
+                       default:
+                               printf(" <Unknown>\n");
+                               break;
+                       }
+                       return;
+               }
+       }
        /* No additional information */
        printf("\n");
 }