summaryrefslogtreecommitdiffhomepage
path: root/test/packetimpact/testbench
diff options
context:
space:
mode:
Diffstat (limited to 'test/packetimpact/testbench')
-rw-r--r--test/packetimpact/testbench/connections.go15
-rw-r--r--test/packetimpact/testbench/layers.go4
2 files changed, 12 insertions, 7 deletions
diff --git a/test/packetimpact/testbench/connections.go b/test/packetimpact/testbench/connections.go
index 50b9ccf68..576577310 100644
--- a/test/packetimpact/testbench/connections.go
+++ b/test/packetimpact/testbench/connections.go
@@ -306,11 +306,11 @@ func (s *tcpState) incoming(received Layer) Layer {
if s.remoteSeqNum != nil {
newIn.SeqNum = Uint32(uint32(*s.remoteSeqNum))
}
- if s.localSeqNum != nil && (*tcpReceived.Flags&header.TCPFlagAck) != 0 {
+ if seq, flags := s.localSeqNum, tcpReceived.Flags; seq != nil && flags != nil && *flags&header.TCPFlagAck != 0 {
// The caller didn't specify an AckNum so we'll expect the calculated one,
// but only if the ACK flag is set because the AckNum is not valid in a
// header if ACK is not set.
- newIn.AckNum = Uint32(uint32(*s.localSeqNum))
+ newIn.AckNum = Uint32(uint32(*seq))
}
return &newIn
}
@@ -603,9 +603,9 @@ func (conn *Connection) ExpectFrame(t *testing.T, layers Layers, timeout time.Du
}
if gotLayers == nil {
if errs == nil {
- return nil, fmt.Errorf("got no frames matching %v during %s", layers, timeout)
+ return nil, fmt.Errorf("got no frames matching %s during %s", layers, timeout)
}
- return nil, fmt.Errorf("got frames %w want %v during %s", errs, layers, timeout)
+ return nil, fmt.Errorf("got frames:\n%w want %s during %s", errs, layers, timeout)
}
if conn.match(layers, gotLayers) {
for i, s := range conn.layerStates {
@@ -615,7 +615,12 @@ func (conn *Connection) ExpectFrame(t *testing.T, layers Layers, timeout time.Du
}
return gotLayers, nil
}
- errs = multierr.Combine(errs, &layersError{got: gotLayers, want: conn.incoming(gotLayers)})
+ want := conn.incoming(layers)
+ if err := want.merge(layers); err != nil {
+ errs = multierr.Combine(errs, err)
+ } else {
+ errs = multierr.Combine(errs, &layersError{got: gotLayers, want: want})
+ }
}
}
diff --git a/test/packetimpact/testbench/layers.go b/test/packetimpact/testbench/layers.go
index dcff4ab36..19e6b8d7d 100644
--- a/test/packetimpact/testbench/layers.go
+++ b/test/packetimpact/testbench/layers.go
@@ -505,13 +505,13 @@ func (l *IPv6) ToBytes() ([]byte, error) {
}
}
if l.NextHeader != nil {
- fields.NextHeader = *l.NextHeader
+ fields.TransportProtocol = tcpip.TransportProtocolNumber(*l.NextHeader)
} else {
nh, err := nextHeaderByLayer(l.next())
if err != nil {
return nil, err
}
- fields.NextHeader = nh
+ fields.TransportProtocol = tcpip.TransportProtocolNumber(nh)
}
if l.HopLimit != nil {
fields.HopLimit = *l.HopLimit