ax

package
v0.0.0-...-683b059 Latest Latest
Warning

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

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

Documentation

Overview

Package ax provides utilities for accessing or controlling AX enabled routers.

Index

Constants

View Source
const RestartWirelessService = "restart_wireless"

RestartWirelessService is the binary name used to restart the wireless server by the ASUS router.

View Source
const RouterIface = "br0"

RouterIface is the default interface used by the ASUS router.

View Source
const SavedConfigLocation = "/tmp/nvram.cfg"

SavedConfigLocation is the path to save the temporary NVRAM config.

Variables

This section is empty.

Functions

func HostIsAXRouter

func HostIsAXRouter(ctx context.Context, host *ssh.Conn) (bool, error)

HostIsAXRouter determines whether the remote host is an AX router.

Types

type BandEnum

type BandEnum int

BandEnum is the type for specifying the radio's transmission frequency desired from the test.

const (
	// Ghz2 corresponds to the 2ghz band on the router.
	Ghz2 BandEnum = iota
	// Ghz5 corresponds to the 5ghz band on the router.
	Ghz5
	// Ghz6 corresponds to the 6ghz band on the router.
	Ghz6
)

type ChanBandwidthEnum

type ChanBandwidthEnum int

ChanBandwidthEnum selects what the channel bandwidth of the AP should be.

const (
	// Bw20 is 20Mhz.
	Bw20 ChanBandwidthEnum = iota
	// Bw40 is 40Mhz.
	Bw40
	// Bw80 is 80Mhz.
	Bw80
	// Bw160 is 160Mhz.
	Bw160
)

type CipherEnum

type CipherEnum int

CipherEnum selects what supported ciphers are for WPA authentication.

const (
	// AES supports the AES symmetrical cipher.
	AES CipherEnum = iota
	// TKIPAES supports the mixed TKIP and AES ciphers.
	TKIPAES
)

type Config

type Config struct {
	Type               DeviceType
	Band               RadioEnum
	SSID               string
	NVRAMOut           *string
	RouterRecoveryMap  map[string]ConfigParam
	RouterConfigParams []ConfigParam
	DUTConnOptions     []dutcfg.ConnOption
}

Config stores the necessary information for an AX test to run.

type ConfigParam

type ConfigParam struct {
	Band  RadioEnum
	Key   NVRAMKeyEnum
	Value string
}

ConfigParam contains the information to configure a parameter on the ax router.

type DeviceType

type DeviceType int

DeviceType is an enum indicating what model an AxRouter is.

const (
	// GtAx11000 is for the GT-Ax11000 device,
	GtAx11000 DeviceType = iota
	// GtAxe11000 is for the GT-Axe11000 device (6e).
	GtAxe11000
	// Ax6100 is for the Ax6100 device.
	Ax6100
	// Unknown means DeviceType will be resolved based on host.
	Unknown
)

func DeviceTypeFromString

func DeviceTypeFromString(deviceType string) (DeviceType, error)

DeviceTypeFromString parses deviceType for its corresponding DeviceType.

func (DeviceType) String

func (dt DeviceType) String() string

String returns a human-readable string describing the DeviceType.

type ModeEnum

type ModeEnum int

ModeEnum selects which WiFi protocol should be used for the AP.

const (
	// Mode80211ac tells the router to support 802.11ac.
	Mode80211ac ModeEnum = iota
	// Mode80211ax tells the router to support 802.11ax.
	Mode80211ax
)

type NVRAMKeyEnum

type NVRAMKeyEnum string

NVRAMKeyEnum is the type for specifying the key to modify when using the NVRAM commands.

const (
	// KeyAKM refers to the Authentication and Key Management chooses the authentication method (e.g None (""), psk2, etc).
	KeyAKM NVRAMKeyEnum = "akm"
	// KeyAuthMode Authentication mode (open, psk2).
	KeyAuthMode NVRAMKeyEnum = "auth_mode_x"
	// KeyWPAPSK is the preshared key for wpa authentication.
	KeyWPAPSK NVRAMKeyEnum = "wpa_psk"
	// KeyCrypto is the supported ciphers for wpa authentication.
	KeyCrypto NVRAMKeyEnum = "crypto"
	// KeySSID is the router's ssid on the chosen band.
	KeySSID NVRAMKeyEnum = "ssid"
	// KeyChanspec is the band's channel (1,2,3, etc).
	KeyChanspec NVRAMKeyEnum = "chanspec"
	// KeyClosed is a boolean (0,1) dictating whether the network is hidden (1 is hidden, 0 is open).
	KeyClosed NVRAMKeyEnum = "closed"
	// KeyRadio is a boolean (0,1) dictating whether the radio is enabled (1 is enabled, 0 is disabled).
	KeyRadio NVRAMKeyEnum = "radio"
	// KeyHeFeatures is an int (0-3) dictating what level of HE throughput features are supported.
	KeyHeFeatures NVRAMKeyEnum = "he_features"
	// KeyTxBfBfeCap is a boolean (0,1) dictating whether the radio is capable of being a beamformee.
	KeyTxBfBfeCap NVRAMKeyEnum = "txbf_bfe_cap"
	// KeyTxBfBfrCap is a boolean (0,1) dictating whether the radio is capable of being a beamformer.
	KeyTxBfBfrCap NVRAMKeyEnum = "txbf_bfr_cap"
	// KeyBw is an int dictating the router's bandwidth value.
	KeyBw NVRAMKeyEnum = "bw"
	// KeyBwCap is an int dictating the router's bandwidth capabilities.
	KeyBwCap NVRAMKeyEnum = "bw_cap"
	// KeyOBSSCap is a boolean (0,1) dictating the router's 160Mhz capabilities on GT0AX11000 devices.
	KeyOBSSCap NVRAMKeyEnum = "obss_coex"
	// KeyBw160 is a boolean (0,1) dictating the router's 160Mhz capabilities on AX6100 devices only.
	KeyBw160 NVRAMKeyEnum = "bw_160"
	// Key11Ax is a boolean (0,1) dictating the router's AX capabilities for Ax6100 only
	Key11Ax NVRAMKeyEnum = "11ax"
	// KeyBSSOpModeCapReqd is an int dictating the required capabilities required for BSS Operation (for Ax6100 only).
	KeyBSSOpModeCapReqd NVRAMKeyEnum = "bss_opmode_cap_reqd"
	// KeyNModeX is an int. Required for AX operation on Ax6100 devices. (0,9).
	KeyNModeX NVRAMKeyEnum = "nmode_x"
)

type Option

type Option func(*Config)

Option is the function signature used to specify options of Config.

func ChanBandwidth

func ChanBandwidth(ch int, bw ChanBandwidthEnum) Option

ChanBandwidth sets the APs supported channel width.

func Hidden

func Hidden(hidden bool) Option

Hidden sets whether the AP is hidden.

func Mode

func Mode(mode ModeEnum) Option

Mode sets the AP protocol of the router.

func Radio

func Radio(enabled bool) Option

Radio sets whether the Radio is enabled.

func SSID

func SSID(ssid string) Option

SSID sets the ssid of the AP.

type RadioEnum

type RadioEnum string

RadioEnum is the type for specifying band selection when using the NVRAM commands.

const (
	// Wl0 is the first radio on the router.
	Wl0 RadioEnum = "wl0"
	// Wl1 is the second radio on the router.
	Wl1 RadioEnum = "wl1"
	// Wl2 is the third radio on the router.
	Wl2 RadioEnum = "wl2"
	// WlInvalid is an invalid radio on the router.
	WlInvalid RadioEnum = "INVALID"
)

func BandToRadio

func BandToRadio(axtype DeviceType, r BandEnum) RadioEnum

BandToRadio converts the desired Band to the appropriate radio on the Ax Router.

type Router

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

Router is used to control an Asus AX wireless router and stores state of the router.

func NewRouter

func NewRouter(ctx, daemonCtx context.Context, host *ssh.Conn, name string) (*Router, error)

NewRouter prepares initial test AP state.

func (*Router) ApplyRouterSettings

func (r *Router) ApplyRouterSettings(ctx context.Context, cfg *Config) error

ApplyRouterSettings will take in the router config parameters, stage them, and then restart the wireless service to have the changes realized on the router.

func (*Router) Close

func (r *Router) Close(ctx context.Context) error

Close cleans the resource used by Router.

func (*Router) ResolveAXDeviceType

func (r *Router) ResolveAXDeviceType(ctx context.Context) (DeviceType, error)

ResolveAXDeviceType attempts to resolve the router's DeviceType based on the wps_modelnum value returned from running "nvram show" on the host.

func (*Router) RetrieveConfiguration

func (r *Router) RetrieveConfiguration(ctx context.Context) (string, error)

RetrieveConfiguration snapshots the current router's configuration in ram into a string.

func (*Router) RouterIP

func (r *Router) RouterIP(ctx context.Context) (string, error)

RouterIP gets the ax router's ip.

func (*Router) RouterName

func (r *Router) RouterName() string

RouterName returns the name of the managed router device.

func (*Router) RouterType

func (r *Router) RouterType() support.RouterType

RouterType returns the router's type.

func (*Router) UpdateConfig

func (r *Router) UpdateConfig(ctx context.Context, recoveryMap map[string]ConfigParam) error

UpdateConfig saves and applies the configuration to the router.

type SecConfigParamFac

type SecConfigParamFac interface {
	// Gen builds a list of ConfigParam.
	Gen(DeviceType, BandEnum) ([]ConfigParam, error)
}

SecConfigParamFac defines a Gen() method to generate a ConfigParam list.

func NewSecOpenConfigParamFac

func NewSecOpenConfigParamFac() SecConfigParamFac

NewSecOpenConfigParamFac builds a SecConfigParamFac for open network for the 802.11ax AP.

func NewSecOweConfigParamFac

func NewSecOweConfigParamFac() SecConfigParamFac

NewSecOweConfigParamFac builds a SecConfigParamFac for the OWE (WiFi Enhanced Open) network for the 802.11ax AP.

func NewSecSAEConfigParamFac

func NewSecSAEConfigParamFac(psk string, cipher CipherEnum) SecConfigParamFac

NewSecSAEConfigParamFac builds a SecConfigParamFac for WPA3-SAE network for the 802.11ay AP.

func NewSecWPAConfigParamFac

func NewSecWPAConfigParamFac(psk string, cipher CipherEnum) SecConfigParamFac

NewSecWPAConfigParamFac builds a SecConfigParamFac for WPA network for the 802.11ax AP.

type Security

type Security int

Security determines the PSK authentication method used by the test

const (
	// SecOpen is for an open (no password) flow
	SecOpen Security = iota
	// SecWPA is for the WPA2-PSK flow
	SecWPA
)

Jump to

Keyboard shortcuts

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