lsquic_di_error.c revision a5fa05f9
17d09751dSDmitri Tikhonov/* Copyright (c) 2017 - 2020 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> 12461e84d8SAmol Deshpande#ifdef WIN32 13461e84d8SAmol Deshpande#include <vc_compat.h> 14461e84d8SAmol Deshpande#endif 1550aadb33SDmitri Tikhonov 165392f7a3SLiteSpeed Tech#include "lsquic_types.h" 1750aadb33SDmitri Tikhonov#include "lsquic_data_in_if.h" 1850aadb33SDmitri Tikhonov 1950aadb33SDmitri Tikhonov 20b93f59beSBob Perperstatic const struct data_in *error_data_in_ptr; 2150aadb33SDmitri Tikhonov 2250aadb33SDmitri Tikhonov 23b93f59beSBob Perperstruct data_in * 24a5fa05f9SDmitri Tikhonovlsquic_data_in_error_new (struct lsquic_conn_public *conn_pub) 25b93f59beSBob Perper{ 26b93f59beSBob Perper return (struct data_in *) error_data_in_ptr; 27b93f59beSBob Perper} 2850aadb33SDmitri Tikhonov 2950aadb33SDmitri Tikhonov 3050aadb33SDmitri Tikhonovstatic void 3150aadb33SDmitri Tikhonoverror_di_destroy (struct data_in *data_in) 3250aadb33SDmitri Tikhonov{ 3350aadb33SDmitri Tikhonov} 3450aadb33SDmitri Tikhonov 3550aadb33SDmitri Tikhonov 3650aadb33SDmitri Tikhonovstatic enum ins_frame 3750aadb33SDmitri Tikhonoverror_di_insert_frame (struct data_in *data_in, 3850aadb33SDmitri Tikhonov struct stream_frame *new_frame, uint64_t read_offset) 3950aadb33SDmitri Tikhonov{ 4050aadb33SDmitri Tikhonov return INS_FRAME_ERR; 4150aadb33SDmitri Tikhonov} 4250aadb33SDmitri Tikhonov 4350aadb33SDmitri Tikhonov 4450aadb33SDmitri Tikhonovstatic struct data_frame * 4550aadb33SDmitri Tikhonoverror_di_get_frame (struct data_in *data_in, uint64_t read_offset) 4650aadb33SDmitri Tikhonov{ 4750aadb33SDmitri Tikhonov return NULL; 4850aadb33SDmitri Tikhonov} 4950aadb33SDmitri Tikhonov 5050aadb33SDmitri Tikhonov 5150aadb33SDmitri Tikhonovstatic void 5250aadb33SDmitri Tikhonoverror_di_frame_done (struct data_in *data_in, struct data_frame *data_frame) 5350aadb33SDmitri Tikhonov{ 5450aadb33SDmitri Tikhonov} 5550aadb33SDmitri Tikhonov 5650aadb33SDmitri Tikhonov 5750aadb33SDmitri Tikhonovstatic int 5850aadb33SDmitri Tikhonoverror_di_empty (struct data_in *data_in) 5950aadb33SDmitri Tikhonov{ 6050aadb33SDmitri Tikhonov return 1; 6150aadb33SDmitri Tikhonov} 6250aadb33SDmitri Tikhonov 6350aadb33SDmitri Tikhonov 64a5fa05f9SDmitri Tikhonovstatic struct data_in * 6550aadb33SDmitri Tikhonoverror_di_switch_impl (struct data_in *data_in, uint64_t read_offset) 6650aadb33SDmitri Tikhonov{ 6750aadb33SDmitri Tikhonov assert(0); 6850aadb33SDmitri Tikhonov return data_in; 6950aadb33SDmitri Tikhonov} 7050aadb33SDmitri Tikhonov 7150aadb33SDmitri Tikhonov 72c51ce338SDmitri Tikhonovstatic size_t 73c51ce338SDmitri Tikhonoverror_di_mem_used (struct data_in *data_in) 74c51ce338SDmitri Tikhonov{ 75c51ce338SDmitri Tikhonov return 0; 76c51ce338SDmitri Tikhonov} 77c51ce338SDmitri Tikhonov 78c51ce338SDmitri Tikhonov 795392f7a3SLiteSpeed Techstatic void 805392f7a3SLiteSpeed Techerror_di_dump_state (struct data_in *data_in) 815392f7a3SLiteSpeed Tech{ 825392f7a3SLiteSpeed Tech} 835392f7a3SLiteSpeed Tech 845392f7a3SLiteSpeed Techstatic uint64_t 855392f7a3SLiteSpeed Techerror_di_readable_bytes (struct data_in *data_in, uint64_t read_offset) 865392f7a3SLiteSpeed Tech{ 875392f7a3SLiteSpeed Tech return 0; 885392f7a3SLiteSpeed Tech} 895392f7a3SLiteSpeed Tech 905392f7a3SLiteSpeed Tech 9150aadb33SDmitri Tikhonovstatic const struct data_in_iface di_if_error = { 9250aadb33SDmitri Tikhonov .di_destroy = error_di_destroy, 935392f7a3SLiteSpeed Tech .di_dump_state = error_di_dump_state, 9450aadb33SDmitri Tikhonov .di_empty = error_di_empty, 9550aadb33SDmitri Tikhonov .di_frame_done = error_di_frame_done, 9650aadb33SDmitri Tikhonov .di_get_frame = error_di_get_frame, 9750aadb33SDmitri Tikhonov .di_insert_frame = error_di_insert_frame, 98c51ce338SDmitri Tikhonov .di_mem_used = error_di_mem_used, 99cca25415SDmitri Tikhonov .di_own_on_ok = 0, /* Never returns INS_FRAME_OK, but anyway */ 1005392f7a3SLiteSpeed Tech .di_readable_bytes 1015392f7a3SLiteSpeed Tech = error_di_readable_bytes, 10250aadb33SDmitri Tikhonov .di_switch_impl = error_di_switch_impl, 10350aadb33SDmitri Tikhonov}; 104b93f59beSBob Perper 105b93f59beSBob Perper 106461e84d8SAmol Deshpandestatic const struct data_in error_data_in = { 107461e84d8SAmol Deshpande .di_if = &di_if_error, 108461e84d8SAmol Deshpande .di_flags = 0, 109461e84d8SAmol Deshpande}; 110b93f59beSBob Perper 111b93f59beSBob Perper 112b93f59beSBob Perperstatic const struct data_in *error_data_in_ptr = &error_data_in; 113