google / gopacket

Provides packet processing capabilities for Go
BSD 3-Clause "New" or "Revised" License
6.32k stars 1.13k forks source link

Compiling af_packet on 2.6 kernel #598

Open ajaykul opened 5 years ago

ajaykul commented 5 years ago

Hi, I am using a 2.6 kernel to compile af_packet. I see that the linux/if_packet.h does not have the fields and structs that are introduced by afpacket/header.go.

22:20:28 gopath/src/github.com/../vendor/github.com/google/gopacket/afpacket/header.go:148:24: could not determine kind of name for C.TP_STATUS_VLAN_VALID 22:20:28 gopath/src/github.com/../vendor/github.com/google/gopacket/afpacket/header.go:174:103: could not determine kind of name for C.sizeof_struct_tpacket3_hdr

I am trying to find a solution to fix this issue. How do you recommend we compile on older kernels?

ajaykul commented 5 years ago

462 added one of the fixes which caused the compilation error on my old system. Thoughts @deadpixi @gconnell

notti commented 5 years ago

C.TP_STATUS_VLAN_VALID: add C-code that #defines the constant (guarded with an #ifndef so it still works in older versions) for struct tpacket3_hdr you could do something similar - although for the corresponding #ifndef you would nee to search linux kernel git to find a #define that was added at the same time