scroot / gopacket

Automatically exported from code.google.com/p/gopacket
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

Mistake in pf_ring documentation #12

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello!

Here http://godoc.org/code.google.com/p/gopacket/pfring I found this example:
 if ring, err := pfring.NewRing("eth0", 65536, pfring.FlagPromisc); err != nil {
   panic(err)
 } else if err := ring.SetBPFFilter("tcp and port 80"); err != nil {  // optional
   panic(err)
 } else if err := ring.Enable(); err != nil { // Must do this!, or you get no packets!
   panic(err)
 } else {
   packetSource := gopacket.NewPacketSource(ring, gopacket.LinkTypeEthernet)
     for packet := range packetSource.Packets() {
    fmt.Println(packet)
     //handlePacket(packet)  // Do something with a packet here.
   }   
 }

But it has one mistake which prevent correct compiling:
go build example.go 
# command-line-arguments
./example.go:15: undefined: gopacket.LinkTypeEthernet 

You should replace gopacket.LinkTypeEthernet by layers.LayerTypeEthernet and 
add importing: 
import "code.google.com/p/gopacket/layers"

After this fixes all works prefectly.

Thank you!

Original issue reported on code.google.com by pavel.odintsov on 15 Jun 2014 at 10:56

GoogleCodeExporter commented 9 years ago
Done, thanks for the report.

Original comment by gconnell@google.com on 16 Jun 2014 at 4:52