lsquic_rechist.h revision 10c492f0
1/* Copyright (c) 2017 - 2018 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 11#include "lsquic_packints.h" 12 13struct lsquic_rechist { 14 struct packints rh_pints; 15 lsquic_packno_t rh_cutoff; 16 lsquic_time_t rh_largest_acked_received; 17 lsquic_cid_t rh_cid; /* Used for logging */ 18 /* Chromium limits the number of tracked packets (see 19 * kMaxTrackedPackets). We could do this, too. 20 */ 21 unsigned rh_n_packets; 22 enum { 23 RH_CUTOFF_SET = (1 << 0), 24 } rh_flags; 25}; 26 27typedef struct lsquic_rechist lsquic_rechist_t; 28 29void 30lsquic_rechist_init (struct lsquic_rechist *, lsquic_cid_t); 31 32void 33lsquic_rechist_cleanup (struct lsquic_rechist *); 34 35enum received_st { 36 REC_ST_OK, 37 REC_ST_DUP, 38 REC_ST_ERR, 39}; 40 41enum received_st 42lsquic_rechist_received (lsquic_rechist_t *, lsquic_packno_t, 43 lsquic_time_t now); 44 45void 46lsquic_rechist_stop_wait (lsquic_rechist_t *, lsquic_packno_t); 47 48/* Returns number of bytes written on success, -1 on failure */ 49int 50lsquic_rechist_make_ackframe (lsquic_rechist_t *, 51 void *outbuf, size_t outbuf_sz, int *has_missing, 52 lsquic_time_t now); 53 54const struct lsquic_packno_range * 55lsquic_rechist_first (lsquic_rechist_t *); 56 57const struct lsquic_packno_range * 58lsquic_rechist_next (lsquic_rechist_t *); 59 60lsquic_packno_t 61lsquic_rechist_largest_packno (const lsquic_rechist_t *); 62 63lsquic_packno_t 64lsquic_rechist_cutoff (const lsquic_rechist_t *); 65 66lsquic_time_t 67lsquic_rechist_largest_recv (const lsquic_rechist_t *); 68 69size_t 70lsquic_rechist_mem_used (const struct lsquic_rechist *); 71 72#endif 73