lsquic_qdec_hdl.h revision 5392f7a3
1/* Copyright (c) 2017 - 2019 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;
17
18
19struct qpack_dec_hdl
20{
21    struct lsquic_conn      *qdh_conn;
22    enum {
23        QDH_INITIALIZED     = 1 << 0,
24    }                        qdh_flags;
25    struct lsqpack_dec       qdh_decoder;
26    struct lsquic_stream    *qdh_enc_sm_in;
27    struct frab_list         qdh_fral;
28    struct lsquic_stream    *qdh_dec_sm_out;
29    const struct lsquic_engine_public
30                            *qdh_enpub;
31    struct http1x_ctor_ctx   qdh_h1x_ctor_ctx;
32    void                    *qdh_hsi_ctx;
33};
34
35int
36lsquic_qdh_init (struct qpack_dec_hdl *, struct lsquic_conn *,
37                    int is_server, const struct lsquic_engine_public *,
38                    unsigned dyn_table_size, unsigned max_risked_streams);
39
40void
41lsquic_qdh_cleanup (struct qpack_dec_hdl *);
42
43#define lsquic_qdh_has_enc_stream(qdh) ((qdh)->qdh_enc_sm_in != NULL)
44
45enum header_in_status
46{
47    HIS_DONE,
48    HIS_NEED,
49    HIS_BLOCKED,
50    HIS_ERROR,
51};
52
53
54enum lsqpack_read_header_status
55lsquic_qdh_header_in_begin (struct qpack_dec_hdl *, struct lsquic_stream *,
56                            uint64_t size, const unsigned char **, size_t);
57
58enum lsqpack_read_header_status
59lsquic_qdh_header_in_continue (struct qpack_dec_hdl *, struct lsquic_stream *,
60                                const unsigned char **, size_t);
61
62void
63lsquic_qdh_unref_stream (struct qpack_dec_hdl *, struct lsquic_stream *);
64
65void
66lsquic_qdh_cancel_stream (struct qpack_dec_hdl *,
67                                                struct lsquic_stream *);
68
69extern const struct lsquic_stream_if *const lsquic_qdh_enc_sm_in_if;
70extern const struct lsquic_stream_if *const lsquic_qdh_dec_sm_out_if;
71
72#endif
73