usbip

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	USB_CONFIG_ATTR_BASE          = 0b10000000
	USB_CONFIG_ATTR_SELF_POWERED  = 0b01000000
	USB_CONFIG_ATTR_REMOTE_WAKEUP = 0b00100000

	USB_INTERFACE_CLASS_HID = 3

	USB_LANGID_ENG_USA = 0x0409
)
View Source
const (
	USBIP_VERSION = 0x0111

	USBIP_COMMAND_SUBMIT     = 0x1
	USBIP_COMMAND_UNLINK     = 0x2
	USBIP_COMMAND_RET_SUBMIT = 0x3
	USBIP_COMMAND_RET_UNLINK = 0x4

	USBIP_DIR_OUT = 0x0
	USBIP_DIR_IN  = 0x1
)

Variables

View Source
var USBIPControlCommandDescriptions = map[USBIPControlCommand]string{
	USBIP_COMMAND_OP_REQ_DEVLIST: "USBIP_COMMAND_OP_REQ_DEVLIST",
	USBIP_COMMAND_OP_REP_DEVLIST: "USBIP_COMMAND_OP_REP_DEVLIST",
	USBIP_COMMAND_OP_REQ_IMPORT:  "USBIP_COMMAND_OP_REQ_IMPORT",
	USBIP_COMMAND_OP_REP_IMPORT:  "USBIP_COMMAND_OP_REP_IMPORT",
}

Functions

This section is empty.

Types

type DummyUSBDevice

type DummyUSBDevice struct{}

type USBConfigurationDescriptor

type USBConfigurationDescriptor struct {
	BLength             uint8
	BDescriptorType     USBDescriptorType
	WTotalLength        uint16
	BNumInterfaces      uint8
	BConfigurationValue uint8
	IConfiguration      uint8
	BmAttributes        uint8
	BMaxPower           uint8
}

type USBDescriptorType

type USBDescriptorType uint8
const (
	USB_DESCRIPTOR_DEVICE                    USBDescriptorType = 1
	USB_DESCRIPTOR_CONFIGURATION             USBDescriptorType = 2
	USB_DESCRIPTOR_STRING                    USBDescriptorType = 3
	USB_DESCRIPTOR_INTERFACE                 USBDescriptorType = 4
	USB_DESCRIPTOR_ENDPOINT                  USBDescriptorType = 5
	USB_DESCRIPTOR_DEVICE_QUALIFIER          USBDescriptorType = 6
	USB_DESCRIPTOR_OTHER_SPEED_CONFIGURATION USBDescriptorType = 7
	USB_DESCRIPTOR_INTERFACE_POWER           USBDescriptorType = 8
	USB_DESCRIPTOR_HID                       USBDescriptorType = 33
	USB_DESCRIPTOR_HID_REPORT                USBDescriptorType = 34
)

type USBDevice

type USBDevice interface {
	// contains filtered or unexported methods
}

type USBDeviceDescriptor

type USBDeviceDescriptor struct {
	BLength            uint8
	BDescriptorType    USBDescriptorType
	BcdUSB             uint16
	BDeviceClass       uint8
	BDeviceSubclass    uint8
	BDeviceProtocol    uint8
	BMaxPacketSize     uint8
	IdVendor           uint16
	IdProduct          uint16
	BcdDevice          uint16
	IManufacturer      uint8
	IProduct           uint8
	ISerialNumber      uint8
	BNumConfigurations uint8
}

type USBDeviceImpl

type USBDeviceImpl struct {
	Index int
	// contains filtered or unexported fields
}

func NewUSBDevice

func NewUSBDevice(ctapHIDServer *ctap_hid.CTAPHIDServer) *USBDeviceImpl

type USBDirection

type USBDirection uint8
const (
	USB_HOST_TO_DEVICE USBDirection = 0
	USB_DEVICE_TO_HOST USBDirection = 1
)

type USBEndpointDescriptor

type USBEndpointDescriptor struct {
	BLength          uint8
	BDescriptorType  USBDescriptorType
	BEndpointAddress uint8
	BmAttributes     uint8
	WMaxPacketSize   uint16
	BInterval        uint8
}

type USBHIDDescriptor

type USBHIDDescriptor struct {
	BLength                 uint8
	BDescriptorType         USBDescriptorType
	BcdHID                  uint16
	BCountryCode            uint8
	BNumDescriptors         uint8
	BClassDescriptorType    USBDescriptorType
	WReportDescriptorLength uint16
}

type USBHIDRequestType

type USBHIDRequestType uint8
const (
	USB_HID_REQUEST_GET_REPORT     USBHIDRequestType = 1
	USB_HID_REQUEST_GET_IDLE       USBHIDRequestType = 2
	USB_HID_REQUEST_GET_PROTOCOL   USBHIDRequestType = 3
	USB_HID_REQUEST_GET_DESCRIPTOR USBHIDRequestType = 6
	USB_HID_REQUEST_SET_DESCRIPTOR USBHIDRequestType = 7
	USB_HID_REQUEST_SET_REPORT     USBHIDRequestType = 9
	USB_HID_REQUEST_SET_IDLE       USBHIDRequestType = 10
	USB_HID_REQUEST_SET_PROTOCOL   USBHIDRequestType = 11
)

type USBIPCommandSubmitBody

type USBIPCommandSubmitBody struct {
	TransferFlags        uint32
	TransferBufferLength uint32
	StartFrame           uint32
	NumberOfPackets      uint32
	Interval             uint32
	SetupBytes           [8]byte
}

func (USBIPCommandSubmitBody) Setup

func (USBIPCommandSubmitBody) String

func (body USBIPCommandSubmitBody) String() string

type USBIPCommandUnlinkBody

type USBIPCommandUnlinkBody struct {
	UnlinkSequenceNumber uint32
	Padding              [24]byte
}

type USBIPControlCommand

type USBIPControlCommand uint16
const (
	USBIP_COMMAND_OP_REQ_DEVLIST USBIPControlCommand = 0x8005
	USBIP_COMMAND_OP_REP_DEVLIST USBIPControlCommand = 0x0005
	USBIP_COMMAND_OP_REQ_IMPORT  USBIPControlCommand = 0x8003
	USBIP_COMMAND_OP_REP_IMPORT  USBIPControlCommand = 0x0003
)

type USBIPControlHeader

type USBIPControlHeader struct {
	Version     uint16
	CommandCode USBIPControlCommand
	Status      uint32
}

func (*USBIPControlHeader) String

func (header *USBIPControlHeader) String() string

type USBIPDeviceInterface

type USBIPDeviceInterface struct {
	BInterfaceClass    uint8
	BInterfaceSubclass uint8
	Padding            uint8
}

type USBIPDeviceSummary

type USBIPDeviceSummary struct {
	Header          USBIPDeviceSummaryHeader
	DeviceInterface USBIPDeviceInterface // We only support one interface to use binary.Write/Read
}

func (USBIPDeviceSummary) String

func (summary USBIPDeviceSummary) String() string

type USBIPDeviceSummaryHeader

type USBIPDeviceSummaryHeader 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 (USBIPDeviceSummaryHeader) String

func (header USBIPDeviceSummaryHeader) String() string

type USBIPMessageHeader

type USBIPMessageHeader struct {
	Command        uint32
	SequenceNumber uint32
	DeviceId       uint32
	Direction      uint32
	Endpoint       uint32
}

func (USBIPMessageHeader) CommandName

func (header USBIPMessageHeader) CommandName() string

func (USBIPMessageHeader) DirectionName

func (header USBIPMessageHeader) DirectionName() string

func (USBIPMessageHeader) String

func (header USBIPMessageHeader) String() string

type USBIPOpRepDevlist

type USBIPOpRepDevlist struct {
	Header     USBIPControlHeader
	NumDevices uint32
	Devices    []USBIPDeviceSummary
}

type USBIPOpRepImport

type USBIPOpRepImport struct {
	// contains filtered or unexported fields
}

func (USBIPOpRepImport) String

func (reply USBIPOpRepImport) String() string

type USBIPReturnSubmitBody

type USBIPReturnSubmitBody struct {
	Status          uint32
	ActualLength    uint32
	StartFrame      uint32
	NumberOfPackets uint32
	ErrorCount      uint32
	Padding         uint64
}

type USBIPReturnUnlinkBody

type USBIPReturnUnlinkBody struct {
	Status  int32
	Padding [24]byte
}

type USBIPServer

type USBIPServer struct {
	// contains filtered or unexported fields
}

func NewUSBIPServer

func NewUSBIPServer(device USBDevice) *USBIPServer

func (*USBIPServer) Start

func (server *USBIPServer) Start()

type USBISOPacketDescriptor

type USBISOPacketDescriptor struct {
	Offset       uint32
	Length       uint32
	ActualLength uint32
	Status       uint32
}

type USBInterfaceDescriptor

type USBInterfaceDescriptor struct {
	BLength            uint8
	BDescriptorType    USBDescriptorType
	BInterfaceNumber   uint8
	BAlternateSetting  uint8
	BNumEndpoints      uint8
	BInterfaceClass    uint8
	BInterfaceSubclass uint8
	BInterfaceProtocol uint8
	IInterface         uint8
}

type USBRequestClass

type USBRequestClass uint8
const (
	USB_REQUEST_CLASS_STANDARD USBRequestClass = 0
	USB_REQUEST_CLASS_CLASS    USBRequestClass = 1
	USB_REQUEST_CLASS_VENDOR   USBRequestClass = 2
	USB_REQUEST_CLASS_RESERVED USBRequestClass = 3
)

type USBRequestRecipient

type USBRequestRecipient uint8
const (
	USB_REQUEST_RECIPIENT_DEVICE    USBRequestRecipient = 0
	USB_REQUEST_RECIPIENT_INTERFACE USBRequestRecipient = 1
	USB_REQUEST_RECIPIENT_ENDPOINT  USBRequestRecipient = 2
	USB_REQUEST_RECIPIENT_OTHER     USBRequestRecipient = 3
)

type USBRequestType

type USBRequestType uint8
const (
	USB_REQUEST_GET_STATUS        USBRequestType = 0
	USB_REQUEST_CLEAR_FEATURE     USBRequestType = 1
	USB_REQUEST_SET_FEATURE       USBRequestType = 3
	USB_REQUEST_SET_ADDRESS       USBRequestType = 5
	USB_REQUEST_GET_DESCRIPTOR    USBRequestType = 6
	USB_REQUEST_SET_DESCRIPTOR    USBRequestType = 7
	USB_REQUEST_GET_CONFIGURATION USBRequestType = 8
	USB_REQUEST_SET_CONFIGURATION USBRequestType = 9
	USB_REQUEST_GET_INTERFACE     USBRequestType = 10
	USB_REQUEST_SET_INTERFACE     USBRequestType = 11
	USB_REQUEST_SYNCH_FRAME       USBRequestType = 12
)

type USBSetupPacket

type USBSetupPacket struct {
	BmRequestType uint8
	BRequest      USBRequestType
	WValue        uint16
	WIndex        uint16
	WLength       uint16
}

func (USBSetupPacket) String

func (setup USBSetupPacket) String() string

type USBStringDescriptorHeader

type USBStringDescriptorHeader struct {
	BLength         uint8
	BDescriptorType USBDescriptorType
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL