Date: Wed, 19 Nov 2014 08:55:08 +0000 (UTC) From: Hans Petter Selasky <hselasky@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r274701 - stable/9/usr.sbin/usbconfig Message-ID: <201411190855.sAJ8t83Z099751@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: hselasky Date: Wed Nov 19 08:55:07 2014 New Revision: 274701 URL: https://svnweb.freebsd.org/changeset/base/274701 Log: MFC r274435: Decode more fields when dumping USB descriptors. - Some minor style changes while at it. Modified: stable/9/usr.sbin/usbconfig/dump.c Directory Properties: stable/9/usr.sbin/ (props changed) Modified: stable/9/usr.sbin/usbconfig/dump.c ============================================================================== --- stable/9/usr.sbin/usbconfig/dump.c Wed Nov 19 08:51:15 2014 (r274700) +++ stable/9/usr.sbin/usbconfig/dump.c Wed Nov 19 08:55:07 2014 (r274701) @@ -110,7 +110,6 @@ dump_field(struct libusb20_device *pdev, printf(" <OUT>\n"); return; } - if (strcmp(field, "bmAttributes") == 0) { switch (value & 0x03) { case 0: @@ -142,7 +141,6 @@ dump_field(struct libusb20_device *pdev, return; } } - if ((field[0] == 'i') && (field[1] != 'd')) { /* Indirect String Descriptor */ if (value == 0) { @@ -157,7 +155,84 @@ dump_field(struct libusb20_device *pdev, 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"); } @@ -390,8 +465,8 @@ dump_string_by_index(struct libusb20_dev printf("STRING_0x%02x = ", str_index); len = (uint8_t)pbuf[0]; for (n = 0; n != len; n++) { - printf("0x%02x%s", (uint8_t)pbuf[n], - (n != (len-1)) ? ", " : ""); + printf("0x%02x%s", (uint8_t)pbuf[n], + (n != (len - 1)) ? ", " : ""); } printf("\n"); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201411190855.sAJ8t83Z099751>