Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InterfaceByName ¶
InterfaceByName returns the interface specified by name.
func OpenLive ¶
func OpenLive(conf *Config, pw ...PacketWriter) error
OpenLive opens a live capture based on the given configuration and writes all captured packets to the given PacketWriters.
Types ¶
type Config ¶
type Config struct { Device *net.Interface // The name of the network interface ("any" means listen on all interfaces). Snaplen int // The maximum length of each packet snapshot. Promisc bool // Promiscuous mode. This setting is ignored for "any" interface. Timeout time.Duration // The maximum duration of the packet capture process. PacketCount int // The maximum number of packets to capture. Expr string // BPF filter expression. }
type PacketWriter ¶
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
func (*Writer) WriteHeader ¶
WriteHeader writes a header to the writer.
The header contains metadata about the capture, such as the interface name, snapshot length, promiscuous mode, timeout, number of packets, and BPF filter.
The header is written in the following format:
- Interface: eth0
- Snapshot Length: 65535
- Promiscuous Mode: true
- Timeout: 5s
- Number of Packets: 0
- BPF Filter: "ip proto tcp"
- Verbose: true
Click to show internal directories.
Click to hide internal directories.