Line data Source code
1 : #ifndef HEADER_fd_src_waltz_quic_templ_fd_quic_frame_h
2 : #define HEADER_fd_src_waltz_quic_templ_fd_quic_frame_h
3 :
4 : #include "../../../util/fd_util_base.h"
5 : #include "../fd_quic_enum.h"
6 :
7 : /* FD_QUIC_FRAME_TYPES describes QUIC frame types and their attributes.
8 : Indexed by frame ID. Some frame IDs have the same handler.
9 :
10 : Columns:
11 : - ID: frame type as seen on the wire
12 : - MID: frame ID used in fd_quic metrics (FIXME use ID instead when fd_metrics supports sparse enums)
13 : - Flags:
14 : - '_': Placeholder
15 : - 'I': Allowed in Initial packet
16 : - 'H': Allowed in Handshake packet
17 : - '0': Allowed in 0-RTT packet
18 : - '1': Allowed in 1-RTT packet
19 : - 'N': Not ACK eliciting (absence implies the contrary) */
20 :
21 : #define FD_QUIC_FRAME_TYPES(X) \
22 : /* ID MID Name Flags */ \
23 1599097 : X(0x00, 21, padding, I, H, 0, 1, N) /* Section 19.1 */ \
24 1599097 : X(0x01, 20, ping, I, H, 0, 1, _) /* Section 19.2 */ \
25 1599779 : X(0x02, 1, ack, I, H, _, 1, N) /* Section 19.3 */ \
26 1599779 : X(0x03, 1, ack, I, H, _, 1, N) /* Section 19.3 */ \
27 12 : X(0x04, 2, reset_stream, _, _, 0, 1, _) /* Section 19.4 */ \
28 0 : X(0x05, 3, stop_sending, _, _, 0, 1, _) /* Section 19.5 */ \
29 42111 : X(0x06, 4, crypto, I, H, _, 1, _) /* Section 19.6 */ \
30 42111 : X(0x07, 5, new_token, _, _, _, 1, _) /* Section 19.7 */ \
31 0 : X(0x08, 6, stream_8, _, _, 0, 1, _) /* Section 19.8 */ \
32 0 : X(0x09, 6, stream_8, _, _, 0, 1, _) /* Section 19.8 */ \
33 9366 : X(0x0a, 6, stream_a, _, _, 0, 1, _) /* Section 19.8 */ \
34 92020356 : X(0x0b, 6, stream_a, _, _, 0, 1, _) /* Section 19.8 */ \
35 92020356 : X(0x0c, 6, stream_c, _, _, 0, 1, _) /* Section 19.8 */ \
36 0 : X(0x0d, 6, stream_c, _, _, 0, 1, _) /* Section 19.8 */ \
37 7509 : X(0x0e, 6, stream_e, _, _, 0, 1, _) /* Section 19.8 */ \
38 9354 : X(0x0f, 6, stream_e, _, _, 0, 1, _) /* Section 19.8 */ \
39 9354 : X(0x10, 7, max_data, _, _, 0, 1, _) /* Section 19.9 */ \
40 0 : X(0x11, 8, max_stream_data, _, _, 0, 1, _) /* Section 19.10 */ \
41 0 : X(0x12, 9, max_streams, _, _, 0, 1, _) /* Section 19.11 */ \
42 0 : X(0x13, 9, max_streams, _, _, 0, 1, _) /* Section 19.11 */ \
43 0 : X(0x14, 10, data_blocked, _, _, 0, 1, _) /* Section 19.12 */ \
44 0 : X(0x15, 11, stream_data_blocked, _, _, 0, 1, _) /* Section 19.13 */ \
45 0 : X(0x16, 12, streams_blocked, _, _, 0, 1, _) /* Section 19.14 */ \
46 0 : X(0x17, 12, streams_blocked, _, _, 0, 1, _) /* Section 19.14 */ \
47 0 : X(0x18, 13, new_conn_id, _, _, 0, 1, _) /* Section 19.15 */ \
48 0 : X(0x19, 14, retire_conn_id, _, _, 0, 1, _) /* Section 19.16 */ \
49 0 : X(0x1a, 15, path_challenge, _, _, 0, 1, _) /* Section 19.17 */ \
50 0 : X(0x1b, 16, path_response, _, _, _, 1, _) /* Section 19.18 */ \
51 0 : X(0x1c, 17, conn_close_0, I, H, 0, 1, N) /* Section 19.19 */ \
52 6015 : X(0x1d, 18, conn_close_1, _, _, 0, 1, N) /* Section 19.19 */ \
53 6015 : X(0x1e, 19, handshake_done, _, _, _, 1, _) /* Section 19.20 */
54 :
55 : #define FD_QUIC_FRAME_TYPE_CNT (0x1f) /* lookup tables should have this many entries */
56 :
57 : extern uchar const __attribute__((aligned(0x20)))
58 : fd_quic_frame_type_flags[ FD_QUIC_FRAME_TYPE_CNT ];
59 :
60 : #define FD_QUIC_FRAME_FLAG__ 0u
61 : #define FD_QUIC_FRAME_FLAG_I (1u<<FD_QUIC_PKT_TYPE_INITIAL) /* allowed in INITIAL */
62 : #define FD_QUIC_FRAME_FLAG_H (1u<<FD_QUIC_PKT_TYPE_HANDSHAKE) /* allowed in HANDSHAKE */
63 : #define FD_QUIC_FRAME_FLAG_0 (1u<<FD_QUIC_PKT_TYPE_ZERO_RTT) /* allowed in 0-RTT */
64 : #define FD_QUIC_FRAME_FLAG_1 (1u<<FD_QUIC_PKT_TYPE_ONE_RTT) /* allowed in 1-RTT */
65 95299626 : #define FD_QUIC_FRAME_FLAG_N (1u<<5) /* not ack eliciting */
66 :
67 : FD_PROTOTYPES_BEGIN
68 :
69 : /* fd_quic_frame_type_allowed checks whether a frame type is allowed for
70 : a given packet type. pkt_type is one of FD_QUIC_PKT_TYPE_{INITIAL,
71 : HANDSHAKE,ZERO_RTT,ONE_RTT}. Returns 1 if the frame type is allowed,
72 : 0 otherwise. */
73 :
74 : FD_FN_PURE static inline int
75 : fd_quic_frame_type_allowed( uint pkt_type,
76 95299677 : uint frame_type ) {
77 95299677 : if( FD_UNLIKELY( pkt_type>4 ) ) return 0;
78 95299677 : if( FD_UNLIKELY( frame_type>=FD_QUIC_FRAME_TYPE_CNT ) ) return 0;
79 95299671 : return !!( fd_quic_frame_type_flags[frame_type] & (1u<<pkt_type) );
80 95299677 : }
81 :
82 : FD_PROTOTYPES_END
83 :
84 : #endif /* HEADER_fd_src_waltz_quic_templ_fd_quic_frame_h */
|