iw

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: 15 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

View Source
var ErrWatcherClosed = errors.New("event channel is closed")

ErrWatcherClosed is an error for detecting that watcher is closed.

Functions

This section is empty.

Types

type Event

type Event struct {
	Type      EventType
	Timestamp time.Time
	Interface string
	Message   string
}

Event is the structure to store one event from "iw event".

type EventLogger

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

EventLogger captures events on a WiFi interface with "iw event".

func NewEventLogger

func NewEventLogger(ctx context.Context, dut *dut.DUT, ops ...EventWatcherOption) (*EventLogger, error)

NewEventLogger creates and starts a new EventLogger. Note that the logger may not be ready right after this function returned due to race condition, and it probably won't be fixed. Choose other solution if possible.

func (*EventLogger) ConnectedTime

func (e *EventLogger) ConnectedTime() (time.Time, error)

ConnectedTime finds the first connected event and returns the time.

func (*EventLogger) DisconnectTime

func (e *EventLogger) DisconnectTime() (time.Time, error)

DisconnectTime finds the first disconnect event and returns the time.

func (*EventLogger) Events

func (e *EventLogger) Events() []*Event

Events returns the captured events till now. Caller should not modify the returned slice.

func (*EventLogger) EventsByType

func (e *EventLogger) EventsByType(ets ...EventType) []*Event

EventsByType returns events captured with given EventType.

func (*EventLogger) Stop

func (e *EventLogger) Stop() error

Stop the EventLogger.

type EventType

type EventType int

EventType defines types of events captured by EventWatcher.

const (
	EventTypeDisconnect EventType = iota
	EventTypeChanSwitch
	EventTypeScanStart
	EventTypeConnected
	EventTypeUnknown
)

EventType enums.

type EventWatcher

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

EventWatcher captures events from a WiFi interface with "iw event".

func NewEventWatcher

func NewEventWatcher(ctx context.Context, dut *dut.DUT, ops ...EventWatcherOption) (*EventWatcher, error)

NewEventWatcher creates and starts a new EventWatcher. Note that the watcher may not be ready right after this function returned due to race condition, and it probably won't be fixed. Choose other solution if possible.

func (*EventWatcher) Stop

func (e *EventWatcher) Stop() error

Stop stops the EventWatcher. Note that it also closes the channel, that is, events are dropped even if they arrived before calling Stop() if the channel buffer is full.

func (*EventWatcher) Wait

func (e *EventWatcher) Wait(ctx context.Context) (*Event, error)

Wait waits for the next event. If there is no more event (i.e., channel has been closed), Wait returns an ErrWatcherClosed.

func (*EventWatcher) WaitByType

func (e *EventWatcher) WaitByType(ctx context.Context, ets ...EventType) (*Event, error)

WaitByType waits for the next matched event. Similar to Wait, a ErrWatcherClosed may be returned.

type EventWatcherOption

type EventWatcherOption func(*eventWatcherConfig)

EventWatcherOption is a function object type used to specify options of NewEventWatcher.

func EventsBufferSize

func EventsBufferSize(size int) EventWatcherOption

EventsBufferSize returns a Option that sets the buffer size of the events channel.

type Runner

type Runner = iw.Runner

Runner is an alias for common iw Runner but only for remote execution.

func NewRemoteRunner

func NewRemoteRunner(host *ssh.Conn) *Runner

NewRemoteRunner creates a iw runner for remote execution.

Jump to

Keyboard shortcuts

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