Documentation ¶
Overview ¶
Package sniffer provides the implementation of data-link layer endpoints that wrap another endpoint and logs inbound and outbound packets.
Sniffer endpoints can be used in the networking stack by calling New(eID) to create a new endpoint, where eID is the ID of the endpoint being wrapped, and then passing it as an argument to Stack.CreateNIC().
Index ¶
Constants ¶
This section is empty.
Variables ¶
var LogPackets uint32 = 1
LogPackets is a flag used to enable or disable packet logging via the log package. Valid values are 0 or 1.
LogPackets must be accessed atomically.
var LogPacketsToFile uint32 = 1
LogPacketsToFile is a flag used to enable or disable logging packets to a pcap file. Valid values are 0 or 1. A file must have been specified when the sniffer was created for this flag to have effect.
LogPacketsToFile must be accessed atomically.
Functions ¶
func New ¶
func New(lower tcpip.LinkEndpointID) tcpip.LinkEndpointID
New creates a new sniffer link-layer endpoint. It wraps around another endpoint and logs packets and they traverse the endpoint.
func NewWithFile ¶
func NewWithFile(lower tcpip.LinkEndpointID, file *os.File, snapLen uint32) (tcpip.LinkEndpointID, error)
NewWithFile creates a new sniffer link-layer endpoint. It wraps around another endpoint and logs packets and they traverse the endpoint.
Packets can be logged to file in the pcap format. A sniffer created with this function will not emit packets using the standard log package.
snapLen is the maximum amount of a packet to be saved. Packets with a length less than or equal too snapLen will be saved in their entirety. Longer packets will be truncated to snapLen.
Types ¶
This section is empty.