Line data Source code
1 : /* 17.2. Long Header Packets
2 : Long Header Packet {
3 : Header Form (1) = 1,
4 : Fixed Bit (1) = 1,
5 : Long Packet Type (2),
6 : Type-Specific Bits (4),
7 : Version (32),
8 : Destination Connection ID Length (8),
9 : Destination Connection ID (0..160),
10 : Source Connection ID Length (8),
11 : Source Connection ID (0..160),
12 : Type-Specific Payload (..),
13 : }
14 : Figure 13: Long Header Packet Format */
15 :
16 : /* long header except first byte */
17 29298 : FD_TEMPL_DEF_STRUCT_BEGIN(long_hdr)
18 29286 : FD_TEMPL_MBR_ELEM ( version, uint )
19 29286 : FD_TEMPL_MBR_ELEM ( dst_conn_id_len, uchar )
20 58266 : FD_TEMPL_MBR_ELEM_VAR( dst_conn_id, 0,160, dst_conn_id_len )
21 58266 : FD_TEMPL_MBR_ELEM ( src_conn_id_len, uchar )
22 57900 : FD_TEMPL_MBR_ELEM_VAR( src_conn_id, 0,160, src_conn_id_len )
23 57900 : FD_TEMPL_DEF_STRUCT_END(long_hdr)
24 :
25 :
26 : /* 17.2.2 Version Negotiation Packet
27 : Version Negotiation Packet {
28 : Header Form (1) = 1,
29 : Unused (7),
30 : Version (32) = 0,
31 : Destination Connection ID Length (8),
32 : Destination Connection ID (0..2040),
33 : Source Connection ID Length (8),
34 : Source Connection ID (0..2040),
35 : Supported Version (32) ...,
36 : }
37 : Figure 14: Version Negotiation Packet */
38 :
39 12 : FD_TEMPL_DEF_STRUCT_BEGIN(version_neg)
40 0 : FD_TEMPL_MBR_ELEM ( h0, uchar )
41 0 : FD_TEMPL_MBR_ELEM ( version, uint )
42 0 : FD_TEMPL_MBR_ELEM ( dst_conn_id_len, uchar )
43 0 : FD_TEMPL_MBR_ELEM_VAR ( dst_conn_id, 0,2040, dst_conn_id_len )
44 0 : FD_TEMPL_MBR_ELEM ( src_conn_id_len, uchar )
45 0 : FD_TEMPL_MBR_ELEM_VAR ( src_conn_id, 0,2040, src_conn_id_len )
46 : /* TODO determine proper range here */
47 0 : FD_TEMPL_MBR_ELEM_ARRAY( supported_versions, uint, 1,FD_QUIC_MAX_VERSIONS )
48 0 : FD_TEMPL_DEF_STRUCT_END(version_neg)
49 :
50 :
51 : /* 17.2.2 Initial Packet
52 : Initial Packet {
53 : Header Form (1) = 1,
54 : Fixed Bit (1) = 1,
55 : Long Packet Type (2) = 0,
56 : Reserved Bits (2),
57 : Packet Number Length (2),
58 : Version (32),
59 : Destination Connection ID Length (8),
60 : Destination Connection ID (0..160),
61 : Source Connection ID Length (8),
62 : Source Connection ID (0..160),
63 :
64 : Token Length (i),
65 : Token (..),
66 : Length (i),
67 : Packet Number (8..32),
68 : Packet Payload (8..),
69 : }
70 : Figure 15: Initial Packet
71 :
72 : The first CRYPTO frame sent always begins at an offset of 0 */
73 :
74 29433 : FD_TEMPL_DEF_STRUCT_BEGIN(initial)
75 29421 : FD_TEMPL_MBR_ELEM ( h0, uchar )
76 29421 : FD_TEMPL_MBR_ELEM ( version, uint )
77 29421 : FD_TEMPL_MBR_ELEM ( dst_conn_id_len, uchar )
78 58842 : FD_TEMPL_MBR_ELEM_VAR ( dst_conn_id, 0,160, dst_conn_id_len )
79 58842 : FD_TEMPL_MBR_ELEM ( src_conn_id_len, uchar )
80 58842 : FD_TEMPL_MBR_ELEM_VAR ( src_conn_id, 0,160, src_conn_id_len )
81 :
82 : /* FIXME use a pointer here */
83 58842 : FD_TEMPL_MBR_ELEM_VARINT ( token_len, ulong )
84 73431 : FD_TEMPL_MBR_ELEM_VAR ( token, 0,2048, token_len )
85 :
86 73431 : FD_TEMPL_MBR_ELEM_VARINT ( len, ulong )
87 43140 : FD_TEMPL_MBR_ELEM_PKTNUM ( pkt_num, ulong )
88 :
89 : // CRYPTO frames, etc, may start here
90 43140 : FD_TEMPL_DEF_STRUCT_END(initial)
91 :
92 :
93 : /* 17.2.3 0-RTT
94 : 0-RTT Packet {
95 : Header Form (1) = 1,
96 : Fixed Bit (1) = 1,
97 : Long Packet Type (2) = 1,
98 : Reserved Bits (2),
99 : Packet Number Length (2),
100 : Version (32),
101 : Destination Connection ID Length (8),
102 : Destination Connection ID (0..160),
103 : Source Connection ID Length (8),
104 : Source Connection ID (0..160),
105 : Length (i),
106 : Packet Number (8..32),
107 : Packet Payload (8..),
108 : }
109 : Figure 16: 0-RTT Packet */
110 12 : FD_TEMPL_DEF_STRUCT_BEGIN(zero_rtt)
111 0 : FD_TEMPL_MBR_ELEM ( h0, uchar )
112 0 : FD_TEMPL_MBR_ELEM ( version, uint )
113 0 : FD_TEMPL_MBR_ELEM ( dst_conn_id_len, uchar )
114 0 : FD_TEMPL_MBR_ELEM_VAR ( dst_conn_id, 0,160, dst_conn_id_len )
115 0 : FD_TEMPL_MBR_ELEM ( src_conn_id_len, uchar )
116 0 : FD_TEMPL_MBR_ELEM_VAR ( src_conn_id, 0,160, src_conn_id_len )
117 :
118 0 : FD_TEMPL_MBR_ELEM_VARINT ( len, ulong )
119 0 : FD_TEMPL_MBR_ELEM_VARINT ( pkt_num, ulong )
120 :
121 : // payload starts here
122 0 : FD_TEMPL_DEF_STRUCT_END(zero_rtt)
123 :
124 :
125 : /* 17.2.4 Handshake Packet
126 : Handshake Packet {
127 : Header Form (1) = 1,
128 : Fixed Bit (1) = 1,
129 : Long Packet Type (2) = 2,
130 : Reserved Bits (2),
131 : Packet Number Length (2),
132 : Version (32),
133 : Destination Connection ID Length (8),
134 : Destination Connection ID (0..160),
135 : Source Connection ID Length (8),
136 : Source Connection ID (0..160),
137 : Length (i),
138 : Packet Number (8..32),
139 : Packet Payload (8..),
140 : }
141 : Figure 17: Handshake Protected Packet */
142 :
143 24228 : FD_TEMPL_DEF_STRUCT_BEGIN(handshake)
144 24216 : FD_TEMPL_MBR_ELEM ( h0, uchar )
145 24216 : FD_TEMPL_MBR_ELEM ( version, uint )
146 24216 : FD_TEMPL_MBR_ELEM ( dst_conn_id_len, uchar )
147 48432 : FD_TEMPL_MBR_ELEM_VAR ( dst_conn_id, 0,160, dst_conn_id_len )
148 48432 : FD_TEMPL_MBR_ELEM ( src_conn_id_len, uchar )
149 48432 : FD_TEMPL_MBR_ELEM_VAR ( src_conn_id, 0,160, src_conn_id_len )
150 :
151 48432 : FD_TEMPL_MBR_ELEM_VARINT ( len, ulong )
152 36246 : FD_TEMPL_MBR_ELEM_PKTNUM ( pkt_num, ulong )
153 :
154 : // payload starts here
155 36246 : FD_TEMPL_DEF_STRUCT_END(handshake)
156 :
157 :
158 : /* 17.2.5 Retry Packet
159 : Retry Packet {
160 : Header Form (1) = 1,
161 : Fixed Bit (1) = 1,
162 : Long Packet Type (2) = 3,
163 : Unused (4),
164 : Version (32),
165 : Destination Connection ID Length (8),
166 : Destination Connection ID (0..160),
167 : Source Connection ID Length (8),
168 : Source Connection ID (0..160),
169 : Retry Token (..),
170 : Retry Integrity Tag (128),
171 : }
172 : Figure 18: Retry Packet */
173 6002964 : FD_TEMPL_DEF_STRUCT_BEGIN(retry_hdr)
174 6002952 : FD_TEMPL_MBR_ELEM ( h0, uchar )
175 6002952 : FD_TEMPL_MBR_ELEM ( version, uint )
176 6002952 : FD_TEMPL_MBR_ELEM ( dst_conn_id_len, uchar )
177 12005880 : FD_TEMPL_MBR_ELEM_VAR ( dst_conn_id, 0,160, dst_conn_id_len )
178 12005880 : FD_TEMPL_MBR_ELEM ( src_conn_id_len, uchar )
179 12005730 : FD_TEMPL_MBR_ELEM_VAR ( src_conn_id, 8,160, src_conn_id_len )
180 12005730 : FD_TEMPL_DEF_STRUCT_END(retry_hdr)
181 :
182 :
183 :
184 : /* 17.2. Short Header Packets
185 : 1-RTT Packet {
186 : Header Form (1) = 0,
187 : Fixed Bit (1) = 1,
188 : Spin Bit (1),
189 : Reserved Bits (2),
190 : Key Phase (1),
191 : Packet Number Length (2),
192 : Destination Connection ID (0..160),
193 : Packet Number (8..32),
194 : Packet Payload (8..),
195 : }
196 : Figure 19: 1-RTT Packet */
197 37569060 : FD_TEMPL_DEF_STRUCT_BEGIN(one_rtt)
198 37569048 : FD_TEMPL_MBR_ELEM ( h0, uchar )
199 37569048 : FD_TEMPL_MBR_ELEM_HIDDEN( dst_conn_id_len, uint )
200 75138096 : FD_TEMPL_MBR_ELEM_VAR ( dst_conn_id, 0,160, dst_conn_id_len )
201 :
202 75138096 : FD_TEMPL_MBR_ELEM_PKTNUM( pkt_num, ulong )
203 :
204 : // payload starts here
205 37569048 : FD_TEMPL_DEF_STRUCT_END(one_rtt)
206 :
207 :
208 :
209 : /* 18. Transport Parameter Encoding
210 : Transport Parameters {
211 : Transport Parameter (..) ...,
212 : }
213 : Figure 20: Sequence of Transport Parameters
214 : Each transport parameter is encoded as an (identifier, length, value) tuple, as shown in Figure 21:
215 :
216 : Transport Parameter {
217 : Transport Parameter ID (i),
218 : Transport Parameter Length (i),
219 : Transport Parameter Value (..),
220 : }
221 : Figure 21: Transport Parameter Encoding */
222 :
223 : // one transport entry - repeats
224 12 : FD_TEMPL_DEF_STRUCT_BEGIN(transport_param_entry)
225 0 : FD_TEMPL_MBR_ELEM_VARINT ( param_id, ulong )
226 0 : FD_TEMPL_MBR_ELEM_VARINT ( param_len, ulong )
227 0 : FD_TEMPL_MBR_ELEM_VAR_RAW( param_val, 0,8192, param_len )
228 0 : FD_TEMPL_DEF_STRUCT_END(transport_param_entry)
229 :
230 :
231 : /* 19. Frame common header
232 :
233 : COMMON Frag {
234 : Type (i)
235 : } */
236 18 : FD_TEMPL_DEF_STRUCT_BEGIN(common_frag)
237 6 : FD_TEMPL_MBR_ELEM_VARINT( type, ulong )
238 6 : FD_TEMPL_DEF_STRUCT_END(common_frag)
239 :
240 :
241 : /* 19.3.1. ACK Ranges (part of ACK frame)
242 :
243 : ACK Range {
244 : Gap (i),
245 : ACK Range Length (i),
246 : }
247 : Figure 26: ACK Ranges */
248 :
249 426 : FD_TEMPL_DEF_STRUCT_BEGIN(ack_range_frag)
250 414 : FD_TEMPL_MBR_ELEM_VARINT( gap, ulong )
251 408 : FD_TEMPL_MBR_ELEM_VARINT( length, ulong )
252 396 : FD_TEMPL_DEF_STRUCT_END(ack_range_frag)
253 :
254 :
255 : /* 19.3.2. ECN Counts (part of ACK frame)
256 :
257 : ECN Counts {
258 : ECT0 Count (i),
259 : ECT1 Count (i),
260 : ECN-CE Count (i),
261 : }
262 : Figure 27: ECN Count Format
263 : The ECN count fields are:
264 :
265 : ECT0 Count:
266 : A variable-length integer representing the total number of packets received with the
267 : ECT(0) codepoint in the packet number space of the ACK frame.
268 :
269 : ECT1 Count:
270 : A variable-length integer representing the total number of packets received with the
271 : ECT(1) codepoint in the packet number space of the ACK frame.
272 :
273 : ECN-CE Count:
274 : A variable-length integer representing the total number of packets received with the
275 : ECN-CE codepoint in the packet number space of the ACK frame. */
276 :
277 120 : FD_TEMPL_DEF_STRUCT_BEGIN(ecn_counts_frag)
278 108 : FD_TEMPL_MBR_ELEM_VARINT( ect0_count, ulong )
279 105 : FD_TEMPL_MBR_ELEM_VARINT( ect1_count, ulong )
280 102 : FD_TEMPL_MBR_ELEM_VARINT( ecn_ce_count, ulong )
281 96 : FD_TEMPL_DEF_STRUCT_END(ecn_counts_frag)
282 :
283 :
284 : /* 18.2. Transport Parameter Definitions > Preferred Address */
285 :
286 24 : FD_TEMPL_DEF_STRUCT_BEGIN(preferred_address)
287 18 : FD_TEMPL_MBR_ELEM_FIXED( ipv4_address, uchar, 4 )
288 18 : FD_TEMPL_MBR_ELEM ( ipv4_port, ushort )
289 18 : FD_TEMPL_MBR_ELEM_FIXED( ipv6_address, uchar, 16 )
290 18 : FD_TEMPL_MBR_ELEM ( ipv6_port, ushort )
291 12 : FD_TEMPL_MBR_ELEM ( conn_id_len, uchar )
292 24 : FD_TEMPL_MBR_ELEM_VAR ( conn_id, 0,160, conn_id_len )
293 24 : FD_TEMPL_MBR_ELEM_FIXED( reset_token, uchar, 16 )
294 18 : FD_TEMPL_DEF_STRUCT_END(preferred_address)
|