Open ihciah opened 4 years ago
If that's how it works, yes, I do not have any macOS systems so cannot develop it myself.
@ihciah I have the same problem on macos, I have been using a Golang implementation without this problem: https://github.com/songgao/water
I just figured it out, the bytes are [0, 0, 0, 2], 2 stands for AF_INET/ AF_INET6. The header need also to be sent while writing to the socket, a userspace copy is required.
I checked out broingtun: https://github.com/cloudflare/boringtun, it use sengmsg with vectors so that it will reduce data copy.
On linux,
packet_information
default value is false, which means IFF_NO_PI will be used. But on macos, the 4-byte ethernet family header will be passed when read. I think the behavior should be consistent on different platforms. Should the behavior on macos changed? Maybepacket_information
can be applied for macos too to control whether remove the header?