Documentation ¶
Overview ¶
Package iw contains utility functions to wrap around the iw program.
Index ¶
- Constants
- type BSSData
- type Band
- type ChWidth
- type ChannelConfig
- type IfType
- type NetDev
- type Phy
- type Runner
- func (r *Runner) AddInterface(ctx context.Context, phy, iface string, t IfType) error
- func (r *Runner) CurrentBSSID(ctx context.Context, iface string) (string, error)
- func (r *Runner) InterfaceAttributes(ctx context.Context, iface string) (*NetDev, error)
- func (r *Runner) IsRegulatorySelfManaged(ctx context.Context) (bool, error)
- func (r *Runner) LinkValue(ctx context.Context, iface, iwLinkKey string) (string, error)
- func (r *Runner) ListInterfaces(ctx context.Context) ([]*NetDev, error)
- func (r *Runner) ListPhys(ctx context.Context) ([]*Phy, []byte, error)
- func (r *Runner) OperatingMode(ctx context.Context, iface string) (string, error)
- func (r *Runner) PhyByID(ctx context.Context, id int) (*Phy, error)
- func (r *Runner) PhyByName(ctx context.Context, name string) (*Phy, error)
- func (r *Runner) PhyRegulatoryDomain(ctx context.Context, phy string) (string, error)
- func (r *Runner) PowersaveMode(ctx context.Context, iface string) (bool, error)
- func (r *Runner) RadioConfig(ctx context.Context, iface string) (*ChannelConfig, error)
- func (r *Runner) RegulatoryDomain(ctx context.Context) (string, error)
- func (r *Runner) RemoveInterface(ctx context.Context, iface string) error
- func (r *Runner) ScanDump(ctx context.Context, iface string) ([]*BSSData, error)
- func (r *Runner) SetAntennaBitmap(ctx context.Context, phy string, txBitmap, rxBitmap int) error
- func (r *Runner) SetFreq(ctx context.Context, iface string, freq int, ops ...SetFreqOption) error
- func (r *Runner) SetPowersaveMode(ctx context.Context, iface string, turnOn bool) error
- func (r *Runner) SetRegulatoryDomain(ctx context.Context, country string) error
- func (r *Runner) SetTxPower(ctx context.Context, iface, mode string, power int) error
- func (r *Runner) SetTxPowerAuto(ctx context.Context, iface string) error
- func (r *Runner) TimedScan(ctx context.Context, iface string, frequencies []int, ssids []string) (*TimedScanData, error)
- type SetFreqOption
- type TimedScanData
Constants ¶
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 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.
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 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 ¶
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 (*Runner) AddInterface ¶
AddInterface creates a interface on phy with name=iface and type=t.
func (*Runner) CurrentBSSID ¶
CurrentBSSID gets the BSS ID the interface associated with from iw link output.
func (*Runner) InterfaceAttributes ¶
InterfaceAttributes gets the interface's attributes.
func (*Runner) IsRegulatorySelfManaged ¶
IsRegulatorySelfManaged determines if any WiFi device on the system manages its own regulatory info (NL80211_ATTR_WIPHY_SELF_MANAGED_REG).
func (*Runner) ListInterfaces ¶
ListInterfaces yields all the attributes (NetDev) for each interface.
func (*Runner) ListPhys ¶
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 ¶
OperatingMode gets the interface's operating mode.
func (*Runner) PhyRegulatoryDomain ¶
PhyRegulatoryDomain gets the phy-specific regulatory domain code.
func (*Runner) PowersaveMode ¶
PowersaveMode returns true if powersave mode is enabled and false if it is disabled.
func (*Runner) RadioConfig ¶
RadioConfig gets the radio configuration from the interface's information.
func (*Runner) RegulatoryDomain ¶
RegulatoryDomain gets the regulatory domain code.
func (*Runner) RemoveInterface ¶
RemoveInterface removes the iface.
func (*Runner) SetAntennaBitmap ¶
SetAntennaBitmap sets the antenna bitmap.
func (*Runner) SetFreq ¶
SetFreq sets the wireless interface's LO center freq. Interface should be in monitor mode before scanning.
func (*Runner) SetPowersaveMode ¶
SetPowersaveMode sets the powersave mode.
func (*Runner) SetRegulatoryDomain ¶
SetRegulatoryDomain sets the regulatory domain code. country is ISO/IEC 3166-1 alpha2 code for the country.
func (*Runner) SetTxPower ¶
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 ¶
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 ¶
TimedScanData contains the BSS responses from an `iw scan` and its execution time.