-
Notifications
You must be signed in to change notification settings - Fork 8
/
README.md
54 lines (42 loc) · 1.07 KB
/
README.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# golibwireshark
[![GoDoc](http://godoc.org/github.com/sunwxg/golibwireshark?status.svg)](http://godoc.org/github.com/sunwxg/golibwireshark)
Package golibwireshark use libwireshark library to decode pcap file and analyse dissection data.
This package can only be used in OS linux with CPU x86_64.
If you want to use it on other CPU structure, you need compile library in libs folder from source code.
### Dependencies
* libwireshark library (version 1.12.8)
* libglib2.0
### Install
- ubuntu
```
apt-get install libglib2.0-dev
go get github.com/sunwxg/golibwireshark
cd $GOPATH/src/github.com/sunwxg/golibwireshark
cat libs/libwireshark.{00,01,02,03} > libs/libwireshark.so
chmod 775 libs/libwireshark.so
go build
go test
```
### Examples
```go
file := "1.pcap"
outfile := "o.pcap"
key := "ip.addr"
err := golibwireshark.Init(file, outfile)
if err != nil {
fmt.Printf("open file failed\n")
return
}
defer golibwireshark.Clean()
var p golibwireshark.Packet
for {
p.GetPacket()
if p.Edt == nil {
break
}
if _, ok := p.IsKey(key); ok {
p.WriteToFile()
}
p.FreePacket()
}
```