lsquic_hcsi_reader.h revision 92f6e17b
1/* Copyright (c) 2017 - 2019 LiteSpeed Technologies Inc.  See LICENSE. */
2/*
3 * lsquic_hcsi_reader.h -- HTTP Control Stream Incoming (HCSI) reader
4 */
5
6#ifndef LSQUIC_HCSI_READER_H
7#define LSQUIC_HCSI_READER_H 1
8
9struct lsquic_conn;
10
11
12struct hcsi_callbacks
13{
14    void    (*on_cancel_push)(void *ctx, uint64_t push_id);
15    void    (*on_max_push_id)(void *ctx, uint64_t push_id);
16    /* Gets called at the *end* of the SETTING frame */
17    void    (*on_settings_frame)(void *ctx);
18    void    (*on_setting)(void *ctx, uint64_t setting_id, uint64_t value);
19    void    (*on_goaway)(void *ctx, uint64_t stream_id);
20    void    (*on_unexpected_frame)(void *ctx, uint64_t frame_type);
21};
22
23
24struct hcsi_reader
25{
26    enum {
27        HR_READ_FRAME_BEGIN,
28        HR_READ_FRAME_CONTINUE,
29        HR_SKIPPING,
30        HR_READ_SETTING_BEGIN,
31        HR_READ_SETTING_CONTINUE,
32        HR_READ_VARINT,
33        HR_READ_VARINT_CONTINUE,
34        HR_ERROR,
35    }                               hr_state;
36    struct lsquic_conn             *hr_conn;
37    uint64_t                        hr_frame_type;
38    uint64_t                        hr_frame_length;
39    union
40    {
41        struct varint_read_state            vint_state;
42        struct varint_read2_state           vint2_state;
43    }                               hr_u;
44    const struct hcsi_callbacks    *hr_cb;
45    void                           *hr_ctx;
46    unsigned                        hr_nread;  /* Used for PRIORITY and SETTINGS frames */
47};
48
49
50void
51lsquic_hcsi_reader_init (struct hcsi_reader *, struct lsquic_conn *,
52                                const struct hcsi_callbacks *, void *cb_ctx);
53
54int
55lsquic_hcsi_reader_feed (struct hcsi_reader *, const void *buf, size_t bufsz);
56
57#endif
58