summaryrefslogtreecommitdiffhomepage
path: root/test/packetimpact/testbench
diff options
context:
space:
mode:
authorEyal Soha <eyalsoha@google.com>2020-04-22 07:27:34 -0700
committergVisor bot <gvisor-bot@google.com>2020-04-22 07:28:39 -0700
commit6d23673e10bca2fb573809ff78506fc0566817dd (patch)
tree586112c39dd14df495fbacafc51d71a06d196784 /test/packetimpact/testbench
parent5e3596a6b8abb4c7ee8253be447b86a7b0fad7ad (diff)
Add comments about deepcopy in Layer.incoming()
PiperOrigin-RevId: 307812340
Diffstat (limited to 'test/packetimpact/testbench')
-rw-r--r--test/packetimpact/testbench/connections.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/test/packetimpact/testbench/connections.go b/test/packetimpact/testbench/connections.go
index 00a366894..952a717e0 100644
--- a/test/packetimpact/testbench/connections.go
+++ b/test/packetimpact/testbench/connections.go
@@ -72,7 +72,8 @@ type layerState interface {
// incoming creates an expected Layer for comparing against a received Layer.
// Because the expectation can depend on values in the received Layer, it is
// an input to incoming. For example, the ACK number needs to be checked in a
- // TCP packet but only if the ACK flag is set in the received packet.
+ // TCP packet but only if the ACK flag is set in the received packet. The
+ // calles takes ownership of the returned Layer.
incoming(received Layer) Layer
// sent updates the layerState based on the Layer that was sent. The input is
@@ -124,6 +125,7 @@ func (s *etherState) outgoing() Layer {
return &s.out
}
+// incoming implements layerState.incoming.
func (s *etherState) incoming(Layer) Layer {
return deepcopy.Copy(&s.in).(Layer)
}
@@ -168,6 +170,7 @@ func (s *ipv4State) outgoing() Layer {
return &s.out
}
+// incoming implements layerState.incoming.
func (s *ipv4State) incoming(Layer) Layer {
return deepcopy.Copy(&s.in).(Layer)
}
@@ -234,6 +237,7 @@ func (s *tcpState) outgoing() Layer {
return &newOutgoing
}
+// incoming implements layerState.incoming.
func (s *tcpState) incoming(received Layer) Layer {
tcpReceived, ok := received.(*TCP)
if !ok {
@@ -328,6 +332,7 @@ func (s *udpState) outgoing() Layer {
return &s.out
}
+// incoming implements layerState.incoming.
func (s *udpState) incoming(Layer) Layer {
return deepcopy.Copy(&s.in).(Layer)
}