iw

package
v0.0.0-...-9474aff Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package iw contains utility functions to wrap around the iw program.

Index

Constants

View Source
const (
	LinkKeyBeaconInterval = "beacon int"
	LinkKeyDtimPeriod     = "dtim period"
	LinkKeyFrequency      = "freq"
	LinkKeySignal         = "signal"
	LinkKeyRxBitrate      = "rx bitrate"
	LinkKeyRxDrops        = "rx drop misc"
	LinkKeyRxPackets      = "rx packets"
	LinkKeyTxBitrate      = "tx bitrate"
	LinkKeyTxFailures     = "tx failed"
	LinkKeyTxPackets      = "tx packets"
	LinkKeyTxRetries      = "tx retries"
)

The iw link keys.

Variables

This section is empty.

Functions

This section is empty.

Types

type BSSData

type BSSData struct {
	BSS       string
	Frequency int
	SSID      string
	Security  string
	HT        string
	Signal    float64
}

BSSData contains contents pertaining to a BSS response.

type Band

type Band struct {
	Num            int
	FrequencyFlags map[int][]string
	MCSIndices     []int
}

Band contains supported wireless band attributes.

type ChWidth

type ChWidth string

ChWidth is the type of channel width setting (e.g. HT40+, 80 ...).

const (
	ChWidthNOHT      ChWidth = "NOHT"
	ChWidthHT20      ChWidth = "HT20"
	ChWidthHT40Plus  ChWidth = "HT40+"
	ChWidthHT40Minus ChWidth = "HT40-"
	ChWidth80        ChWidth = "80"
	ChWidth80P80     ChWidth = "80+80"
	ChWidth160       ChWidth = "160"
)

ChWidth enum values. TODO(crbug.com/1017533, crbug.com/1005443): we can use 80MHz instead of 80 if the routers in testlab are upgraded to have new enough iw (>4.14).

type ChannelConfig

type ChannelConfig struct {
	Number, Freq, Width, Center1Freq int
}

ChannelConfig contains the configuration data for a radio config.

type IfType

type IfType string

IfType is the type of WiFi interface.

const (
	IfTypeManaged IfType = "managed"
	IfTypeMonitor IfType = "monitor"
)

IfType enums. (Only defines the values useful for us. For complete list of possible values, please refer to iftype_name in iw.) NOTE: When adding new types, please also update the busy type logic in remote/wificell/router.go

type NetDev

type NetDev struct {
	PhyNum int
	IfName string
	IfType IfType
}

NetDev contains interface attributes from `iw dev`.

func (NetDev) String

func (n NetDev) String() string

String implements the Stringer interface for NetDev.

type Phy

type Phy struct {
	Name                      string
	Bands                     []Band
	Modes, Commands, Features []string
	RxAntenna, TxAntenna      int
	MaxScanSSIDs              int
	MaxSTAs                   int
	SupportHESTA              bool
	SupportHE40HE80STA        bool
	SupportHE160STA           bool
	SupportHEAP               bool
	SupportHE40HE80AP         bool
	SupportHE160AP            bool
	SupportHT2040             bool
	SupportHT20SGI            bool
	SupportHT40SGI            bool
	SupportVHT                bool
	SupportVHT80SGI           bool
	SupportMUMIMO             bool
}

Phy contains phy# attributes.

func (*Phy) SupportSetAntennaMask

func (p *Phy) SupportSetAntennaMask() bool

SupportSetAntennaMask tells if we can set the antenna bitmap on the Phy.

type Runner

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

Runner is the object contains iw utilities.

func NewRunner

func NewRunner(c cmd.Runner) *Runner

NewRunner creates a new iw command utility runner.

func (*Runner) AddInterface

func (r *Runner) AddInterface(ctx context.Context, phy, iface string, t IfType) error

AddInterface creates a interface on phy with name=iface and type=t.

func (*Runner) CurrentBSSID

func (r *Runner) CurrentBSSID(ctx context.Context, iface string) (string, error)

CurrentBSSID gets the BSS ID the interface associated with from iw link output.

func (*Runner) InterfaceAttributes

func (r *Runner) InterfaceAttributes(ctx context.Context, iface string) (*NetDev, error)

InterfaceAttributes gets the interface's attributes.

func (*Runner) IsRegulatorySelfManaged

func (r *Runner) IsRegulatorySelfManaged(ctx context.Context) (bool, error)

IsRegulatorySelfManaged determines if any WiFi device on the system manages its own regulatory info (NL80211_ATTR_WIPHY_SELF_MANAGED_REG).

func (*Runner) LinkValue

func (r *Runner) LinkValue(ctx context.Context, iface, iwLinkKey string) (string, error)

LinkValue gets the specified link value from the iw link output.

func (*Runner) ListInterfaces

func (r *Runner) ListInterfaces(ctx context.Context) ([]*NetDev, error)

ListInterfaces yields all the attributes (NetDev) for each interface.

func (*Runner) ListPhys

func (r *Runner) ListPhys(ctx context.Context) ([]*Phy, []byte, error)

ListPhys returns a list of Phy struct for each phy on the DUT. Note that it returns an empty list without error when "iw list" command returns nothing. Client must check []*Phy's length before accessing it.

func (*Runner) OperatingMode

func (r *Runner) OperatingMode(ctx context.Context, iface string) (string, error)

OperatingMode gets the interface's operating mode.

func (*Runner) PhyByID

func (r *Runner) PhyByID(ctx context.Context, id int) (*Phy, error)

PhyByID returns a Phy struct for the given phy id.

func (*Runner) PhyByName

func (r *Runner) PhyByName(ctx context.Context, name string) (*Phy, error)

PhyByName returns a Phy struct for the given name.

func (*Runner) PhyRegulatoryDomain

func (r *Runner) PhyRegulatoryDomain(ctx context.Context, phy string) (string, error)

PhyRegulatoryDomain gets the phy-specific regulatory domain code.

func (*Runner) PowersaveMode

func (r *Runner) PowersaveMode(ctx context.Context, iface string) (bool, error)

PowersaveMode returns true if powersave mode is enabled and false if it is disabled.

func (*Runner) RadioConfig

func (r *Runner) RadioConfig(ctx context.Context, iface string) (*ChannelConfig, error)

RadioConfig gets the radio configuration from the interface's information.

func (*Runner) RegulatoryDomain

func (r *Runner) RegulatoryDomain(ctx context.Context) (string, error)

RegulatoryDomain gets the regulatory domain code.

func (*Runner) RemoveInterface

func (r *Runner) RemoveInterface(ctx context.Context, iface string) error

RemoveInterface removes the iface.

func (*Runner) ScanDump

func (r *Runner) ScanDump(ctx context.Context, iface string) ([]*BSSData, error)

ScanDump returns a list of BSSData from a scan dump.

func (*Runner) SetAntennaBitmap

func (r *Runner) SetAntennaBitmap(ctx context.Context, phy string, txBitmap, rxBitmap int) error

SetAntennaBitmap sets the antenna bitmap.

func (*Runner) SetFreq

func (r *Runner) SetFreq(ctx context.Context, iface string, freq int, ops ...SetFreqOption) error

SetFreq sets the wireless interface's LO center freq. Interface should be in monitor mode before scanning.

func (*Runner) SetPowersaveMode

func (r *Runner) SetPowersaveMode(ctx context.Context, iface string, turnOn bool) error

SetPowersaveMode sets the powersave mode.

func (*Runner) SetRegulatoryDomain

func (r *Runner) SetRegulatoryDomain(ctx context.Context, country string) error

SetRegulatoryDomain sets the regulatory domain code. country is ISO/IEC 3166-1 alpha2 code for the country.

func (*Runner) SetTxPower

func (r *Runner) SetTxPower(ctx context.Context, iface, mode string, power int) error

SetTxPower sets the wireless interface's transmit power. mode: 'fixed' or 'limit' power: power in mBm (milli-Bel-milliwatts). 1 mBm = 100 * dBm (deci-Bell-milliwatts).

func (*Runner) SetTxPowerAuto

func (r *Runner) SetTxPowerAuto(ctx context.Context, iface string) error

SetTxPowerAuto sets the wireless interface's transmit power to auto mode.

func (*Runner) TimedScan

func (r *Runner) TimedScan(ctx context.Context, iface string,
	frequencies []int, ssids []string) (*TimedScanData, error)

TimedScan runs a scan on a specified interface and frequencies (if applicable). A channel map for valid frequencies can be found in third_party/autotest/files/server/cros/network/hostap_config.py The frequency slice is used to list which frequencies/bands to scan on. The SSIDs slice will filter the results of the scan to those that pertain to the allowed SSIDs (although this doesn't seem to work on some devices).

type SetFreqOption

type SetFreqOption func(*setFreqConf)

SetFreqOption is a function signature that modifies setFreqConf.

func SetFreqCenterFreq1

func SetFreqCenterFreq1(f int) SetFreqOption

SetFreqCenterFreq1 returns a SetFreqOption which sets the first center frequency (in MHz).

func SetFreqCenterFreq2

func SetFreqCenterFreq2(f int) SetFreqOption

SetFreqCenterFreq2 returns a SetFreqOption which sets the second center frequency (in MHz).

func SetFreqChWidth

func SetFreqChWidth(cw ChWidth) SetFreqOption

SetFreqChWidth returns a SetFreqOption which sets channel width.

func (SetFreqOption) Equal

func (op SetFreqOption) Equal(other SetFreqOption) bool

Equal checks if the effects of the two SetFreqOptions on an empty setFreqConfig are the same. This is useful for external package to write unit tests.

func (SetFreqOption) String

func (op SetFreqOption) String() string

String formats the option to string by the result of applying it on empty config. This is useful for external packages to write unit tests.

type TimedScanData

type TimedScanData struct {
	Time    time.Duration
	BSSList []*BSSData
}

TimedScanData contains the BSS responses from an `iw scan` and its execution time.

Jump to

Keyboard shortcuts

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