PatchworkOS  28a9544
A non-POSIX operating system.
Loading...
Searching...
No Matches
socket.h
Go to the documentation of this file.
1#pragma once
2
3#include "socket_type.h"
4#include <kernel/fs/path.h>
5#include <kernel/fs/sysfs.h>
7#include <kernel/utils/ref.h>
8
9#include <sys/io.h>
10
11typedef struct socket_family socket_family_t;
12
75
80typedef struct socket
81{
82 ref_t ref;
83 char id[MAX_NAME];
84 char address[MAX_NAME];
85 socket_family_t* family;
86 socket_type_t type;
87 path_flags_t flags;
88 void* private;
89 socket_state_t currentState;
90 socket_state_t nextState;
92 dentry_t* ctlFile;
93 dentry_t* dataFile;
94 dentry_t* acceptFile;
95} socket_t;
96
108
117
125
132void socket_end_transition(socket_t* sock, uint64_t result);
133
#define MAX_NAME
Maximum length of names.
Definition MAX_NAME.h:11
path_flags_t
Path flags.
Definition path.h:83
socket_type_t
Socket type enumeration.
Definition socket_type.h:18
socket_state_t
Socket states.
Definition socket.h:65
socket_t * socket_new(socket_family_t *family, socket_type_t type, path_flags_t flags)
Create a new socket.
Definition socket.c:359
void socket_continue_transition(socket_t *sock, socket_state_t state)
Without releasing the socket mutex, start a transition to a new target state.
Definition socket.c:519
uint64_t socket_start_transition(socket_t *sock, socket_state_t state)
Starts a socket state transition.
Definition socket.c:491
void socket_end_transition(socket_t *sock, uint64_t result)
Ends a socket state transition.
Definition socket.c:528
@ SOCKET_CLOSED
Definition socket.h:72
@ SOCKET_LISTENING
Definition socket.h:68
@ SOCKET_STATE_AMOUNT
Definition socket.h:73
@ SOCKET_CONNECTED
Definition socket.h:70
@ SOCKET_NEW
Definition socket.h:66
@ SOCKET_CLOSING
Definition socket.h:71
@ SOCKET_BOUND
Definition socket.h:67
@ SOCKET_CONNECTING
Definition socket.h:69
static uintptr_t address
Mapped virtual address of the HPET registers.
Definition hpet.c:93
static mtx_t mutex
Definition heap.c:35
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
Directory entry structure.
Definition dentry.h:83
Reference counting structure.
Definition ref.h:30
Read-Write Mutex structure.
Definition rwmutex.h:42
Socket Family structure.
Socket structure.
Definition socket.h:81