testutil

package
v0.0.0-202406181927 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2024 License: Apache-2.0, MIT Imports: 10 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 CheckIGMPv2Stats

func CheckIGMPv2Stats(t *testing.T, s *stack.Stack, reports, leaves, reportsV2 uint64)

CheckIGMPv2Stats checks IGMPv2 stats.

func CheckIGMPv3Stats

func CheckIGMPv3Stats(t *testing.T, s *stack.Stack, reports, leaves, reportsV2 uint64)

CheckIGMPv3Stats checks IGMPv3 stats.

func CheckMLDv1Stats

func CheckMLDv1Stats(t *testing.T, s *stack.Stack, reports, leaves, reportsV2 uint64)

CheckMLDv1Stats checks MLDv1 stats.

func CheckMLDv2Stats

func CheckMLDv2Stats(t *testing.T, s *stack.Stack, reports, leaves, reportsV2 uint64)

CheckMLDv2Stats checks MLDv2 stats.

func MakeRandPkt

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

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.

func ValidMultipleIGMPv2ReportLeaves

func ValidMultipleIGMPv2ReportLeaves(t *testing.T, e *channel.Endpoint, srcAddr tcpip.Address, addrs []tcpip.Address, leave bool)

ValidMultipleIGMPv2ReportLeaves validates the reception of multiple IGMPv2 report/leave messages.

func ValidMultipleMLDv1ReportLeaves

func ValidMultipleMLDv1ReportLeaves(t *testing.T, e *channel.Endpoint, srcAddr tcpip.Address, addrs []tcpip.Address, leave bool)

ValidMultipleMLDv1ReportLeaves validates the reception of multiple MLDv1 report/leave messages.

func ValidateIGMPv3RecordsAcrossReports

func ValidateIGMPv3RecordsAcrossReports(t *testing.T, e *channel.Endpoint, srcAddr tcpip.Address, addrs []tcpip.Address, recordType header.IGMPv3ReportRecordType)

ValidateIGMPv3RecordsAcrossReports validates IGMPv3 records across one or more reports.

func ValidateIGMPv3Report

func ValidateIGMPv3Report(t *testing.T, v *buffer.View, srcAddr tcpip.Address, addrs []tcpip.Address, recordType header.IGMPv3ReportRecordType)

ValidateIGMPv3Report validates an IGMPv3 report.

func ValidateIGMPv3ReportWithRecords

func ValidateIGMPv3ReportWithRecords(t *testing.T, v *buffer.View, srcAddr tcpip.Address, expectedRecords map[tcpip.Address]header.IGMPv3ReportRecordType)

ValidateIGMPv3ReportWithRecords validates an IGMPv3 report.

Note that observed records are removed from expectedRecords. No error is logged if the report does not have all the records expected.

func ValidateMLDv2RecordsAcrossReports

func ValidateMLDv2RecordsAcrossReports(t *testing.T, e *channel.Endpoint, srcAddr tcpip.Address, addrs []tcpip.Address, recordType header.MLDv2ReportRecordType)

ValidateMLDv2RecordsAcrossReports validates MLDv2 records across one or more reports.

func ValidateMLDv2Report

func ValidateMLDv2Report(t *testing.T, v *buffer.View, srcAddr tcpip.Address, addrs []tcpip.Address, recordType header.MLDv2ReportRecordType)

ValidateMLDv2Report validates an MLDv2 report.

func ValidateMLDv2ReportWithRecords

func ValidateMLDv2ReportWithRecords(t *testing.T, v *buffer.View, srcAddr tcpip.Address, expectedRecords map[tcpip.Address]header.MLDv2ReportRecordType)

ValidateMLDv2ReportWithRecords validates an MLDv2 report.

Note that observed records are removed from expectedRecords. No error is logged if the report does not have all the records expected.

Types

type MockLinkEndpoint

type MockLinkEndpoint struct {
	// WrittenPackets is where packets written to the endpoint are stored.
	WrittenPackets []*stack.PacketBuffer
	// 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

func (*MockLinkEndpoint) AddHeader(*stack.PacketBuffer)

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) ParseHeader

func (*MockLinkEndpoint) ParseHeader(*stack.PacketBuffer) bool

ParseHeader implements LinkEndpoint.ParseHeader.

func (*MockLinkEndpoint) SetLinkAddress

func (*MockLinkEndpoint) SetLinkAddress(tcpip.LinkAddress)

SetLinkAddress implements LinkEndpoint.LinkAddress.

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