Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindDeviceByName ¶
FindDeviceByName returns the device with the provided name.
func ListDeviceNames ¶
ListDeviceNames returns a list of available network adapters. The printDescription parameter will include the adapter name and printIP will include the IP assigned to it.
Types ¶
type AFPacketHandle ¶
AFPacketHandle is an implementation of a gopacket PacketSource.
func OpenAFPacket ¶
func OpenAFPacket(device, filter string, bufferSize int, timeout time.Duration) (*AFPacketHandle, error)
OpenAFPacket opens a DeviceHandle for live capture via AF_Packet on a given interface. The buffer size depends on system memory, with frame and block sizes calculated from the size of the buffer, system page size, and a default snaplen of 1600. Generally multiples of 25MB are a good size, since 1600 bytes is an even multiple when page sizes are in powers of 2. By default, 128 blocks can fit in 25MB. AF_Packet is only available on Linux systems.
func (*AFPacketHandle) Close ¶
func (h *AFPacketHandle) Close()
Close is an implementation of a gopacket PacketSource's Close method.
func (*AFPacketHandle) LinkType ¶
func (h *AFPacketHandle) LinkType() layers.LinkType
LinkType is an implementation of a gopacket PacketSource's LinkType method.
func (*AFPacketHandle) ReadPacketData ¶
func (h *AFPacketHandle) ReadPacketData() (data []byte, ci gopacket.CaptureInfo, err error)
ReadPacketData is an implementation of a gopacket PacketSource's ReadPacketData method.
func (*AFPacketHandle) SetBPFFilter ¶
func (h *AFPacketHandle) SetBPFFilter(filter string, frameSize int) (_ error)
SetBPFFilter is an implementation of a gopacket PacketSource's SetBPFFilter method.
type DeviceHandle ¶
type DeviceHandle interface { gopacket.PacketDataSource LinkType() layers.LinkType Close() }
DeviceHandle is an implementation of the gopacket PacketDataSource. A custom handle is used so that we can stub out different device types across platforms.