The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
inet_internal.h
Go to the documentation of this file.
1#pragma once
2
3/**
4 * @file inet_internal.h
5 * @brief the parts of the IPv4 sockets that inet_socket.c (datagrams) and
6 * tcp_socket.c (streams) share. not for other code.
7 */
8
9#include "inet_socket.h"
11#include "tcp.h"
12
21
23{
24 inet_socket_t *next; // on the list of all sockets
25 uint8_t protocol; // IPPROTO_UDP, IPPROTO_ICMP or IPPROTO_TCP
26 uint32_t local; // network byte order, 0: any
27 uint16_t port; // host byte order, 0: not bound
37 uint32_t queued; // bytes in the queue
39 tcp_conn_t *conn; // TCP: the connection or the listener, or NULL
40};
41
42/**
43 * make a socket and its file, on the list of all sockets.
44 * @param flags O_NONBLOCK or 0.
45 * @return 0, or -ENOMEM.
46 */
47int32_t inet_socket_alloc(uint8_t protocol, uint32_t flags, struct file **out,
49
50/**
51 * give a socket a free port (net_lock held).
52 * @return false if all ports are taken.
53 */
55
56/**
57 * the TCP side of the socket calls (tcp_socket.c). those marked "lock
58 * held" are called with net_lock held; the others take it.
59 */
62int32_t tcp_socket_accept(struct file *file, uint32_t flags, struct file **out,
63 ksockaddr_in_t *peer);
65 uint32_t iov_count, bool dontwait);
67 uint32_t iov_count, uint32_t flags, bool dontwait);
uint8_t flags
Definition idt.c:3
int32_t tcp_socket_accept(struct file *file, uint32_t flags, struct file **out, ksockaddr_in_t *peer)
Definition tcp_socket.c:195
int32_t tcp_socket_receive(struct file *file, inet_socket_t *s, const kiovec_t *iov, uint32_t iov_count, uint32_t flags, bool dontwait)
Definition tcp_socket.c:335
int32_t tcp_socket_send(struct file *file, inet_socket_t *s, const kiovec_t *iov, uint32_t iov_count, bool dontwait)
Definition tcp_socket.c:259
bool inet_bind_any_port(inet_socket_t *s)
give a socket a free port (net_lock held).
Definition inet_socket.c:139
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).
Definition tcp_socket.c:86
struct datagram datagram_t
uint32_t tcp_socket_poll(inet_socket_t *s)
Definition tcp_socket.c:393
int32_t tcp_socket_shutdown(inet_socket_t *s, int32_t how)
Definition tcp_socket.c:428
int32_t inet_socket_alloc(uint8_t protocol, uint32_t flags, struct file **out, inet_socket_t **socket)
make a socket and its file, on the list of all sockets.
Definition inet_socket.c:71
int32_t tcp_socket_listen(inet_socket_t *s, uint32_t backlog)
Definition tcp_socket.c:170
IPv4 sockets: TCP (SOCK_STREAM), UDP (SOCK_DGRAM) and ICMP echo (SOCK_DGRAM with IPPROTO_ICMP,...
struct inet_socket inet_socket_t
Definition inet_socket.h:66
TCP (RFC 9293): reliable byte streams between ports.
struct tcp_conn tcp_conn_t
Definition tcp.h:58
unsigned int uint32_t
Definition fb.h:17
unsigned char uint8_t
Definition fb.h:18
unsigned short uint16_t
Definition stdint.h:13
int int32_t
Definition stdint.h:14
int socket(int domain, int type, int protocol)
Definition inet_internal.h:14
struct datagram * next
Definition inet_internal.h:15
uint8_t data[]
Definition inet_internal.h:19
uint32_t from
Definition inet_internal.h:16
uint32_t length
Definition inet_internal.h:18
uint16_t from_port
Definition inet_internal.h:17
an open-file description.
Definition file.h:64
Definition inet_internal.h:23
inet_socket_t * next
Definition inet_internal.h:24
uint8_t protocol
Definition inet_internal.h:25
bool connected
Definition inet_internal.h:30
bool reuse_address
Definition inet_internal.h:31
bool broadcast
Definition inet_internal.h:32
uint32_t queued
Definition inet_internal.h:37
uint16_t port
Definition inet_internal.h:27
uint32_t local
Definition inet_internal.h:26
wait_queue_t waiters
Definition inet_internal.h:38
bool shut_write
Definition inet_internal.h:34
tcp_conn_t * conn
Definition inet_internal.h:39
uint16_t remote_port
Definition inet_internal.h:29
bool shut_read
Definition inet_internal.h:33
uint32_t remote
Definition inet_internal.h:28
datagram_t * tail
Definition inet_internal.h:36
datagram_t * head
Definition inet_internal.h:35
Definition unix_socket.h:49
Definition inet_socket.h:59
a queue of blocked processes, linked through process_t::wait_next.
Definition wait_queue.h:35