PatchworkOS
Loading...
Searching...
No Matches
socket_family.h
Go to the documentation of this file.
1#pragma once
2
3#include <kernel/fs/sysfs.h>
5
6#include <stdint.h>
7#include <sys/io.h>
8#include <sys/list.h>
9
10typedef struct socket socket_t;
11typedef struct socket_family socket_family_t;
12
42
47typedef struct socket_family_ops
48{
49 uint64_t (*init)(socket_t* sock);
50 void (*deinit)(socket_t* sock);
51 uint64_t (*bind)(socket_t* sock, const char* address);
52 uint64_t (*listen)(socket_t* sock, uint32_t backlog);
53 uint64_t (*connect)(socket_t* sock, const char* address);
54 uint64_t (*accept)(socket_t* sock, socket_t* newSock);
55 uint64_t (*send)(socket_t* sock, const void* buffer, uint64_t count, uint64_t* offset);
56 uint64_t (*recv)(socket_t* sock, void* buffer, uint64_t count, uint64_t* offset);
57 wait_queue_t* (*poll)(socket_t* sock, poll_events_t* revents);
58 uint64_t (*shutdown)(socket_t* socket, uint32_t how); // TODO: This is not used nor implemented, implement it.
60
75
84uint64_t socket_family_register(const socket_family_ops_t* ops, const char* name, socket_type_t supportedTypes);
85
91void socket_family_unregister(const char* name);
92
99socket_family_t* socket_family_get(const char* name);
100
109
#define MAX_NAME
Maximum length of names.
Definition MAX_NAME.h:11
uint64_t socket_family_register(const socket_family_ops_t *ops, const char *name, socket_type_t supportedTypes)
Register a socket family.
uint64_t socket_family_get_dir(socket_family_t *family, path_t *outPath)
Get the directory of a socket family.
void socket_family_unregister(const char *name)
Unregister a socket family.
socket_family_t * socket_family_get(const char *name)
Get a socket family by name.
socket_type_t
Socket type enumeration.
Definition socket_type.h:18
uint64_t bind(fd_t source, const char *mountpoint)
System call for binding a file descriptor to a mountpoint.
Definition bind.c:5
poll_events_t
Poll events type.
Definition io.h:288
static uintptr_t address
Definition hpet.c:12
EFI_PHYSICAL_ADDRESS buffer
Definition mem.c:15
static socket_family_ops_t ops
Definition local.c:505
static atomic_long count
Definition main.c:9
__UINT32_TYPE__ uint32_t
Definition stdint.h:15
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
Directory entry structure.
Definition dentry.h:83
A entry in a doubly linked list.
Definition list.h:38
A doubly linked list.
Definition list.h:51
Path structure.
Definition path.h:110
Socket Factory structure.
list_entry_t entry
socket_family_t * family
socket_type_t type
Socket Family operations structure.
Socket Family structure.
list_entry_t entry
const socket_family_ops_t * ops
atomic_uint64_t newId
socket_type_t supportedTypes
Socket structure.
Definition socket.h:81
Wait queue structure.
Definition wait.h:166