packetcapture

package
v0.0.0-...-a73b073 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler func(gopacket.Layer, gopacket.Packet)

Handler is passed to AddHandler() to capture a specific gopacket.LayerType.

type PacketCapture

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

func New

func New(netInterface string) *PacketCapture

New returns a new PacketCapture instance for the given netInterface

Close() must be called on the PacketCapture instance.

func (*PacketCapture) Close

func (pc *PacketCapture) Close()

func (*PacketCapture) RegisterReceiver

func (pc *PacketCapture) RegisterReceiver(receiver PacketReceiver)

RegisterReceiver registers a receiver for a given set of gopacket LayerTypes.

Each PacketReceiver will be called each time a packet in the set of LayerTypes is received.

Calls to PacketReceiver.Receiver happen in a separate goroutine.

func (*PacketCapture) Start

func (pc *PacketCapture) Start() error

type PacketReceiver

type PacketReceiver interface {
	LayerTypes() []gopacket.LayerType
	Receive(gopacket.Layer, gopacket.Packet)
}

PacketReceiver implementations can be registered with a PacketCapture to be recieve all the packets for a specified set of LayerTypes.

Jump to

Keyboard shortcuts

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