diff --git a/bin/usb-client b/bin/usb-client index 97f7cb4..acdfd0c 100755 Binary files a/bin/usb-client and b/bin/usb-client differ diff --git a/bin/usb-relay b/bin/usb-relay index 61279f8..fc31968 100755 Binary files a/bin/usb-relay and b/bin/usb-relay differ diff --git a/internal/usbip/server.go b/internal/usbip/server.go index 090055d..449c82b 100644 --- a/internal/usbip/server.go +++ b/internal/usbip/server.go @@ -336,6 +336,26 @@ func (s *Server) handleCmdSubmit(r io.Reader, hdr *URBHeader, retChan chan<- []b endpoint := uint8(hdr.Endpoint) urbType := s.getURBType(endpoint) + dirStr := "OUT" + if hdr.Direction == DirIn { + dirStr = "IN" + } + + // Log all transfers for debugging + if endpoint == 0 { + bmReqType := body.Setup[0] + bReq := body.Setup[1] + wVal := binary.LittleEndian.Uint16(body.Setup[2:4]) + wIdx := binary.LittleEndian.Uint16(body.Setup[4:6]) + wLen := binary.LittleEndian.Uint16(body.Setup[6:8]) + log.Printf("[usbip-server] CTRL %s seq=%d bmReqType=0x%02x bReq=0x%02x wVal=0x%04x wIdx=0x%04x wLen=%d bufLen=%d", + dirStr, hdr.SeqNum, bmReqType, bReq, wVal, wIdx, wLen, body.TransferBufferLen) + } else { + typeNames := map[uint8]string{0: "ISO", 1: "INT", 2: "CTRL", 3: "BULK"} + log.Printf("[usbip-server] EP%d %s seq=%d type=%s bufLen=%d numPkts=%d", + endpoint, dirStr, hdr.SeqNum, typeNames[urbType], body.TransferBufferLen, numPackets) + } + // Handle control transfers specially (endpoint 0) if endpoint == 0 && hdr.Direction == DirIn { buf := make([]byte, body.TransferBufferLen) @@ -348,6 +368,7 @@ func (s *Server) handleCmdSubmit(r io.Reader, hdr *URBHeader, retChan chan<- []b ) var status int32 if err != nil { + log.Printf("[usbip-server] CTRL IN failed: %v", err) status = -32 // -EPIPE n = 0 } @@ -441,6 +462,7 @@ func (s *Server) handleCmdSubmit(r io.Reader, hdr *URBHeader, retChan chan<- []b UserContext: uintptr(hdr.SeqNum), }) if err != nil { + log.Printf("[usbip-server] SubmitURB(ep=0x%02x, type=%d, len=%d) FAILED: %v", ep, urbType, len(buf), err) resp, _ := BuildRetSubmit(hdr.SeqNum, hdr.DevID, hdr.Direction, hdr.Endpoint, -32, nil) retChan <- resp return nil @@ -494,6 +516,9 @@ func (s *Server) handleISOSubmit(hdr *URBHeader, body *CmdSubmitBody, transferBu } // Submit ISO URB + log.Printf("[usbip-server] ISO submit: ep=0x%02x dir=%d pkts=%d totalBuf=%d", + ep, hdr.Direction, numPackets, totalBufLen) + urb, isoMem, err := s.handle.SubmitISOURB(&usb.SubmitISOURBParams{ Endpoint: ep, Flags: 0x02, // URB_ISO_ASAP @@ -503,6 +528,7 @@ func (s *Server) handleISOSubmit(hdr *URBHeader, body *CmdSubmitBody, transferBu UserContext: uintptr(hdr.SeqNum), }) if err != nil { + log.Printf("[usbip-server] ISO submit FAILED: %v", err) // Submit failed - send error response resp, _ := BuildRetSubmit(hdr.SeqNum, hdr.DevID, hdr.Direction, hdr.Endpoint, -32, nil) retChan <- resp @@ -601,6 +627,11 @@ func (s *Server) reapLoop(retChan chan<- []byte, done <-chan struct{}) { continue } + 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) + } + var resp []byte if pending.isISO { resp, err = s.buildISOResponse(urbInfo, pending)