epsocket

package
v0.0.0-...-23e6066 Latest Latest
Warning

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

Go to latest
Published: May 3, 2018 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Package epsocket provides an implementation of the socket.Socket interface that is backed by a tcpip.Endpoint.

It does not depend on any particular endpoint implementation, and thus can be used to expose certain endpoints to the sentry while leaving others out, for example, TCP endpoints and Unix-domain endpoints.

Lock ordering: netstack => mm: ioSequencePayload copies user memory inside tcpip.Endpoint.Write(). Netstack is allowed to (and does) hold locks during this operation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertAddress

func ConvertAddress(family int, addr tcpip.FullAddress) (interface{}, uint32)

ConvertAddress converts the given address to a native format.

func ConvertShutdown

func ConvertShutdown(how int) (tcpip.ShutdownFlags, *syserr.Error)

ConvertShutdown converts Linux shutdown flags into tcpip shutdown flags.

func GetAddress

func GetAddress(sfamily int, addr []byte) (tcpip.FullAddress, *syserr.Error)

GetAddress reads an sockaddr struct from the given address and converts it to the FullAddress format. It supports AF_UNIX, AF_INET and AF_INET6 addresses.

func GetSockOpt

func GetSockOpt(t *kernel.Task, s socket.Socket, ep commonEndpoint, family int, skType unix.SockType, level, name, outLen int) (interface{}, *syserr.Error)

GetSockOpt can be used to implement the linux syscall getsockopt(2) for sockets backed by a commonEndpoint.

func GetTransportProtocol

func GetTransportProtocol(stype unix.SockType, protocol int) (tcpip.TransportProtocolNumber, *syserr.Error)

GetTransportProtocol figures out transport protocol. Currently only TCP, UDP, and ICMP are supported.

func Ioctl

func Ioctl(ctx context.Context, ep commonEndpoint, io usermem.IO, args arch.SyscallArguments) (uintptr, error)

Ioctl implements fs.FileOperations.Ioctl for sockets backed by a commonEndpoint.

func New

func New(t *kernel.Task, family int, skType unix.SockType, queue *waiter.Queue, endpoint tcpip.Endpoint) *fs.File

New creates a new endpoint socket.

func SetSockOpt

func SetSockOpt(t *kernel.Task, s socket.Socket, ep commonEndpoint, level int, name int, optVal []byte) *syserr.Error

SetSockOpt can be used to implement the linux syscall setsockopt(2) for sockets backed by a commonEndpoint.

Types

type SocketOperations

type SocketOperations struct {
	socket.ReceiveTimeout
	fsutil.PipeSeek      `state:"nosave"`
	fsutil.NotDirReaddir `state:"nosave"`
	fsutil.NoFsync       `state:"nosave"`
	fsutil.NoopFlush     `state:"nosave"`
	fsutil.NoMMap        `state:"nosave"`
	*waiter.Queue

	Endpoint tcpip.Endpoint
	// contains filtered or unexported fields
}

SocketOperations encapsulates all the state needed to represent a network stack endpoint in the kernel context.

func (*SocketOperations) Accept

func (s *SocketOperations) Accept(t *kernel.Task, peerRequested bool, flags int, blocking bool) (kdefs.FD, interface{}, uint32, *syserr.Error)

Accept implements the linux syscall accept(2) for sockets backed by tcpip.Endpoint.

func (*SocketOperations) Bind

func (s *SocketOperations) Bind(t *kernel.Task, sockaddr []byte) *syserr.Error

Bind implements the linux syscall bind(2) for sockets backed by tcpip.Endpoint.

func (*SocketOperations) Connect

func (s *SocketOperations) Connect(t *kernel.Task, sockaddr []byte, blocking bool) *syserr.Error

Connect implements the linux syscall connect(2) for sockets backed by tpcip.Endpoint.

func (*SocketOperations) GetPeerName

func (s *SocketOperations) GetPeerName(t *kernel.Task) (interface{}, uint32, *syserr.Error)

GetPeerName implements the linux syscall getpeername(2) for sockets backed by tcpip.Endpoint.

func (*SocketOperations) GetSockName

func (s *SocketOperations) GetSockName(t *kernel.Task) (interface{}, uint32, *syserr.Error)

GetSockName implements the linux syscall getsockname(2) for sockets backed by tcpip.Endpoint.

func (*SocketOperations) GetSockOpt

func (s *SocketOperations) GetSockOpt(t *kernel.Task, level, name, outLen int) (interface{}, *syserr.Error)

GetSockOpt implements the linux syscall getsockopt(2) for sockets backed by tcpip.Endpoint.

func (*SocketOperations) Ioctl

Ioctl implements fs.FileOperations.Ioctl.

func (*SocketOperations) Listen

func (s *SocketOperations) Listen(t *kernel.Task, backlog int) *syserr.Error

Listen implements the linux syscall listen(2) for sockets backed by tcpip.Endpoint.

func (*SocketOperations) Read

func (s *SocketOperations) Read(ctx context.Context, _ *fs.File, dst usermem.IOSequence, _ int64) (int64, error)

Read implements fs.FileOperations.Read.

func (*SocketOperations) Readiness

func (s *SocketOperations) Readiness(mask waiter.EventMask) waiter.EventMask

Readiness returns a mask of ready events for socket s.

func (*SocketOperations) RecvMsg

func (s *SocketOperations) RecvMsg(t *kernel.Task, dst usermem.IOSequence, flags int, haveDeadline bool, deadline ktime.Time, senderRequested bool, controlDataLen uint64) (n int, senderAddr interface{}, senderAddrLen uint32, controlMessages socket.ControlMessages, err *syserr.Error)

RecvMsg implements the linux syscall recvmsg(2) for sockets backed by tcpip.Endpoint.

func (*SocketOperations) Release

func (s *SocketOperations) Release()

Release implements fs.FileOperations.Release.

func (*SocketOperations) SendMsg

func (s *SocketOperations) SendMsg(t *kernel.Task, src usermem.IOSequence, to []byte, flags int, controlMessages socket.ControlMessages) (int, *syserr.Error)

SendMsg implements the linux syscall sendmsg(2) for sockets backed by tcpip.Endpoint.

func (*SocketOperations) SetSockOpt

func (s *SocketOperations) SetSockOpt(t *kernel.Task, level int, name int, optVal []byte) *syserr.Error

SetSockOpt implements the linux syscall setsockopt(2) for sockets backed by tcpip.Endpoint.

func (*SocketOperations) Shutdown

func (s *SocketOperations) Shutdown(t *kernel.Task, how int) *syserr.Error

Shutdown implements the linux syscall shutdown(2) for sockets backed by tcpip.Endpoint.

func (*SocketOperations) Write

func (s *SocketOperations) Write(ctx context.Context, _ *fs.File, src usermem.IOSequence, _ int64) (int64, error)

Write implements fs.FileOperations.Write.

type Stack

type Stack struct {
	Stack *stack.Stack `state:"manual"`
}

Stack implements inet.Stack for netstack/tcpip/stack.Stack.

func (*Stack) InterfaceAddrs

func (s *Stack) InterfaceAddrs() map[int32][]inet.InterfaceAddr

InterfaceAddrs implements inet.Stack.InterfaceAddrs.

func (*Stack) Interfaces

func (s *Stack) Interfaces() map[int32]inet.Interface

Interfaces implements inet.Stack.Interfaces.

func (*Stack) SetTCPReceiveBufferSize

func (s *Stack) SetTCPReceiveBufferSize(size inet.TCPBufferSize) error

SetTCPReceiveBufferSize implements inet.Stack.SetTCPReceiveBufferSize.

func (*Stack) SetTCPSACKEnabled

func (s *Stack) SetTCPSACKEnabled(enabled bool) error

SetTCPSACKEnabled implements inet.Stack.SetTCPSACKEnabled.

func (*Stack) SetTCPSendBufferSize

func (s *Stack) SetTCPSendBufferSize(size inet.TCPBufferSize) error

SetTCPSendBufferSize implements inet.Stack.SetTCPSendBufferSize.

func (*Stack) SupportsIPv6

func (s *Stack) SupportsIPv6() bool

SupportsIPv6 implements Stack.SupportsIPv6.

func (*Stack) TCPReceiveBufferSize

func (s *Stack) TCPReceiveBufferSize() (inet.TCPBufferSize, error)

TCPReceiveBufferSize implements inet.Stack.TCPReceiveBufferSize.

func (*Stack) TCPSACKEnabled

func (s *Stack) TCPSACKEnabled() (bool, error)

TCPSACKEnabled implements inet.Stack.TCPSACKEnabled.

func (*Stack) TCPSendBufferSize

func (s *Stack) TCPSendBufferSize() (inet.TCPBufferSize, error)

TCPSendBufferSize implements inet.Stack.TCPSendBufferSize.

Jump to

Keyboard shortcuts

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