public USBIP_RET_SUBMIT(USBIP_CMD_SUBMIT copy) { //Use the same seqnum, devid, direction, ep, //transfer flags, start_frame, num_packets, interval, urb always 0 command = 3; seqnum = copy.seqnum; devid = copy.devid; direction = copy.direction; ep = copy.ep; status = 0; //actual_length start_frame = 0; number_of_packets = 0; error_count = 0; urb = new UrbSetup(); ReadyToSend = false; }
public USBIP_CMD_SUBMIT(byte[] input) { bool flip = false; command = GTL.ReadInt(input, 0, 4, flip); seqnum = GTL.ReadInt(input, 4, 4, flip); devid = GTL.ReadInt(input, 8, 4, flip); direction = GTL.ReadInt(input, 12, 4, flip); ep = GTL.ReadInt(input, 16, 4, flip); transfer_flags = GTL.ReadInt(input, 20, 4, flip); transfer_buffer_length = GTL.ReadInt(input, 24, 4, flip); start_frame = GTL.ReadInt(input, 28, 4, flip); number_of_packets = GTL.ReadInt(input, 32, 4, flip); interval = GTL.ReadInt(input, 36, 4, flip); urb = new UrbSetup(input, 40); if (input.Length > 48) { _remainingURB = new byte[input.Length - 48]; Array.Copy(input, 48, _remainingURB, 0, _remainingURB.Length); } }
public static USBIP_RET_SUBMIT HandleRequest(ref USBIP_CMD_SUBMIT cmd) { USBIP_RET_SUBMIT submit = new USBIP_RET_SUBMIT(cmd); if (lastURB != null && lastURB.ToBytes().SequenceEqual(cmd.urb.ToBytes())) { //Send interrupt data } else { if (cmd.urb.bmRequestType == 0x80) // Host Request { if (cmd.urb.bRequest == 0x06) { HandleGetDescriptor(ref cmd, ref submit); } else if (cmd.urb.bRequest == 0x00) // Get STATUS { } } else if (cmd.urb.bmRequestType == 0x81) { if (cmd.urb.wValue == 0x22) { //if (!sentHIDreport) { Console.WriteLine("sentHIDreport"); sentHIDreport = true; //Get Descriptor Request HID Report //bmRequestType: 81, bRequest: 6, wValue: 22, wIndex: 0, wLength: C900 if (cmd.urb.wLength == 0xC900) { submit._data = new byte[] { 0x05, 0x01, 0x09, 0x05, 0xa1, 0x01, 0x15, 0x00, 0x25, 0x01, 0x35, 0x00, 0x45, 0x01, 0x75, 0x01, 0x95, 0x0d, 0x05, 0x09, 0x19, 0x01, 0x29, 0x0d, 0x81, 0x02, 0x95, 0x03, 0x81, 0x01, 0x05, 0x01, 0x25, 0x07, 0x46, 0x3b, 0x01, 0x75, 0x04, 0x95, 0x01, 0x65, 0x14, 0x09, 0x39, 0x81, 0x42, 0x65, 0x00, 0x95, 0x01, 0x81, 0x01, 0x26, 0xff, 0x00, 0x46, 0xff, 0x00, 0x09, 0x30, 0x09, 0x31, 0x09, 0x32, 0x09, 0x35, 0x75, 0x08, 0x95, 0x04, 0x81, 0x02, 0x06, 0x00, 0xff, 0x09, 0x20, 0x09, 0x21, 0x09, 0x22, 0x09, 0x23, 0x09, 0x24, 0x09, 0x25, 0x09, 0x26, 0x09, 0x27, 0x09, 0x28, 0x09, 0x29, 0x09, 0x2a, 0x09, 0x2b, 0x95, 0x0c, 0x81, 0x02, 0x0a, 0x21, 0x26, 0x95, 0x08, 0xb1, 0x02, 0x0a, 0x21, 0x26, 0x91, 0x02, 0x26, 0xff, 0x03, 0x46, 0xff, 0x03, 0x09, 0x2c, 0x09, 0x2d, 0x09, 0x2e, 0x09, 0x2f, 0x75, 0x10, 0x95, 0x04, 0x81, 0x02, 0xc0 }; submit.ReadyToSend = true; } //} } } else if (cmd.urb.bmRequestType == 0xA1) { submit.status = -75; submit.ReadyToSend = true; } else if (cmd.urb.bmRequestType == 0x00) { //Data? } else if (cmd.urb.bmRequestType == 0x01) { } else if (cmd.urb.bmRequestType == 0x21) { //SET_IDLE Request submit.ReadyToSend = true; } } lastURB = cmd.urb; if (!submit.ReadyToSend) { if (sentHIDreport) { submit._data = Server.guitar.Read(); //Console.WriteLine(GTL.ByteArrayToString(submit._data, " ")); submit.ReadyToSend = true; } else { Console.WriteLine("bmRequestType: {0:X2} | bRequest: {1:X2}", cmd.urb.bmRequestType, cmd.urb.bRequest); Console.WriteLine(); } } return(submit); }