19
19
#include <aws/http/request_response.h>
20
20
21
21
#include <aws/common/byte_buf.h>
22
- #include <aws/common/hash_table.h>
23
22
24
23
/* Ids for each frame type (RFC-7540 6) */
25
24
enum aws_h2_frame_type {
@@ -159,6 +158,12 @@ struct aws_h2_frame_rst_stream {
159
158
enum aws_h2_error_codes error_code ;
160
159
};
161
160
161
+ /* A h2 setting and its value, used in SETTINGS frame */
162
+ struct aws_h2_frame_setting {
163
+ uint16_t id ; /* aws_h2_settings */
164
+ uint32_t value ;
165
+ };
166
+
162
167
/* Represents a SETTINGS frame */
163
168
struct aws_h2_frame_settings {
164
169
/* Header */
@@ -168,8 +173,8 @@ struct aws_h2_frame_settings {
168
173
bool ack ; /* AWS_H2_FRAME_F_ACK */
169
174
170
175
/* Payload */
171
- /* uint16_t -> uint32_t */
172
- struct aws_hash_table settings ;
176
+ struct aws_h2_frame_setting * settings_array ;
177
+ size_t settings_count ;
173
178
};
174
179
175
180
/* Represents a PUSH_PROMISE frame */
@@ -186,6 +191,8 @@ struct aws_h2_frame_push_promise {
186
191
struct aws_h2_frame_header_block header_block ;
187
192
};
188
193
194
+ #define AWS_H2_PING_DATA_SIZE (8)
195
+
189
196
/* Represents a PING frame */
190
197
struct aws_h2_frame_ping {
191
198
/* Header */
@@ -195,7 +202,7 @@ struct aws_h2_frame_ping {
195
202
bool ack ; /* AWS_H2_FRAME_F_ACK */
196
203
197
204
/* Payload */
198
- struct aws_byte_cursor opaque_data ;
205
+ uint8_t opaque_data [ AWS_H2_PING_DATA_SIZE ] ;
199
206
};
200
207
201
208
/* Represents a GOAWAY frame */
@@ -238,19 +245,6 @@ struct aws_h2_frame_encoder {
238
245
bool use_huffman ;
239
246
};
240
247
241
- /* Used to decode a frame */
242
- struct aws_h2_frame_decoder {
243
- /* Larger state */
244
- struct aws_allocator * allocator ;
245
- struct aws_byte_buf header_scratch ;
246
- struct aws_hpack_context * hpack ;
247
-
248
- /* Packet-in-progress */
249
- struct aws_h2_frame_header header ;
250
- uint8_t flags ;
251
- struct aws_byte_cursor payload ;
252
- };
253
-
254
248
AWS_EXTERN_C_BEGIN
255
249
256
250
AWS_HTTP_API
@@ -271,48 +265,34 @@ int aws_h2_frame_header_block_encode(
271
265
const struct aws_h2_frame_header_block * header_block ,
272
266
struct aws_h2_frame_encoder * encoder ,
273
267
struct aws_byte_buf * output );
274
- AWS_HTTP_API
275
- int aws_h2_frame_header_block_decode (
276
- struct aws_h2_frame_header_block * header_block ,
277
- struct aws_h2_frame_decoder * decoder );
278
268
279
269
/**
280
270
* The process of encoding a frame looks like:
281
271
* 1. Create a encoder object on the stack and initialize with aws_h2_frame_encoder_init
282
272
* 2. Encode the header using aws_h2_frame_*_encode
283
273
*/
284
-
285
274
AWS_HTTP_API
286
275
int aws_h2_frame_encoder_init (struct aws_h2_frame_encoder * encoder , struct aws_allocator * allocator );
287
276
AWS_HTTP_API
288
277
void aws_h2_frame_encoder_clean_up (struct aws_h2_frame_encoder * encoder );
289
278
290
- /**
291
- * The process of decoding a frame looks like:
292
- * 1. Create a decoder object on the stack and initialize with aws_h2_frame_decoder_init
293
- * 2. Decode the header using aws_h2_frame_decoder_begin
294
- * 3. Switch on header->type, and create a new instance of the appropriate frame type
295
- * 4. Call aws_h2_frame_*_decode to decode the rest of the frame
296
- */
297
-
298
- AWS_HTTP_API
299
- int aws_h2_frame_decoder_init (struct aws_h2_frame_decoder * decoder , struct aws_allocator * allocator );
279
+ /* #TODO: remove each frame type's specific encode() function from API */
300
280
AWS_HTTP_API
301
- void aws_h2_frame_decoder_clean_up (struct aws_h2_frame_decoder * decoder );
302
- AWS_HTTP_API
303
- int aws_h2_frame_decoder_begin (struct aws_h2_frame_decoder * decoder , struct aws_byte_cursor * data );
281
+ int aws_h2_encode_frame (
282
+ struct aws_h2_frame_encoder * encoder ,
283
+ struct aws_h2_frame_header * frame_header ,
284
+ struct aws_byte_buf * output );
304
285
305
286
AWS_HTTP_API
306
287
int aws_h2_frame_data_init (struct aws_h2_frame_data * frame , struct aws_allocator * allocator );
307
288
AWS_HTTP_API
308
289
void aws_h2_frame_data_clean_up (struct aws_h2_frame_data * frame );
290
+
309
291
AWS_HTTP_API
310
292
int aws_h2_frame_data_encode (
311
293
struct aws_h2_frame_data * frame ,
312
294
struct aws_h2_frame_encoder * encoder ,
313
295
struct aws_byte_buf * output );
314
- AWS_HTTP_API
315
- int aws_h2_frame_data_decode (struct aws_h2_frame_data * frame , struct aws_h2_frame_decoder * decoder );
316
296
317
297
AWS_HTTP_API
318
298
int aws_h2_frame_headers_init (struct aws_h2_frame_headers * frame , struct aws_allocator * allocator );
@@ -323,8 +303,6 @@ int aws_h2_frame_headers_encode(
323
303
struct aws_h2_frame_headers * frame ,
324
304
struct aws_h2_frame_encoder * encoder ,
325
305
struct aws_byte_buf * output );
326
- AWS_HTTP_API
327
- int aws_h2_frame_headers_decode (struct aws_h2_frame_headers * frame , struct aws_h2_frame_decoder * decoder );
328
306
329
307
AWS_HTTP_API
330
308
int aws_h2_frame_priority_init (struct aws_h2_frame_priority * frame , struct aws_allocator * allocator );
@@ -335,8 +313,6 @@ int aws_h2_frame_priority_encode(
335
313
struct aws_h2_frame_priority * frame ,
336
314
struct aws_h2_frame_encoder * encoder ,
337
315
struct aws_byte_buf * output );
338
- AWS_HTTP_API
339
- int aws_h2_frame_priority_decode (struct aws_h2_frame_priority * frame , struct aws_h2_frame_decoder * decoder );
340
316
341
317
AWS_HTTP_API
342
318
int aws_h2_frame_rst_stream_init (struct aws_h2_frame_rst_stream * frame , struct aws_allocator * allocator );
@@ -347,24 +323,16 @@ int aws_h2_frame_rst_stream_encode(
347
323
struct aws_h2_frame_rst_stream * frame ,
348
324
struct aws_h2_frame_encoder * encoder ,
349
325
struct aws_byte_buf * output );
350
- AWS_HTTP_API
351
- int aws_h2_frame_rst_stream_decode (struct aws_h2_frame_rst_stream * frame , struct aws_h2_frame_decoder * decoder );
352
326
353
327
AWS_HTTP_API
354
328
int aws_h2_frame_settings_init (struct aws_h2_frame_settings * frame , struct aws_allocator * allocator );
355
329
AWS_HTTP_API
356
330
void aws_h2_frame_settings_clean_up (struct aws_h2_frame_settings * frame );
357
331
AWS_HTTP_API
358
- int aws_h2_frame_settings_set (struct aws_h2_frame_settings * frame , uint16_t identifier , uint32_t value );
359
- AWS_HTTP_API
360
- int aws_h2_frame_settings_remove (struct aws_h2_frame_settings * frame , uint16_t identifier );
361
- AWS_HTTP_API
362
332
int aws_h2_frame_settings_encode (
363
333
struct aws_h2_frame_settings * frame ,
364
334
struct aws_h2_frame_encoder * encoder ,
365
335
struct aws_byte_buf * output );
366
- AWS_HTTP_API
367
- int aws_h2_frame_settings_decode (struct aws_h2_frame_settings * frame , struct aws_h2_frame_decoder * decoder );
368
336
369
337
AWS_HTTP_API
370
338
int aws_h2_frame_push_promise_init (struct aws_h2_frame_push_promise * frame , struct aws_allocator * allocator );
@@ -375,8 +343,6 @@ int aws_h2_frame_push_promise_encode(
375
343
struct aws_h2_frame_push_promise * frame ,
376
344
struct aws_h2_frame_encoder * encoder ,
377
345
struct aws_byte_buf * output );
378
- AWS_HTTP_API
379
- int aws_h2_frame_push_promise_decode (struct aws_h2_frame_push_promise * frame , struct aws_h2_frame_decoder * decoder );
380
346
381
347
AWS_HTTP_API
382
348
int aws_h2_frame_ping_init (struct aws_h2_frame_ping * frame , struct aws_allocator * allocator );
@@ -387,8 +353,6 @@ int aws_h2_frame_ping_encode(
387
353
struct aws_h2_frame_ping * frame ,
388
354
struct aws_h2_frame_encoder * encoder ,
389
355
struct aws_byte_buf * output );
390
- AWS_HTTP_API
391
- int aws_h2_frame_ping_decode (struct aws_h2_frame_ping * frame , struct aws_h2_frame_decoder * decoder );
392
356
393
357
AWS_HTTP_API
394
358
int aws_h2_frame_goaway_init (struct aws_h2_frame_goaway * frame , struct aws_allocator * allocator );
@@ -399,8 +363,6 @@ int aws_h2_frame_goaway_encode(
399
363
struct aws_h2_frame_goaway * frame ,
400
364
struct aws_h2_frame_encoder * encoder ,
401
365
struct aws_byte_buf * output );
402
- AWS_HTTP_API
403
- int aws_h2_frame_goaway_decode (struct aws_h2_frame_goaway * frame , struct aws_h2_frame_decoder * decoder );
404
366
405
367
AWS_HTTP_API
406
368
int aws_h2_frame_window_update_init (struct aws_h2_frame_window_update * frame , struct aws_allocator * allocator );
@@ -411,8 +373,6 @@ int aws_h2_frame_window_update_encode(
411
373
struct aws_h2_frame_window_update * frame ,
412
374
struct aws_h2_frame_encoder * encoder ,
413
375
struct aws_byte_buf * output );
414
- AWS_HTTP_API
415
- int aws_h2_frame_window_update_decode (struct aws_h2_frame_window_update * frame , struct aws_h2_frame_decoder * decoder );
416
376
417
377
AWS_HTTP_API
418
378
int aws_h2_frame_continuation_init (struct aws_h2_frame_continuation * frame , struct aws_allocator * allocator );
@@ -423,8 +383,6 @@ int aws_h2_frame_continuation_encode(
423
383
struct aws_h2_frame_continuation * frame ,
424
384
struct aws_h2_frame_encoder * encoder ,
425
385
struct aws_byte_buf * output );
426
- AWS_HTTP_API
427
- int aws_h2_frame_continuation_decode (struct aws_h2_frame_continuation * frame , struct aws_h2_frame_decoder * decoder );
428
386
429
387
AWS_EXTERN_C_END
430
388
0 commit comments