diff options
Diffstat (limited to 'test/packetimpact/testbench/layers.go')
-rw-r--r-- | test/packetimpact/testbench/layers.go | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/test/packetimpact/testbench/layers.go b/test/packetimpact/testbench/layers.go index 2fb7ca9ba..7401a1991 100644 --- a/test/packetimpact/testbench/layers.go +++ b/test/packetimpact/testbench/layers.go @@ -298,7 +298,7 @@ func (l *IPv4) ToBytes() ([]byte, error) { // An IPv4 header is variable length depending on the size of the Options. hdrLen := header.IPv4MinimumSize if l.Options != nil { - hdrLen += l.Options.AllocationSize() + hdrLen += l.Options.SizeWithPadding() if hdrLen > header.IPv4MaximumHeaderSize { // While ToBytes can be called on packets that were received as well // as packets locally generated, it is physically impossible for a @@ -410,13 +410,7 @@ func Address(v tcpip.Address) *tcpip.Address { // continues parsing further encapsulations. func parseIPv4(b []byte) (Layer, layerParser) { h := header.IPv4(b) - hdrLen := h.HeaderLength() - // Even if there are no options, we set an empty options field instead of nil - // so that the decision to compare is up to the caller of that comparison. - var options header.IPv4Options - if hdrLen > header.IPv4MinimumSize { - options = append(options, h.Options()...) - } + options := h.Options() tos, _ := h.TOS() ipv4 := IPv4{ IHL: Uint8(h.HeaderLength()), |