lsquic_rechist.h revision 5392f7a3
1/* Copyright (c) 2017 - 2019 LiteSpeed Technologies Inc. See LICENSE. */ 2/* 3 * lsquic_rechist.h -- History of received packets. 4 * 5 * The purpose of received packet history is to generate ACK frames. 6 */ 7 8#ifndef LSQUIC_RECHIST_H 9#define LSQUIC_RECHIST_H 1 10 11struct lsquic_conn; 12 13#include "lsquic_packints.h" 14 15struct lsquic_rechist { 16 struct packints rh_pints; 17 lsquic_packno_t rh_cutoff; 18 lsquic_time_t rh_largest_acked_received; 19 const struct lsquic_conn *rh_conn; /* Used for logging */ 20 /* Chromium limits the number of tracked packets (see 21 * kMaxTrackedPackets). We could do this, too. 22 */ 23 unsigned rh_n_packets; 24 enum { 25 RH_CUTOFF_SET = (1 << 0), 26 } rh_flags; 27}; 28 29typedef struct lsquic_rechist lsquic_rechist_t; 30 31void 32lsquic_rechist_init (struct lsquic_rechist *, const struct lsquic_conn *, int); 33 34void 35lsquic_rechist_cleanup (struct lsquic_rechist *); 36 37enum received_st { 38 REC_ST_OK, 39 REC_ST_DUP, 40 REC_ST_ERR, 41}; 42 43enum received_st 44lsquic_rechist_received (lsquic_rechist_t *, lsquic_packno_t, 45 lsquic_time_t now); 46 47void 48lsquic_rechist_stop_wait (lsquic_rechist_t *, lsquic_packno_t); 49 50/* Returns number of bytes written on success, -1 on failure */ 51int 52lsquic_rechist_make_ackframe (lsquic_rechist_t *, 53 void *outbuf, size_t outbuf_sz, int *has_missing, 54 lsquic_time_t now); 55 56const struct lsquic_packno_range * 57lsquic_rechist_first (lsquic_rechist_t *); 58 59const struct lsquic_packno_range * 60lsquic_rechist_next (lsquic_rechist_t *); 61 62lsquic_packno_t 63lsquic_rechist_largest_packno (const lsquic_rechist_t *); 64 65lsquic_packno_t 66lsquic_rechist_cutoff (const lsquic_rechist_t *); 67 68lsquic_time_t 69lsquic_rechist_largest_recv (const lsquic_rechist_t *); 70 71size_t 72lsquic_rechist_mem_used (const struct lsquic_rechist *); 73 74#endif 75