Fix #1
parent
00bd0836d9
commit
003bb39786
36
d4-tlsf.go
36
d4-tlsf.go
|
@ -265,12 +265,7 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
var dec gopacket.Decoder
|
||||
var ok bool
|
||||
if dec, ok = gopacket.DecodersByLayerName["Ethernet"]; !ok {
|
||||
log.Fatal("No eth decoder")
|
||||
}
|
||||
source := gopacket.NewPacketSource(handle, dec)
|
||||
source := gopacket.NewPacketSource(handle, handle.LinkType())
|
||||
source.NoCopy = true
|
||||
Info("Starting to read packets\n")
|
||||
count := 0
|
||||
|
@ -294,12 +289,32 @@ func main() {
|
|||
w.Add(1)
|
||||
go processCompletedSession(jobQ, &w)
|
||||
|
||||
var eth layers.Ethernet
|
||||
var ip4 layers.IPv4
|
||||
var ip6 layers.IPv6
|
||||
parser := gopacket.NewDecodingLayerParser(layers.LayerTypeEthernet, ð, &ip4, &ip6)
|
||||
decoded := []gopacket.LayerType{}
|
||||
|
||||
for packet := range source.Packets() {
|
||||
count++
|
||||
Debug("PACKET #%d\n", count)
|
||||
data := packet.Data()
|
||||
bytes += int64(len(data))
|
||||
|
||||
data := packet.Data()
|
||||
|
||||
if err := parser.DecodeLayers(data, &decoded); err != nil {
|
||||
// Well it sures complaing about not knowing how to decode TCP
|
||||
}
|
||||
|
||||
fmt.Printf("%s\n", ip4.SrcIP)
|
||||
// fmt.Printf("%s", hex.Dump(decoded))
|
||||
|
||||
for _, layerType := range decoded {
|
||||
switch layerType {
|
||||
case layers.LayerTypeIPv6:
|
||||
fmt.Println(" IP6 ", ip6.SrcIP, ip6.DstIP)
|
||||
case layers.LayerTypeIPv4:
|
||||
|
||||
fmt.Println(" IP4 ", ip4.SrcIP, ip4.DstIP)
|
||||
// defrag the IPv4 packet if required
|
||||
if !*nodefrag {
|
||||
ip4Layer := packet.Layer(layers.LayerTypeIPv4)
|
||||
|
@ -341,6 +356,11 @@ func main() {
|
|||
assembler.AssembleWithContext(packet.NetworkLayer().NetworkFlow(), tcp, &c)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
bytes += int64(len(data))
|
||||
|
||||
var done bool
|
||||
select {
|
||||
case <-signalChan:
|
||||
|
|
Loading…
Reference in New Issue