usbip

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version = 0x0111

	// Management commands
	OpReqDevlist = 0x8005
	OpRepDevlist = 0x0005
	OpReqImport  = 0x8003
	OpRepImport  = 0x0003

	// URB transfer commands
	CmdSubmitCode = 0x00000001
	CmdUnlinkCode = 0x00000002
	RetSubmitCode = 0x00000003
	RetUnlinkCode = 0x00000004

	// Directions used in usbip_header_basic.direction
	DirOut = 0x00000000
	DirIn  = 0x00000001
)

Wire constants (network byte order / big-endian)

Variables

This section is empty.

Functions

func ReadExactly

func ReadExactly(r io.Reader, buf []byte) error

Types

type CmdSubmit

type CmdSubmit struct {
	Basic             HeaderBasic
	TransferFlags     uint32
	TransferBufferLen uint32
	StartFrame        uint32
	NumberOfPackets   uint32
	Interval          uint32
	Setup             [8]byte
}

CmdSubmit header (before payload) length is 0x30.

func (*CmdSubmit) Write

func (c *CmdSubmit) Write(w io.Writer) error
type CmdUnlink struct {
	Basic        HeaderBasic
	UnlinkSeqnum uint32
	Padding      [24]byte
}

CmdUnlink and RetUnlink

func (*CmdUnlink) Write

func (c *CmdUnlink) Write(w io.Writer) error

type DevListReplyHeader

type DevListReplyHeader struct {
	NDevices uint32
}

DevListReplyHeader is the header after MgmtHeader for OP_REP_DEVLIST.

func (*DevListReplyHeader) Write

func (d *DevListReplyHeader) Write(w io.Writer) error

type ExportMeta

type ExportMeta struct {
	Path     [256]byte
	USBBusId [32]byte
	BusId    uint32
	DevId    uint32
}

ExportMeta carries USB-IP bus identity for an emulated device. Uses fixed-size arrays matching the wire protocol format.

type ExportedDevice

type ExportedDevice struct {
	ExportMeta
	Speed uint32

	IDVendor            uint16
	IDProduct           uint16
	BcdDevice           uint16
	BDeviceClass        uint8
	BDeviceSubClass     uint8
	BDeviceProtocol     uint8
	BConfigurationValue uint8
	BNumConfigurations  uint8
	BNumInterfaces      uint8

	// Interfaces: for each interface: class, subclass, protocol, pad
	Interfaces []InterfaceDesc
}

ExportedDevice describes one exported device in devlist/import replies. Layout matches kernel doc, strings are fixed-size, remaining numbers are BE.

func (*ExportedDevice) WriteDevlist

func (d *ExportedDevice) WriteDevlist(w io.Writer) error

WriteDevlist writes the device entry for OP_REP_DEVLIST (includes interface triplets).

func (*ExportedDevice) WriteImport

func (d *ExportedDevice) WriteImport(w io.Writer) error

WriteImport writes the device entry for OP_REP_IMPORT (ends at bNumInterfaces).

type HeaderBasic

type HeaderBasic struct {
	Command uint32
	Seqnum  uint32
	Devid   uint32
	Dir     uint32
	Ep      uint32
}

HeaderBasic is common to all URB cmds and replies.

type InterfaceDesc

type InterfaceDesc struct {
	Class    uint8
	SubClass uint8
	Protocol uint8
}

type MgmtHeader

type MgmtHeader struct {
	Version uint16
	Command uint16
	Status  uint32
}

MgmtHeader is the 8-byte header for management ops (devlist/import).

func (*MgmtHeader) Write

func (h *MgmtHeader) Write(w io.Writer) error

type RetSubmit

type RetSubmit struct {
	Basic           HeaderBasic
	Status          int32
	ActualLength    uint32
	StartFrame      uint32
	NumberOfPackets uint32
	ErrorCount      uint32
	Padding         [8]byte
}

RetSubmit header (before payload) length is 0x30.

func (*RetSubmit) Write

func (r *RetSubmit) Write(w io.Writer) error
type RetUnlink struct {
	Basic   HeaderBasic
	Status  int32
	Padding [24]byte
}

func (*RetUnlink) Write

func (r *RetUnlink) Write(w io.Writer) error

Jump to

Keyboard shortcuts

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