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

@ -335,7 +335,7 @@ func (b IPv4) FragmentOffset() uint16 {
}
func (b IPv4) FragmentOffsetDarwinRaw() uint16 {
return binary.NativeEndian.Uint16(b[flagsFO:]) << 3
return common.NativeEndian.Uint16(b[flagsFO:]) << 3
}
// TotalLength returns the "total length" field of the IPv4 header.
@ -344,7 +344,7 @@ func (b IPv4) TotalLength() uint16 {
}
func (b IPv4) TotalLengthDarwinRaw() uint16 {
return binary.NativeEndian.Uint16(b[IPv4TotalLenOffset:]) + uint16(b.HeaderLength())
return common.NativeEndian.Uint16(b[IPv4TotalLenOffset:]) + uint16(b.HeaderLength())
}
// Checksum returns the checksum field of the IPv4 header.
@ -441,7 +441,7 @@ func (b IPv4) SetTotalLength(totalLength uint16) {
}
func (b IPv4) SetTotalLengthDarwinRaw(totalLength uint16) {
binary.NativeEndian.PutUint16(b[IPv4TotalLenOffset:], totalLength)
common.NativeEndian.PutUint16(b[IPv4TotalLenOffset:], totalLength)
}
// SetChecksum sets the checksum field of the IPv4 header.
@ -458,7 +458,7 @@ func (b IPv4) SetFlagsFragmentOffset(flags uint8, offset uint16) {
func (b IPv4) SetFlagsFragmentOffsetDarwinRaw(flags uint8, offset uint16) {
v := (uint16(flags) << 13) | (offset >> 3)
binary.NativeEndian.PutUint16(b[flagsFO:], v)
common.NativeEndian.PutUint16(b[flagsFO:], v)
}
// SetID sets the identification field.