unix

package
v0.0.0-...-522126a Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2019 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package unix provides an implementation of the socket.Socket interface for the AF_UNIX protocol family.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, endpoint transport.Endpoint, stype linux.SockType) *fs.File

New creates a new unix socket.

func NewWithDirent

func NewWithDirent(ctx context.Context, d *fs.Dirent, ep transport.Endpoint, stype linux.SockType, flags fs.FileFlags) *fs.File

NewWithDirent creates a new unix socket using an existing dirent.

Types

type EndpointReader

type EndpointReader struct {
	Ctx context.Context

	// Endpoint is the transport.Endpoint to read from.
	Endpoint transport.Endpoint

	// Creds indicates if credential control messages are requested.
	Creds bool

	// NumRights is the number of SCM_RIGHTS FDs requested.
	NumRights int

	// Peek indicates that the data should not be consumed from the
	// endpoint.
	Peek bool

	// MsgSize is the size of the message that was read from. For stream
	// sockets, it is the amount read.
	MsgSize int64

	// From, if not nil, will be set with the address read from.
	From *tcpip.FullAddress

	// Control contains the received control messages.
	Control transport.ControlMessages

	// ControlTrunc indicates that SCM_RIGHTS FDs were discarded based on
	// the value of NumRights.
	ControlTrunc bool
}

EndpointReader implements safemem.Reader that reads from a transport.Endpoint.

EndpointReader is not thread-safe.

func (*EndpointReader) ReadToBlocks

func (r *EndpointReader) ReadToBlocks(dsts safemem.BlockSeq) (uint64, error)

ReadToBlocks implements safemem.Reader.ReadToBlocks.

type EndpointWriter

type EndpointWriter struct {
	Ctx context.Context

	// Endpoint is the transport.Endpoint to write to.
	Endpoint transport.Endpoint

	// Control is the control messages to send.
	Control transport.ControlMessages

	// To is the endpoint to send to. May be nil.
	To transport.BoundEndpoint
}

EndpointWriter implements safemem.Writer that writes to a transport.Endpoint.

EndpointWriter is not thread-safe.

func (*EndpointWriter) WriteFromBlocks

func (w *EndpointWriter) WriteFromBlocks(srcs safemem.BlockSeq) (uint64, error)

WriteFromBlocks implements safemem.Writer.WriteFromBlocks.

type SocketOperations

type SocketOperations struct {
	fsutil.FilePipeSeek             `state:"nosave"`
	fsutil.FileNotDirReaddir        `state:"nosave"`
	fsutil.FileNoFsync              `state:"nosave"`
	fsutil.FileNoMMap               `state:"nosave"`
	fsutil.FileNoSplice             `state:"nosave"`
	fsutil.FileNoopFlush            `state:"nosave"`
	fsutil.FileUseInodeUnstableAttr `state:"nosave"`
	refs.AtomicRefCount
	socket.SendReceiveTimeout
	// contains filtered or unexported fields
}

SocketOperations is a Unix socket. It is similar to a netstack socket, except it is backed by a transport.Endpoint instead of a tcpip.Endpoint.

+stateify savable

func (*SocketOperations) Accept

func (s *SocketOperations) Accept(t *kernel.Task, peerRequested bool, flags int, blocking bool) (int32, linux.SockAddr, uint32, *syserr.Error)

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

func (*SocketOperations) Bind

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

Bind implements the linux syscall bind(2) for unix sockets.

func (*SocketOperations) Connect

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

Connect implements the linux syscall connect(2) for unix sockets.

func (*SocketOperations) ConnectedPasscred

func (s *SocketOperations) ConnectedPasscred() bool

ConnectedPasscred implements transport.Credentialer.ConnectedPasscred.

func (*SocketOperations) DecRef

func (s *SocketOperations) DecRef()

DecRef implements RefCounter.DecRef.

func (*SocketOperations) Endpoint

func (s *SocketOperations) Endpoint() transport.Endpoint

Endpoint extracts the transport.Endpoint.

func (*SocketOperations) EventRegister

func (s *SocketOperations) EventRegister(e *waiter.Entry, mask waiter.EventMask)

EventRegister implements waiter.Waitable.EventRegister.

func (*SocketOperations) EventUnregister

func (s *SocketOperations) EventUnregister(e *waiter.Entry)

EventUnregister implements waiter.Waitable.EventUnregister.

func (*SocketOperations) GetPeerName

func (s *SocketOperations) GetPeerName(t *kernel.Task) (linux.SockAddr, uint32, *syserr.Error)

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

func (*SocketOperations) GetSockName

func (s *SocketOperations) GetSockName(t *kernel.Task) (linux.SockAddr, uint32, *syserr.Error)

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

func (*SocketOperations) GetSockOpt

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

GetSockOpt implements the linux syscall getsockopt(2) for sockets backed by a transport.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 a transport.Endpoint.

func (*SocketOperations) Passcred

func (s *SocketOperations) Passcred() bool

Passcred implements transport.Credentialer.Passcred.

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 implements waiter.Waitable.Readiness.

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, msgFlags int, senderAddr linux.SockAddr, senderAddrLen uint32, controlMessages socket.ControlMessages, err *syserr.Error)

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

func (*SocketOperations) Release

func (s *SocketOperations) Release()

Release implemements fs.FileOperations.Release.

func (*SocketOperations) SendMsg

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

SendMsg implements the linux syscall sendmsg(2) for unix sockets backed by a transport.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 a transport.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 a transport.Endpoint.

func (*SocketOperations) State

func (s *SocketOperations) State() uint32

State implements socket.Socket.State.

func (*SocketOperations) Type

func (s *SocketOperations) Type() (family int, skType linux.SockType, protocol int)

Type implements socket.Socket.Type.

func (*SocketOperations) Write

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

Writev implements fs.FileOperations.Write.

Directories

Path Synopsis
Package transport contains the implementation of Unix endpoints.
Package transport contains the implementation of Unix endpoints.

Jump to

Keyboard shortcuts

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