lsquic_di_error.c revision 229fce07
1229fce07SDmitri Tikhonov/* Copyright (c) 2017 - 2019 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 1650aadb33SDmitri Tikhonov#include "lsquic_data_in_if.h" 1750aadb33SDmitri Tikhonov 1850aadb33SDmitri Tikhonov 19b93f59beSBob Perperstatic const struct data_in *error_data_in_ptr; 2050aadb33SDmitri Tikhonov 2150aadb33SDmitri Tikhonov 22b93f59beSBob Perperstruct data_in * 23b93f59beSBob Perperdata_in_error_new (struct lsquic_conn_public *conn_pub) 24b93f59beSBob Perper{ 25b93f59beSBob Perper return (struct data_in *) error_data_in_ptr; 26b93f59beSBob Perper} 2750aadb33SDmitri Tikhonov 2850aadb33SDmitri Tikhonov 2950aadb33SDmitri Tikhonovstatic void 3050aadb33SDmitri Tikhonoverror_di_destroy (struct data_in *data_in) 3150aadb33SDmitri Tikhonov{ 3250aadb33SDmitri Tikhonov} 3350aadb33SDmitri Tikhonov 3450aadb33SDmitri Tikhonov 3550aadb33SDmitri Tikhonovstatic enum ins_frame 3650aadb33SDmitri Tikhonoverror_di_insert_frame (struct data_in *data_in, 3750aadb33SDmitri Tikhonov struct stream_frame *new_frame, uint64_t read_offset) 3850aadb33SDmitri Tikhonov{ 3950aadb33SDmitri Tikhonov return INS_FRAME_ERR; 4050aadb33SDmitri Tikhonov} 4150aadb33SDmitri Tikhonov 4250aadb33SDmitri Tikhonov 4350aadb33SDmitri Tikhonovstatic struct data_frame * 4450aadb33SDmitri Tikhonoverror_di_get_frame (struct data_in *data_in, uint64_t read_offset) 4550aadb33SDmitri Tikhonov{ 4650aadb33SDmitri Tikhonov return NULL; 4750aadb33SDmitri Tikhonov} 4850aadb33SDmitri Tikhonov 4950aadb33SDmitri Tikhonov 5050aadb33SDmitri Tikhonovstatic void 5150aadb33SDmitri Tikhonoverror_di_frame_done (struct data_in *data_in, struct data_frame *data_frame) 5250aadb33SDmitri Tikhonov{ 5350aadb33SDmitri Tikhonov} 5450aadb33SDmitri Tikhonov 5550aadb33SDmitri Tikhonov 5650aadb33SDmitri Tikhonovstatic int 5750aadb33SDmitri Tikhonoverror_di_empty (struct data_in *data_in) 5850aadb33SDmitri Tikhonov{ 5950aadb33SDmitri Tikhonov return 1; 6050aadb33SDmitri Tikhonov} 6150aadb33SDmitri Tikhonov 6250aadb33SDmitri Tikhonov 6350aadb33SDmitri Tikhonovstruct data_in * 6450aadb33SDmitri Tikhonoverror_di_switch_impl (struct data_in *data_in, uint64_t read_offset) 6550aadb33SDmitri Tikhonov{ 6650aadb33SDmitri Tikhonov assert(0); 6750aadb33SDmitri Tikhonov return data_in; 6850aadb33SDmitri Tikhonov} 6950aadb33SDmitri Tikhonov 7050aadb33SDmitri Tikhonov 71c51ce338SDmitri Tikhonovstatic size_t 72c51ce338SDmitri Tikhonoverror_di_mem_used (struct data_in *data_in) 73c51ce338SDmitri Tikhonov{ 74c51ce338SDmitri Tikhonov return 0; 75c51ce338SDmitri Tikhonov} 76c51ce338SDmitri Tikhonov 77c51ce338SDmitri Tikhonov 7850aadb33SDmitri Tikhonovstatic const struct data_in_iface di_if_error = { 7950aadb33SDmitri Tikhonov .di_destroy = error_di_destroy, 8050aadb33SDmitri Tikhonov .di_empty = error_di_empty, 8150aadb33SDmitri Tikhonov .di_frame_done = error_di_frame_done, 8250aadb33SDmitri Tikhonov .di_get_frame = error_di_get_frame, 8350aadb33SDmitri Tikhonov .di_insert_frame = error_di_insert_frame, 84c51ce338SDmitri Tikhonov .di_mem_used = error_di_mem_used, 8550aadb33SDmitri Tikhonov .di_switch_impl = error_di_switch_impl, 8650aadb33SDmitri Tikhonov}; 87b93f59beSBob Perper 88b93f59beSBob Perper 89461e84d8SAmol Deshpandestatic const struct data_in error_data_in = { 90461e84d8SAmol Deshpande .di_if = &di_if_error, 91461e84d8SAmol Deshpande .di_flags = 0, 92461e84d8SAmol Deshpande}; 93b93f59beSBob Perper 94b93f59beSBob Perper 95b93f59beSBob Perperstatic const struct data_in *error_data_in_ptr = &error_data_in; 96