This commit is contained in:
2026-02-19 16:51:32 +01:00
parent 14a9e87423
commit 54178dce75
5 changed files with 50 additions and 17 deletions
+25 -12
View File
@@ -414,16 +414,11 @@ func (s *Server) handleCmdSubmit(r io.Reader, hdr *URBHeader, retChan chan<- []b
// device's endpoint state without updating the kernel's internal USB
// subsystem, breaking all subsequent SETINTERFACE and SUBMITURB calls
// (ESRCH / EHOSTUNREACH).
// Just reset host-side data toggles to DATA0 (matching the fresh VHCI
// state on the use-side) and return success.
log.Printf("[usbip-server] SET_CONFIGURATION(%d) intercepted (device already configured), resetting endpoint toggles", wValue)
for epNum := range s.epTypes {
if epNum == 0 {
continue
}
s.handle.ResetEndpoint(uint32(epNum))
s.handle.ResetEndpoint(uint32(epNum) | 0x80)
}
// Do NOT reset host-side data toggles either: after DisconnectClaimInterface
// the host and device toggles are already in sync. Resetting host-side
// toggles to DATA0 would create a mismatch (device still at its current
// toggle), causing the first interrupt packet to be silently discarded.
log.Printf("[usbip-server] SET_CONFIGURATION(%d) intercepted (device already configured)", wValue)
default:
// Generic OUT control transfer
@@ -647,9 +642,27 @@ func (s *Server) reapLoop(retChan chan<- []byte, done <-chan struct{}) {
continue
}
dirStr := "OUT"
if pending.direction == DirIn {
dirStr = "IN"
}
urbType := s.getURBType(uint8(pending.endpoint))
typeNames := map[uint8]string{0: "ISO", 1: "INT", 2: "CTRL", 3: "BULK"}
if urbInfo.Status != 0 {
log.Printf("[usbip-server] URB completed: seq=%d ep=%d status=%d actual=%d iso=%v",
pending.seqNum, pending.endpoint, urbInfo.Status, urbInfo.ActualLength, pending.isISO)
log.Printf("[usbip-server] URB completed: seq=%d EP%d %s type=%s status=%d actual=%d",
pending.seqNum, pending.endpoint, dirStr, typeNames[urbType], urbInfo.Status, urbInfo.ActualLength)
} else if urbType == 1 { // interrupt — always log for HID debugging
hexStr := ""
if pending.direction == DirIn && urbInfo.ActualLength > 0 {
n := int(urbInfo.ActualLength)
if n > 16 {
n = 16
}
hexStr = fmt.Sprintf(" data=%x", pending.buffer[:n])
}
log.Printf("[usbip-server] INT completed: seq=%d EP%d %s actual=%d%s",
pending.seqNum, pending.endpoint, dirStr, urbInfo.ActualLength, hexStr)
}
var resp []byte