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
>
4
#include <
kernel/net/socket_type.h
>
5
6
#include <
stdint.h
>
7
#include <
sys/io.h
>
8
#include <
sys/list.h
>
9
10
typedef
struct
socket
socket_t
;
11
typedef
struct
socket_family
socket_family_t
;
12
35
typedef
struct
socket_factory
36
{
37
list_entry_t
entry
;
38
socket_type_t
type
;
39
socket_family_t
*
family
;
40
dentry_t
*
file
;
41
}
socket_factory_t
;
42
47
typedef
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.
59
}
socket_family_ops_t
;
60
65
typedef
struct
socket_family
66
{
67
list_entry_t
entry
;
68
char
name[
MAX_NAME
];
69
const
socket_family_ops_t
*
ops
;
70
socket_type_t
supportedTypes
;
71
atomic_uint64_t
newId
;
72
list_t
factories
;
73
dentry_t
*
dir
;
74
}
socket_family_t
;
75
84
uint64_t
socket_family_register
(
const
socket_family_ops_t
*
ops
,
const
char
* name,
socket_type_t
supportedTypes);
85
91
void
socket_family_unregister
(
const
char
* name);
92
99
socket_family_t
*
socket_family_get
(
const
char
* name);
100
108
uint64_t
socket_family_get_dir
(
socket_family_t
* family,
path_t
* outPath);
109
MAX_NAME
#define MAX_NAME
Maximum length of names.
Definition
MAX_NAME.h:11
socket_family_register
uint64_t socket_family_register(const socket_family_ops_t *ops, const char *name, socket_type_t supportedTypes)
Register a socket family.
Definition
socket_family.c:53
socket_family_get_dir
uint64_t socket_family_get_dir(socket_family_t *family, path_t *outPath)
Get the directory of a socket family.
Definition
socket_family.c:195
socket_family_unregister
void socket_family_unregister(const char *name)
Unregister a socket family.
Definition
socket_family.c:172
socket_family_get
socket_family_t * socket_family_get(const char *name)
Get a socket family by name.
Definition
socket_family.c:143
socket_type_t
socket_type_t
Socket type enumeration.
Definition
socket_type.h:18
bind
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_t
Poll events type.
Definition
io.h:288
address
static uintptr_t address
Definition
hpet.c:12
io.h
list.h
buffer
EFI_PHYSICAL_ADDRESS buffer
Definition
mem.c:15
ops
static socket_family_ops_t ops
Definition
local.c:505
count
static atomic_long count
Definition
main.c:9
socket_type.h
stdint.h
uint32_t
__UINT32_TYPE__ uint32_t
Definition
stdint.h:15
uint64_t
__UINT64_TYPE__ uint64_t
Definition
stdint.h:17
dentry_t
Directory entry structure.
Definition
dentry.h:83
list_entry_t
A entry in a doubly linked list.
Definition
list.h:38
list_t
A doubly linked list.
Definition
list.h:51
path_t
Path structure.
Definition
path.h:110
socket_factory_t
Socket Factory structure.
Definition
socket_family.h:36
socket_factory_t::entry
list_entry_t entry
Definition
socket_family.h:37
socket_factory_t::family
socket_family_t * family
Definition
socket_family.h:39
socket_factory_t::type
socket_type_t type
Definition
socket_family.h:38
socket_factory_t::file
dentry_t * file
Definition
socket_family.h:40
socket_family_ops_t
Socket Family operations structure.
Definition
socket_family.h:48
socket_family_t
Socket Family structure.
Definition
socket_family.h:66
socket_family_t::entry
list_entry_t entry
Definition
socket_family.h:67
socket_family_t::factories
list_t factories
Definition
socket_family.h:72
socket_family_t::ops
const socket_family_ops_t * ops
Definition
socket_family.h:69
socket_family_t::dir
dentry_t * dir
Definition
socket_family.h:73
socket_family_t::newId
atomic_uint64_t newId
Definition
socket_family.h:71
socket_family_t::supportedTypes
socket_type_t supportedTypes
Definition
socket_family.h:70
socket_t
Socket structure.
Definition
socket.h:81
wait_queue_t
Wait queue structure.
Definition
wait.h:166
sysfs.h
include
kernel
net
socket_family.h
Generated by
1.9.8