1/* Copyright (c) 2017 - 2022 LiteSpeed Technologies Inc.  See LICENSE. */
2/*
3 * lsquic_frame_writer.h -- write frames to HEADERS stream.
4 */
5
6#ifndef LSQUIC_FRAME_WRITER_H
7#define LSQUIC_FRAME_WRITER_H 1
8
9#include <stddef.h>
10#include <stdint.h>
11
12struct iovec;
13struct lshpack_enc;
14struct lsquic_mm;
15struct lsquic_frame_writer;
16struct lsquic_stream;
17struct lsquic_reader;
18struct lsquic_http_headers;
19struct lsquic_http2_setting;
20#if LSQUIC_CONN_STATS
21struct conn_stats;
22#endif
23
24typedef ssize_t (*fw_writef_f)(struct lsquic_stream *, struct lsquic_reader *);
25
26struct lsquic_frame_writer *
27lsquic_frame_writer_new (struct lsquic_mm *, struct lsquic_stream *,
28                         unsigned max_frame_sz, struct lshpack_enc *,
29                         fw_writef_f,
30#if LSQUIC_CONN_STATS
31                         struct conn_stats *,
32#endif
33                         int is_server);
34
35void
36lsquic_frame_writer_destroy (struct lsquic_frame_writer *);
37
38int
39lsquic_frame_writer_have_leftovers (const struct lsquic_frame_writer *);
40
41int
42lsquic_frame_writer_flush (struct lsquic_frame_writer *);
43
44int
45lsquic_frame_writer_write_headers (struct lsquic_frame_writer *,
46                                   lsquic_stream_id_t stream_id,
47                                   const struct lsquic_http_headers *,
48                                   int eos, unsigned weight);
49
50int
51lsquic_frame_writer_write_settings (struct lsquic_frame_writer *,
52    const struct lsquic_http2_setting *, unsigned n_settings);
53
54int
55lsquic_frame_writer_write_priority (struct lsquic_frame_writer *,
56                lsquic_stream_id_t stream_id, int exclusive,
57                lsquic_stream_id_t stream_dep_id, unsigned priority);
58
59int
60lsquic_frame_writer_write_promise (struct lsquic_frame_writer *,
61        lsquic_stream_id_t stream_id, lsquic_stream_id_t promised_stream_id,
62        const struct lsquic_http_headers *headers);
63
64void
65lsquic_frame_writer_max_header_list_size (struct lsquic_frame_writer *,
66                                          uint32_t max_size);
67
68size_t
69lsquic_frame_writer_mem_used (const struct lsquic_frame_writer *);
70
71#endif
72