Documentation ¶
Overview ¶
Provides native packet capturing and injection on pcap dump files without requiring the libpcap library.
Index ¶
- Variables
- type Handle
- func (h *Handle) Activate() error
- func (h *Handle) ApplyFilter(filter *filter.Filter) error
- func (h *Handle) Capture() ([]byte, error)
- func (h *Handle) Close()
- func (h *Handle) Inject(buf []byte) error
- func (h *Handle) LinkType() packet.Type
- func (h *Handle) SetMTU(mtu int) error
- func (h *Handle) SetMonitorMode(monitor bool) error
- func (h *Handle) SetPromiscMode(promisc bool) error
Constants ¶
This section is empty.
Variables ¶
var BigEndian = []byte{0xa1, 0xb2, 0xc3, 0xd4}
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 ¶
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 ¶
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 ¶
Apply the given filter it to the packet source. Only packets that match this filter will be captured.
func (*Handle) Capture ¶
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) Inject ¶
Inject a packet in the packet source. This will automatically append packets at the end of the dump file, instead of truncating it.