1/* Copyright (c) 2017 - 2022 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_frame_error)(void *ctx, unsigned code, 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:8; 39 enum { 40 HR_FLAG_RCVD_SETTING = 1, 41 } hr_flag:8; 42 unsigned hr_nread; /* Used for PRIORITY_UPDATE and SETTINGS frames */ 43 struct lsquic_conn *hr_conn; 44 uint64_t hr_frame_type; 45 uint64_t hr_frame_length; 46 union 47 { 48 struct varint_read_state vint_state; 49 struct varint_read2_state vint2_state; 50 struct { 51 /* We just need the offset to rest of prio_state to read Priority 52 * Field Value. 53 */ 54 struct varint_read_state UNUSED; 55 char buf[ 56 sizeof(struct varint_read2_state) 57 - sizeof(struct varint_read_state)]; 58 } prio_state; 59 } hr_u; 60 const struct hcsi_callbacks *hr_cb; 61 void *hr_ctx; 62}; 63 64 65void 66lsquic_hcsi_reader_init (struct hcsi_reader *, struct lsquic_conn *, 67 const struct hcsi_callbacks *, void *cb_ctx); 68 69int 70lsquic_hcsi_reader_feed (struct hcsi_reader *, const void *buf, size_t bufsz); 71 72#endif 73