func main() { flag.Parse() var handle *pcap.Handle var err error if *fname != "" { if handle, err = pcap.OpenOffline(*fname); err != nil { log.Fatalln("PCAP OpenOffline error:", err) } } else { if handle, err = pcap.OpenLive(*iface, int32(*snaplen), true, time.Second); err != nil { log.Fatalln("PCAP OpenLive error:", err) } if *tstype != "" { if t, err := pcap.TimestampSourceFromString(*tstype); err != nil { log.Fatalf("Supported timestamp types: %v", handle.SupportedTimestamps()) } else if err := handle.SetTimestampSource(t); err != nil { log.Fatalf("Supported timestamp types: %v", handle.SupportedTimestamps()) } } if len(flag.Args()) > 0 { bpffilter := strings.Join(flag.Args(), " ") fmt.Fprintf(os.Stderr, "Using BPF filter %q\n", bpffilter) if err = handle.SetBPFFilter(bpffilter); err != nil { log.Fatalln("BPF filter error:", err) } } } dumpcommand.Run(handle) }
func main() { defer util.Run()() var ring *pfring.Ring var err error if ring, err = pfring.NewRing(*iface, uint32(*snaplen), pfring.FlagPromisc); err != nil { log.Fatalln("pfring ring creation error:", err) } if len(flag.Args()) > 0 { bpffilter := strings.Join(flag.Args(), " ") fmt.Fprintf(os.Stderr, "Using BPF filter %q\n", bpffilter) if err = ring.SetBPFFilter(bpffilter); err != nil { log.Fatalln("BPF filter error:", err) } } if *cluster >= 0 { if err = ring.SetCluster(*cluster, pfring.ClusterType(*clustertype)); err != nil { log.Fatalln("pfring SetCluster error:", err) } } if err = ring.SetSocketMode(pfring.ReadOnly); err != nil { log.Fatalln("pfring SetSocketMode error:", err) } else if err = ring.Enable(); err != nil { log.Fatalln("pfring Enable error:", err) } dumpcommand.Run(ring) }
func main() { flag.Parse() var handle *pcap.Handle var err error if *fname != "" { if handle, err = pcap.OpenOffline(*fname); err != nil { log.Fatalln("PCAP OpenOffline error:", err) } } else { if handle, err = pcap.OpenLive(*iface, int32(*snaplen), true, time.Second); err != nil { log.Fatalln("PCAP OpenLive error:", err) } if len(flag.Args()) > 0 { bpffilter := strings.Join(flag.Args(), " ") fmt.Fprintf(os.Stderr, "Using BPF filter %q\n", bpffilter) if err = handle.SetBPFFilter(bpffilter); err != nil { log.Fatalln("BPF filter error:", err) } } } dumpcommand.Run(handle) }