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