wifi

package module
v0.0.0-...-cf6c83a Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2018 License: MIT Imports: 13 Imported by: 0

README

wifi Build Status GoDoc Go Report Card

Package wifi provides access to IEEE 802.11 WiFi device actions and statistics. MIT Licensed.

At this time, package wifi supports the following operating systems:

  • Linux: using netlink, generic netlink, and nl80211.

If you would like to contribute support for another operating system, your contributions would be very welcome! Feel free to file an issue to discuss your plans.

Documentation

Overview

Package wifi provides access to IEEE 802.11 WiFi device actions and statistics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChannelToFreq

func ChannelToFreq(channel int) int

func FreqToChannel

func FreqToChannel(freq int) int

Types

type BSS

type BSS struct {
	// The service set identifier, or "network name" of the BSS.
	SSID string

	// The BSS service set identifier.  In infrastructure mode, this is the
	// hardware address of the wireless access point that a client is associated
	// with.
	BSSID net.HardwareAddr

	// The frequency used by the BSS, in MHz.
	Frequency int

	// The interval between beacon transmissions for this BSS.
	BeaconInterval time.Duration

	// The time since the client last scanned this BSS's information.
	LastSeen time.Duration

	// The status of the client within the BSS.
	Status BSSStatus
}

A BSS is an 802.11 basic service set. It contains information about a wireless network associated with an Interface.

type BSSStatus

type BSSStatus int

A BSSStatus indicates the current status of client within a BSS.

const (
	// BSSStatusAuthenticated indicates that a client is authenticated with a BSS.
	BSSStatusAuthenticated BSSStatus = iota

	// BSSStatusAssociated indicates that a client is associated with a BSS.
	BSSStatusAssociated

	// BSSStatusIBSSJoined indicates that a client has joined an independent BSS.
	BSSStatusIBSSJoined
)

func (BSSStatus) String

func (s BSSStatus) String() string

String returns the string representation of a BSSStatus.

type Client

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

A Client is a type which can access WiFi device actions and statistics using operating system-specific operations.

func New

func New() (*Client, error)

New creates a new Client.

func (*Client) BSS

func (c *Client) BSS(ifi *Interface) (*BSS, error)

BSS retrieves the BSS associated with a WiFi interface.

func (*Client) Close

func (c *Client) Close() error

Close releases resources used by a Client.

func (*Client) DelSTA

func (c *Client) DelSTA(STAMAC string) error

func (*Client) GetInterface

func (c *Client) GetInterface(ifiName string) (*Interface, error)

func (*Client) GetSTA

func (c *Client) GetSTA(MAC string) (*StationInfo, error)

func (*Client) GetWiphy

func (c *Client) GetWiphy(ifi *Interface) error

func (*Client) Interfaces

func (c *Client) Interfaces() ([]*Interface, error)

Interfaces returns a list of the system's WiFi network interfaces.

func (*Client) SetChannel

func (c *Client) SetChannel(ifiName string, channel int, channelType int) error

func (*Client) SetPhyName

func (c *Client) SetPhyName(ifiName string, name string) error

func (*Client) SetTxPower

func (c *Client) SetTxPower(ifiName string, PowerSetting int, dBm uint16) error

func (*Client) StationInfo

func (c *Client) StationInfo(ifiName string, STAMAC string) (*StationInfo, error)

func (*Client) StationInfoDump

func (c *Client) StationInfoDump(ifi *Interface) ([]*StationInfo, error)

StationInfo retrieves all station statistics about a WiFi interface.

type Interface

type Interface struct {
	// The index of the interface.
	Index int

	// The name of the interface.
	Name string

	// The hardware address of the interface.
	HardwareAddr net.HardwareAddr

	// The physical device that this interface belongs to.
	PHY int

	// The name of the physical device that this interface belongs to.
	PHYName string

	// The virtual device number of this interface within a PHY.
	Device int

	// The operating mode of the interface.
	Type InterfaceType

	// The interface's wireless frequency in MHz.
	Frequency int

	// Channel index
	Channel int

	// Channel type
	ChannelType int

	// Channel width
	ChanWidth string

	// Center frequency pimary
	CenterFreq1 int

	// Center frequency secondary
	CenterFreq2 int

	// Transmit power in dBm
	TxPower float32

	// SSID
	SSID string

	// List of the STAs associated to this interface
	STAList []string
}

An Interface is a WiFi network interface.

type InterfaceType

type InterfaceType int

An InterfaceType is the operating mode of an Interface.

const (
	// InterfaceTypeUnspecified indicates that an interface's type is unspecified
	// and the driver determines its function.
	InterfaceTypeUnspecified InterfaceType = iota

	// InterfaceTypeAdHoc indicates that an interface is part of an independent
	// basic service set (BSS) of client devices without a controlling access
	// point.
	InterfaceTypeAdHoc

	// InterfaceTypeStation indicates that an interface is part of a managed
	// basic service set (BSS) of client devices with a controlling access point.
	InterfaceTypeStation

	// InterfaceTypeAP indicates that an interface is an access point.
	InterfaceTypeAP

	// InterfaceTypeAPVLAN indicates that an interface is a VLAN interface
	// associated with an access point.
	InterfaceTypeAPVLAN

	// InterfaceTypeWDS indicates that an interface is a wireless distribution
	// interface, used as part of a network of multiple access points.
	InterfaceTypeWDS

	// InterfaceTypeMonitor indicates that an interface is a monitor interface,
	// receiving all frames from all clients in a given network.
	InterfaceTypeMonitor

	// InterfaceTypeMeshPoint indicates that an interface is part of a wireless
	// mesh network.
	InterfaceTypeMeshPoint

	// InterfaceTypeP2PClient indicates that an interface is a client within
	// a peer-to-peer network.
	InterfaceTypeP2PClient

	// InterfaceTypeP2PGroupOwner indicates that an interface is the group
	// owner within a peer-to-peer network.
	InterfaceTypeP2PGroupOwner

	// InterfaceTypeP2PDevice indicates that an interface is a device within
	// a peer-to-peer client network.
	InterfaceTypeP2PDevice

	// InterfaceTypeOCB indicates that an interface is outside the context
	// of a basic service set (BSS).
	InterfaceTypeOCB

	// InterfaceTypeNAN indicates that an interface is part of a near-me
	// area network (NAN).
	InterfaceTypeNAN
)

func (InterfaceType) String

func (t InterfaceType) String() string

String returns the string representation of an InterfaceType.

type StationInfo

type StationInfo struct {
	// The hardware address of the station.
	HardwareAddr net.HardwareAddr

	// The MAC of the interface that the STA is associated to
	Interface net.HardwareAddr

	// The index of the interface that the STA is associated to
	InterfaceIndex int

	// The time since the station last connected.
	Connected float64

	// The time since wireless activity last occurred.
	Inactive float64

	// Mesh LLID
	LLID int

	// Mesh PLID
	PLID int

	// Link status
	PlinkState string

	// The number of bytes received by this station.
	ReceivedBytes int

	// The number of bytes transmitted by this station.
	TransmittedBytes int

	// The number of packets received by this station.
	ReceivedPackets int

	// The number of packets transmitted by this station.
	TransmittedPackets int

	// The current data receive bitrate, in bits/second.
	ReceiveBitrate int

	// Transmit Digital Modulation Scheme (MCS)
	TransmitMCS string

	// The current data transmit bitrate, in bits/second.
	TransmitBitrate int

	// Transmit Digital Modulation Scheme (MCS)
	ReceiveMCS string

	// The signal strength of this station's connection, in dBm.
	Signal int

	// The signal strength of this station's connection, in dBm. Horizontal polarization
	SignalH int

	// The signal strength of this station's connection, in dBm. Vertical polarization
	SignalV int

	// The average signal strength of this station's connection, in dBm.
	SignalAvg int

	// The average signal strength of this station's connection, in dBm. Horizontal polarization
	SignalAvgH int

	// The average signal strength of this station's connection, in dBm. Vertical polarization
	SignalAvgV int

	// Authorized flag
	Authorized int

	// Authenticated flag
	Authenticated int

	// Associated flag
	Associated int

	// The number of times the station has had to retry while sending a packet.
	TransmitRetries int

	// The number of times a packet transmission failed.
	TransmitFailed int

	// The number of times a beacon loss was detected.
	BeaconLoss int
}

StationInfo contains statistics about a WiFi interface operating in station mode.

Directories

Path Synopsis
Package nl80211 is an auto-generated package which contains constants and types used to access nl80211 information using generic netlink.
Package nl80211 is an auto-generated package which contains constants and types used to access nl80211 information using generic netlink.

Jump to

Keyboard shortcuts

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