-void hexdump(unsigned char *buf, int len);
-void diff(unsigned char *buf1, unsigned char *buf2, int len);
-
-//unique: 94, bytes: 276, options: 0
-//Vendor: 3fd
-//12 01 00 02 00 00 00 40 fd 03 08 00 00 00 01 02 12 01 00 02 00 00 00 40 fd 03 08 00 00 00 01 02
-//00 01 00 00 00 00 00 00 40 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 40 00 00 00 00 00 00 00
-//03 00 00 00 00 00 00 00 38 45 21 08 38 45 21 08 03 00 00 00 00 00 00 00 38 45 21 08 38 45 21 08
-//4c 45 21 08 00 00 00 00 00 00 00 00 00 00 00 00 4c 45 21 08 00 00 00 00 00 00 00 00 00 00 00 00
-//00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-//00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-//00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-//00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-//00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-//00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-//00 00 00 00 00 00 00 00 09 02 20 00 01 02 00 80 00 00 00 00 00 00 00 00 09 02 20 00 01 02 00 80
-//8c 00 00 00 01 00 00 00 4c 45 21 08 58 45 21 08 8c 00 00 00 01 00 00 00 4c 45 21 08 58 45 21 08
-//01 00 00 00 58 45 21 08 09 04 00 00 02 ff 00 00 01 00 00 00 58 45 21 08 09 04 00 00 02 ff 00 00
-//00 00 00 00 6c 45 21 08 7c 45 21 08 07 05 02 02 00 00 00 00 6c 45 21 08 7c 45 21 08 07 05 02 02
-//00 02 00 00 07 05 86 02 00 02 00 00 02 00 00 00 00 02 00 00 07 05 86 02 00 02 00 00 02 00 00 00
-//00 02 00 00 02 00 00 00 02 00 00 00 00 00 00 00 00 02 00 00 02 00 00 00 02 00 00 00 00 00 00 00
-//86 00 00 00 00 02 00 00 02 00 00 00 01 00 00 00 86 00 00 00 00 02 00 00 02 00 00 00 01 00 00 00
-//00 00 00 00 00 00 00 00
-int usb_deviceinfo(unsigned char *buf) {
- int i,j,k,l;
- int len = 0;
- WDU_CONFIGURATION **pConfigs, **pActiveConfig;
- WDU_INTERFACE **pActiveInterface;
-
- if (buf) {
- struct usb_device_info *udi = (struct usb_device_info*)(buf+len);
-
- udi->Descriptor.bLength = sizeof(WDU_DEVICE_DESCRIPTOR);
- udi->Descriptor.bDescriptorType = usbdevice->descriptor.bDescriptorType;
- udi->Descriptor.bcdUSB = usbdevice->descriptor.bcdUSB;
- udi->Descriptor.bDeviceClass = usbdevice->descriptor.bDeviceClass;
- udi->Descriptor.bDeviceSubClass = usbdevice->descriptor.bDeviceSubClass;
- udi->Descriptor.bDeviceProtocol = usbdevice->descriptor.bDeviceProtocol;
- udi->Descriptor.bMaxPacketSize0 = usbdevice->descriptor.bMaxPacketSize0;
- udi->Descriptor.idVendor = usbdevice->descriptor.idVendor;
- udi->Descriptor.idProduct = usbdevice->descriptor.idProduct;
- udi->Descriptor.bcdDevice = usbdevice->descriptor.bcdDevice;
- udi->Descriptor.iManufacturer = usbdevice->descriptor.iManufacturer;
- udi->Descriptor.iProduct = usbdevice->descriptor.iProduct;
- udi->Descriptor.iSerialNumber = usbdevice->descriptor.iSerialNumber;
- udi->Descriptor.bNumConfigurations = usbdevice->descriptor.bNumConfigurations;
-
- /* TODO: Fix Pipe0! */
- udi->Pipe0.dwNumber = 0x00;
- udi->Pipe0.dwMaximumPacketSize = usbdevice->descriptor.bMaxPacketSize0;
- udi->Pipe0.type = 0;
- udi->Pipe0.direction = 3;
- udi->Pipe0.dwInterval = 0;
-
- pConfigs = &(udi->pConfigs);
- pActiveConfig = &(udi->pActiveConfig);
- pActiveInterface = &(udi->pActiveInterface[0]);
- }
-
- len = sizeof(struct usb_device_info);
-
- for (i=0; i<usbdevice->descriptor.bNumConfigurations; i++)
- {
- struct usb_config_descriptor *conf_desc = &usbdevice->config[i];
- WDU_INTERFACE **pInterfaces;
- WDU_ALTERNATE_SETTING **pAlternateSettings[conf_desc->bNumInterfaces];
- WDU_ALTERNATE_SETTING **pActiveAltSetting[conf_desc->bNumInterfaces];
-
- if (buf) {
- WDU_CONFIGURATION *cfg = (WDU_CONFIGURATION*)(buf+len);
-
- *pConfigs = cfg;
- *pActiveConfig = cfg;
-
- cfg->Descriptor.bLength = conf_desc->bLength;
- cfg->Descriptor.bDescriptorType = conf_desc->bDescriptorType;
- cfg->Descriptor.wTotalLength = conf_desc->wTotalLength;
- cfg->Descriptor.bNumInterfaces = conf_desc->bNumInterfaces;
- cfg->Descriptor.bConfigurationValue = conf_desc->bConfigurationValue;
- cfg->Descriptor.iConfiguration = conf_desc->iConfiguration;
- cfg->Descriptor.bmAttributes = conf_desc->bmAttributes;
- cfg->Descriptor.MaxPower = conf_desc->MaxPower;
-
- cfg->dwNumInterfaces = conf_desc->bNumInterfaces;
-
- pInterfaces = &(cfg->pInterfaces);
- }
- len += sizeof(WDU_CONFIGURATION);
-
- if (buf) {
- *pInterfaces = (WDU_INTERFACE*)(buf+len);
- for (j=0; j<conf_desc->bNumInterfaces; j++) {
- WDU_INTERFACE *iface = (WDU_INTERFACE*)(buf+len);
-
- pActiveInterface[j] = iface;
-
- pAlternateSettings[j] = &(iface->pAlternateSettings);
- iface->dwNumAltSettings = usbdevice->config[i].interface[j].num_altsetting;
- pActiveAltSetting[j] = &(iface->pActiveAltSetting);
-
- len += sizeof(WDU_INTERFACE);
- }
- } else {
- len += sizeof(WDU_INTERFACE) * conf_desc->bNumInterfaces;
- }
-
- for (j=0; j<conf_desc->bNumInterfaces; j++)
- {
- struct usb_interface *interface = &usbdevice->config[i].interface[j];
-
- if (buf) {
- *pAlternateSettings[j] = (WDU_ALTERNATE_SETTING*)(buf+len);
- /* FIXME: */
- *pActiveAltSetting[j] = (WDU_ALTERNATE_SETTING*)(buf+len);
- }
-
- for(k=0; k<interface->num_altsetting; k++)
- {
- unsigned char bNumEndpoints = interface->altsetting[k].bNumEndpoints;
- WDU_ENDPOINT_DESCRIPTOR **pEndpointDescriptors;
- WDU_PIPE_INFO **pPipes;
-
- if (buf) {
- WDU_ALTERNATE_SETTING *altset = (WDU_ALTERNATE_SETTING*)(buf+len);
-
- altset->Descriptor.bLength = interface->altsetting[k].bLength;
- altset->Descriptor.bDescriptorType = interface->altsetting[k].bDescriptorType;
- altset->Descriptor.bInterfaceNumber = interface->altsetting[k].bInterfaceNumber;
- altset->Descriptor.bAlternateSetting = interface->altsetting[k].bAlternateSetting;
- altset->Descriptor.bNumEndpoints = interface->altsetting[k].bNumEndpoints;
- altset->Descriptor.bInterfaceClass = interface->altsetting[k].bInterfaceClass;
- altset->Descriptor.bInterfaceSubClass = interface->altsetting[k].bInterfaceSubClass;
- altset->Descriptor.bInterfaceProtocol = interface->altsetting[k].bInterfaceProtocol;
- altset->Descriptor.iInterface = interface->altsetting[k].iInterface;
- pEndpointDescriptors = &(altset->pEndpointDescriptors);
- pPipes = &(altset->pPipes);