lsquic_hcsi_reader.h revision 5392f7a3
1/* Copyright (c) 2017 - 2019 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_priority)(void *ctx, const struct hq_priority *); 15 void (*on_cancel_push)(void *ctx, uint64_t push_id); 16 void (*on_max_push_id)(void *ctx, uint64_t push_id); 17 /* Gets called at the *end* of the SETTING frame */ 18 void (*on_settings_frame)(void *ctx); 19 void (*on_setting)(void *ctx, uint64_t setting_id, uint64_t value); 20 void (*on_goaway)(void *ctx, uint64_t stream_id); 21 void (*on_unexpected_frame)(void *ctx, uint64_t frame_type); 22}; 23 24 25struct hcsi_reader 26{ 27 enum { 28 HR_READ_FRAME_BEGIN, 29 HR_READ_FRAME_CONTINUE, 30 HR_SKIPPING, 31 HR_READ_SETTING_BEGIN, 32 HR_READ_SETTING_CONTINUE, 33 HR_READ_PRIORITY_BEGIN, 34 HR_READ_PRIORITY_CONTINUE, 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 h3_prio_frame_read_state prio; 47 } hr_u; 48 const struct hcsi_callbacks *hr_cb; 49 void *hr_ctx; 50 unsigned hr_nread; /* Used for PRIORITY and SETTINGS frames */ 51}; 52 53 54void 55lsquic_hcsi_reader_init (struct hcsi_reader *, struct lsquic_conn *, 56 const struct hcsi_callbacks *, void *cb_ctx); 57 58int 59lsquic_hcsi_reader_feed (struct hcsi_reader *, const void *buf, size_t bufsz); 60 61#endif 62