1a74702c6SGeorge Wang/* Copyright (c) 2017 - 2022 LiteSpeed Technologies Inc. See LICENSE. */ 25392f7a3SLiteSpeed Tech/* 35392f7a3SLiteSpeed Tech * lsquic_qenc_hdl.h -- QPACK encoder streams handler 45392f7a3SLiteSpeed Tech * 55392f7a3SLiteSpeed Tech * The handler owns two unidirectional streams: a) locally-initiated QPACK 65392f7a3SLiteSpeed Tech * encoder stream, to which it writes; and b) peer-initiated QPACK decoder 75392f7a3SLiteSpeed Tech * stream, from which it reads. 85392f7a3SLiteSpeed Tech */ 95392f7a3SLiteSpeed Tech 105392f7a3SLiteSpeed Tech#ifndef LSQUIC_QENC_HDL_H 115392f7a3SLiteSpeed Tech#define LSQUIC_QENC_HDL_H 1 125392f7a3SLiteSpeed Tech 135392f7a3SLiteSpeed Techstruct lsquic_conn; 145392f7a3SLiteSpeed Techstruct lsquic_stream; 155392f7a3SLiteSpeed Techstruct lsquic_stream_if; 16758aff32SDmitri Tikhonovstruct qpack_exp_record; 175392f7a3SLiteSpeed Tech 185392f7a3SLiteSpeed Techstruct qpack_enc_hdl 195392f7a3SLiteSpeed Tech{ 205392f7a3SLiteSpeed Tech struct lsquic_conn *qeh_conn; 215392f7a3SLiteSpeed Tech enum { 225392f7a3SLiteSpeed Tech QEH_INITIALIZED = 1 << 0, 235392f7a3SLiteSpeed Tech QEH_HAVE_SETTINGS = 1 << 1, 245392f7a3SLiteSpeed Tech } qeh_flags; 255392f7a3SLiteSpeed Tech unsigned qeh_max_prefix_size; 265392f7a3SLiteSpeed Tech struct lsqpack_enc qeh_encoder; 275392f7a3SLiteSpeed Tech struct lsquic_stream *qeh_enc_sm_out; 285392f7a3SLiteSpeed Tech struct frab_list qeh_fral; 295392f7a3SLiteSpeed Tech struct lsquic_stream *qeh_dec_sm_in; 30758aff32SDmitri Tikhonov struct qpack_exp_record *qeh_exp_rec; 315392f7a3SLiteSpeed Tech size_t qeh_tsu_sz; 325392f7a3SLiteSpeed Tech unsigned char qeh_tsu_buf[LSQPACK_LONGEST_SDTC]; 335392f7a3SLiteSpeed Tech}; 345392f7a3SLiteSpeed Tech 355392f7a3SLiteSpeed Techvoid 365392f7a3SLiteSpeed Techlsquic_qeh_init (struct qpack_enc_hdl *, struct lsquic_conn *); 375392f7a3SLiteSpeed Tech 385392f7a3SLiteSpeed Techint 395392f7a3SLiteSpeed Techlsquic_qeh_settings (struct qpack_enc_hdl *, unsigned max_table_size, 405392f7a3SLiteSpeed Tech unsigned dyn_table_size, unsigned max_risked_streams, int server); 415392f7a3SLiteSpeed Tech 425392f7a3SLiteSpeed Techvoid 435392f7a3SLiteSpeed Techlsquic_qeh_cleanup (struct qpack_enc_hdl *); 445392f7a3SLiteSpeed Tech 455392f7a3SLiteSpeed Tech#define lsquic_qeh_has_dec_stream(qeh) ((qeh)->qeh_dec_sm_in != NULL) 465392f7a3SLiteSpeed Tech 475392f7a3SLiteSpeed Techenum qwh_status { 485392f7a3SLiteSpeed Tech QWH_FULL, /* All bytes written to encoder stream. This is also returned 495392f7a3SLiteSpeed Tech * if there were no bytes to write. 505392f7a3SLiteSpeed Tech */ 515392f7a3SLiteSpeed Tech QWH_PARTIAL,/* Not all bytes are written to the encoder stream. In this 525392f7a3SLiteSpeed Tech * case, `completion_offset' is set to the value of the 535392f7a3SLiteSpeed Tech * encoder stream offset when the necessary bytes will have 545392f7a3SLiteSpeed Tech * been written. 555392f7a3SLiteSpeed Tech */ 565392f7a3SLiteSpeed Tech QWH_ENOBUF, /* Not enough room in `buf' to write the full header block */ 575392f7a3SLiteSpeed Tech QWH_ERR, /* Some other error */ 585392f7a3SLiteSpeed Tech}; 595392f7a3SLiteSpeed Tech 605392f7a3SLiteSpeed Techenum qwh_status 615392f7a3SLiteSpeed Techlsquic_qeh_write_headers (struct qpack_enc_hdl *, lsquic_stream_id_t stream_id, 625392f7a3SLiteSpeed Tech unsigned seqno, const struct lsquic_http_headers *, unsigned char *buf, 634947ba95SDmitri Tikhonov size_t *prefix_sz, size_t *headers_sz, uint64_t *completion_offset, 644947ba95SDmitri Tikhonov enum lsqpack_enc_header_flags *hflags); 655392f7a3SLiteSpeed Tech 665392f7a3SLiteSpeed Techuint64_t 675392f7a3SLiteSpeed Techlsquic_qeh_enc_off (struct qpack_enc_hdl *); 685392f7a3SLiteSpeed Tech 695392f7a3SLiteSpeed Techsize_t 705392f7a3SLiteSpeed Techlsquic_qeh_write_avail (struct qpack_enc_hdl *); 715392f7a3SLiteSpeed Tech 725392f7a3SLiteSpeed Techsize_t 735392f7a3SLiteSpeed Techlsquic_qeh_max_prefix_size (const struct qpack_enc_hdl *); 745392f7a3SLiteSpeed Tech 755392f7a3SLiteSpeed Techextern const struct lsquic_stream_if *const lsquic_qeh_enc_sm_out_if; 765392f7a3SLiteSpeed Techextern const struct lsquic_stream_if *const lsquic_qeh_dec_sm_in_if; 775392f7a3SLiteSpeed Tech 785392f7a3SLiteSpeed Tech#endif 79