Documentation ¶
Overview ¶
Package testutil defines types and functions used to test Network Layer functionality such as IP fragmentation.
Index ¶
- func CheckIGMPv2Stats(t *testing.T, s *stack.Stack, reports, leaves, reportsV2 uint64)
- func CheckIGMPv3Stats(t *testing.T, s *stack.Stack, reports, leaves, reportsV2 uint64)
- func CheckMLDv1Stats(t *testing.T, s *stack.Stack, reports, leaves, reportsV2 uint64)
- func CheckMLDv2Stats(t *testing.T, s *stack.Stack, reports, leaves, reportsV2 uint64)
- func MakeRandPkt(transportHeaderLength int, extraHeaderReserveLength int, viewSizes []int, ...) *stack.PacketBuffer
- func ValidMultipleIGMPv2ReportLeaves(t *testing.T, e *channel.Endpoint, srcAddr tcpip.Address, ...)
- func ValidMultipleMLDv1ReportLeaves(t *testing.T, e *channel.Endpoint, srcAddr tcpip.Address, ...)
- func ValidateIGMPv3RecordsAcrossReports(t *testing.T, e *channel.Endpoint, srcAddr tcpip.Address, ...)
- func ValidateIGMPv3Report(t *testing.T, v *buffer.View, srcAddr tcpip.Address, addrs []tcpip.Address, ...)
- func ValidateIGMPv3ReportWithRecords(t *testing.T, v *buffer.View, srcAddr tcpip.Address, ...)
- func ValidateMLDv2RecordsAcrossReports(t *testing.T, e *channel.Endpoint, srcAddr tcpip.Address, ...)
- func ValidateMLDv2Report(t *testing.T, v *buffer.View, srcAddr tcpip.Address, addrs []tcpip.Address, ...)
- func ValidateMLDv2ReportWithRecords(t *testing.T, v *buffer.View, srcAddr tcpip.Address, ...)
- type MockLinkEndpoint
- func (*MockLinkEndpoint) ARPHardwareType() header.ARPHardwareType
- func (*MockLinkEndpoint) AddHeader(*stack.PacketBuffer)
- func (*MockLinkEndpoint) Attach(stack.NetworkDispatcher)
- func (*MockLinkEndpoint) Capabilities() stack.LinkEndpointCapabilities
- func (ep *MockLinkEndpoint) Close()
- func (*MockLinkEndpoint) IsAttached() bool
- func (*MockLinkEndpoint) LinkAddress() tcpip.LinkAddress
- func (ep *MockLinkEndpoint) MTU() uint32
- func (*MockLinkEndpoint) MaxHeaderLength() uint16
- func (*MockLinkEndpoint) ParseHeader(*stack.PacketBuffer) bool
- func (*MockLinkEndpoint) Wait()
- func (ep *MockLinkEndpoint) WritePackets(pkts stack.PacketBufferList) (int, tcpip.Error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckIGMPv2Stats ¶
CheckIGMPv2Stats checks IGMPv2 stats.
func CheckIGMPv3Stats ¶
CheckIGMPv3Stats checks IGMPv3 stats.
func CheckMLDv1Stats ¶
CheckMLDv1Stats checks MLDv1 stats.
func CheckMLDv2Stats ¶
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 ¶
func (*MockLinkEndpoint) Attach(stack.NetworkDispatcher)
Attach implements LinkEndpoint.Attach.
func (*MockLinkEndpoint) Capabilities ¶
func (*MockLinkEndpoint) Capabilities() stack.LinkEndpointCapabilities
Capabilities implements LinkEndpoint.Capabilities.
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) WritePackets ¶
func (ep *MockLinkEndpoint) WritePackets(pkts stack.PacketBufferList) (int, tcpip.Error)
WritePackets implements LinkEndpoint.WritePackets.