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

LinkType.LayerType() returns 0 for all types #1190

Open
en-vee opened this issue Sep 27, 2024 · 1 comment
Open

LinkType.LayerType() returns 0 for all types #1190

en-vee opened this issue Sep 27, 2024 · 1 comment

Comments

@en-vee
Copy link

en-vee commented Sep 27, 2024

In the following snippet, the LinkType().LayerType() method always returns a value of 0 for all layer types. It should return type=1 for example, when the link type is "Ethernet" or 113 when the linkType of the pcapgo.Reader is "Linux Cooked SLL"

	pcapReader, err := pcapgo.NewReader(r)
	if err != nil {
		return "", err
	}
	layerType := pcapReader.LinkType().LayerType()
@en-vee
Copy link
Author

en-vee commented Sep 27, 2024

I guess I can workaround by performing a type conversion of LinkType to LayerType as their underlying types are compatible. This works for me for now as I can pass this layerType to the NewPacketSource method when decoding individual packets.

	pcapReader, err := pcapgo.NewReader(r)
	if err != nil {
		return "", err
	}
	linkType := pcapReader.LinkType()
	layerType := gopacket.LayerType(linkType)

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

1 participant