Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to decode LinkType 20 #1198

Open
HaibaraAi119 opened this issue Nov 19, 2024 · 5 comments
Open

Unable to decode LinkType 20 #1198

HaibaraAi119 opened this issue Nov 19, 2024 · 5 comments

Comments

@HaibaraAi119
Copy link

i use tcpdump to get a tcp package,and then save a cap file,
but i use gopacket parsing this cap file,following error occurs:
"Packet decoding error: Unable to decode LinkType 20"

my code:
handle, err = pcap.OpenOffline(capFile)

packetSource := gopacket.NewPacketSource(handle, handle.LinkType())
//go print_counter()
for packet := range packetSource.Packets() {
fmt.Println(packet) //Packet decoding error: Unable to decode LinkType 20
printPacketInfo(packet)
}

... ...

tcpLayer := packet.Layer(layers.LayerTypeTCP) //Causes an error here ,is null

@scila1996
Copy link

Please switch to this. The newer link type with the latest device has been updated, and it is working for me

https://pkg.go.dev/github.com/gopacket/gopacket

@8ugr4
Copy link

8ugr4 commented Nov 29, 2024

I fixed it like this once, it was causing because of linux sll2 packet and afaik this lib doesn't include it. so smth like

const sll2HeaderSize       = 20
// remove the first 20 bytes that only has sll2 information, unrelated to the packet info.
packetBytes := packet.Data()[sll2HeaderSize:] 
// create new packet 
packet = gopacket.NewPacket(packetBytes, layers.LayerTypeIPv4, gopacket.Default)

@HaibaraAi119
Copy link
Author

Please switch to this. The newer link type with the latest device has been updated, and it is working for me

https://pkg.go.dev/github.com/gopacket/gopacket

gopacket

i'd like to how about its compatibility with old gopacket

@8ugr4
Copy link

8ugr4 commented Dec 2, 2024

It's the same, just a maintained fork afaik.

@HaibaraAi119
Copy link
Author

It's the same, just a maintained fork afaik.

i had tested it today,it's working great !!!
Thank you again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants