lsquic_frame_writer.h revision 19f667fb
1/* Copyright (c) 2017 - 2019 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
12#define MAX_HEADERS_SIZE (64 * 1024)
13
14struct iovec;
15struct lshpack_enc;
16struct lsquic_mm;
17struct lsquic_frame_writer;
18struct lsquic_stream;
19struct lsquic_http_headers;
20struct lsquic_http2_setting;
21#if LSQUIC_CONN_STATS
22struct conn_stats;
23#endif
24
25typedef ssize_t (*fw_write_f)(struct lsquic_stream *, const void *, size_t);
26
27struct lsquic_frame_writer *
28lsquic_frame_writer_new (struct lsquic_mm *, struct lsquic_stream *,
29                         unsigned max_frame_sz, struct lshpack_enc *,
30                         fw_write_f,
31#if LSQUIC_CONN_STATS
32                         struct conn_stats *,
33#endif
34                         int is_server);
35
36void
37lsquic_frame_writer_destroy (struct lsquic_frame_writer *);
38
39int
40lsquic_frame_writer_have_leftovers (const struct lsquic_frame_writer *);
41
42int
43lsquic_frame_writer_flush (struct lsquic_frame_writer *);
44
45int
46lsquic_frame_writer_write_headers (struct lsquic_frame_writer *,
47                                   uint32_t stream_id,
48                                   const struct lsquic_http_headers *,
49                                   int eos, unsigned weight);
50
51int
52lsquic_frame_writer_write_settings (struct lsquic_frame_writer *,
53    const struct lsquic_http2_setting *, unsigned n_settings);
54
55int
56lsquic_frame_writer_write_priority (struct lsquic_frame_writer *,
57            uint32_t stream_id, int exclusive, uint32_t stream_dep_id,
58            unsigned priority);
59
60int
61lsquic_frame_writer_write_promise (struct lsquic_frame_writer *,
62                       uint32_t stream_id, uint32_t promised_stream_id,
63                       const struct iovec *path, const struct iovec *host,
64                       const struct lsquic_http_headers *headers);
65
66void
67lsquic_frame_writer_max_header_list_size (struct lsquic_frame_writer *,
68                                          uint32_t max_size);
69
70size_t
71lsquic_frame_writer_mem_used (const struct lsquic_frame_writer *);
72
73#endif
74