diff options
author | Googler <noreply@google.com> | 2019-02-26 14:57:27 -0800 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-02-26 14:58:37 -0800 |
commit | 12d9cf6fabb53d18da3602564f45ff6fbbf032d6 (patch) | |
tree | 176227d1ca05a54c89d1236e58dc2793b8b74abb /pkg/tcpip/link/muxed/injectable_test.go | |
parent | a2b794b30dd952793f4d99a9423cef7efdc7843f (diff) |
Adds a WriteRawPacket method to the InjectableLinkEndpoint interface.
Also exposes ipv4.MaxTotalSize since it is a generally useful constant.
PiperOrigin-RevId: 235799755
Change-Id: I1fa8d5294bf355acf5527cfdf274b3687d3c8b13
Diffstat (limited to 'pkg/tcpip/link/muxed/injectable_test.go')
-rw-r--r-- | pkg/tcpip/link/muxed/injectable_test.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/pkg/tcpip/link/muxed/injectable_test.go b/pkg/tcpip/link/muxed/injectable_test.go index 65db14b5d..d1d2875cc 100644 --- a/pkg/tcpip/link/muxed/injectable_test.go +++ b/pkg/tcpip/link/muxed/injectable_test.go @@ -28,8 +28,24 @@ import ( "gvisor.googlesource.com/gvisor/pkg/tcpip/stack" ) +func TestInjectableEndpointRawDispatch(t *testing.T) { + endpoint, sock, dstIP := makeTestInjectableEndpoint(t) + + endpoint.WriteRawPacket(dstIP, []byte{0xFA}) + + buf := make([]byte, ipv4.MaxTotalSize) + bytesRead, err := sock.Read(buf) + if err != nil { + t.Fatalf("Unable to read from socketpair: %v", err) + } + if got, want := buf[:bytesRead], []byte{0xFA}; !bytes.Equal(got, want) { + t.Fatalf("Read %v from the socketpair, wanted %v", got, want) + } +} + func TestInjectableEndpointDispatch(t *testing.T) { endpoint, sock, dstIP := makeTestInjectableEndpoint(t) + hdr := buffer.NewPrependable(1) hdr.Prepend(1)[0] = 0xFA packetRoute := stack.Route{RemoteAddress: dstIP} |