fixed hid devices attach
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
+14
-23
@@ -408,30 +408,21 @@ func (s *Server) handleCmdSubmit(r io.Reader, hdr *URBHeader, retChan chan<- []b
|
|||||||
}
|
}
|
||||||
|
|
||||||
case bmRequestType == 0x00 && bRequest == 0x09:
|
case bmRequestType == 0x00 && bRequest == 0x09:
|
||||||
// SET_CONFIGURATION — the device resets all endpoint data toggles
|
// SET_CONFIGURATION — do NOT forward to the physical device.
|
||||||
// to DATA0 on SET_CONFIGURATION, but USBDEVFS_CONTROL doesn't update
|
// The device is already configured (we claimed interfaces during Attach).
|
||||||
// the host controller's toggle state. We must manually reset host-side
|
// Sending SET_CONFIGURATION via raw USBDEVFS_CONTROL would reset the
|
||||||
// toggles via USBDEVFS_RESETEP, otherwise data toggle mismatch causes
|
// device's endpoint state without updating the kernel's internal USB
|
||||||
// all non-control transfers (bulk, interrupt) to fail silently.
|
// subsystem, breaking all subsequent SETINTERFACE and SUBMITURB calls
|
||||||
buf := transferBuf
|
// (ESRCH / EHOSTUNREACH).
|
||||||
if buf == nil {
|
// Just reset host-side data toggles to DATA0 (matching the fresh VHCI
|
||||||
buf = make([]byte, 0)
|
// state on the use-side) and return success.
|
||||||
}
|
log.Printf("[usbip-server] SET_CONFIGURATION(%d) intercepted (device already configured), resetting endpoint toggles", wValue)
|
||||||
_, err := s.handle.ControlTransfer(bmRequestType, bRequest, wValue, wIndex, 0, 5000, buf)
|
for epNum := range s.epTypes {
|
||||||
if err != nil {
|
if epNum == 0 {
|
||||||
log.Printf("[usbip-server] SET_CONFIGURATION(%d) failed: %v", wValue, err)
|
continue
|
||||||
status = -32
|
|
||||||
} else {
|
|
||||||
log.Printf("[usbip-server] SET_CONFIGURATION(%d) OK, resetting endpoint toggles", wValue)
|
|
||||||
for epNum := range s.epTypes {
|
|
||||||
if epNum == 0 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
// Reset both OUT and IN directions; ignore errors for
|
|
||||||
// non-existent directions (e.g. endpoint only has IN)
|
|
||||||
s.handle.ResetEndpoint(uint32(epNum))
|
|
||||||
s.handle.ResetEndpoint(uint32(epNum) | 0x80)
|
|
||||||
}
|
}
|
||||||
|
s.handle.ResetEndpoint(uint32(epNum))
|
||||||
|
s.handle.ResetEndpoint(uint32(epNum) | 0x80)
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user