31 return REF(
data->listen.listen);
74 data->listen.listen->isClosed =
true;
86 data->conn.conn->isClosed =
true;
127 data->listen.listen =
REF(listen);
215 data->conn.isServer =
false;
251 conn =
REF(container);
279 newData->
conn.conn =
REF(conn);
280 newData->
conn.isServer =
true;
521 panic(
NULL,
"Failed to register local socket family");
#define assert(expression)
NORETURN void panic(const interrupt_frame_t *frame, const char *format,...)
Panic the kernel, printing a message and halting.
local_conn_t * local_conn_new(local_listen_t *listen)
Allocate and initialize a new local connection.
local_listen_t * local_listen_find(const char *address)
Find a local listener by its address.
local_listen_t * local_listen_new(const char *address)
Allocate and initialize a new local listener.
void local_listen_dir_init(void)
Initialize the /net/local/listen/ directory.
void net_local_init(void)
Initialize the local networking subsystem.
#define LOCAL_MAX_PACKET_SIZE
The maximum size of a packet allowed to be sent/received via local sockets.
#define LOCAL_PACKET_MAGIC
Magic number for local socket packets, used for validation.
#define LOCAL_MAX_BACKLOG
The maximum backlog of connections for a local listener.
uint64_t socket_family_register(const socket_family_ops_t *ops, const char *name, socket_type_t supportedTypes)
Register a socket family.
uint64_t wait_unblock(wait_queue_t *waitQueue, uint64_t amount, errno_t err)
Unblock threads waiting on a wait queue.
#define WAIT_ALL
Wait for all.
#define WAIT_BLOCK_LOCK(waitQueue, lock, condition)
Block with a spinlock.
static void lock_init(lock_t *lock)
Initializes a lock.
#define LOCK_SCOPE(lock)
Acquires a lock for the reminder of the current scope.
static void lock_release(lock_t *lock)
Releases a lock.
static void lock_acquire(lock_t *lock)
Acquires a lock, blocking until it is available.
#define DEREF_DEFER(ptr)
RAII-style cleanup for scoped references.
#define REF(ptr)
Increment reference count.
#define DEREF(ptr)
Decrement reference count.
static uint64_t ring_write(ring_t *ring, const void *buffer, uint64_t count)
Write data to the ring buffer.
static void ring_move_read_forward(ring_t *ring, uint64_t offset)
Move the read index forward by a specified offset.
static uint64_t ring_free_length(const ring_t *ring)
Get the length of free space in the ring buffer.
static uint64_t ring_data_length(const ring_t *ring)
Get the length of data currently stored in the ring buffer.
static uint64_t ring_read(ring_t *ring, void *buffer, uint64_t count)
Read data from the ring buffer.
static uint64_t ring_read_at(const ring_t *ring, uint64_t offset, void *buffer, uint64_t count)
Read data from the ring buffer at a specific offset without modifying the read index.
#define EBADMSG
Not a data message.
#define EINVAL
Invalid argument.
#define ECONNABORTED
Software caused connection abort.
#define EINTR
Interrupted system call.
#define EWOULDBLOCK
Operation would block.
#define ECONNREFUSED
Connection refused.
#define errno
Error number variable.
#define ECONNRESET
Connection reset by peer.
#define EMSGSIZE
Message too long.
poll_events_t
Poll events type.
@ POLLIN
File descriptor is ready to read.
@ POLLHUP
Stream socket peer closed connection, or shut down writing of connection.
@ POLLOUT
File descriptor is ready to write.
@ POLLERR
File descriptor caused an error.
static void list_push(list_t *list, list_entry_t *entry)
Pushes an entry to the end of the list.
static bool list_is_empty(list_t *list)
Checks if a list is empty.
static list_entry_t * list_pop(list_t *list)
Pops the first entry from the list.
#define NULL
Pointer error value.
#define ERR
Integer error value.
#define CONTAINER_OF(ptr, type, member)
Container of macro.
EFI_PHYSICAL_ADDRESS buffer
static uint64_t local_socket_send(socket_t *sock, const void *buffer, uint64_t count, uint64_t *offset)
static uint64_t local_socket_bind(socket_t *sock, const char *address)
static uint64_t local_socket_accept(socket_t *sock, socket_t *newSock)
static local_listen_t * local_socket_data_get_listen(local_socket_data_t *data)
static uint64_t local_socket_connect(socket_t *sock, const char *address)
static uint64_t local_socket_recv(socket_t *sock, void *buffer, uint64_t count, uint64_t *offset)
static local_conn_t * local_socket_data_get_conn(local_socket_data_t *data)
static void local_socket_deinit(socket_t *sock)
static socket_family_ops_t ops
static uint64_t local_socket_init(socket_t *sock)
static wait_queue_t * local_socket_poll(socket_t *sock, poll_events_t *revents)
static uint64_t local_socket_listen(socket_t *sock, uint32_t backlog)
_PUBLIC void * calloc(size_t nmemb, size_t size)
_PUBLIC void free(void *ptr)
A entry in a doubly linked list.
Local Connection structure.
Local Listener structure.
Local socket data structure. struct local_socket_data_t.
Socket Family operations structure.
uint64_t(* init)(socket_t *sock)
socket_state_t currentState