Udipe 1.0
Solving the riddle of high-throughput UDP
Loading...
Searching...
No Matches
connect.h
Go to the documentation of this file.
1#pragma once
2
10
11#include "time.h"
12
13#include <stdbool.h>
14#include <stdint.h>
15
16#ifdef __unix__
17 #include <netinet/in.h>
18 #include <sys/socket.h>
19#elif defined(_WIN32)
20 #include <winsock2.h>
21 #include <ws2tcpip.h>
22#endif
23
24
45
55typedef union ip_address_u {
56 struct sockaddr any;
57 struct sockaddr_in v4;
58 struct sockaddr_in6 v6;
60
71
93 //
94 // TODO: Maps to SO_SNDTIMEO if set
96
103 //
104 // TODO: Maps to SO_RCVTIMEO if set
106
107 // TODO: Add `udipe_future_t* after` option to chain this after other ops.
108
126 //
127 // TODO: Maps to SO_BINDTODEVICE
128 const char* local_interface;
129
141 //
142 // TODO: Provide a way to get that auto-assigned port after connection, this
143 // is done via getsockname().
149 //
150 // TODO: Maps to bind() if set + check type consistency with
151 // remote_address
153
169 //
170 // TODO: Maps to connect() if set + check type consistency with
171 // local_address
173
190 //
191 // TODO: Implement by trying SO_SNDBUF then SO_SNDBUFFORCE
192 unsigned send_buffer : 31;
193
210 //
211 // TODO: Implement by trying SO_RCVBUF then SO_RCVBUFFORCE
212 unsigned recv_buffer : 31;
213
222 //
223 // TODO: Used to enforce usage validation by detecting invalid parameters
224 // and commands.
226
242 //
243 // TODO: Sets UDP_SEGMENT in tandem with gso_segment_size
245
262 //
263 // TODO: Sets UDP_GRO
265
285 //
286 // TODO: Sets UDP_SEGMENT in tandem with enable_gso
288
299 //
300 // TODO: Implement by setting SO_PRIORITY
301 uint8_t priority;
302
320 //
321 // TODO: This will require SO_REUSEPORT + fancier infrastructure in
322 // udipe_context as a connexion may now be associated with multiple
323 // worker threads. In any case, udipe_context will need a way to know
324 // which worker threads can handle which connexion.
326
335 //
336 // TODO: Implement by setting SO_TIMESTAMPNS and checking the
337 // `SCM_TIMESTAMPNS` cmsg.
339
340 // TODO: Activer aussi IP_RECVERR et logger voire gérer les erreurs, cf man
341 // 7 ip pour plus d'infos. C'est aussi utilisé pour le zero-copy.
342
343 // TODO: Activer périodiquement SO_RXQ_OVFL pour check l'overflow côté
344 // socket, puis le désactiver après réception du cmsg suivant.
345
346 // TODO: Utiliser IP_MTU après binding pour autotuning de la segment size
347 // GRO, cf man 7 ip.
348
349 // TODO: Dans udipe-config, creuser man 7 netdevice et man 7 rtnetlink pour
350 // la configuration device + check pseudofichiers mentionnés à la fin
351 // de man 7 socket, man 7 ip et man 7 udp pour la config kernel.
352
353 // TODO: Quand j'aurai implémenté le multithreading des workers, utiliser
354 // SO_INCOMING_CPU pour associer le socket de chaque worker à son CPU.
356
357// TODO: Flesh out definitions, add docs
358//
359// TODO: Add max-size warnings in \internal, beware that they will not be the
360// same for options and results as for options we need to fit in the
361// internal command_t type.
362typedef int udipe_connect_result_t;
363typedef int udipe_disconnect_options_t;
364typedef int udipe_disconnect_result_t;
udipe_direction_e
Definition connect.h:35
@ UDIPE_OUT
Can send datagrams to the remote peer.
Definition connect.h:40
@ UDIPE_IN
Can receive datagrams from the remote peer.
Definition connect.h:37
@ UDIPE_INOUT
Can exchange datagrams with the remote peer in either direction.
Definition connect.h:43
enum udipe_direction_e udipe_direction_t
struct udipe_connect_options_s udipe_connect_options_t
enum udipe_bool_with_default_e udipe_bool_with_default_t
union ip_address_u ip_address_t
udipe_bool_with_default_e
Definition connect.h:66
@ UDIPE_DEFAULT
Use default value (depends on context)
Definition connect.h:69
@ UDIPE_FALSE
Set to false
Definition connect.h:67
@ UDIPE_TRUE
Set to true
Definition connect.h:68
Definition connect.h:86
bool enable_timestamps
Definition connect.h:338
ip_address_t local_address
Definition connect.h:152
unsigned send_buffer
Definition connect.h:192
udipe_duration_ns_t send_timeout
Definition connect.h:95
udipe_bool_with_default_t enable_gro
Definition connect.h:264
udipe_bool_with_default_t enable_gso
Definition connect.h:244
const char * local_interface
Definition connect.h:128
udipe_direction_t direction
Definition connect.h:225
uint8_t priority
Definition connect.h:301
udipe_duration_ns_t recv_timeout
Definition connect.h:105
bool allow_multithreading
Definition connect.h:325
uint16_t gso_segment_size
Definition connect.h:287
ip_address_t remote_address
Definition connect.h:172
unsigned recv_buffer
Definition connect.h:212
Time-related definitions.
uint64_t udipe_duration_ns_t
Definition time.h:40
Definition connect.h:55
struct sockaddr_in v4
IPv4 address.
Definition connect.h:57
struct sockaddr any
Used to safely query the sa_family field.
Definition connect.h:56
struct sockaddr_in6 v6
IPv6 address.
Definition connect.h:58