Expand description
USB CCID interface handler — the usbip::UsbInterfaceHandler for a virtual card reader.
usbip 0.9 ships handlers for HID and CDC only; there is no CCID handler, so the whole of
this is written here against the CCID rev 1.1 specification.
§What is answered where
handle_urb is synchronous — it cannot await an LLM call. So the split is:
| Command | Answered by |
|---|---|
IccPowerOn | here, from the ATR the handler configured at startup |
IccPowerOff, GetSlotStatus, Abort, IccClock, T0APDU | here |
GetParameters, SetParameters, ResetParameters | here, with the default T=0 block |
Escape | here, refused (CMD_NOT_SUPPORTED) |
XfrBlock (an APDU) | forwarded on a channel; mod.rs raises the event and queues the answer |
Nothing about what the card says is decided here. The ATR and every response APDU come
from the handler (script, static or LLM) via mod.rs.
§Bulk IN framing
Responses are queued as whole CCID messages. A bulk IN URB takes at most
min(wMaxPacketSize, transfer_buffer_length) bytes; a message longer than that is split
and the remainder stays at the front of the queue, so a 64-byte-packet host reassembles
it exactly as it would from real hardware. Two queued messages are never merged into one
transfer, because a host parses one CCID message per transfer.
Structs§
- Card
State - Card state shared between the connection task (which the handler cannot reach) and every live USB/IP session. One reader, one slot, one card: sessions deliberately share it.
- Pending
Apdu - An
XfrBlockwaiting for an answer from the handler. - UsbCcid
Handler - A virtual USB CCID card reader.
Constants§
- SLOT
- The single slot this reader exposes.