Struct devices::usb::backend::fido_backend::fido_passthrough::FidoPassthroughDevice
source · pub struct FidoPassthroughDevice {
device: Arc<Mutex<FidoDevice>>,
state: Arc<RwLock<DeviceState>>,
control_transfer_state: Arc<RwLock<ControlTransferState>>,
transfer_job_queue: Arc<AsyncJobQueue>,
kill_evt: Event,
worker_thread: Option<WorkerThread<()>>,
pending_in_transfers: Arc<Mutex<VecDeque<(FidoTransferHandle, Arc<Mutex<Option<FidoTransfer>>>)>>>,
}
Expand description
Host-level fido passthrough device that handles USB operations and relays them to the appropriate virtual fido device.
Fields§
§device: Arc<Mutex<FidoDevice>>
The virtual FIDO device implementation.
state: Arc<RwLock<DeviceState>>
The state of the device as seen by the backend provider.
control_transfer_state: Arc<RwLock<ControlTransferState>>
The state of the control transfer exchange with the xhci layer.
transfer_job_queue: Arc<AsyncJobQueue>
§kill_evt: Event
§worker_thread: Option<WorkerThread<()>>
§pending_in_transfers: Arc<Mutex<VecDeque<(FidoTransferHandle, Arc<Mutex<Option<FidoTransfer>>>)>>>
Implementations§
source§impl FidoPassthroughDevice
impl FidoPassthroughDevice
pub fn new( device: Arc<Mutex<FidoDevice>>, state: DeviceState, event_loop: Arc<EventLoop> ) -> Result<Self>
sourcepub fn read_hidraw_file(&mut self) -> Result<()>
pub fn read_hidraw_file(&mut self) -> Result<()>
This function is called from the low-level event handler when the monitored fd
is ready
to transmit data from the host to the guest.
sourcepub fn handle_control(
transfer: &mut FidoTransfer,
device: &Arc<Mutex<FidoDevice>>
) -> Result<()>
pub fn handle_control( transfer: &mut FidoTransfer, device: &Arc<Mutex<FidoDevice>> ) -> Result<()>
This function is called by a queued job to handle all communication related to USB control transfer packets between the guest and the virtual security key.
sourcepub fn handle_interrupt_out(
transfer: &mut FidoTransfer,
device: &Arc<Mutex<FidoDevice>>
) -> Result<()>
pub fn handle_interrupt_out( transfer: &mut FidoTransfer, device: &Arc<Mutex<FidoDevice>> ) -> Result<()>
This function is called by a queued job to handle all USB OUT requests from the guest down
to the host by writing the given FidoTransfer
data into the hidraw file.
Trait Implementations§
source§impl AsRawDescriptor for FidoPassthroughDevice
impl AsRawDescriptor for FidoPassthroughDevice
source§fn as_raw_descriptor(&self) -> RawDescriptor
fn as_raw_descriptor(&self) -> RawDescriptor
Returns the underlying raw descriptor. Read more
source§impl BackendDevice for FidoPassthroughDevice
impl BackendDevice for FidoPassthroughDevice
source§fn submit_backend_transfer(
&mut self,
transfer: BackendTransferType
) -> BackendResult<BackendTransferHandle>
fn submit_backend_transfer( &mut self, transfer: BackendTransferType ) -> BackendResult<BackendTransferHandle>
Submits a transfer to the specific backend implementation.
source§fn detach_event_handler(
&self,
_event_loop: &Arc<EventLoop>
) -> BackendResult<()>
fn detach_event_handler( &self, _event_loop: &Arc<EventLoop> ) -> BackendResult<()>
This is called by a generic backend provider when a USB detach message is received from the
vm control socket. It detaches the backend device from the backend provider event loop.
source§fn request_transfer_buffer(&mut self, size: usize) -> TransferBuffer
fn request_transfer_buffer(&mut self, size: usize) -> TransferBuffer
Gets a buffer used for data transfer between the host and this device. The buffer returned
by this function must be consumed by
submit_backend_transfer()
.source§fn build_bulk_transfer(
&mut self,
_ep_addr: u8,
_transfer_buffer: TransferBuffer,
_stream_id: Option<u16>
) -> BackendResult<BackendTransferType>
fn build_bulk_transfer( &mut self, _ep_addr: u8, _transfer_buffer: TransferBuffer, _stream_id: Option<u16> ) -> BackendResult<BackendTransferType>
Requests the backend to build a backend-specific bulk transfer request
source§fn build_interrupt_transfer(
&mut self,
ep_addr: u8,
transfer_buffer: TransferBuffer
) -> BackendResult<BackendTransferType>
fn build_interrupt_transfer( &mut self, ep_addr: u8, transfer_buffer: TransferBuffer ) -> BackendResult<BackendTransferType>
Requests the backend to build a backend-specific interrupt transfer request
source§fn get_control_transfer_state(&mut self) -> Arc<RwLock<ControlTransferState>>
fn get_control_transfer_state(&mut self) -> Arc<RwLock<ControlTransferState>>
Returns the
ControlTransferState
for the given backend device.source§fn get_device_state(&mut self) -> Arc<RwLock<DeviceState>>
fn get_device_state(&mut self) -> Arc<RwLock<DeviceState>>
Returns the
DeviceState
for the given backend device. This state contains all the
backend-agnostic state for all generic USB backends.source§fn get_active_config_descriptor(
&mut self
) -> BackendResult<ConfigDescriptorTree>
fn get_active_config_descriptor( &mut self ) -> BackendResult<ConfigDescriptorTree>
Gets the device active config descriptor tree.
source§fn get_config_descriptor(
&mut self,
config: u8
) -> BackendResult<ConfigDescriptorTree>
fn get_config_descriptor( &mut self, config: u8 ) -> BackendResult<ConfigDescriptorTree>
Gets a specific device config descriptor tree.
source§fn get_config_descriptor_by_index(
&mut self,
config_index: u8
) -> BackendResult<ConfigDescriptorTree>
fn get_config_descriptor_by_index( &mut self, config_index: u8 ) -> BackendResult<ConfigDescriptorTree>
Gets a specific device config descriptor tree by index.
source§fn get_device_descriptor_tree(&mut self) -> BackendResult<DeviceDescriptorTree>
fn get_device_descriptor_tree(&mut self) -> BackendResult<DeviceDescriptorTree>
Gets the device descriptor tree.
source§fn get_active_configuration(&mut self) -> BackendResult<u8>
fn get_active_configuration(&mut self) -> BackendResult<u8>
Gets the device current active configuration.
source§fn set_active_configuration(&mut self, config: u8) -> BackendResult<()>
fn set_active_configuration(&mut self, config: u8) -> BackendResult<()>
Sets the device active configuration.
source§fn clear_feature(
&mut self,
_value: u16,
_index: u16
) -> BackendResult<TransferStatus>
fn clear_feature( &mut self, _value: u16, _index: u16 ) -> BackendResult<TransferStatus>
Handles a clear feature endpoint request for the given device.
source§fn create_endpoints(
&mut self,
_config_descriptor: &ConfigDescriptorTree
) -> BackendResult<()>
fn create_endpoints( &mut self, _config_descriptor: &ConfigDescriptorTree ) -> BackendResult<()>
Creates endpoints for the device with the given config descriptor tree.
source§impl Drop for FidoPassthroughDevice
impl Drop for FidoPassthroughDevice
source§impl XhciBackendDevice for FidoPassthroughDevice
impl XhciBackendDevice for FidoPassthroughDevice
source§fn get_backend_type(&self) -> BackendType
fn get_backend_type(&self) -> BackendType
Returns the type of USB device provided by this device.
source§fn set_address(&mut self, _address: UsbDeviceAddress)
fn set_address(&mut self, _address: UsbDeviceAddress)
Set address of this backend.
source§fn reset(&mut self) -> BackendResult<()>
fn reset(&mut self) -> BackendResult<()>
Reset the backend device.
source§fn get_speed(&self) -> Option<DeviceSpeed>
fn get_speed(&self) -> Option<DeviceSpeed>
Get speed of this device.
source§fn alloc_streams(&self, _ep: u8, _num_streams: u16) -> BackendResult<()>
fn alloc_streams(&self, _ep: u8, _num_streams: u16) -> BackendResult<()>
Allocate streams for the endpoint
source§fn free_streams(&self, _ep: u8) -> BackendResult<()>
fn free_streams(&self, _ep: u8) -> BackendResult<()>
Free streams for the endpoint
Auto Trait Implementations§
impl !RefUnwindSafe for FidoPassthroughDevice
impl Send for FidoPassthroughDevice
impl Sync for FidoPassthroughDevice
impl Unpin for FidoPassthroughDevice
impl !UnwindSafe for FidoPassthroughDevice
Blanket Implementations§
source§impl<T> AsRawDescriptors for Twhere
T: AsRawDescriptor,
impl<T> AsRawDescriptors for Twhere
T: AsRawDescriptor,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.