in internal/ip/ip_darwin.go [45:67]
func getIPHeaderLayerV4(tos DSCPValue, tcpLen uint16, srcIP net.IP, dstIP net.IP) *layers.IPv4 {
header := &layers.IPv4{
Version: 4, // IP Version 4
TOS: uint8(tos),
IHL: 5, // IHL: 20 bytes
Length: tcpLen + 20, // Total IP packet length
FragOffset: 0, // No fragmentation
Flags: 0, // Flags for fragmentation
TTL: defines.IPTTL,
Protocol: layers.IPProtocolTCP,
Checksum: 0, // Computed at serialization time
SrcIP: srcIP,
DstIP: dstIP,
}
// Manually convert Length and FragOffset to host-byte order for Darwin
header.Length = (header.Length << 8) | (header.Length >> 8)
nf := layers.IPv4Flag(header.FragOffset & 0xE0)
header.FragOffset = (header.FragOffset & 0x1F << 8) | (header.FragOffset>>8 | uint16(header.Flags))
header.Flags = nf
return header
}