lsquic_data_in_if.h revision c51ce338
1/* Copyright (c) 2017 LiteSpeed Technologies Inc.  See LICENSE. */
2/*
3 * lsquic_data_in_if.h -- DATA in interface
4 */
5
6#ifndef LSQUIC_DATA_IN_IF_H
7#define LSQUIC_DATA_IN_IF_H 1
8
9
10struct data_frame;
11struct data_in;
12struct lsquic_conn_public;
13struct stream_frame;
14
15
16enum ins_frame
17{
18    INS_FRAME_OK,
19    INS_FRAME_ERR,
20    INS_FRAME_DUP,
21};
22
23
24struct data_in_iface
25{
26    void
27    (*di_destroy) (struct data_in *);
28
29    int
30    (*di_empty) (struct data_in *);
31
32    /* The caller releases control of stream frame.  Do not reference it
33     * after the call.
34     */
35    enum ins_frame
36    (*di_insert_frame) (struct data_in *, struct stream_frame *,
37                                                        uint64_t read_offset);
38
39    struct data_frame *
40    (*di_get_frame) (struct data_in *, uint64_t read_offset);
41
42    void
43    (*di_frame_done) (struct data_in *, struct data_frame *);
44
45    /* Creates a new data_in object, feeds its stream frames to it, deletes
46     * itself and returns the new object.
47     */
48    struct data_in *
49    (*di_switch_impl) (struct data_in *, uint64_t read_offset);
50
51    size_t
52    (*di_mem_used) (struct data_in *);
53};
54
55
56struct data_in
57{
58    const struct data_in_iface  *di_if;
59    enum {
60        /* If DI_SWITCH_IMPL is set, switching data_in implementation is
61         * recommended in order to get better performance for current
62         * incoming stream frame scenario.  Check the value of this flag
63         * after calls to di_insert_frame() and di_frame_done().
64         */
65        DI_SWITCH_IMPL = (1 << 0),
66    }                            di_flags;
67};
68
69
70struct data_in *
71data_in_nocopy_new (struct lsquic_conn_public *, uint32_t stream_id);
72
73struct data_in *
74data_in_hash_new (struct lsquic_conn_public *, uint32_t stream_id,
75                  uint64_t byteage);
76
77enum ins_frame
78data_in_hash_insert_data_frame (struct data_in *data_in,
79                const struct data_frame *data_frame, uint64_t read_offset);
80
81struct data_in *
82data_in_error_new ();
83
84#endif
85