pcap

package
v0.0.0-...-c97f47a Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2020 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Overview

Provides packet capturing and injection on live network interfaces via libpcap.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handle

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

func Open

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

Create a new capture handle from the given network interface. Noe that this may require root privileges.

func (*Handle) Activate

func (h *Handle) Activate() error

Activate the packet source. Note that after calling this method it will not be possible to change the packet source configuration (MTU, promiscuous mode, monitor mode, ...)

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. This will block until a packet is received.

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.

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

func (*Handle) SetMonitorMode

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

Enable/disable monitor mode. This is only relevant to RF-based packet sources (e.g. a WiFi or Bluetooth network interface)

func (*Handle) SetPromiscMode

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

Enable/disable promiscuous mode.

Jump to

Keyboard shortcuts

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