cezanne / usbip-win

USB/IP for Windows
GNU General Public License v3.0
1.94k stars 349 forks source link

Confused about how usbipd is handling an HID SET_IDLE control packet #262

Closed jdh104 closed 3 years ago

jdh104 commented 3 years ago

By attaching a mouse over a network and using a TCP tunnel to sniff the usbip packets and wireshark to sniff the corresponding urb's, I was able to collect the following:

URB capture: image

raw USBIP capture (decimal):

2021-08-10T13:46:28.697Z -> [0,0,0,1,0,0,0,1,0,1,0,158,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,1,0,0,0,0,0,0,0,0,1,0,0,0,2,0,1,0,158,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,11,0,0,0,0,0,0]

parsed USBIP capture:

2021-08-10T13:46:28.697Z {
  commandCode: 'USBIP_CMD_SUBMIT',
  body: {
    header: { seqnum: 1, devid: 65694, direction: 0, endpoint: 0 },
    transferFlags: 1,
    transferBufferLength: 0,
    startFrame: 0,
    numberOfPackets: 0,
    interval: 0,
    setup: {
      bmRequestType: { direction: 0, rType: 0, recipient: 0 },
      bRequest: 9,
      wValue: 1,
      wIndex: 0,
      wLength: 0
    },
    transferBuffer: <Buffer >,
    isoPacketDescriptor: <Buffer >,
    leftoverData: {
      commandCode: 'USBIP_CMD_SUBMIT',
      body: {
        header: { seqnum: 2, devid: 65694, direction: 0, endpoint: 0 },
        transferFlags: 1,
        transferBufferLength: 0,
        startFrame: 0,
        numberOfPackets: 0,
        interval: 0,
        setup: {
          bmRequestType: { direction: 0, rType: 0, recipient: 1 },
          bRequest: 11,
          wValue: 0,
          wIndex: 0,
          wLength: 0
        },
        transferBuffer: <Buffer >,
        isoPacketDescriptor: <Buffer >,
        leftoverData: null
      }
    }
  }
}

What's confusing is that the seqnum = 2 packet has a setup.bmRequestType.rType of "Standard" (0x00), but the wireshark capture clearly shows "Class" (0x01)

The value for SET_IDLE happens to be 0x0a which coincidentally lines up with the value of the Standard GET_INTERFACE request image

but.... process_standard_request doesn't accept GET_INTERFACE

https://github.com/cezanne/usbip-win/blob/692ccb5f28acbebcf2488e7e8a79492ed8d44574/driver/stub/stub_write.c#L175-L200

The daemon must be processing the data somehow because I am able to capture the response (both usbip and urb).

jdh104 commented 3 years ago

Nevermind on this: I seem to have misunderstood the data