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 ¶
- func HostIsLegacyRouter(ctx context.Context, host *ssh.Conn) (bool, error)
- type Router
- func (r *Router) BindVethToBridge(ctx context.Context, veth, br string) error
- func (r *Router) Close(ctx context.Context) error
- func (r *Router) CloseFrameSender(ctx context.Context, s *framesender.Sender) error
- func (r *Router) CollectLogs(ctx context.Context) error
- func (r *Router) MAC(ctx context.Context, iface string) (net.HardwareAddr, error)
- func (r *Router) NewBridge(ctx context.Context) (_ string, retErr error)
- func (r *Router) NewFrameSender(ctx context.Context, iface string) (ret *framesender.Sender, retErr error)
- func (r *Router) NewVethPair(ctx context.Context) (_, _ string, retErr error)
- func (r *Router) ReconfigureHostapd(ctx context.Context, hs *hostapd.Server, conf *hostapd.Config) (_ *hostapd.Server, retErr error)
- func (r *Router) ReleaseBridge(ctx context.Context, br string) error
- func (r *Router) ReleaseVethPair(ctx context.Context, veth string) error
- func (r *Router) ReserveForCloseFrameSender(ctx context.Context) (context.Context, context.CancelFunc)
- func (r *Router) ReserveForStopCapture(ctx context.Context, capturer *pcap.Capturer) (context.Context, context.CancelFunc)
- func (r *Router) ReserveForStopRawCapturer(ctx context.Context, capturer *pcap.Capturer) (context.Context, context.CancelFunc)
- func (r *Router) RouterName() string
- func (r *Router) RouterType() support.RouterType
- func (r *Router) SetAPIfaceDown(ctx context.Context, iface string) error
- func (r *Router) StartCapture(ctx context.Context, name string, ch int, freqOps []iw.SetFreqOption, ...) (ret *pcap.Capturer, retErr error)
- func (r *Router) StartDHCP(ctx context.Context, name, iface string, ...) (_ *dhcp.Server, retErr error)
- func (r *Router) StartHostapd(ctx context.Context, name string, conf *hostapd.Config) (_ *hostapd.Server, retErr error)
- func (r *Router) StartRawCapturer(ctx context.Context, name, iface string, ops ...pcap.Option) (*pcap.Capturer, error)
- func (r *Router) StopCapture(ctx context.Context, capturer *pcap.Capturer) error
- func (r *Router) StopDHCP(ctx context.Context, ds *dhcp.Server) error
- func (r *Router) StopHostapd(ctx context.Context, hs *hostapd.Server) error
- func (r *Router) StopRawCapturer(ctx context.Context, capturer *pcap.Capturer) error
- func (r *Router) UnbindVeth(ctx context.Context, veth string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ¶
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 ¶
BindVethToBridge binds the veth to bridge.
func (*Router) CloseFrameSender ¶
CloseFrameSender closes frame sender and releases related resources.
func (*Router) CollectLogs ¶
CollectLogs downloads log files from router to OutDir.
func (*Router) NewBridge ¶
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 ¶
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 ¶
ReleaseBridge releases the bridge.
func (*Router) ReleaseVethPair ¶
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 ¶
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 ¶
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 ¶
StopCapture stops the packet capturer and releases related resources.
func (*Router) StopHostapd ¶
StopHostapd stops the hostapd server.
func (*Router) StopRawCapturer ¶
StopRawCapturer stops the packet capturer (no extra resources to release).