lsquic_di_error.c revision c51ce338
150aadb33SDmitri Tikhonov/* Copyright (c) 2017 LiteSpeed Technologies Inc.  See LICENSE. */
250aadb33SDmitri Tikhonov/*
350aadb33SDmitri Tikhonov * lsquic_di_error.c -- A placeholder when things go wrong
450aadb33SDmitri Tikhonov *
550aadb33SDmitri Tikhonov * This object is used in order to avoid dereferencing NULLs in stream.c
650aadb33SDmitri Tikhonov */
750aadb33SDmitri Tikhonov
850aadb33SDmitri Tikhonov
950aadb33SDmitri Tikhonov#include <assert.h>
1050aadb33SDmitri Tikhonov#include <stddef.h>
1150aadb33SDmitri Tikhonov#include <stdint.h>
1250aadb33SDmitri Tikhonov
1350aadb33SDmitri Tikhonov#include "lsquic_data_in_if.h"
1450aadb33SDmitri Tikhonov
1550aadb33SDmitri Tikhonov
1650aadb33SDmitri Tikhonovstatic const struct data_in_iface di_if_error;
1750aadb33SDmitri Tikhonov
1850aadb33SDmitri Tikhonov
1950aadb33SDmitri Tikhonovstatic const struct data_in error_data_in = {
2050aadb33SDmitri Tikhonov    .di_if    = &di_if_error,
2150aadb33SDmitri Tikhonov    .di_flags = 0,
2250aadb33SDmitri Tikhonov};
2350aadb33SDmitri Tikhonov
2450aadb33SDmitri Tikhonov
2550aadb33SDmitri Tikhonovstruct data_in *
2650aadb33SDmitri Tikhonovdata_in_error_new (struct lsquic_conn_public *conn_pub)
2750aadb33SDmitri Tikhonov{
2850aadb33SDmitri Tikhonov    return (struct data_in *) &error_data_in;
2950aadb33SDmitri Tikhonov}
3050aadb33SDmitri Tikhonov
3150aadb33SDmitri Tikhonov
3250aadb33SDmitri Tikhonovstatic void
3350aadb33SDmitri Tikhonoverror_di_destroy (struct data_in *data_in)
3450aadb33SDmitri Tikhonov{
3550aadb33SDmitri Tikhonov}
3650aadb33SDmitri Tikhonov
3750aadb33SDmitri Tikhonov
3850aadb33SDmitri Tikhonovstatic enum ins_frame
3950aadb33SDmitri Tikhonoverror_di_insert_frame (struct data_in *data_in,
4050aadb33SDmitri Tikhonov                        struct stream_frame *new_frame, uint64_t read_offset)
4150aadb33SDmitri Tikhonov{
4250aadb33SDmitri Tikhonov    return INS_FRAME_ERR;
4350aadb33SDmitri Tikhonov}
4450aadb33SDmitri Tikhonov
4550aadb33SDmitri Tikhonov
4650aadb33SDmitri Tikhonovstatic struct data_frame *
4750aadb33SDmitri Tikhonoverror_di_get_frame (struct data_in *data_in, uint64_t read_offset)
4850aadb33SDmitri Tikhonov{
4950aadb33SDmitri Tikhonov    return NULL;
5050aadb33SDmitri Tikhonov}
5150aadb33SDmitri Tikhonov
5250aadb33SDmitri Tikhonov
5350aadb33SDmitri Tikhonovstatic void
5450aadb33SDmitri Tikhonoverror_di_frame_done (struct data_in *data_in, struct data_frame *data_frame)
5550aadb33SDmitri Tikhonov{
5650aadb33SDmitri Tikhonov}
5750aadb33SDmitri Tikhonov
5850aadb33SDmitri Tikhonov
5950aadb33SDmitri Tikhonovstatic int
6050aadb33SDmitri Tikhonoverror_di_empty (struct data_in *data_in)
6150aadb33SDmitri Tikhonov{
6250aadb33SDmitri Tikhonov    return 1;
6350aadb33SDmitri Tikhonov}
6450aadb33SDmitri Tikhonov
6550aadb33SDmitri Tikhonov
6650aadb33SDmitri Tikhonovstruct data_in *
6750aadb33SDmitri Tikhonoverror_di_switch_impl (struct data_in *data_in, uint64_t read_offset)
6850aadb33SDmitri Tikhonov{
6950aadb33SDmitri Tikhonov    assert(0);
7050aadb33SDmitri Tikhonov    return data_in;
7150aadb33SDmitri Tikhonov}
7250aadb33SDmitri Tikhonov
7350aadb33SDmitri Tikhonov
74c51ce338SDmitri Tikhonovstatic size_t
75c51ce338SDmitri Tikhonoverror_di_mem_used (struct data_in *data_in)
76c51ce338SDmitri Tikhonov{
77c51ce338SDmitri Tikhonov    return 0;
78c51ce338SDmitri Tikhonov}
79c51ce338SDmitri Tikhonov
80c51ce338SDmitri Tikhonov
8150aadb33SDmitri Tikhonovstatic const struct data_in_iface di_if_error = {
8250aadb33SDmitri Tikhonov    .di_destroy      = error_di_destroy,
8350aadb33SDmitri Tikhonov    .di_empty        = error_di_empty,
8450aadb33SDmitri Tikhonov    .di_frame_done   = error_di_frame_done,
8550aadb33SDmitri Tikhonov    .di_get_frame    = error_di_get_frame,
8650aadb33SDmitri Tikhonov    .di_insert_frame = error_di_insert_frame,
87c51ce338SDmitri Tikhonov    .di_mem_used     = error_di_mem_used,
8850aadb33SDmitri Tikhonov    .di_switch_impl  = error_di_switch_impl,
8950aadb33SDmitri Tikhonov};
90