unsafe int handle_get_descriptor(Socket clntSocket, USB_DEVICE_DESCRIPTOR desc, CONFIG_HID configuration_hid, StandardDeviceRequest control_req, USBIP_RET_SUBMIT usb_req) { int handled = 0; TraceLog($"handle_get_descriptor {control_req.wValue1} [{control_req.wValue0}]"); if (control_req.wValue1 == 0x1) // Device { TraceLog("Device"); handled = 1; byte [] buf = StructureToBytes(desc); send_usb_req(clntSocket, usb_req, buf, (uint)sizeof(USB_DEVICE_DESCRIPTOR) /*control_req->wLength*/, 0); } if (control_req.wValue1 == 0x2) // configuration { TraceLog("Configuration\n"); handled = 1; byte[] buf = StructureToBytes(configuration_hid); send_usb_req(clntSocket, usb_req, buf, (uint)control_req.wLength, 0); } if (control_req.wValue1 == 0x3) // string { /* * byte [] str = new byte[255]; * int i; * for (i = 0; i < (*strings[control_req->wValue0] / 2) - 1; i++) * str[i] = strings[control_req->wValue0][i * 2 + 2]; * Console.WriteLine("String (%s)\n", str); * handled = 1; * send_usb_req(clntSocket, usb_req, (char*)strings[control_req->wValue0], *strings[control_req->wValue0], 0); */ } if (control_req.wValue1 == 0x6) // qualifier { TraceLog("Qualifier"); handled = 1; byte[] buf = StructureToBytes(dev_qua); send_usb_req(clntSocket, usb_req, buf, (uint)control_req.wLength, 0); } if (control_req.wValue1 == 0xA) // config status ??? { TraceLog("Unknow"); handled = 1; send_usb_req(clntSocket, usb_req, null, 0, 1); } return(handled); }
public Usbip(USB_DEVICE_DESCRIPTOR desc, CONFIG_HID configuration_hid, byte [] report_descriptor) { _desc = desc; _configuration_hid = configuration_hid; _report_descriptor = report_descriptor; }