From 6d23673e10bca2fb573809ff78506fc0566817dd Mon Sep 17 00:00:00 2001 From: Eyal Soha Date: Wed, 22 Apr 2020 07:27:34 -0700 Subject: Add comments about deepcopy in Layer.incoming() PiperOrigin-RevId: 307812340 --- test/packetimpact/testbench/connections.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'test/packetimpact') 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) } -- cgit v1.2.3