ping: Add comments

This commit is contained in:
wwqgtxx 2025-08-25 10:18:22 +08:00
parent c089ffbd6c
commit 06ddb3e0a7
3 changed files with 11 additions and 7 deletions

View file

@ -160,6 +160,9 @@ func (c *Conn) ReadIP(buffer *buf.Buffer) error {
if !c.destination.Is6() {
ipHdr := header.IPv4(buffer.Bytes())
if runtime.GOOS == "darwin" || runtime.GOOS == "ios" {
// MacOS have different TotalLen and FragOff in ipv4 header from socket api:
// https://stackoverflow.com/questions/13829712/mac-changes-ip-total-length-field/15881825#15881825
// but in the tun api still same data format as other system
ipHdr.SetTotalLength(ipHdr.TotalLengthDarwinRaw())
ipHdr.SetFlagsFragmentOffset(ipHdr.FlagsDarwinRaw(), ipHdr.FragmentOffsetDarwinRaw())
}