1/* Copyright (c) 2017 - 2022 LiteSpeed Technologies Inc. See LICENSE. */ 2/* 3 * lsquic_qdec_hdl.h -- QPACK decoder streams handler 4 * 5 * The handler owns two unidirectional streams: a) peer-initiated QPACK 6 * encoder stream, from which it reads; and b) locally-initiated QPACK 7 * decoder stream, to which it writes. 8 */ 9 10#ifndef LSQUIC_QDEC_HDL_H 11#define LSQUIC_QDEC_HDL_H 1 12 13struct lsquic_conn; 14struct lsquic_stream; 15struct lsquic_stream_if; 16struct lsquic_engine_public; 17struct qpack_exp_record; 18 19 20struct qpack_dec_hdl 21{ 22 struct lsquic_conn *qdh_conn; 23 enum { 24 QDH_INITIALIZED = 1 << 0, 25 QDH_PUSH_PROMISE = 1 << 1, 26 QDH_SAVE_UA = 1 << 2, 27 QDH_SERVER = 1 << 3, 28 } qdh_flags; 29 struct lsqpack_dec qdh_decoder; 30 struct lsquic_stream *qdh_enc_sm_in; 31 struct frab_list qdh_fral; 32 struct lsquic_stream *qdh_dec_sm_out; 33 const struct lsquic_engine_public 34 *qdh_enpub; 35 struct http1x_ctor_ctx qdh_h1x_ctor_ctx; 36 void *qdh_hsi_ctx; 37 void (*qdh_on_dec_sent_func)(void *); 38 void *qdh_on_dec_sent_ctx; 39 struct qpack_exp_record *qdh_exp_rec; 40 char *qdh_ua; 41}; 42 43int 44lsquic_qdh_init (struct qpack_dec_hdl *, struct lsquic_conn *, 45 int is_server, const struct lsquic_engine_public *, 46 unsigned dyn_table_size, unsigned max_risked_streams); 47 48void 49lsquic_qdh_cleanup (struct qpack_dec_hdl *); 50 51#define lsquic_qdh_has_enc_stream(qdh) ((qdh)->qdh_enc_sm_in != NULL) 52 53enum header_in_status 54{ 55 HIS_DONE, 56 HIS_NEED, 57 HIS_BLOCKED, 58 HIS_ERROR, 59}; 60 61 62enum lsqpack_read_header_status 63lsquic_qdh_header_in_begin (struct qpack_dec_hdl *, struct lsquic_stream *, 64 uint64_t size, const unsigned char **, size_t); 65 66enum lsqpack_read_header_status 67lsquic_qdh_header_in_continue (struct qpack_dec_hdl *, struct lsquic_stream *, 68 const unsigned char **, size_t); 69 70void 71lsquic_qdh_cancel_stream (struct qpack_dec_hdl *, 72 struct lsquic_stream *); 73 74void 75lsquic_qdh_cancel_stream_id (struct qpack_dec_hdl *, lsquic_stream_id_t); 76 77int 78lsquic_qdh_arm_if_unsent (struct qpack_dec_hdl *, void (*)(void *), void *); 79 80const char * 81lsquic_qdh_get_ua (const struct qpack_dec_hdl *); 82 83extern const struct lsquic_stream_if *const lsquic_qdh_enc_sm_in_if; 84extern const struct lsquic_stream_if *const lsquic_qdh_dec_sm_out_if; 85 86#endif 87