lsquic_data_in_if.h revision 50aadb33
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
52
53struct data_in
54{
55    const struct data_in_iface  *di_if;
56    enum {
57        /* If DI_SWITCH_IMPL is set, switching data_in implementation is
58         * recommended in order to get better performance for current
59         * incoming stream frame scenario.  Check the value of this flag
60         * after calls to di_insert_frame() and di_frame_done().
61         */
62        DI_SWITCH_IMPL = (1 << 0),
63    }                            di_flags;
64};
65
66
67struct data_in *
68data_in_nocopy_new (struct lsquic_conn_public *, uint32_t stream_id);
69
70struct data_in *
71data_in_hash_new (struct lsquic_conn_public *, uint32_t stream_id,
72                  uint64_t byteage);
73
74enum ins_frame
75data_in_hash_insert_data_frame (struct data_in *data_in,
76                const struct data_frame *data_frame, uint64_t read_offset);
77
78struct data_in *
79data_in_error_new ();
80
81#endif
82