Improve checksum usages
This commit is contained in:
parent
f9bbb15bfb
commit
adc106bcf6
9 changed files with 23 additions and 45 deletions
|
|
@ -90,7 +90,6 @@ func (f *ICMPForwarder) HandlePacket(id stack.TransportEndpointID, pkt *stack.Pa
|
|||
sourceAddress := ipHdr.SourceAddress()
|
||||
ipHdr.SetSourceAddress(ipHdr.DestinationAddress())
|
||||
ipHdr.SetDestinationAddress(sourceAddress)
|
||||
icmpHdr.SetChecksum(0)
|
||||
icmpHdr.SetChecksum(header.ICMPv4Checksum(icmpHdr[:header.ICMPv4MinimumSize], pkt.Data().Checksum()))
|
||||
ipHdr.SetChecksum(0)
|
||||
ipHdr.SetChecksum(^ipHdr.CalculateChecksum())
|
||||
|
|
@ -154,9 +153,11 @@ func (f *ICMPForwarder) HandlePacket(id stack.TransportEndpointID, pkt *stack.Pa
|
|||
ipHdr.SetSourceAddress(ipHdr.DestinationAddress())
|
||||
ipHdr.SetDestinationAddress(sourceAddress)
|
||||
icmpHdr.SetChecksum(header.ICMPv6Checksum(header.ICMPv6ChecksumParams{
|
||||
Header: icmpHdr,
|
||||
Src: ipHdr.SourceAddress(),
|
||||
Dst: ipHdr.DestinationAddress(),
|
||||
Header: icmpHdr,
|
||||
Src: ipHdr.SourceAddress(),
|
||||
Dst: ipHdr.DestinationAddress(),
|
||||
PayloadCsum: pkt.Data().Checksum(),
|
||||
PayloadLen: pkt.Data().Size(),
|
||||
}))
|
||||
outgoingEP, gErr := f.stack.GetNetworkEndpoint(DefaultNIC, header.IPv4ProtocolNumber)
|
||||
if gErr != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue