Improve checksum usages
This commit is contained in:
parent
f9bbb15bfb
commit
adc106bcf6
9 changed files with 23 additions and 45 deletions
|
|
@ -479,7 +479,9 @@ func (b IPv4) SetDestinationAddress(addr tcpip.Address) {
|
|||
|
||||
// CalculateChecksum calculates the checksum of the IPv4 header.
|
||||
func (b IPv4) CalculateChecksum() uint16 {
|
||||
return checksum.Checksum(b[:b.HeaderLength()], 0)
|
||||
xsum0 := checksum.Checksum(b[:xsum], 0)
|
||||
xsum0 = checksum.Checksum(b[xsum+2:b.HeaderLength()], xsum0)
|
||||
return xsum0
|
||||
}
|
||||
|
||||
// Encode encodes all the fields of the IPv4 header.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue