Documentation
¶
Index ¶
- Constants
- Variables
- func ReadOpReqImportBody(r io.Reader) (string, error)
- func RebaseFrame(currentFrame uint64, low8 uint8) uint64
- func ScatterIsoResponse(dst, payload []byte, packets []IsoPacketDescriptor)
- func SelectMatches(patterns []DeviceMatch, keys []DeviceKey) []int
- func ValidateIsoResponse(requestLen int, actualLength int, packets []IsoPacketDescriptor, ...) error
- func WriteOpHeader(w io.Writer, code uint16, status uint32) error
- func WriteOpRepDevList(w io.Writer, entries []DeviceEntry) error
- func WriteOpRepImport(w io.Writer, code uint16, status uint32, info *DeviceInfoTruncated) error
- func WriteOpReqImport(w io.Writer, busid string) error
- func WriteSubmitCommand(w io.Writer, command SubmitCommand) error
- func WriteSubmitResponse(w io.Writer, response SubmitResponse) error
- func WriteUnlinkCommand(w io.Writer, command UnlinkCommand) error
- func WriteUnlinkResponse(w io.Writer, response UnlinkResponse) error
- type AttachedSession
- type BackendID
- type ClientOptions
- type ClientService
- type ControlDeviceInfo
- type ControlDeviceInterface
- type DataHeader
- type DataSession
- type DeviceEntry
- type DeviceInfoTruncated
- type DeviceInterface
- type DeviceKey
- type DeviceMatch
- type DeviceState
- type DeviceTransport
- type DynamicHost
- func (h *DynamicHost) AddDevice(info ProvidedDeviceInfo, transport DeviceTransport) (string, error)
- func (h *DynamicHost) Close() error
- func (h *DynamicHost) Events() (<-chan struct{}, error)
- func (h *DynamicHost) FinishImport(busid string) (bool, error)
- func (h *DynamicHost) Reconcile(isReserved func(busid string) bool) (map[string]Export, []string, error)
- func (h *DynamicHost) RemoveDevice(busid string)
- func (h *DynamicHost) Start() error
- type Export
- type ExportHost
- type ExportSnapshot
- type ImportHost
- type IsoPacketDescriptor
- type ListenFunc
- type LocalDevice
- type LocalDeviceInfo
- type OpHeader
- type ProvidedDeviceInfo
- type ServerOptions
- type ServerService
- type SubmitCommand
- type SubmitResponse
- type URBEngine
- type URBRequest
- type URBResponse
- type UnlinkCommand
- type UnlinkResponse
- type UrbTransaction
- type UsbIpPeer
Constants ¶
View Source
const ( CmdSubmit uint32 = 0x00000001 CmdUnlink uint32 = 0x00000002 RetSubmit uint32 = 0x00000003 RetUnlink uint32 = 0x00000004 USBIPDirOut uint32 = 0 USBIPDirIn uint32 = 1 )
Variables ¶
View Source
var ( ErrPeerClosed error = peerClosedError{} ErrCanceled error = urbCanceledError{} )
Functions ¶
func RebaseFrame ¶
Apple's IOUSBHostCI iso messages only carry the low 8 bits; the host recovers the high bits against the controller's monotonic counter.
func ScatterIsoResponse ¶
func ScatterIsoResponse(dst, payload []byte, packets []IsoPacketDescriptor)
func SelectMatches ¶
func SelectMatches(patterns []DeviceMatch, keys []DeviceKey) []int
func ValidateIsoResponse ¶
func ValidateIsoResponse(requestLen int, actualLength int, packets []IsoPacketDescriptor, payloadLen int) error
func WriteOpRepDevList ¶
func WriteOpRepDevList(w io.Writer, entries []DeviceEntry) error
func WriteOpRepImport ¶
func WriteSubmitCommand ¶
func WriteSubmitCommand(w io.Writer, command SubmitCommand) error
func WriteSubmitResponse ¶
func WriteSubmitResponse(w io.Writer, response SubmitResponse) error
func WriteUnlinkCommand ¶
func WriteUnlinkCommand(w io.Writer, command UnlinkCommand) error
func WriteUnlinkResponse ¶
func WriteUnlinkResponse(w io.Writer, response UnlinkResponse) error
Types ¶
type AttachedSession ¶
type AttachedSession interface {
DataSession
Description() string
}
type ClientOptions ¶
type ClientOptions struct {
Logger logger.ContextLogger
Dialer N.Dialer
ServerAddress M.Socksaddr
Devices []DeviceMatch
}
type ClientService ¶
type ClientService struct {
// contains filtered or unexported fields
}
func NewClientService ¶
func NewClientService(ctx context.Context, options ClientOptions) (*ClientService, error)
func (*ClientService) Close ¶
func (c *ClientService) Close() error
func (*ClientService) Start ¶
func (c *ClientService) Start() error
type ControlDeviceInfo ¶
type ControlDeviceInfo struct {
BusID string `json:"busid"`
StableID string `json:"stable_id,omitempty"`
Backend BackendID `json:"backend,omitempty"`
Path string `json:"path,omitempty"`
Serial string `json:"serial,omitempty"`
Product string `json:"product,omitempty"`
VendorID uint16 `json:"vendor_id"`
ProductID uint16 `json:"product_id"`
BCDDevice uint16 `json:"bcd_device,omitempty"`
BusNum uint32 `json:"busnum"`
DevNum uint32 `json:"devnum"`
Speed uint32 `json:"speed"`
DeviceClass uint8 `json:"device_class"`
DeviceSubClass uint8 `json:"device_subclass"`
DeviceProtocol uint8 `json:"device_protocol"`
ConfigurationValue uint8 `json:"configuration_value"`
NumConfigurations uint8 `json:"num_configurations"`
NumInterfaces uint8 `json:"num_interfaces"`
Interfaces []ControlDeviceInterface `json:"interfaces,omitempty"`
State DeviceState `json:"state"`
StatusCode int `json:"status_code,omitempty"`
StatusReason string `json:"status_reason,omitempty"`
}
type ControlDeviceInterface ¶
type DataHeader ¶
type DataHeader struct {
Command uint32
SeqNum uint32
DevID uint32
Direction uint32
Endpoint uint32
}
func ReadDataHeader ¶
func ReadDataHeader(r io.Reader) (DataHeader, error)
type DataSession ¶
type DeviceEntry ¶
type DeviceEntry struct {
Info DeviceInfoTruncated
Interfaces []DeviceInterface
Serial string
Product string
}
func FetchControlDeviceEntries ¶
func FetchControlDeviceEntries(conn net.Conn) ([]DeviceEntry, error)
func ReadOpRepDevListBody ¶
func ReadOpRepDevListBody(r io.Reader) ([]DeviceEntry, error)
type DeviceInfoTruncated ¶
type DeviceInfoTruncated struct {
Path [256]byte
BusID [32]byte
BusNum uint32
DevNum uint32
Speed uint32
IDVendor uint16
IDProduct uint16
BCDDevice uint16
BDeviceClass uint8
BDeviceSubClass uint8
BDeviceProtocol uint8
BConfigurationValue uint8
BNumConfigurations uint8
BNumInterfaces uint8
}
func ReadOpRepImportBody ¶
func ReadOpRepImportBody(r io.Reader) (DeviceInfoTruncated, error)
func (*DeviceInfoTruncated) BusIDString ¶
func (d *DeviceInfoTruncated) BusIDString() string
func (*DeviceInfoTruncated) DevID ¶
func (d *DeviceInfoTruncated) DevID() uint32
func (*DeviceInfoTruncated) PathString ¶
func (d *DeviceInfoTruncated) PathString() string
type DeviceInterface ¶
type DeviceMatch ¶
func (DeviceMatch) IsZero ¶
func (m DeviceMatch) IsZero() bool
type DeviceState ¶
type DeviceState int32
const ( DeviceStateIdle DeviceState = iota DeviceStateAttached )
func (DeviceState) String ¶
func (s DeviceState) String() string
type DeviceTransport ¶
type DeviceTransport interface {
Submit(request URBRequest) URBResponse
AbortEndpoint(endpoint uint8) error
}
type DynamicHost ¶
type DynamicHost struct {
// contains filtered or unexported fields
}
func NewDynamicHost ¶
func NewDynamicHost(contextLogger logger.ContextLogger) *DynamicHost
func (*DynamicHost) AddDevice ¶
func (h *DynamicHost) AddDevice(info ProvidedDeviceInfo, transport DeviceTransport) (string, error)
func (*DynamicHost) Close ¶
func (h *DynamicHost) Close() error
func (*DynamicHost) Events ¶
func (h *DynamicHost) Events() (<-chan struct{}, error)
func (*DynamicHost) FinishImport ¶
func (h *DynamicHost) FinishImport(busid string) (bool, error)
func (*DynamicHost) RemoveDevice ¶
func (h *DynamicHost) RemoveDevice(busid string)
func (*DynamicHost) Start ¶
func (h *DynamicHost) Start() error
type Export ¶
type Export interface {
BusID() string
Snapshot(busy bool) ExportSnapshot
DeviceInfo() (DeviceInfoTruncated, error)
NewServerDataSession(ctx context.Context, conn net.Conn) (DataSession, error)
}
type ExportHost ¶
type ExportSnapshot ¶
type ExportSnapshot struct {
Entry DeviceEntry
Backend BackendID
StableID string
State DeviceState
StatusReason string
RawStatus int
}
type ImportHost ¶
type ImportHost interface {
Start() error
Close() error
Attach(ctx context.Context, info DeviceInfoTruncated, conn net.Conn) (AttachedSession, error)
}
type IsoPacketDescriptor ¶
type LocalDevice ¶
type LocalDevice interface {
DeviceTransport
StableID() string
Entry() DeviceEntry
Close() error
}
func OpenLocalDevice ¶
func OpenLocalDevice(id string, capture bool) (LocalDevice, error)
type LocalDeviceInfo ¶
type LocalDeviceInfo struct {
StableID string
Backend BackendID
Entry DeviceEntry
}
func ListLocalDevices ¶
func ListLocalDevices() ([]LocalDeviceInfo, error)
type OpHeader ¶
func ParseOpHeader ¶
type ProvidedDeviceInfo ¶
type ProvidedDeviceInfo struct {
Entry DeviceEntry
StableID string
}
type ServerOptions ¶
type ServerOptions struct {
Logger logger.ContextLogger
Devices []DeviceMatch
Listen ListenFunc
ListenAddress M.Socksaddr
}
type ServerService ¶
type ServerService struct {
// contains filtered or unexported fields
}
func NewDynamicServerService ¶
func NewDynamicServerService(ctx context.Context, options ServerOptions, host *DynamicHost) (*ServerService, error)
func NewServerService ¶
func NewServerService(ctx context.Context, options ServerOptions) (*ServerService, error)
func (*ServerService) Close ¶
func (s *ServerService) Close() error
func (*ServerService) DeviceSnapshot ¶
func (s *ServerService) DeviceSnapshot() []ControlDeviceInfo
func (*ServerService) ListenAddr ¶
func (s *ServerService) ListenAddr() net.Addr
func (*ServerService) Start ¶
func (s *ServerService) Start() (err error)
func (*ServerService) SubscribeDevices ¶
func (s *ServerService) SubscribeDevices(ctx context.Context, listener func([]ControlDeviceInfo))
type SubmitCommand ¶
type SubmitCommand struct {
Header DataHeader
TransferFlags int32
TransferBufferLength int32
StartFrame int32
NumberOfPackets int32
Interval int32
Setup [8]byte
Buffer []byte
IsoPackets []IsoPacketDescriptor
}
func EncodeIsoSubmit ¶
func EncodeIsoSubmit(currentFrame uint64, base SubmitCommand, ciFrame uint8, asap bool) SubmitCommand
func ReadSubmitCommandBody ¶
func ReadSubmitCommandBody(r io.Reader, header DataHeader) (SubmitCommand, error)
type SubmitResponse ¶
type SubmitResponse struct {
Header DataHeader
Status int32
ActualLength int32
StartFrame int32
NumberOfPackets int32
ErrorCount int32
Setup [8]byte
Buffer []byte
IsoPackets []IsoPacketDescriptor
}
func ReadSubmitResponseBody ¶
func ReadSubmitResponseBody(r io.Reader, header DataHeader, requestDirection uint32) (SubmitResponse, error)
The USB/IP response header zeroes direction on the wire; requestDirection must be the original CMD_SUBMIT direction.
type URBEngine ¶
type URBEngine interface {
Submit(request URBRequest) URBResponse
AbortEndpoint(endpoint uint8) error
Close() error
}
type URBRequest ¶
type URBRequest struct {
Command SubmitCommand
Endpoint uint8
Buffer []byte
IsoPackets []IsoPacketDescriptor
}
type URBResponse ¶
type URBResponse struct {
Status int32
ActualLength int32
Buffer []byte
IsoPackets []IsoPacketDescriptor
Error error
}
type UnlinkCommand ¶
type UnlinkCommand struct {
Header DataHeader
SeqNum uint32
}
func ReadUnlinkCommandBody ¶
func ReadUnlinkCommandBody(r io.Reader, header DataHeader) (UnlinkCommand, error)
type UnlinkResponse ¶
type UnlinkResponse struct {
Header DataHeader
Status int32
}
func ReadUnlinkResponseBody ¶
func ReadUnlinkResponseBody(r io.Reader, header DataHeader) (UnlinkResponse, error)
type UrbTransaction ¶
type UrbTransaction struct {
// contains filtered or unexported fields
}
func (*UrbTransaction) Cancel ¶
func (t *UrbTransaction) Cancel() error
func (*UrbTransaction) Direction ¶
func (t *UrbTransaction) Direction() uint32
func (*UrbTransaction) Done ¶
func (t *UrbTransaction) Done() <-chan struct{}
func (*UrbTransaction) SeqNum ¶
func (t *UrbTransaction) SeqNum() uint32
func (*UrbTransaction) Wait ¶
func (t *UrbTransaction) Wait() (SubmitResponse, error)
type UsbIpPeer ¶
type UsbIpPeer struct {
// contains filtered or unexported fields
}
func NewUsbIpPeer ¶
func (*UsbIpPeer) Submit ¶
func (p *UsbIpPeer) Submit(command SubmitCommand) (*UrbTransaction, error)
Source Files
¶
- client.go
- client_assignment.go
- client_shared.go
- control_protocol.go
- data_protocol.go
- dynamic_host.go
- export_ledger.go
- handoff_linux.go
- host.go
- host_linux.go
- iso_scheduler.go
- local_device.go
- local_device_linux.go
- match.go
- options.go
- protocol.go
- server.go
- server_shared.go
- session_userspace.go
- shared.go
- sysfs_linux.go
- uevent_linux.go
- urb_engine.go
- urb_transaction.go
- usbfs_linux.go
- usbip_peer.go
Click to show internal directories.
Click to hide internal directories.