support

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

Documentation

Overview

Package support identifies the different common features routers may support through interfaces that each router may or may not support.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bridge

type Bridge interface {
	Router
	// NewBridge returns a bridge name for tests to use.
	NewBridge(ctx context.Context) (string, error)
	// ReleaseBridge releases the bridge.
	ReleaseBridge(ctx context.Context, br string) error
}

Bridge shall be implemented if the router supports network bridges.

type Capture

type Capture interface {
	Router
	// StartCapture starts a packet capturer.
	StartCapture(ctx context.Context, name string, ch int, freqOps []iw.SetFreqOption, pcapOps ...pcap.Option) (*pcap.Capturer, error)
	// StartRawCapturer starts a capturer on an existing interface on the router instead of a
	// monitor type interface.
	StartRawCapturer(ctx context.Context, name, iface string, ops ...pcap.Option) (*pcap.Capturer, error)
	// StopCapture stops the packet capturer and releases related resources.
	StopCapture(ctx context.Context, capturer *pcap.Capturer) error
	// StopRawCapturer stops the packet capturer (no extra resources to release).
	StopRawCapturer(ctx context.Context, capturer *pcap.Capturer) error
	// ReserveForStopCapture returns a shortened ctx with cancel function.
	ReserveForStopCapture(ctx context.Context, capturer *pcap.Capturer) (context.Context, context.CancelFunc)
	// ReserveForStopRawCapturer returns a shortened ctx with cancel function.
	ReserveForStopRawCapturer(ctx context.Context, capturer *pcap.Capturer) (context.Context, context.CancelFunc)
}

Capture shall be implemented if the router supports pcap capture.

type DHCP

type DHCP interface {
	Router
	// StartDHCP starts the DHCP server and configures the server IP.
	StartDHCP(ctx context.Context, name, iface string, ipStart, ipEnd, serverIP, broadcastIP net.IP, mask net.IPMask) (*dhcp.Server, error)
	// StopDHCP stops the DHCP server and flushes the interface.
	StopDHCP(ctx context.Context, ds *dhcp.Server) error
}

DHCP shall be implemented if the router supports DHCP configuration.

type FrameSender

type FrameSender interface {
	Router
	// CloseFrameSender closes frame sender and releases related resources.
	CloseFrameSender(ctx context.Context, s *framesender.Sender) error
	// NewFrameSender creates a frame sender object.
	NewFrameSender(ctx context.Context, iface string) (*framesender.Sender, error)
	// ReserveForCloseFrameSender returns a shortened ctx with cancel function.
	ReserveForCloseFrameSender(ctx context.Context) (context.Context, context.CancelFunc)
}

FrameSender shall be implemented if the router can send management frames.

type Hostapd

type Hostapd interface {
	Router
	// StartHostapd starts the hostapd server.
	StartHostapd(ctx context.Context, name string, conf *hostapd.Config) (*hostapd.Server, error)
	// StopHostapd stops the hostapd server.
	StopHostapd(ctx context.Context, hs *hostapd.Server) error
	// ReconfigureHostapd restarts the hostapd server with the new config. It preserves the interface and the name of the old hostapd server.
	ReconfigureHostapd(ctx context.Context, hs *hostapd.Server, conf *hostapd.Config) (*hostapd.Server, error)
}

Hostapd shall be implemented if the router supports hostapd.

type IfaceManipulation

type IfaceManipulation interface {
	Router
	// SetAPIfaceDown brings down the interface that the APIface uses.
	SetAPIfaceDown(ctx context.Context, iface string) error
	// MAC returns the MAC address of iface on this router.
	MAC(ctx context.Context, iface string) (net.HardwareAddr, error)
}

IfaceManipulation shall be implemented if the router can modify its iface configuration.

type Logs

type Logs interface {
	Router
	// CollectLogs downloads log files from router to OutDir.
	CollectLogs(ctx context.Context) error
}

Logs shall be implemented if the router supports log collection.

type Router

type Router interface {
	// Close cleans the resource used by Router.
	Close(ctx context.Context) error
	// RouterName returns the name of the managed router device.
	RouterName() string
	// RouterType returns the router type.
	RouterType() RouterType
}

Router contains the basic methods that must be implemented across all routers.

type RouterType

type RouterType int

RouterType is an enum indicating what type of router style a router is.

const (
	// LegacyT is the legacy router type.
	LegacyT RouterType = iota
	// AxT is the ax router type.
	AxT
	// OpenWrtT is the openwrt router type.
	OpenWrtT
	// UnknownT is an unknown router type.
	UnknownT
)

func ParseRouterType

func ParseRouterType(rTypeStr string) (RouterType, error)

ParseRouterType parses a RouterType from a string.

func (RouterType) String

func (rt RouterType) String() string

String returns RouterType as a string.

type Veth

type Veth interface {
	Router
	// NewVethPair returns a veth pair for tests to use.
	NewVethPair(ctx context.Context) (string, string, error)
	// ReleaseVethPair release the veth pair.
	ReleaseVethPair(ctx context.Context, veth string) error
}

Veth shall be implemented if the router supports veths (virtual ethernet devices).

type VethBridgeBinding

type VethBridgeBinding interface {
	Router
	Bridge
	Veth
	// BindVethToBridge binds the veth to bridge.
	BindVethToBridge(ctx context.Context, veth, br string) error
	// UnbindVeth unbinds the veth to any other interface.
	UnbindVeth(ctx context.Context, veth string) error
}

VethBridgeBinding shall be implemented if the router supports bridges, veths, and can bind bridges and veths.

Jump to

Keyboard shortcuts

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