lsquic_qenc_hdl.h revision 06b2a236
1/* Copyright (c) 2017 - 2021 LiteSpeed Technologies Inc. See LICENSE. */ 2/* 3 * lsquic_qenc_hdl.h -- QPACK encoder streams handler 4 * 5 * The handler owns two unidirectional streams: a) locally-initiated QPACK 6 * encoder stream, to which it writes; and b) peer-initiated QPACK decoder 7 * stream, from which it reads. 8 */ 9 10#ifndef LSQUIC_QENC_HDL_H 11#define LSQUIC_QENC_HDL_H 1 12 13struct lsquic_conn; 14struct lsquic_stream; 15struct lsquic_stream_if; 16struct qpack_exp_record; 17 18struct qpack_enc_hdl 19{ 20 struct lsquic_conn *qeh_conn; 21 enum { 22 QEH_INITIALIZED = 1 << 0, 23 QEH_HAVE_SETTINGS = 1 << 1, 24 } qeh_flags; 25 unsigned qeh_max_prefix_size; 26 struct lsqpack_enc qeh_encoder; 27 struct lsquic_stream *qeh_enc_sm_out; 28 struct frab_list qeh_fral; 29 struct lsquic_stream *qeh_dec_sm_in; 30 struct qpack_exp_record *qeh_exp_rec; 31 size_t qeh_tsu_sz; 32 unsigned char qeh_tsu_buf[LSQPACK_LONGEST_SDTC]; 33}; 34 35void 36lsquic_qeh_init (struct qpack_enc_hdl *, struct lsquic_conn *); 37 38int 39lsquic_qeh_settings (struct qpack_enc_hdl *, unsigned max_table_size, 40 unsigned dyn_table_size, unsigned max_risked_streams, int server); 41 42void 43lsquic_qeh_cleanup (struct qpack_enc_hdl *); 44 45#define lsquic_qeh_has_dec_stream(qeh) ((qeh)->qeh_dec_sm_in != NULL) 46 47enum qwh_status { 48 QWH_FULL, /* All bytes written to encoder stream. This is also returned 49 * if there were no bytes to write. 50 */ 51 QWH_PARTIAL,/* Not all bytes are written to the encoder stream. In this 52 * case, `completion_offset' is set to the value of the 53 * encoder stream offset when the necessary bytes will have 54 * been written. 55 */ 56 QWH_ENOBUF, /* Not enough room in `buf' to write the full header block */ 57 QWH_ERR, /* Some other error */ 58}; 59 60enum qwh_status 61lsquic_qeh_write_headers (struct qpack_enc_hdl *, lsquic_stream_id_t stream_id, 62 unsigned seqno, const struct lsquic_http_headers *, unsigned char *buf, 63 size_t *prefix_sz, size_t *headers_sz, uint64_t *completion_offset, 64 enum lsqpack_enc_header_flags *hflags); 65 66uint64_t 67lsquic_qeh_enc_off (struct qpack_enc_hdl *); 68 69size_t 70lsquic_qeh_write_avail (struct qpack_enc_hdl *); 71 72size_t 73lsquic_qeh_max_prefix_size (const struct qpack_enc_hdl *); 74 75extern const struct lsquic_stream_if *const lsquic_qeh_enc_sm_out_if; 76extern const struct lsquic_stream_if *const lsquic_qeh_dec_sm_in_if; 77 78#endif 79