usb

package
v0.0.0-...-aefe1c9 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GC_LIST_STATE_IGNORE gcListState = iota
	GC_LIST_STATE_IGNORE_ACTION
	GC_LIST_STATE_GLOBAL_FIELD
	GC_LIST_STATE_LANGUAGE
	GC_LIST_STATE_LANGUAGE_FIELD
	GC_LIST_STATE_FUNCTION
	GC_LIST_STATE_FUNCTION_FIELD
	GC_LIST_STATE_CONFIG
	GC_LIST_STATE_CONFIG_FIELD
	GC_LIST_STATE_CONFIG_LANGUAGE
)
View Source
const (
	GC_LIST_MATCHER_ID                = "ID "
	GC_LIST_MATCHER_LANGUAGE          = "Language: "
	GC_LIST_MATCHER_FUNCTION          = "Function, type: "
	GC_LIST_MATCHER_FUNCTION_INSTANCE = "instance: "
	GC_LIST_MATCHER_CONFIG            = "Configuration: "
)
View Source
const RNDIS_USE_GADGET_FUNCTION = "rndis"

Variables

View Source
var MAX_USB_GADGET_SUBPATH_FILESIZE = int(max(
	1<<20,
	min(memory.TotalMemory()>>1, 1<<30),

)) // at least 1 MiB

Functions

This section is empty.

Types

type UsbGadget

type UsbGadget struct {
	base.SubpathWriter
	base.PathChecker
	// contains filtered or unexported fields
}

func NewUsbGadget

func NewUsbGadget(config_fs string) (*UsbGadget, error)

func (*UsbGadget) GetBasepath

func (this *UsbGadget) GetBasepath() string

type UsbGadgetAdb

type UsbGadgetAdb struct {
	UsbGadgetFunctionBase
	// contains filtered or unexported fields
}

func NewUsbGadgetAdb

func NewUsbGadgetAdb(ffs_path string) *UsbGadgetAdb

func SnapshotUsbGadgetAdb

func SnapshotUsbGadgetAdb(instance string) *UsbGadgetAdb

type UsbGadgetContext

type UsbGadgetContext = *UsbGadget

type UsbGadgetController

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

func NewUsbGadgetController

func NewUsbGadgetController(
	config_fs string,
	gc_path string,

) (*UsbGadgetController, error)

func (*UsbGadgetController) AddFunction

func (this *UsbGadgetController) AddFunction(function UsbGadgetFunction) error

add function to `this.target_functions` or overwrite the function which have the same path

func (*UsbGadgetController) Apply

func (this *UsbGadgetController) Apply() map[string]error

func (*UsbGadgetController) ClearFunctions

func (this *UsbGadgetController) ClearFunctions() []error

func (*UsbGadgetController) GetFunctions

func (this *UsbGadgetController) GetFunctions() map[string]UsbGadgetFunction

func (*UsbGadgetController) RemoveFunction

func (this *UsbGadgetController) RemoveFunction(function UsbGadgetFunction) error

remove function which `getType()` matched in `this.target_functions`

func (*UsbGadgetController) ReplaceFunction

func (this *UsbGadgetController) ReplaceFunction(function UsbGadgetFunction, replace_only bool) error

replace function which `getType()` matched in `this.target_functions`, the action as same as `AddFunction()` if not found and `replace_only` is not true

also, whenever `getInstance()` is empty, the action as same as `AddFunction()` if `replace_only` is not true

func (*UsbGadgetController) UpdateGadget

func (this *UsbGadgetController) UpdateGadget() []error

type UsbGadgetFunction

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

func AdaptUsbGadgetFunction

func AdaptUsbGadgetFunction(_type string, instance string, fields map[string]string) (UsbGadgetFunction, error)

type UsbGadgetFunctionBase

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

type UsbGadgetFunctionCode

type UsbGadgetFunctionCode uint32
const (
	USB_GADGET_FUNCTION_CODE_NONE  UsbGadgetFunctionCode = 0
	USB_GADGET_FUNCTION_CODE_RNDIS UsbGadgetFunctionCode = 0b1
	USB_GADGET_FUNCTION_CODE_ADB   UsbGadgetFunctionCode = 0b01
)

type UsbGadgetRndis

type UsbGadgetRndis struct {
	UsbGadgetFunctionBase
	// contains filtered or unexported fields
}

func NewUsbGadgetRndis

func NewUsbGadgetRndis(ip_addr netip.Prefix, connection_prefix string, dev_addr string, host_addr string, ifname string, qmult string, dnsmasq_args []string, serial_number string, manufacturer string, product string) *UsbGadgetRndis

func SnapshotUsbGadgetRndis

func SnapshotUsbGadgetRndis(instance string) *UsbGadgetRndis

type UsbGadgetState

type UsbGadgetState map[string]string

type UsbGadgetSubpath

type UsbGadgetSubpath string
const (
	USB_GADGET_SUBPATH_VENDOR          UsbGadgetSubpath = "idVendor"
	USB_GADGET_SUBPATH_PRODUCT         UsbGadgetSubpath = "idProduct"
	USB_GADGET_SUBPATH_BCD_USB         UsbGadgetSubpath = "bcdUSB"
	USB_GADGET_SUBPATH_DEVICE_CLASS    UsbGadgetSubpath = "bDeviceClass"
	USB_GADGET_SUBPATH_DEVICE_SUBCLASS UsbGadgetSubpath = "bDeviceSubClass"
	USB_GADGET_SUBPATH_DEVICE_PROTOCOL UsbGadgetSubpath = "bDeviceProtocol"
)

type UsbGadgetSubpathStrings

type UsbGadgetSubpathStrings string
const (
	USB_GADGET_SUBPATH_STRINGS_SERIALNUMBER UsbGadgetSubpathStrings = "serialnumber"
	USB_GADGET_SUBPATH_STRINGS_MANUFACTURER UsbGadgetSubpathStrings = "manufacturer"
	USB_GADGET_SUBPATH_STRINGS_PRODUCT      UsbGadgetSubpathStrings = "product"
)

Jump to

Keyboard shortcuts

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