示例#1
0
文件: pcap.go 项目: jasonish/dumpy
func DumpOpen(pcap *Pcap, filename string) (*Dumper, error) {
	var dumper Dumper
	dumper.dumper = C.pcap_dump_open(pcap.pcap, C.CString(filename))
	if dumper.dumper == nil {
		return nil, errors.New(pcap.GetErr())
	}
	return &dumper, nil
}
示例#2
0
func (p *Pcap) DumpOpen(ofile *string) (dumper *PcapDumper, err error) {
	d := new(PcapDumper)
	d.cptr = C.pcap_dump_open(p.cptr, C.CString(*ofile))
	if nil == d.cptr {
		return d, errors.New("Cannot open dumpfile")
	}
	dumper = d
	return
}
示例#3
0
文件: pcap.go 项目: donckers/gopacket
// Returns a Dumper read to write packets from the given pcap
// handler in the file given as parameter.
func (h *Handle) NewDumper(file string) (dumper *Dumper, err error) {
	cf := C.CString(file)
	defer C.free(unsafe.Pointer(cf))

	cptr, err := C.pcap_dump_open(h.cptr, cf)
	if err != nil {
		return
	}
	if cptr == nil {
		return nil, fmt.Errorf("Failed to open file: %s", file)
	}
	return &Dumper{h: h, cptr: cptr}, nil
}
示例#4
0
文件: pcap.go 项目: sungit/gopcap
func NewPcapDumper(p *Pcap, filename string) (pd *PcapDumper) {
	pd = new(PcapDumper)
	pd.cptr = C.pcap_dump_open(p.cptr, C.CString(filename))
	return
}