lsquic_headers_stream.h revision 55613f44
1/* Copyright (c) 2017 - 2020 LiteSpeed Technologies Inc.  See LICENSE. */
2/*
3 * lsquic_headers_stream.h -- HEADERS stream interface
4 */
5
6#ifndef LSQUIC_HEADERS_STREAM_H
7#define LSQUIC_HEADERS_STREAM_H 1
8
9#include <stdint.h>
10
11struct iovec;
12struct lsquic_stream_if;
13struct lsquic_stream;
14struct lsquic_mm;
15struct lsquic_http_headers;
16struct lsquic_frame_reader;
17struct lsquic_frame_writer;
18struct uncompressed_headers;
19struct lsquic_engine_public;
20struct lsquic_http2_setting;
21#if LSQUIC_CONN_STATS
22struct conn_stats;
23#endif
24
25
26/* Incoming frames result in new objects or events.  Callbacks in this
27 * struct are used to dispatch them.
28 */
29struct headers_stream_callbacks
30{
31    void (*hsc_on_headers)
32                    (void *frame_cb_ctx, struct uncompressed_headers *);
33    void (*hsc_on_enable_push)  (void *hs_cb_ctx, int enable_push);
34    void (*hsc_on_push_promise)
35                    (void *frame_cb_ctx, struct uncompressed_headers *);
36    void (*hsc_on_priority)     (void *hs_cb_ctx, lsquic_stream_id_t stream_id,
37            int exclusive, lsquic_stream_id_t dep_stream_id, unsigned weight);
38    void (*hsc_on_stream_error) (void *hs_cb_ctx, lsquic_stream_id_t stream_id);
39    void (*hsc_on_conn_error)   (void *hs_cb_ctx);
40};
41
42
43struct headers_stream *
44lsquic_headers_stream_new (int is_server, struct lsquic_engine_public *,
45                           const struct headers_stream_callbacks *,
46#if LSQUIC_CONN_STATS
47                           struct conn_stats *,
48#endif
49                           void *hs_cb_ctx);
50
51void
52lsquic_headers_stream_destroy (struct headers_stream *);
53
54int
55lsquic_headers_stream_send_headers (struct headers_stream *hs,
56                                lsquic_stream_id_t stream_id,
57                                const struct lsquic_http_headers *, int eos,
58                                unsigned weight);
59
60int
61lsquic_headers_stream_push_promise (struct headers_stream *hs,
62            lsquic_stream_id_t stream_id, lsquic_stream_id_t promised_stream_id,
63                        const struct lsquic_http_headers *);
64
65int
66lsquic_headers_stream_send_priority (struct headers_stream *hs,
67    lsquic_stream_id_t stream_id, int exclusive,
68    lsquic_stream_id_t dep_stream_id, unsigned weight);
69
70int
71lsquic_headers_stream_send_settings (struct headers_stream *hs,
72                        const struct lsquic_http2_setting *, unsigned count);
73
74struct lsquic_stream *
75lsquic_headers_stream_get_stream (const struct headers_stream *);
76
77size_t
78lsquic_headers_stream_mem_used (const struct headers_stream *);
79
80extern const struct lsquic_stream_if *const lsquic_headers_stream_if;
81
82#endif
83