Skip to content

Commit

Permalink
Added Close function.
Browse files Browse the repository at this point in the history
  • Loading branch information
dustin committed Feb 16, 2012
1 parent b012e23 commit f83c6d1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pcap.go
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ func (p *Pcap) NextEx() (pkt *Packet, result int32) {
return return
} }


func (p *Pcap) Close() {
C.pcap_close(p.cptr)
}

func (p *Pcap) Geterror() string { func (p *Pcap) Geterror() string {
return C.GoString(C.pcap_geterr(p.cptr)) return C.GoString(C.pcap_geterr(p.cptr))
} }
Expand Down
1 change: 1 addition & 0 deletions tools/pcaptest/pcaptest.go
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func main() {
fmt.Printf("usage: pcaptest [-d <device> | -r <file>]\n") fmt.Printf("usage: pcaptest [-d <device> | -r <file>]\n")
return return
} }
defer h.Close()


fmt.Printf("pcap version: %s\n", pcap.Version()) fmt.Printf("pcap version: %s\n", pcap.Version())


Expand Down
1 change: 1 addition & 0 deletions tools/tcpdump/tcpdump.go
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func main() {
errout.Flush() errout.Flush()
return return
} }
defer h.Close()


if expr != "" { if expr != "" {
ferr := h.Setfilter(expr) ferr := h.Setfilter(expr)
Expand Down

0 comments on commit f83c6d1

Please sign in to comment.