summaryrefslogtreecommitdiffhomepage
path: root/test/packetimpact/testbench
diff options
context:
space:
mode:
authorTing-Yu Wang <anivia@google.com>2021-03-03 16:03:04 -0800
committergVisor bot <gvisor-bot@google.com>2021-03-03 16:05:16 -0800
commit1cd76d958a9b3eb29f6b55a8bea71fbe464e67d3 (patch)
tree1f4df3b516c62a2aa630ffaf9c6ecba99482e3d3 /test/packetimpact/testbench
parentcfd2c31962a4358d7d05a4bd04dde271dc238339 (diff)
Make dedicated methods for data operations in PacketBuffer
One of the preparation to decouple underlying buffer implementation. There are still some methods that tie to VectorisedView, and they will be changed gradually in later CLs. This CL also introduce a new ICMPv6ChecksumParams to replace long list of parameters when calling ICMPv6Checksum, aiming to be more descriptive. PiperOrigin-RevId: 360778149
Diffstat (limited to 'test/packetimpact/testbench')
-rw-r--r--test/packetimpact/testbench/layers.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/test/packetimpact/testbench/layers.go b/test/packetimpact/testbench/layers.go
index 19e6b8d7d..64a7a171a 100644
--- a/test/packetimpact/testbench/layers.go
+++ b/test/packetimpact/testbench/layers.go
@@ -852,7 +852,13 @@ func (l *ICMPv6) ToBytes() ([]byte, error) {
if err != nil {
return nil, err
}
- h.SetChecksum(header.ICMPv6Checksum(h, *ipv6.SrcAddr, *ipv6.DstAddr, payload))
+ h.SetChecksum(header.ICMPv6Checksum(header.ICMPv6ChecksumParams{
+ Header: h,
+ Src: *ipv6.SrcAddr,
+ Dst: *ipv6.DstAddr,
+ PayloadCsum: header.ChecksumVV(payload, 0 /* initial */),
+ PayloadLen: payload.Size(),
+ }))
break
}
}
@@ -974,7 +980,7 @@ func (l *ICMPv4) ToBytes() ([]byte, error) {
var vv buffer.VectorisedView
vv.AppendView(buffer.View(l.Payload))
vv.Append(payload)
- h.SetChecksum(header.ICMPv4Checksum(h, vv))
+ h.SetChecksum(header.ICMPv4Checksum(h, header.ChecksumVV(vv, 0 /* initial */)))
}
return h, nil