The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
tcp_socket.c File Reference

TCP sockets (SOCK_STREAM): the socket calls over tcp.c. More...

#include "byteorder.h"
#include "common/memory.h"
#include "inet_internal.h"
#include "kernel/errno.h"
#include "kernel/memory/heap.h"
#include "kernel/process/process.h"
#include "kernel/signal/signal.h"
#include "kernel/usermode/uaccess.h"
#include "kernel/vfs/file.h"
#include "kernel/vfs/poll.h"
#include "netif.h"

Macros

#define CHUNK   (32 * 1024)

Functions

int32_t tcp_socket_connect (file_t *file, inet_socket_t *s, const ksockaddr_in_t *addr)
 the TCP side of the socket calls (tcp_socket.c).
int32_t tcp_socket_listen (inet_socket_t *s, uint32_t backlog)
int32_t tcp_socket_accept (file_t *file, uint32_t flags, file_t **out, ksockaddr_in_t *peer)
int32_t tcp_socket_send (file_t *file, inet_socket_t *s, const kiovec_t *iov, uint32_t iov_count, bool dontwait)
int32_t tcp_socket_receive (file_t *file, inet_socket_t *s, const kiovec_t *iov, uint32_t iov_count, uint32_t flags, bool dontwait)
uint32_t tcp_socket_poll (inet_socket_t *s)
int32_t tcp_socket_shutdown (inet_socket_t *s, int32_t how)

Detailed Description

TCP sockets (SOCK_STREAM): the socket calls over tcp.c.

user data goes through a kernel buffer of CHUNK bytes: it is copied from user memory before net_lock is taken, and to user memory after the lock is let go, as a copy can fault and sleep.

Macro Definition Documentation

◆ CHUNK

#define CHUNK   (32 * 1024)

Function Documentation

◆ tcp_socket_connect()

int32_t tcp_socket_connect ( struct file * file,
inet_socket_t * s,
const ksockaddr_in_t * addr )

the TCP side of the socket calls (tcp_socket.c).

those marked "lock held" are called with net_lock held; the others take it.

◆ tcp_socket_listen()

int32_t tcp_socket_listen ( inet_socket_t * s,
uint32_t backlog )

◆ tcp_socket_accept()

int32_t tcp_socket_accept ( file_t * file,
uint32_t flags,
file_t ** out,
ksockaddr_in_t * peer )

◆ tcp_socket_send()

int32_t tcp_socket_send ( file_t * file,
inet_socket_t * s,
const kiovec_t * iov,
uint32_t iov_count,
bool dontwait )

◆ tcp_socket_receive()

int32_t tcp_socket_receive ( file_t * file,
inet_socket_t * s,
const kiovec_t * iov,
uint32_t iov_count,
uint32_t flags,
bool dontwait )

◆ tcp_socket_poll()

uint32_t tcp_socket_poll ( inet_socket_t * s)

◆ tcp_socket_shutdown()

int32_t tcp_socket_shutdown ( inet_socket_t * s,
int32_t how )