My Kernel v0.1.0

Berkley Sockets implementation. More...

Collaboration diagram for BSD Sockets:

Data Structures

struct  socket
 A BSD socket. More...
 
struct  socket_node
 Socket node. More...
 
struct  socket_domain
 Socket communication domain. More...
 

Enumerations

enum  socket_state { SOCKET_DISCONNECTED , SOCKET_CONNECTED }
 Socket connection state. More...
 

Functions

static bool socket_mode_is_connection (enum socket_type socket_type)
 Check whether the socket is connection oriented (TCP, ...)
 
static struct socketsocket_from_vnode (struct vnode *vnode)
 
static struct vnodesocket_node (struct socket *socket)
 
struct socketsocket_alloc (void)
 Allocate and initialize a new socket.
 
error_t socket_init (struct socket *socket, int domain, int type, int proto)
 Initialize a socket's underlying protocol. More...
 
error_t socket_enqueue_packet (struct socket *socket, struct packet *packet)
 Place a packet inside the socket's receive queue. More...
 
struct packetsocket_dequeue_packet (struct socket *socket)
 Retreive one packet from the socket's receive queue. More...
 
error_t socket_domain_register (struct socket_domain *)
 Register a new domain of sockets.
 

Detailed Description

Enumeration Type Documentation

◆ socket_state

Enumerator
SOCKET_DISCONNECTED 

Connected to a partner

SOCKET_CONNECTED 

Not connected to a remote partner

Function Documentation

◆ socket_dequeue_packet()

struct packet * socket_dequeue_packet ( struct socket socket)

If the queue is empty, return NULL.

◆ socket_enqueue_packet()

error_t socket_enqueue_packet ( struct socket socket,
struct packet packet 
)

Packets received can be read by the user using the recv syscall.

◆ socket_from_vnode()

static struct socket * socket_from_vnode ( struct vnode vnode)
inlinestatic
Returns
The socket corresponding to a vnode

◆ socket_init()

error_t socket_init ( struct socket socket,
int  domain,
int  type,
int  proto 
)
Parameters
domainCommunication domain (AF_*).
typeConnection type (SOCK_STREAM, ...).
protoPacket protocol type

◆ socket_node()

static struct vnode * socket_node ( struct socket socket)
inlinestatic
Returns
The socket's vnode