lsquic_di_error.c revision 461e84d8
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#ifdef WIN32 13#include <vc_compat.h> 14#endif 15 16#include "lsquic_data_in_if.h" 17 18 19 20 21 22 23 24 25static void 26error_di_destroy (struct data_in *data_in) 27{ 28} 29 30 31static enum ins_frame 32error_di_insert_frame (struct data_in *data_in, 33 struct stream_frame *new_frame, uint64_t read_offset) 34{ 35 return INS_FRAME_ERR; 36} 37 38 39static struct data_frame * 40error_di_get_frame (struct data_in *data_in, uint64_t read_offset) 41{ 42 return NULL; 43} 44 45 46static void 47error_di_frame_done (struct data_in *data_in, struct data_frame *data_frame) 48{ 49} 50 51 52static int 53error_di_empty (struct data_in *data_in) 54{ 55 return 1; 56} 57 58 59struct data_in * 60error_di_switch_impl (struct data_in *data_in, uint64_t read_offset) 61{ 62 assert(0); 63 return data_in; 64} 65 66 67static size_t 68error_di_mem_used (struct data_in *data_in) 69{ 70 return 0; 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_mem_used = error_di_mem_used, 81 .di_switch_impl = error_di_switch_impl, 82}; 83static const struct data_in error_data_in = { 84 .di_if = &di_if_error, 85 .di_flags = 0, 86}; 87struct data_in * 88data_in_error_new (struct lsquic_conn_public *conn_pub) 89{ 90 return (struct data_in *) &error_data_in; 91} 92