Documentation ¶
Overview ¶
Package openwrt provides utilities for accessing and controlling Router routers.
Index ¶
- func HostIsOpenWrtRouter(ctx context.Context, host *ssh.Conn) (bool, error)
- type Router
- func (r *Router) Close(ctx context.Context) error
- func (r *Router) CollectLogs(ctx context.Context) error
- func (r *Router) ReconfigureHostapd(ctx context.Context, hs *hostapd.Server, conf *hostapd.Config) (*hostapd.Server, error)
- 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) StartCapture(ctx context.Context, name string, ch int, freqOps []iw.SetFreqOption, ...) (_ *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, 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) (retErr error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router controls an OpenWrt router and stores the router state.
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) CollectLogs ¶
CollectLogs downloads log files from router to OutDir.
func (*Router) ReconfigureHostapd ¶
func (r *Router) ReconfigureHostapd(ctx context.Context, hs *hostapd.Server, conf *hostapd.Config) (*hostapd.Server, error)
ReconfigureHostapd restarts the hostapd server with the new config. It preserves the interface and the name of the old hostapd server.
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.
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 type.
func (*Router) StartCapture ¶
func (r *Router) StartCapture(ctx context.Context, name string, ch int, freqOps []iw.SetFreqOption, pcapOps ...pcap.Option) (_ *pcap.Capturer, retErr error)
StartCapture starts a packet capturer.
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, 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.
func (*Router) StopCapture ¶
StopCapture stops the packet capturer and releases related resources.
func (*Router) StopHostapd ¶
StopHostapd stops the hostapd server.