lsquic_data_in_if.h revision 50aadb33
150aadb33SDmitri Tikhonov/* Copyright (c) 2017 LiteSpeed Technologies Inc. See LICENSE. */ 250aadb33SDmitri Tikhonov/* 350aadb33SDmitri Tikhonov * lsquic_data_in_if.h -- DATA in interface 450aadb33SDmitri Tikhonov */ 550aadb33SDmitri Tikhonov 650aadb33SDmitri Tikhonov#ifndef LSQUIC_DATA_IN_IF_H 750aadb33SDmitri Tikhonov#define LSQUIC_DATA_IN_IF_H 1 850aadb33SDmitri Tikhonov 950aadb33SDmitri Tikhonov 1050aadb33SDmitri Tikhonovstruct data_frame; 1150aadb33SDmitri Tikhonovstruct data_in; 1250aadb33SDmitri Tikhonovstruct lsquic_conn_public; 1350aadb33SDmitri Tikhonovstruct stream_frame; 1450aadb33SDmitri Tikhonov 1550aadb33SDmitri Tikhonov 1650aadb33SDmitri Tikhonovenum ins_frame 1750aadb33SDmitri Tikhonov{ 1850aadb33SDmitri Tikhonov INS_FRAME_OK, 1950aadb33SDmitri Tikhonov INS_FRAME_ERR, 2050aadb33SDmitri Tikhonov INS_FRAME_DUP, 2150aadb33SDmitri Tikhonov}; 2250aadb33SDmitri Tikhonov 2350aadb33SDmitri Tikhonov 2450aadb33SDmitri Tikhonovstruct data_in_iface 2550aadb33SDmitri Tikhonov{ 2650aadb33SDmitri Tikhonov void 2750aadb33SDmitri Tikhonov (*di_destroy) (struct data_in *); 2850aadb33SDmitri Tikhonov 2950aadb33SDmitri Tikhonov int 3050aadb33SDmitri Tikhonov (*di_empty) (struct data_in *); 3150aadb33SDmitri Tikhonov 3250aadb33SDmitri Tikhonov /* The caller releases control of stream frame. Do not reference it 3350aadb33SDmitri Tikhonov * after the call. 3450aadb33SDmitri Tikhonov */ 3550aadb33SDmitri Tikhonov enum ins_frame 3650aadb33SDmitri Tikhonov (*di_insert_frame) (struct data_in *, struct stream_frame *, 3750aadb33SDmitri Tikhonov uint64_t read_offset); 3850aadb33SDmitri Tikhonov 3950aadb33SDmitri Tikhonov struct data_frame * 4050aadb33SDmitri Tikhonov (*di_get_frame) (struct data_in *, uint64_t read_offset); 4150aadb33SDmitri Tikhonov 4250aadb33SDmitri Tikhonov void 4350aadb33SDmitri Tikhonov (*di_frame_done) (struct data_in *, struct data_frame *); 4450aadb33SDmitri Tikhonov 4550aadb33SDmitri Tikhonov /* Creates a new data_in object, feeds its stream frames to it, deletes 4650aadb33SDmitri Tikhonov * itself and returns the new object. 4750aadb33SDmitri Tikhonov */ 4850aadb33SDmitri Tikhonov struct data_in * 4950aadb33SDmitri Tikhonov (*di_switch_impl) (struct data_in *, uint64_t read_offset); 5050aadb33SDmitri Tikhonov}; 5150aadb33SDmitri Tikhonov 5250aadb33SDmitri Tikhonov 5350aadb33SDmitri Tikhonovstruct data_in 5450aadb33SDmitri Tikhonov{ 5550aadb33SDmitri Tikhonov const struct data_in_iface *di_if; 5650aadb33SDmitri Tikhonov enum { 5750aadb33SDmitri Tikhonov /* If DI_SWITCH_IMPL is set, switching data_in implementation is 5850aadb33SDmitri Tikhonov * recommended in order to get better performance for current 5950aadb33SDmitri Tikhonov * incoming stream frame scenario. Check the value of this flag 6050aadb33SDmitri Tikhonov * after calls to di_insert_frame() and di_frame_done(). 6150aadb33SDmitri Tikhonov */ 6250aadb33SDmitri Tikhonov DI_SWITCH_IMPL = (1 << 0), 6350aadb33SDmitri Tikhonov } di_flags; 6450aadb33SDmitri Tikhonov}; 6550aadb33SDmitri Tikhonov 6650aadb33SDmitri Tikhonov 6750aadb33SDmitri Tikhonovstruct data_in * 6850aadb33SDmitri Tikhonovdata_in_nocopy_new (struct lsquic_conn_public *, uint32_t stream_id); 6950aadb33SDmitri Tikhonov 7050aadb33SDmitri Tikhonovstruct data_in * 7150aadb33SDmitri Tikhonovdata_in_hash_new (struct lsquic_conn_public *, uint32_t stream_id, 7250aadb33SDmitri Tikhonov uint64_t byteage); 7350aadb33SDmitri Tikhonov 7450aadb33SDmitri Tikhonovenum ins_frame 7550aadb33SDmitri Tikhonovdata_in_hash_insert_data_frame (struct data_in *data_in, 7650aadb33SDmitri Tikhonov const struct data_frame *data_frame, uint64_t read_offset); 7750aadb33SDmitri Tikhonov 7850aadb33SDmitri Tikhonovstruct data_in * 7950aadb33SDmitri Tikhonovdata_in_error_new (); 8050aadb33SDmitri Tikhonov 8150aadb33SDmitri Tikhonov#endif 82