PatchworkOS  28a9544
A non-POSIX operating system.
Loading...
Searching...
No Matches
socket_family.h
Go to the documentation of this file.
1#pragma once
2
3#include "socket_type.h"
4#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
35typedef struct socket_factory
36{
37 list_entry_t entry;
38 socket_type_t type;
39 socket_family_t* family;
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
65typedef struct socket_family
66{
67 list_entry_t entry;
68 char name[MAX_NAME];
70 socket_type_t supportedTypes;
71 atomic_uint64_t newId;
72 list_t factories;
73 dentry_t* dir;
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
97
104socket_family_t* socket_family_get(const char* name);
105
114
#define MAX_NAME
Maximum length of names.
Definition MAX_NAME.h:11
static atomic_uint64_t newId
Definition fb.c:15
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:298
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.
void socket_family_unregister_all(void)
Unregister all socket families.
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
static uintptr_t address
Mapped virtual address of the HPET registers.
Definition hpet.c:93
struct socket_family socket_family_t
static dentry_t * file
Definition log_file.c:17
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:10
__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.
Socket Family operations structure.
Socket Family structure.
Socket structure.
Definition socket.h:81
Wait queue structure.
Definition wait.h:166