google / google/gopacket

i can't offline filtering from pcap file

Open
#920 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
6.8k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

I want to filter incoming packets and write them to a new file. But I can't filter. SetBPFFilter function returns empty.
what should I do ?

if handle, err := pcap.**OpenOffline**(/home/x/x/example.pcap); err != nil {
panic(err)
} else if err := **handle.SetBPFFilter(" port 80");** err != nil { // Filter
panic(err)
} else {
packetSource := gopacket.NewPacketSource(handle, handle.LinkType())
for packet := range packetSource.Packets() {
fmt.Println(packet) // Do something with a packet here.
writeFile(packet, fmt.Sprint(t.Id))

}
}
}

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.