wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
Loading...
Searching...
No Matches
pnspace.h
1#ifndef CONN_PNSPACE_H
2#define CONN_PNSPACE_H
3
5
9typedef enum { PNS_INITIAL = 0, PNS_HANDSHAKE, PNS_APP, PNS_COUNT } pns_space;
10
12typedef struct {
13 u64 next[PNS_COUNT];
15} pnspace;
16
17/* RFC 9000 12.3: 2^62-1 is the highest packet number a sender may ever use;
18 * once issued, that space must not send another packet in it (and MUST
19 * close the connection without sending a CONNECTION_CLOSE frame). */
20#define PN_LIMIT (((u64)1 << 62) - 1)
21
22/* Initialize all spaces to packet number 0. */
23void pnspace_init(pnspace* s);
24
25/* Return the next packet number for `space` and advance that space's counter.
26 * Each space is strictly monotonic and independent of the others. */
27u64 pnspace_next(pnspace* s, pns_space space);
28
29/* RFC 9000 12.3: 1 once `space` has issued PN_LIMIT (its highest legal
30 * packet number), meaning the sender must stop sending in it -- silently,
31 * without a CONNECTION_CLOSE. 0 while more packet numbers remain. */
32int pnspace_exhausted(const pnspace* s, pns_space space);
33
34#endif
Per-space next-packet-number counters (RFC 9000 12.3).
Definition pnspace.h:12
u64 next[PNS_COUNT]
next packet number, indexed by pns_space
Definition pnspace.h:13
Linux direct syscalls.
unsigned long u64
unsigned 64-bit integer
Definition types.h:13