test

package
v0.0.0-...-1f64b99 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertDatagram

func AssertDatagram(
	t *testing.T,
	ch <-chan *gplayers.IPv4,
	src, dst net.IP,
	payload []byte,
)

func AssertFrame

func AssertFrame(
	t *testing.T,
	ch <-chan *gplayers.Ethernet,
	src, dst net.HardwareAddr,
	payload []byte,
)

func AssertUDPSegment

func AssertUDPSegment(
	t *testing.T,
	ch <-chan gopacket.TransportLayer,
	srcPort, dstPort uint16,
	srcIPAddress, dstIPAddress net.IP,
	payload []byte,
)

func CloseEthPortsAndFlagErrorForUnexpectedData

func CloseEthPortsAndFlagErrorForUnexpectedData(t *testing.T, cards ...link.EthernetPort)

func CloseIntfsAndFlagErrorForUnexpectedData

func CloseIntfsAndFlagErrorForUnexpectedData(t *testing.T, intfs ...network.Interface)

func FlagErrorForUnexpectedDatagrams

func FlagErrorForUnexpectedDatagrams(t *testing.T, ch <-chan *gplayers.IPv4)

func FlagErrorForUnexpectedFrames

func FlagErrorForUnexpectedFrames(t *testing.T, ch <-chan *gplayers.Ethernet)

func MustParseCIDR

func MustParseCIDR(t *testing.T, s string) *net.IPNet

func MustParseMAC

func MustParseMAC(t *testing.T, s string) net.HardwareAddr

func NewMockNetworkLayer

func NewMockNetworkLayer(
	t *testing.T,
	sentSegments chan<- gopacket.TransportLayer,
	recvdDatagrams <-chan *gplayers.IPv4,
) network.Layer

NewMockNetworkLayer creates a mock network.Layer that simply relays datagrams received on the recvdDatagrams channel to the listener.

func RecvUDPSegment

func RecvUDPSegment(
	t *testing.T,
	recvdDatagrams chan<- *gplayers.IPv4,
	segment *gplayers.UDP,
	srcIPAddress, dstIPAddress net.IP,
)

Types

type MockIPProtocol

type MockIPProtocol struct {
	IPProtocol gplayers.IPProtocol
	RecvFunc   func(datagram *gplayers.IPv4)
}

func (*MockIPProtocol) GetID

func (m *MockIPProtocol) GetID() gplayers.IPProtocol

func (*MockIPProtocol) Recv

func (m *MockIPProtocol) Recv(datagram *gplayers.IPv4)

type TestIPProtocol

type TestIPProtocol struct {
	DatagramsRecvd chan *gplayers.IPv4
}

func NewTestIPProtocol

func NewTestIPProtocol() *TestIPProtocol

func (*TestIPProtocol) Close

func (p *TestIPProtocol) Close(t *testing.T)

func (*TestIPProtocol) GetID

func (p *TestIPProtocol) GetID() gplayers.IPProtocol

func (*TestIPProtocol) Recv

func (p *TestIPProtocol) Recv(datagram *gplayers.IPv4)

Jump to

Keyboard shortcuts

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