dump.c (184610) | dump.c (185087) |
---|---|
1/* $FreeBSD: head/usr.sbin/usbconfig/dump.c 184610 2008-11-04 02:31:03Z alfred $ */ | 1/* $FreeBSD: head/usr.sbin/usbconfig/dump.c 185087 2008-11-19 08:56:35Z alfred $ */ |
2/*- 3 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. --- 81 unchanged lines hidden (view full) --- 91 return ("UNKNOWN"); 92 } 93} 94 95static void 96dump_field(struct libusb20_device *pdev, const char *plevel, 97 const char *field, uint32_t value) 98{ | 2/*- 3 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. --- 81 unchanged lines hidden (view full) --- 91 return ("UNKNOWN"); 92 } 93} 94 95static void 96dump_field(struct libusb20_device *pdev, const char *plevel, 97 const char *field, uint32_t value) 98{ |
99 struct LIBUSB20_CONTROL_SETUP_DECODED req; 100 uint16_t lang_id; 101 uint8_t index; | |
102 uint8_t temp_string[256]; 103 104 printf("%s%s = 0x%04x ", plevel, field, value); 105 106 if ((field[0] != 'i') || (field[1] == 'd')) { 107 printf("\n"); 108 return; 109 } 110 if (value == 0) { | 99 uint8_t temp_string[256]; 100 101 printf("%s%s = 0x%04x ", plevel, field, value); 102 103 if ((field[0] != 'i') || (field[1] == 'd')) { 104 printf("\n"); 105 return; 106 } 107 if (value == 0) { |
111 printf(" <no string> \n"); | 108 printf(" |
112 return; 113 } | 109 return; 110 } |
114 LIBUSB20_INIT(LIBUSB20_CONTROL_SETUP, &req); 115 116 lang_id = 0; 117 index = 0; 118 119 req.bmRequestType = 120 LIBUSB20_REQUEST_TYPE_STANDARD | 121 LIBUSB20_RECIPIENT_DEVICE | 122 LIBUSB20_ENDPOINT_IN; 123 req.bRequest = LIBUSB20_REQUEST_GET_DESCRIPTOR; 124 req.wValue = (256 * LIBUSB20_DT_STRING) | index; 125 req.wIndex = lang_id; 126 req.wLength = 4; /* bytes */ 127 128 if (libusb20_dev_request_sync(pdev, &req, 129 temp_string, NULL, 1000, 0)) { 130 goto done; | 111 if (libusb20_dev_req_string_simple_sync(pdev, value, 112 temp_string, sizeof(temp_string))) { 113 printf(" <retrieving string failed>\n"); 114 return; |
131 } | 115 } |
132 lang_id = temp_string[2] | (temp_string[3] << 8); 133 134 printf(" LangId:0x%04x <", lang_id); 135 136 index = value; 137 138 req.wValue = (256 * LIBUSB20_DT_STRING) | index; 139 req.wIndex = lang_id; 140 req.wLength = 4; /* bytes */ 141 142 if (libusb20_dev_request_sync(pdev, &req, 143 temp_string, NULL, 1000, 0)) { 144 printf("ERROR>\n"); 145 goto done; 146 } 147 req.wValue = (256 * LIBUSB20_DT_STRING) | index; 148 req.wIndex = lang_id; 149 req.wLength = temp_string[0]; /* bytes */ 150 151 if (libusb20_dev_request_sync(pdev, &req, 152 temp_string, NULL, 1000, 0)) { 153 printf("ERROR>\n"); 154 goto done; 155 } 156 req.wLength /= 2; 157 158 for (index = 1; index != req.wLength; index++) { 159 if (isprint(temp_string[(2 * index) + 0])) { 160 printf("%c", temp_string[(2 * index) + 0]); 161 } else if (isprint(temp_string[(2 * index) + 1])) { 162 printf("%c", temp_string[(2 * index) + 1]); 163 } else { 164 printf("?"); 165 } 166 } 167 printf(">\n"); 168done: | 116 printf(" <%s>\n", temp_string); |
169 return; 170} 171 172static void 173dump_extra(struct libusb20_me_struct *str, const char *plevel) 174{ 175 const uint8_t *ptr; 176 uint8_t x; --- 62 unchanged lines hidden (view full) --- 239 return; 240} 241 242void 243dump_be_quirk_names(struct libusb20_backend *pbe) 244{ 245 struct libusb20_quirk q; 246 uint16_t x; | 117 return; 118} 119 120static void 121dump_extra(struct libusb20_me_struct *str, const char *plevel) 122{ 123 const uint8_t *ptr; 124 uint8_t x; --- 62 unchanged lines hidden (view full) --- 187 return; 188} 189 190void 191dump_be_quirk_names(struct libusb20_backend *pbe) 192{ 193 struct libusb20_quirk q; 194 uint16_t x; |
247 int err; | 195 int error; |
248 249 memset(&q, 0, sizeof(q)); 250 251 printf("\nDumping list of supported quirks:\n\n"); 252 253 for (x = 0; x != 0xFFFF; x++) { 254 | 196 197 memset(&q, 0, sizeof(q)); 198 199 printf("\nDumping list of supported quirks:\n\n"); 200 201 for (x = 0; x != 0xFFFF; x++) { 202 |
255 err = libusb20_be_get_quirk_name(pbe, x, &q); 256 if (err) { | 203 error = libusb20_be_get_quirk_name(pbe, x, &q); 204 if (error) { |
257 if (x == 0) { 258 printf("No quirk names - maybe the USB quirk " 259 "module has not been loaded.\n"); 260 } 261 break; 262 } 263 if (strcmp(q.quirkname, "UQ_NONE")) 264 printf("%s\n", q.quirkname); 265 } 266 printf("\n"); 267 return; 268} 269 270void 271dump_be_dev_quirks(struct libusb20_backend *pbe) 272{ 273 struct libusb20_quirk q; 274 uint16_t x; | 205 if (x == 0) { 206 printf("No quirk names - maybe the USB quirk " 207 "module has not been loaded.\n"); 208 } 209 break; 210 } 211 if (strcmp(q.quirkname, "UQ_NONE")) 212 printf("%s\n", q.quirkname); 213 } 214 printf("\n"); 215 return; 216} 217 218void 219dump_be_dev_quirks(struct libusb20_backend *pbe) 220{ 221 struct libusb20_quirk q; 222 uint16_t x; |
275 int err; | 223 int error; |
276 277 memset(&q, 0, sizeof(q)); 278 279 printf("\nDumping current device quirks:\n\n"); 280 281 for (x = 0; x != 0xFFFF; x++) { 282 | 224 225 memset(&q, 0, sizeof(q)); 226 227 printf("\nDumping current device quirks:\n\n"); 228 229 for (x = 0; x != 0xFFFF; x++) { 230 |
283 err = libusb20_be_get_dev_quirk(pbe, x, &q); 284 if (err) { | 231 error = libusb20_be_get_dev_quirk(pbe, x, &q); 232 if (error) { |
285 if (x == 0) { 286 printf("No device quirks - maybe the USB quirk " 287 "module has not been loaded.\n"); 288 } 289 break; 290 } 291 if (strcmp(q.quirkname, "UQ_NONE")) { 292 printf("VID=0x%04x PID=0x%04x REVLO=0x%04x " --- 167 unchanged lines hidden --- | 233 if (x == 0) { 234 printf("No device quirks - maybe the USB quirk " 235 "module has not been loaded.\n"); 236 } 237 break; 238 } 239 if (strcmp(q.quirkname, "UQ_NONE")) { 240 printf("VID=0x%04x PID=0x%04x REVLO=0x%04x " --- 167 unchanged lines hidden --- |