legacy

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

Documentation

Overview

Package legacy provides utilities for accessing or controlling legacy router architecture.

This legacy router implementation is used to manage Gale routers, and also Whirlwind routers previously.

This package is expected to be eventually deprecated in favor of newer router implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HostIsLegacyRouter

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

HostIsLegacyRouter determines whether the remote host is a Legacy router.

Types

type Router

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

Router is used to control the legacy 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 (e.g., initializing wiphy/wdev). ctx is the deadline for the step and daemonCtx is the lifetime for background daemons.

func (*Router) BindVethToBridge

func (r *Router) BindVethToBridge(ctx context.Context, veth, br string) error

BindVethToBridge binds the veth to bridge.

func (*Router) Close

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

Close cleans the resource used by Router.

func (*Router) CloseFrameSender

func (r *Router) CloseFrameSender(ctx context.Context, s *framesender.Sender) error

CloseFrameSender closes frame sender and releases related resources.

func (*Router) CollectLogs

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

CollectLogs downloads log files from router to OutDir.

func (*Router) MAC

func (r *Router) MAC(ctx context.Context, iface string) (net.HardwareAddr, error)

MAC returns the MAC address of iface on this router.

func (*Router) NewBridge

func (r *Router) NewBridge(ctx context.Context) (_ string, retErr error)

NewBridge returns a bridge name for tests to use. Note that the caller is responsible to call ReleaseBridge.

func (*Router) NewFrameSender

func (r *Router) NewFrameSender(ctx context.Context, iface string) (ret *framesender.Sender, retErr error)

NewFrameSender creates a frame sender object.

func (*Router) NewVethPair

func (r *Router) NewVethPair(ctx context.Context) (_, _ string, retErr error)

NewVethPair returns a veth pair for tests to use. Note that the caller is responsible to call ReleaseVethPair.

func (*Router) ReconfigureHostapd

func (r *Router) ReconfigureHostapd(ctx context.Context, hs *hostapd.Server, conf *hostapd.Config) (_ *hostapd.Server, retErr error)

ReconfigureHostapd restarts the hostapd server with the new config. It preserves the interface and the name of the old hostapd server.

func (*Router) ReleaseBridge

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

ReleaseBridge releases the bridge.

func (*Router) ReleaseVethPair

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

ReleaseVethPair release the veth pair. Note that each side of the pair can be passed to this method, but the test should only call the method once for each pair.

func (*Router) ReserveForCloseFrameSender

func (r *Router) ReserveForCloseFrameSender(ctx context.Context) (context.Context, context.CancelFunc)

ReserveForCloseFrameSender returns a shortened ctx with cancel function. The shortened ctx is used for running things before r.CloseFrameSender() to reserve time for it to run.

func (*Router) ReserveForStopCapture

func (r *Router) ReserveForStopCapture(ctx context.Context, capturer *pcap.Capturer) (context.Context, context.CancelFunc)

ReserveForStopCapture returns a shortened ctx with cancel function. The shortened ctx is used for running things before r.StopCapture() to reserve time for it to run.

func (*Router) ReserveForStopRawCapturer

func (r *Router) ReserveForStopRawCapturer(ctx context.Context, capturer *pcap.Capturer) (context.Context, context.CancelFunc)

ReserveForStopRawCapturer returns a shortened ctx with cancel function. The shortened ctx is used for running things before r.StopRawCapture to reserve time for it.

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) SetAPIfaceDown

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

SetAPIfaceDown brings down the interface that the APIface uses.

func (*Router) StartCapture

func (r *Router) StartCapture(ctx context.Context, name string, ch int, freqOps []iw.SetFreqOption, pcapOps ...pcap.Option) (ret *pcap.Capturer, retErr error)

StartCapture starts a packet capturer. After getting a Capturer instance, c, the caller should call r.StopCapture(ctx, c) at the end, and use the shortened ctx (provided by r.ReserveForStopCapture(ctx, c)) before r.StopCapture() to reserve time for it to run.

func (*Router) StartDHCP

func (r *Router) StartDHCP(ctx context.Context, name, iface string, ipStart, ipEnd, serverIP, broadcastIP net.IP, mask net.IPMask) (_ *dhcp.Server, retErr error)

StartDHCP starts the DHCP server and configures the server IP.

func (*Router) StartHostapd

func (r *Router) StartHostapd(ctx context.Context, name string, conf *hostapd.Config) (_ *hostapd.Server, retErr error)

StartHostapd starts the hostapd server.

func (*Router) StartRawCapturer

func (r *Router) StartRawCapturer(ctx context.Context, name, iface string, ops ...pcap.Option) (*pcap.Capturer, error)

StartRawCapturer starts a capturer on an existing interface on the router instead of a monitor type interface. This function is useful for the tests that don't care the 802.11 frames but the behavior of upper layer traffic and tests can capture packets directly on AP's interface.

func (*Router) StopCapture

func (r *Router) StopCapture(ctx context.Context, capturer *pcap.Capturer) error

StopCapture stops the packet capturer and releases related resources.

func (*Router) StopDHCP

func (r *Router) StopDHCP(ctx context.Context, ds *dhcp.Server) error

StopDHCP stops the DHCP server and flushes the interface.

func (*Router) StopHostapd

func (r *Router) StopHostapd(ctx context.Context, hs *hostapd.Server) error

StopHostapd stops the hostapd server.

func (*Router) StopRawCapturer

func (r *Router) StopRawCapturer(ctx context.Context, capturer *pcap.Capturer) error

StopRawCapturer stops the packet capturer (no extra resources to release).

func (*Router) UnbindVeth

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

UnbindVeth unbinds the veth to any other interface.

Jump to

Keyboard shortcuts

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