Documentation ¶
Overview ¶
Package socket provides the interfaces that need to be provided by socket implementations and providers, as well as per family demultiplexing of socket creation.
Index ¶
- func New(t *kernel.Task, family int, stype unix.SockType, protocol int) (*fs.File, *syserr.Error)
- func NewDirent(ctx context.Context, d *device.Device) *fs.Dirent
- func Pair(t *kernel.Task, family int, stype unix.SockType, protocol int) (*fs.File, *fs.File, *syserr.Error)
- func RegisterProvider(family int, provider Provider)
- type ControlMessages
- type Provider
- type ReceiveTimeout
- type Socket
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Pair ¶
func Pair(t *kernel.Task, family int, stype unix.SockType, protocol int) (*fs.File, *fs.File, *syserr.Error)
Pair creates a new connected socket pair with the given family, type and protocol.
func RegisterProvider ¶
RegisterProvider registers the provider of a given address family so that sockets of that type can be created via socket() and/or socketpair() syscalls.
Types ¶
type ControlMessages ¶
type ControlMessages struct { Unix unix.ControlMessages IP tcpip.ControlMessages }
ControlMessages represents the union of unix control messages and tcpip control messages.
type Provider ¶
type Provider interface { // Socket creates a new socket. // // If a nil Socket _and_ a nil error is returned, it means that the // protocol is not supported. A non-nil error should only be returned // if the protocol is supported, but an error occurs during creation. Socket(t *kernel.Task, stype unix.SockType, protocol int) (*fs.File, *syserr.Error) // Pair creates a pair of connected sockets. // // See Socket for error information. Pair(t *kernel.Task, stype unix.SockType, protocol int) (*fs.File, *fs.File, *syserr.Error) }
Provider is the interface implemented by providers of sockets for specific address families (e.g., AF_INET).
type ReceiveTimeout ¶
type ReceiveTimeout struct {
// contains filtered or unexported fields
}
ReceiveTimeout stores a timeout for receive calls.
It is meant to be embedded into Socket implementations to help satisfy the interface.
Care must be taken when copying ReceiveTimeout as it contains atomic variables.
func (*ReceiveTimeout) RecvTimeout ¶
func (rt *ReceiveTimeout) RecvTimeout() int64
RecvTimeout implements Socket.RecvTimeout.
func (*ReceiveTimeout) SetRecvTimeout ¶
func (rt *ReceiveTimeout) SetRecvTimeout(nanoseconds int64)
SetRecvTimeout implements Socket.SetRecvTimeout.
type Socket ¶
type Socket interface { fs.FileOperations // Connect implements the connect(2) linux syscall. Connect(t *kernel.Task, sockaddr []byte, blocking bool) *syserr.Error // Accept implements the accept4(2) linux syscall. // Returns fd, real peer address length and error. Real peer address // length is only set if len(peer) > 0. Accept(t *kernel.Task, peerRequested bool, flags int, blocking bool) (kdefs.FD, interface{}, uint32, *syserr.Error) // Bind implements the bind(2) linux syscall. Bind(t *kernel.Task, sockaddr []byte) *syserr.Error // Listen implements the listen(2) linux syscall. Listen(t *kernel.Task, backlog int) *syserr.Error // Shutdown implements the shutdown(2) linux syscall. Shutdown(t *kernel.Task, how int) *syserr.Error // GetSockOpt implements the getsockopt(2) linux syscall. GetSockOpt(t *kernel.Task, level int, name int, outLen int) (interface{}, *syserr.Error) // SetSockOpt implements the setsockopt(2) linux syscall. SetSockOpt(t *kernel.Task, level int, name int, opt []byte) *syserr.Error // GetSockName implements the getsockname(2) linux syscall. // // addrLen is the address length to be returned to the application, not // necessarily the actual length of the address. GetSockName(t *kernel.Task) (addr interface{}, addrLen uint32, err *syserr.Error) // GetPeerName implements the getpeername(2) linux syscall. // // addrLen is the address length to be returned to the application, not // necessarily the actual length of the address. GetPeerName(t *kernel.Task) (addr interface{}, addrLen uint32, err *syserr.Error) // RecvMsg implements the recvmsg(2) linux syscall. // // senderAddrLen is the address length to be returned to the application, // not necessarily the actual length of the address. 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 ControlMessages, err *syserr.Error) // SendMsg implements the sendmsg(2) linux syscall. SendMsg does not take // ownership of the ControlMessage on error. SendMsg(t *kernel.Task, src usermem.IOSequence, to []byte, flags int, controlMessages ControlMessages) (n int, err *syserr.Error) // SetRecvTimeout sets the timeout (in ns) for recv operations. Zero means // no timeout. SetRecvTimeout(nanoseconds int64) // RecvTimeout gets the current timeout (in ns) for recv operations. Zero // means no timeout. RecvTimeout() int64 }
Socket is the interface containing socket syscalls used by the syscall layer to redirect them to the appropriate implementation.
Directories ¶
Path | Synopsis |
---|---|
Package control provides internal representations of socket control messages.
|
Package control provides internal representations of socket control messages. |
Package epsocket provides an implementation of the socket.Socket interface that is backed by a tcpip.Endpoint.
|
Package epsocket provides an implementation of the socket.Socket interface that is backed by a tcpip.Endpoint. |
Package hostinet implements AF_INET and AF_INET6 sockets using the host's network stack.
|
Package hostinet implements AF_INET and AF_INET6 sockets using the host's network stack. |
Package netlink provides core functionality for netlink sockets.
|
Package netlink provides core functionality for netlink sockets. |
port
Package port provides port ID allocation for netlink sockets.
|
Package port provides port ID allocation for netlink sockets. |
route
Package route provides a NETLINK_ROUTE socket protocol.
|
Package route provides a NETLINK_ROUTE socket protocol. |
Package rpcinet implements sockets using an RPC for each syscall.
|
Package rpcinet implements sockets using an RPC for each syscall. |
conn
Package conn is an RPC connection to a syscall RPC server.
|
Package conn is an RPC connection to a syscall RPC server. |
notifier
Package notifier implements an FD notifier implementation over RPC.
|
Package notifier implements an FD notifier implementation over RPC. |
Package unix provides an implementation of the socket.Socket interface for the AF_UNIX protocol family.
|
Package unix provides an implementation of the socket.Socket interface for the AF_UNIX protocol family. |