Skip to main content

Module handler

Module handler 

Source
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:

CommandAnswered by
IccPowerOnhere, from the ATR the handler configured at startup
IccPowerOff, GetSlotStatus, Abort, IccClock, T0APDUhere
GetParameters, SetParameters, ResetParametershere, with the default T=0 block
Escapehere, 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§

CardState
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.
PendingApdu
An XfrBlock waiting for an answer from the handler.
UsbCcidHandler
A virtual USB CCID card reader.

Constants§

SLOT
The single slot this reader exposes.