wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
Loading...
Searching...
No Matches
srvdriver.h File Reference

Selects and runs one of this SDK's four server drivers (single-process, multi-process fork, AF_XDP, multi-thread fan-out) from --workers/ --ifindex/--cores/--pin-core command-line flags, the exact same exclusive-combination rules examples/word_list's driver_select hand-rolled. More...

Go to the source code of this file.

Data Structures

struct  wired_srvdriver_opt
 Resolved driver selection and its knobs, filled entirely by wired_srvdriver_parse from argv (or by hand for a caller that skips CLI parsing). More...

Enumerations

enum  wired_srvdriver_kind { WIRED_SRVDRIVER_PLAIN = 0 , WIRED_SRVDRIVER_WORKERS , WIRED_SRVDRIVER_XDP , WIRED_SRVDRIVER_THREADS }
 Which of the four run paths wired_srvdriver_run takes. More...

Functions

int wired_srvdriver_parse (int argc, char **argv, wired_srvdriver_opt *opt)
 Parse --port/--workers/--ifindex/--queue/--ip/--skb-mode/ --cores/--control-core/--pin-core from argv into *opt, applying the same exclusive-combination rules as examples/word_list's driver_select: --workers cannot combine with --cores or --ifindex; --pin-core cannot combine with --workers (use its own --pin-cores) or --cores (use --control-core).
int wired_srvdriver_run (wired_srvboot_id *id, wired_srvrun_handler h, wired_srvrun_obs obs, const wired_srvdriver_opt *opt)
 Dispatch to the driver selected by opt->kind, binding/serving on opt->port: WIRED_SRVDRIVER_PLAIN -> wired_server_run_opt (opt->pin_core applied first) WIRED_SRVDRIVER_WORKERS -> wired_srvworkers_run WIRED_SRVDRIVER_XDP -> wired_srvxdp_open + wired_server_run_opt + wired_srvxdp_print_stats + wired_srvxdp_close WIRED_SRVDRIVER_THREADS -> wired_srvthreads_run.

Detailed Description

Selects and runs one of this SDK's four server drivers (single-process, multi-process fork, AF_XDP, multi-thread fan-out) from --workers/ --ifindex/--cores/--pin-core command-line flags, the exact same exclusive-combination rules examples/word_list's driver_select hand-rolled.

Only the CLI-driven decision of WHICH driver to run and its dispatch are here; each driver's own knobs (wired_srvworkers_opt, wired_srvxdp_cfg, wired_srvthreads_opt) are unchanged and still directly usable by a caller that wants to build one by hand instead of parsing argv.

Enumeration Type Documentation

◆ wired_srvdriver_kind

Which of the four run paths wired_srvdriver_run takes.

Enumerator
WIRED_SRVDRIVER_PLAIN 

single-process wired_server_run_opt

WIRED_SRVDRIVER_WORKERS 

multi-process fork, wired_srvworkers_run

WIRED_SRVDRIVER_XDP 

AF_XDP, wired_server_run_opt + opt->xdp.

WIRED_SRVDRIVER_THREADS 

multi-thread fan-out, wired_srvthreads_run

Function Documentation

◆ wired_srvdriver_parse()

int wired_srvdriver_parse ( int argc,
char ** argv,
wired_srvdriver_opt * opt )

Parse --port/--workers/--ifindex/--queue/--ip/--skb-mode/ --cores/--control-core/--pin-core from argv into *opt, applying the same exclusive-combination rules as examples/word_list's driver_select: --workers cannot combine with --cores or --ifindex; --pin-core cannot combine with --workers (use its own --pin-cores) or --cores (use --control-core).

--ifindex alone still composes with --cores (AF_XDP multi-queue mode: worker i serves queue i) – this is why XDP has no dedicated flag of its own, only --ifindex deciding WIRED_SRVDRIVER_XDP when --cores is absent.

opt->port/run/workers/threads are populated only for the fields this parses; a caller that also wants qlog/keylog paths, app callbacks (wt_on_datagram, etc.), or cert-reload paths sets those directly on opt->run and the wired_srvrun_obs it passes to wired_srvdriver_run separately.

Parameters
argcargument count
argvargument vector
optdestination; left untouched if an exclusive-combination conflict is detected before any field is written, but zeroed (and possibly partially filled) on a value-parse failure past that point (e.g. --cores present but unparseable) – always re-check the return value, never trust opt's contents after a 0 return
Returns
1 on success, 0 on a conflicting flag combination or a malformed value

◆ wired_srvdriver_run()

int wired_srvdriver_run ( wired_srvboot_id * id,
wired_srvrun_handler h,
wired_srvrun_obs obs,
const wired_srvdriver_opt * opt )

Dispatch to the driver selected by opt->kind, binding/serving on opt->port: WIRED_SRVDRIVER_PLAIN -> wired_server_run_opt (opt->pin_core applied first) WIRED_SRVDRIVER_WORKERS -> wired_srvworkers_run WIRED_SRVDRIVER_XDP -> wired_srvxdp_open + wired_server_run_opt + wired_srvxdp_print_stats + wired_srvxdp_close WIRED_SRVDRIVER_THREADS -> wired_srvthreads_run.

qlog/keylog paths in obs are passed through for PLAIN/XDP/THREADS; WORKERS silently drops them (multiple forked processes writing the same qlog/ keylog file would interleave, matching examples/word_list's existing run_workers behavior).

Parameters
idthe fixed server identity, passed through to the selected driver
hthe application's request responder
obsqlog/keylog/cert-reload paths (cert-reload is the caller's own concern via wired_certreload_load_or_selfsigned, not this function's)
optthe resolved selection from wired_srvdriver_parse (or built by hand); opt->port is the port bound/served, see wired_srvdriver_opt's doc
Returns
the selected driver's own return value (see each driver's own wired_*_run doc for its exact convention)