lsquic_hcsi_reader.h revision 06b2a236
1/* Copyright (c) 2017 - 2021 LiteSpeed Technologies Inc. See LICENSE. */ 2/* 3 * lsquic_hcsi_reader.h -- HTTP Control Stream Incoming (HCSI) reader 4 */ 5 6#ifndef LSQUIC_HCSI_READER_H 7#define LSQUIC_HCSI_READER_H 1 8 9struct lsquic_conn; 10 11 12struct hcsi_callbacks 13{ 14 void (*on_cancel_push)(void *ctx, uint64_t push_id); 15 void (*on_max_push_id)(void *ctx, uint64_t push_id); 16 /* Gets called at the *end* of the SETTING frame */ 17 void (*on_settings_frame)(void *ctx); 18 void (*on_setting)(void *ctx, uint64_t setting_id, uint64_t value); 19 void (*on_goaway)(void *ctx, uint64_t stream_id); 20 void (*on_unexpected_frame)(void *ctx, uint64_t frame_type); 21 void (*on_priority_update)(void *ctx, enum hq_frame_type, uint64_t id, 22 const char *, size_t); 23}; 24 25 26struct hcsi_reader 27{ 28 enum { 29 HR_READ_FRAME_BEGIN, 30 HR_READ_FRAME_CONTINUE, 31 HR_SKIPPING, 32 HR_READ_SETTING_BEGIN, 33 HR_READ_SETTING_CONTINUE, 34 HR_READ_PRIORITY_UPDATE, 35 HR_READ_VARINT, 36 HR_READ_VARINT_CONTINUE, 37 HR_ERROR, 38 } hr_state; 39 struct lsquic_conn *hr_conn; 40 uint64_t hr_frame_type; 41 uint64_t hr_frame_length; 42 union 43 { 44 struct varint_read_state vint_state; 45 struct varint_read2_state vint2_state; 46 struct { 47 /* We just need the offset to rest of prio_state to read Priority 48 * Field Value. 49 */ 50 struct varint_read_state UNUSED; 51 char buf[ 52 sizeof(struct varint_read2_state) 53 - sizeof(struct varint_read_state)]; 54 } prio_state; 55 } hr_u; 56 const struct hcsi_callbacks *hr_cb; 57 void *hr_ctx; 58 unsigned hr_nread; /* Used for PRIORITY_UPDATE and SETTINGS frames */ 59}; 60 61 62void 63lsquic_hcsi_reader_init (struct hcsi_reader *, struct lsquic_conn *, 64 const struct hcsi_callbacks *, void *cb_ctx); 65 66int 67lsquic_hcsi_reader_feed (struct hcsi_reader *, const void *buf, size_t bufsz); 68 69#endif 70