mdlayher / raw

Package raw enables reading and writing data at the device driver level for a network interface. MIT Licensed.
MIT License
425 stars 71 forks source link

Parse the BPF header for length #50

Open arktos opened 5 years ago

arktos commented 5 years ago

Instead of hard-coding the length of the BPF header, this pull-request casts the header into a Go struct and gets the length of the header from that struct. This neatly solves a problem where the header length varies not only with the OS, but also by the architecture.

This solution works without further hacks on FreeBSD and OpenBSD. I haven't had time to test this on NetBSD as raw doesn't build there yet due to the structure of its timeval.

mdlayher commented 5 years ago

Apologies for the delay. Could you please rebase this on master as well? Thanks.