lsquic_qenc_hdl.h revision 5392f7a3
15392f7a3SLiteSpeed Tech/* Copyright (c) 2017 - 2019 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; 165392f7a3SLiteSpeed Tech 175392f7a3SLiteSpeed Techstruct qpack_enc_hdl 185392f7a3SLiteSpeed Tech{ 195392f7a3SLiteSpeed Tech struct lsquic_conn *qeh_conn; 205392f7a3SLiteSpeed Tech enum { 215392f7a3SLiteSpeed Tech QEH_INITIALIZED = 1 << 0, 225392f7a3SLiteSpeed Tech QEH_HAVE_SETTINGS = 1 << 1, 235392f7a3SLiteSpeed Tech } qeh_flags; 245392f7a3SLiteSpeed Tech unsigned qeh_max_prefix_size; 255392f7a3SLiteSpeed Tech struct lsqpack_enc qeh_encoder; 265392f7a3SLiteSpeed Tech struct lsquic_stream *qeh_enc_sm_out; 275392f7a3SLiteSpeed Tech struct frab_list qeh_fral; 285392f7a3SLiteSpeed Tech struct lsquic_stream *qeh_dec_sm_in; 295392f7a3SLiteSpeed Tech size_t qeh_tsu_sz; 305392f7a3SLiteSpeed Tech unsigned char qeh_tsu_buf[LSQPACK_LONGEST_SDTC]; 315392f7a3SLiteSpeed Tech}; 325392f7a3SLiteSpeed Tech 335392f7a3SLiteSpeed Techvoid 345392f7a3SLiteSpeed Techlsquic_qeh_init (struct qpack_enc_hdl *, struct lsquic_conn *); 355392f7a3SLiteSpeed Tech 365392f7a3SLiteSpeed Techint 375392f7a3SLiteSpeed Techlsquic_qeh_settings (struct qpack_enc_hdl *, unsigned max_table_size, 385392f7a3SLiteSpeed Tech unsigned dyn_table_size, unsigned max_risked_streams, int server); 395392f7a3SLiteSpeed Tech 405392f7a3SLiteSpeed Techvoid 415392f7a3SLiteSpeed Techlsquic_qeh_cleanup (struct qpack_enc_hdl *); 425392f7a3SLiteSpeed Tech 435392f7a3SLiteSpeed Tech#define lsquic_qeh_has_dec_stream(qeh) ((qeh)->qeh_dec_sm_in != NULL) 445392f7a3SLiteSpeed Tech 455392f7a3SLiteSpeed Techenum qwh_status { 465392f7a3SLiteSpeed Tech QWH_FULL, /* All bytes written to encoder stream. This is also returned 475392f7a3SLiteSpeed Tech * if there were no bytes to write. 485392f7a3SLiteSpeed Tech */ 495392f7a3SLiteSpeed Tech QWH_PARTIAL,/* Not all bytes are written to the encoder stream. In this 505392f7a3SLiteSpeed Tech * case, `completion_offset' is set to the value of the 515392f7a3SLiteSpeed Tech * encoder stream offset when the necessary bytes will have 525392f7a3SLiteSpeed Tech * been written. 535392f7a3SLiteSpeed Tech */ 545392f7a3SLiteSpeed Tech QWH_ENOBUF, /* Not enough room in `buf' to write the full header block */ 555392f7a3SLiteSpeed Tech QWH_ERR, /* Some other error */ 565392f7a3SLiteSpeed Tech}; 575392f7a3SLiteSpeed Tech 585392f7a3SLiteSpeed Techenum qwh_status 595392f7a3SLiteSpeed Techlsquic_qeh_write_headers (struct qpack_enc_hdl *, lsquic_stream_id_t stream_id, 605392f7a3SLiteSpeed Tech unsigned seqno, const struct lsquic_http_headers *, unsigned char *buf, 615392f7a3SLiteSpeed Tech size_t *prefix_sz, size_t *headers_sz, uint64_t *completion_offset); 625392f7a3SLiteSpeed Tech 635392f7a3SLiteSpeed Techuint64_t 645392f7a3SLiteSpeed Techlsquic_qeh_enc_off (struct qpack_enc_hdl *); 655392f7a3SLiteSpeed Tech 665392f7a3SLiteSpeed Techsize_t 675392f7a3SLiteSpeed Techlsquic_qeh_write_avail (struct qpack_enc_hdl *); 685392f7a3SLiteSpeed Tech 695392f7a3SLiteSpeed Techsize_t 705392f7a3SLiteSpeed Techlsquic_qeh_max_prefix_size (const struct qpack_enc_hdl *); 715392f7a3SLiteSpeed Tech 725392f7a3SLiteSpeed Techextern const struct lsquic_stream_if *const lsquic_qeh_enc_sm_out_if; 735392f7a3SLiteSpeed Techextern const struct lsquic_stream_if *const lsquic_qeh_dec_sm_in_if; 745392f7a3SLiteSpeed Tech 755392f7a3SLiteSpeed Tech#endif 76