lsquic_di_error.c revision 461e84d8
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> 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 1950aadb33SDmitri Tikhonov 2050aadb33SDmitri Tikhonov 2150aadb33SDmitri Tikhonov 2250aadb33SDmitri Tikhonov 2350aadb33SDmitri Tikhonov 2450aadb33SDmitri Tikhonov 2550aadb33SDmitri Tikhonovstatic void 2650aadb33SDmitri Tikhonoverror_di_destroy (struct data_in *data_in) 2750aadb33SDmitri Tikhonov{ 2850aadb33SDmitri Tikhonov} 2950aadb33SDmitri Tikhonov 3050aadb33SDmitri Tikhonov 3150aadb33SDmitri Tikhonovstatic enum ins_frame 3250aadb33SDmitri Tikhonoverror_di_insert_frame (struct data_in *data_in, 3350aadb33SDmitri Tikhonov struct stream_frame *new_frame, uint64_t read_offset) 3450aadb33SDmitri Tikhonov{ 3550aadb33SDmitri Tikhonov return INS_FRAME_ERR; 3650aadb33SDmitri Tikhonov} 3750aadb33SDmitri Tikhonov 3850aadb33SDmitri Tikhonov 3950aadb33SDmitri Tikhonovstatic struct data_frame * 4050aadb33SDmitri Tikhonoverror_di_get_frame (struct data_in *data_in, uint64_t read_offset) 4150aadb33SDmitri Tikhonov{ 4250aadb33SDmitri Tikhonov return NULL; 4350aadb33SDmitri Tikhonov} 4450aadb33SDmitri Tikhonov 4550aadb33SDmitri Tikhonov 4650aadb33SDmitri Tikhonovstatic void 4750aadb33SDmitri Tikhonoverror_di_frame_done (struct data_in *data_in, struct data_frame *data_frame) 4850aadb33SDmitri Tikhonov{ 4950aadb33SDmitri Tikhonov} 5050aadb33SDmitri Tikhonov 5150aadb33SDmitri Tikhonov 5250aadb33SDmitri Tikhonovstatic int 5350aadb33SDmitri Tikhonoverror_di_empty (struct data_in *data_in) 5450aadb33SDmitri Tikhonov{ 5550aadb33SDmitri Tikhonov return 1; 5650aadb33SDmitri Tikhonov} 5750aadb33SDmitri Tikhonov 5850aadb33SDmitri Tikhonov 5950aadb33SDmitri Tikhonovstruct data_in * 6050aadb33SDmitri Tikhonoverror_di_switch_impl (struct data_in *data_in, uint64_t read_offset) 6150aadb33SDmitri Tikhonov{ 6250aadb33SDmitri Tikhonov assert(0); 6350aadb33SDmitri Tikhonov return data_in; 6450aadb33SDmitri Tikhonov} 6550aadb33SDmitri Tikhonov 6650aadb33SDmitri Tikhonov 67c51ce338SDmitri Tikhonovstatic size_t 68c51ce338SDmitri Tikhonoverror_di_mem_used (struct data_in *data_in) 69c51ce338SDmitri Tikhonov{ 70c51ce338SDmitri Tikhonov return 0; 71c51ce338SDmitri Tikhonov} 72c51ce338SDmitri Tikhonov 73c51ce338SDmitri Tikhonov 7450aadb33SDmitri Tikhonovstatic const struct data_in_iface di_if_error = { 7550aadb33SDmitri Tikhonov .di_destroy = error_di_destroy, 7650aadb33SDmitri Tikhonov .di_empty = error_di_empty, 7750aadb33SDmitri Tikhonov .di_frame_done = error_di_frame_done, 7850aadb33SDmitri Tikhonov .di_get_frame = error_di_get_frame, 7950aadb33SDmitri Tikhonov .di_insert_frame = error_di_insert_frame, 80c51ce338SDmitri Tikhonov .di_mem_used = error_di_mem_used, 8150aadb33SDmitri Tikhonov .di_switch_impl = error_di_switch_impl, 8250aadb33SDmitri Tikhonov}; 83461e84d8SAmol Deshpandestatic const struct data_in error_data_in = { 84461e84d8SAmol Deshpande .di_if = &di_if_error, 85461e84d8SAmol Deshpande .di_flags = 0, 86461e84d8SAmol Deshpande}; 87461e84d8SAmol Deshpandestruct data_in * 88461e84d8SAmol Deshpandedata_in_error_new (struct lsquic_conn_public *conn_pub) 89461e84d8SAmol Deshpande{ 90461e84d8SAmol Deshpande return (struct data_in *) &error_data_in; 91461e84d8SAmol Deshpande} 92