file

package
v0.0.0-...-65a12e2 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Overview

Provides native packet capturing and injection on pcap dump files without requiring the libpcap library.

Index

Constants

This section is empty.

Variables

View Source
var BigEndian = []byte{0xa1, 0xb2, 0xc3, 0xd4}
View Source
var LittleEndian = []byte{0xd4, 0xc3, 0xb2, 0xa1}

Functions

This section is empty.

Types

type Handle

type Handle struct {
	File string
	// contains filtered or unexported fields
}

func Open

func Open(file_name string) (*Handle, error)

Create a new capture handle from the given dump file. This will either open the file if it exists, or create a new one.

func (*Handle) Activate

func (h *Handle) Activate() error

Activate the capture handle (this is not needed for the file capture handle, but you may want to call it anyway in order to make switching to different packet sources easier).

func (*Handle) ApplyFilter

func (h *Handle) ApplyFilter(filter *filter.Filter) error

Apply the given filter it to the packet source. Only packets that match this filter will be captured.

func (*Handle) Capture

func (h *Handle) Capture() ([]byte, error)

Capture a single packet from the packet source. If no packet is available (i.e. if the end of the dump file has been reached) it will return a nil slice.

func (*Handle) Close

func (h *Handle) Close()

Close the packet source.

func (*Handle) Inject

func (h *Handle) Inject(buf []byte) error

Inject a packet in the packet source. This will automatically append packets at the end of the dump file, instead of truncating it.

func (*Handle) LinkType

func (h *Handle) LinkType() packet.Type

Return the link type of the capture handle (that is, the type of packets that come out of the packet source).

func (*Handle) SetMTU

func (h *Handle) SetMTU(mtu int) error

Not supported.

func (*Handle) SetMonitorMode

func (h *Handle) SetMonitorMode(monitor bool) error

Not supported.

func (*Handle) SetPromiscMode

func (h *Handle) SetPromiscMode(promisc bool) error

Not supported.

Jump to

Keyboard shortcuts

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