packetcapture

package
v0.0.0-...-a149a6f Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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