lsquic_di_error.c revision 50aadb33
1/* Copyright (c) 2017 LiteSpeed Technologies Inc.  See LICENSE. */
2/*
3 * lsquic_di_error.c -- A placeholder when things go wrong
4 *
5 * This object is used in order to avoid dereferencing NULLs in stream.c
6 */
7
8
9#include <assert.h>
10#include <stddef.h>
11#include <stdint.h>
12
13#include "lsquic_data_in_if.h"
14
15
16static const struct data_in_iface di_if_error;
17
18
19static const struct data_in error_data_in = {
20    .di_if    = &di_if_error,
21    .di_flags = 0,
22};
23
24
25struct data_in *
26data_in_error_new (struct lsquic_conn_public *conn_pub)
27{
28    return (struct data_in *) &error_data_in;
29}
30
31
32static void
33error_di_destroy (struct data_in *data_in)
34{
35}
36
37
38static enum ins_frame
39error_di_insert_frame (struct data_in *data_in,
40                        struct stream_frame *new_frame, uint64_t read_offset)
41{
42    return INS_FRAME_ERR;
43}
44
45
46static struct data_frame *
47error_di_get_frame (struct data_in *data_in, uint64_t read_offset)
48{
49    return NULL;
50}
51
52
53static void
54error_di_frame_done (struct data_in *data_in, struct data_frame *data_frame)
55{
56}
57
58
59static int
60error_di_empty (struct data_in *data_in)
61{
62    return 1;
63}
64
65
66struct data_in *
67error_di_switch_impl (struct data_in *data_in, uint64_t read_offset)
68{
69    assert(0);
70    return data_in;
71}
72
73
74static const struct data_in_iface di_if_error = {
75    .di_destroy      = error_di_destroy,
76    .di_empty        = error_di_empty,
77    .di_frame_done   = error_di_frame_done,
78    .di_get_frame    = error_di_get_frame,
79    .di_insert_frame = error_di_insert_frame,
80    .di_switch_impl  = error_di_switch_impl,
81};
82