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 }
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 }
// 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 }
func NewPcapDumper(p *Pcap, filename string) (pd *PcapDumper) { pd = new(PcapDumper) pd.cptr = C.pcap_dump_open(p.cptr, C.CString(filename)) return }