hostapd

package
Version: v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package hostapd is used to interact with hostapd's control interface. More information about the control interface: http://w1.fi/wpa_supplicant/devel/hostapd_ctrl_iface_page.html

Index

Constants

This section is empty.

Variables

View Source
var ErrTerminating = errors.New("wpa_supplicant is exiting")

ErrTerminating is returned by attach when and if the control interface terminates the connection. This can be because WiFi interface configuration was changed and hostapd is restarting.

Functions

This section is empty.

Types

type Client

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

Client is a hostapd control interface client.

func NewClient

func NewClient(ctrlSock string) (*Client, error)

NewClient connects to the hostap control interface located at ctrlSock.

func (*Client) Attach

func (c *Client) Attach(ctx context.Context, events func(Event) error) error

Attach subscribes to hostapd events. For each event, the provided callback function will be called. The callback should return quickly, since it blocks attach from processing. Attach blocks until an error occurs or the provided context is canceled. Any error returned from the provided callback will stop attach and be returned.

func (*Client) Close

func (c *Client) Close() error

Close closes the connection to the control interface. The client is no longer usable after closing.

func (*Client) Stations

func (c *Client) Stations() ([]Station, error)

Stations returns the connected stations. Note that stations with Associated=false should not be considered as connected. This state can happen if Stations is called immediately after a station disconnects.

func (*Client) Status

func (c *Client) Status() (Status, error)

Status returns the station's status.

type Event

type Event interface {
	// Raw returns the string used by the control interface
	// to represent this event.
	Raw() string
}

Event is an unsolicited message received from the hostapd control interface.

type EventStationConnect

type EventStationConnect struct {
	MAC string
	// contains filtered or unexported fields
}

EventStationConnect is an event that happens when a station (WiFi client) connects to the AP.

func (EventStationConnect) Raw

func (e EventStationConnect) Raw() string

Raw returns event as given by hostapd. Satisifes the Event interface.

type EventStationDisconnect

type EventStationDisconnect struct {
	MAC string
	// contains filtered or unexported fields
}

EventStationDisconnect is an event that happens when a station (WiFi client) disconnects from the AP.

func (EventStationDisconnect) Raw

Raw returns event as given by hostapd. Satisifes the Event interface.

type EventTerminating

type EventTerminating string

EventTerminating is received when the wpa_supplicant is exiting. This can happen, for example, when the wireless settings are changed and hostapd is restarted.

func (EventTerminating) Raw

func (e EventTerminating) Raw() string

Raw returns event as given by hostapd. Satisifes the Event interface.

type EventUnrecognized

type EventUnrecognized string

EventUnrecognized is a catch-all event for unrecognized events. Its Raw method returns the contents of the message.

func (EventUnrecognized) Raw

func (e EventUnrecognized) Raw() string

Raw returns event as given by hostapd. Satisifes the Event interface.

type Station

type Station struct {
	MAC        string
	Associated bool
	RxBytes    int64
	TxBytes    int64
	Connected  time.Duration
	Inactive   time.Duration
	Signal     int
}

Station contains information about a WiFi station (client).

type Status

type Status struct {
	State      string
	Channel    int
	MaxTxPower int
	SSID       string
	BSSID      string
}

Status holds information about the WPA. This is a subset of all the fields returned from the control interface. More info: https://w1.fi/wpa_supplicant/devel/ctrl_iface_page.html#ctrl_iface_STATUS

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL