Documentation ¶
Overview ¶
Package pcap provides utilities to capture WiFi packets.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseProbeReqSSID ¶
func ParseProbeReqSSID(req *layers.Dot11MgmtProbeReq) (string, error)
ParseProbeReqSSID parses the frame body of a probe request packet and returns the SSID in the request.
Types ¶
type Capturer ¶
type Capturer struct {
// contains filtered or unexported fields
}
Capturer controls a tcpdump process to capture packets on an interface.
func StartCapturer ¶
func StartCapturer(ctx context.Context, host *ssh.Conn, name, iface, workDir string, opts ...Option) (*Capturer, error)
StartCapturer creates and starts a Capturer. After getting a Capturer instance, c, the caller should call c.Close() at the end, and use the shortened ctx (provided by c.ReserveForClose()) before c.Close() to reserve time for it to run.
func (*Capturer) Close ¶
Close terminates the capturer and downloads the pcap file from host to OutDir.
func (*Capturer) PacketPath ¶
PacketPath returns the path of the result pcap file so that the tests can verify the content of captured packets. This function should be called after Close (i.e. packet downloaded), otherwise it will return error.
func (*Capturer) ReserveForClose ¶
ReserveForClose returns a shortened ctx with cancel function. The shortened ctx is used for running things before c.Close() to reserve time for it to run.
type Filter ¶
Filter is the function type for filtering packets. The packet should be dropped if it returns false.
func Dot11FCSValid ¶
func Dot11FCSValid() Filter
Dot11FCSValid returns a Filter which ensures the frame check sequence of the 802.11 frame is valid. It checks RadioTapFCS and Dot11FCS in sequence. Checking Dot11 FCS after RadioTap.Flags.BadFCS=false is redundant for most cases. But there is still one rare case we need to cover, which is RadioTap integrity checking is malfunctioning.
func RejectLowSignal ¶
func RejectLowSignal() Filter
RejectLowSignal returns a Filter which ensures the signal strength is good enough (greater than -85 dBm).
func TransmitterAddress ¶
func TransmitterAddress(mac net.HardwareAddr) Filter
TransmitterAddress returns a Filter which ensures the Transmitter Address matches the given MAC address.