ApertureOS
socket.h
Go to the documentation of this file.
1 #ifndef _SOCKET_PROC_H_
2 #define _SOCKET_PROC_H_
3 
4 #include "types.h"
5 #include "managers.h"
6 
12 typedef uint32_t(*Sock_ReadAsync)(uint8_t* buffer, uint32_t size);
14 
16 typedef uint32_t(*Sock_SeekAsync)(uint64_t offset, int whence);
17 
19 typedef uint32_t(*Sock_WriteAsync)(uint8_t* src_buf, uint32_t size);
20 
22 typedef enum
23 {
25  SOCK_ERROR_UNKNOWN = 1 << 0,
29  SOCK_ERROR_EXISTS = 1 << 4,
31 } SOCK_ERROR;
32 
34 typedef enum
35 {
43 
45 typedef enum
46 {
55 
57 typedef struct
58 {
59  uint32_t size;
60  uint32_t max_connections;
61 
65 
68 } SocketDesc;
69 
71 typedef struct
72 {
73  uint32_t size;
74 
77 
78 
80 
86 Socket_Create(const char *name,
87  SocketDesc *desc);
88 
89 
91 
98 Socket_Connect(const char *name,
100  UID *id);
101 
102 
104 
111 
112 
114 
123  uint8_t *buffer,
124  uint32_t size);
125 
126 
128 
137  uint8_t *buffer,
138  uint32_t size);
139 
140 
142 
151  uint64_t offset,
152  int whence);
153 
156 #endif
Socket may be read from.
Definition: socket.h:38
Send notification on seek.
Definition: socket.h:50
Sock_WriteAsync write
Function to read from the socket.
Definition: socket.h:63
SOCK_ERROR Socket_WriteAsync(UID id, uint8_t *buffer, uint32_t size)
Request an asynchronous write to the socket.
Definition: socket.c:49
SOCK_FEATURES requested_features
The size of the struct. must be sizeof(SocketConnectionDesc)
Definition: socket.h:75
uint32_t(* Sock_SeekAsync)(uint64_t offset, int whence)
A pointer to a function that asynchronously performs a Socket seek.
Definition: socket.h:16
uint32_t(* Sock_ReadAsync)(uint8_t *buffer, uint32_t size)
A pointer to a function that asynchronously performs a Socket read.
Definition: socket.h:13
SOCK_ERROR
Socket errors.
Definition: socket.h:22
The description of the socket.
Definition: socket.h:57
Socket can send notifications into the message pump.
Definition: socket.h:40
SOCK_ERROR Socket_Connect(const char *name, SocketConnectionDesc *desc, UID *id)
Attempt to connect to a socket.
Definition: socket.c:17
SOCK_NOTIFICATIONS notifications
Features supported by the socket.
Definition: socket.h:67
uint64_t UID
Definition: types.h:8
Signals the completion of an asynchronous action for the current thread.
Definition: socket.h:53
Send no notifications.
Definition: socket.h:47
The socket does not exist.
Definition: socket.h:30
Socket is seekable.
Definition: socket.h:39
The socket is busy.
Definition: socket.h:28
SOCK_ERROR Socket_ReadAsync(UID id, uint8_t *buffer, uint32_t size)
Request an asynchronous read from the socket.
Definition: socket.c:37
uint32_t size
Definition: socket.h:73
SOCK_ERROR Socket_Disconnect(UID id)
Attempt to disconnect from the socket.
Definition: socket.c:29
uint32_t size
Definition: socket.h:59
const char name[MAX_PROC_NAME_LEN]
Definition: process_man.h:22
The description of the socket connection.
Definition: socket.h:71
Request supervisor level access.
Definition: socket.h:41
Socket can be written to.
Definition: socket.h:37
No features.
Definition: socket.h:36
Unknown error.
Definition: socket.h:25
No error.
Definition: socket.h:24
SOCK_ERROR Socket_SeekAsync(UID id, uint64_t offset, int whence)
Request an asynchronous seek of the socket.
Definition: socket.c:61
SOCK_FEATURES
Socket features.
Definition: socket.h:34
Send notification on read.
Definition: socket.h:49
Sock_ReadAsync read
The maximum number of connections allowed to the socket.
Definition: socket.h:62
SOCK_ERROR Socket_Create(const char *name, SocketDesc *desc)
Create a new Socket and register it to the kernel.
Definition: socket.c:7
uint32_t max_connections
The size of the struct, must be sizeof(SocketDesc)
Definition: socket.h:60
SOCK_NOTIFICATIONS
Socket notifications.
Definition: socket.h:45
Send notification on write.
Definition: socket.h:48
Send notification on connect.
Definition: socket.h:51
uint32_t(* Sock_WriteAsync)(uint8_t *src_buf, uint32_t size)
A pointer to a function that asynchronously performs a Socket write.
Definition: socket.h:19
The calling thread doesn't have the permissions.
Definition: socket.h:27
Send notification on disconnect.
Definition: socket.h:52
The socket already exists.
Definition: socket.h:29
SOCK_FEATURES flags
Function to seek the socket.
Definition: socket.h:66
Sock_SeekAsync seek
Function to write to the socket.
Definition: socket.h:64
There are no free connections on this socket.
Definition: socket.h:26