testutil

package
v0.0.0-...-9ec6d29 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2022 License: Apache-2.0, MIT Imports: 6 Imported by: 0

Documentation

Overview

Package testutil defines types and functions used to test Network Layer functionality such as IP fragmentation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeRandPkt

func MakeRandPkt(transportHeaderLength int, extraHeaderReserveLength int, viewSizes []int, proto tcpip.NetworkProtocolNumber) stack.PacketBufferPtr

MakeRandPkt generates a randomized packet. transportHeaderLength indicates how many random bytes will be copied in the Transport Header. extraHeaderReserveLength indicates how much extra space will be reserved for the other headers. The payload is made from Views of the sizes listed in viewSizes.

Types

type MockLinkEndpoint

type MockLinkEndpoint struct {
	// WrittenPackets is where packets written to the endpoint are stored.
	WrittenPackets []stack.PacketBufferPtr
	// contains filtered or unexported fields
}

MockLinkEndpoint is an endpoint used for testing, it stores packets written to it and can mock errors.

func NewMockLinkEndpoint

func NewMockLinkEndpoint(mtu uint32, err tcpip.Error, allowPackets int) *MockLinkEndpoint

NewMockLinkEndpoint creates a new MockLinkEndpoint.

err is the error that will be returned once allowPackets packets are written to the endpoint.

func (*MockLinkEndpoint) ARPHardwareType

func (*MockLinkEndpoint) ARPHardwareType() header.ARPHardwareType

ARPHardwareType implements LinkEndpoint.ARPHardwareType.

func (*MockLinkEndpoint) AddHeader

AddHeader implements LinkEndpoint.AddHeader.

func (*MockLinkEndpoint) Attach

Attach implements LinkEndpoint.Attach.

func (*MockLinkEndpoint) Capabilities

Capabilities implements LinkEndpoint.Capabilities.

func (*MockLinkEndpoint) Close

func (ep *MockLinkEndpoint) Close()

Close releases all resources.

func (*MockLinkEndpoint) IsAttached

func (*MockLinkEndpoint) IsAttached() bool

IsAttached implements LinkEndpoint.IsAttached.

func (*MockLinkEndpoint) LinkAddress

func (*MockLinkEndpoint) LinkAddress() tcpip.LinkAddress

LinkAddress implements LinkEndpoint.LinkAddress.

func (*MockLinkEndpoint) MTU

func (ep *MockLinkEndpoint) MTU() uint32

MTU implements LinkEndpoint.MTU.

func (*MockLinkEndpoint) MaxHeaderLength

func (*MockLinkEndpoint) MaxHeaderLength() uint16

MaxHeaderLength implements LinkEndpoint.MaxHeaderLength.

func (*MockLinkEndpoint) Wait

func (*MockLinkEndpoint) Wait()

Wait implements LinkEndpoint.Wait.

func (*MockLinkEndpoint) WritePackets

func (ep *MockLinkEndpoint) WritePackets(pkts stack.PacketBufferList) (int, tcpip.Error)

WritePackets implements LinkEndpoint.WritePackets.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL