lsquic_rechist.h revision de46bf2f
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#if LSQUIC_ACK_ATTACK 27 RH_ACK_ATTACK = (1 << 1), 28#endif 29 } rh_flags; 30#if LSQUIC_ACK_ATTACK 31 struct lsquic_packno_range rh_first; 32#endif 33}; 34 35typedef struct lsquic_rechist lsquic_rechist_t; 36 37void 38lsquic_rechist_init (struct lsquic_rechist *, const struct lsquic_conn *, int); 39 40void 41lsquic_rechist_cleanup (struct lsquic_rechist *); 42 43enum received_st { 44 REC_ST_OK, 45 REC_ST_DUP, 46 REC_ST_ERR, 47}; 48 49enum received_st 50lsquic_rechist_received (lsquic_rechist_t *, lsquic_packno_t, 51 lsquic_time_t now); 52 53void 54lsquic_rechist_stop_wait (lsquic_rechist_t *, lsquic_packno_t); 55 56/* Returns number of bytes written on success, -1 on failure */ 57int 58lsquic_rechist_make_ackframe (lsquic_rechist_t *, 59 void *outbuf, size_t outbuf_sz, int *has_missing, 60 lsquic_time_t now); 61 62const struct lsquic_packno_range * 63lsquic_rechist_first (lsquic_rechist_t *); 64 65const struct lsquic_packno_range * 66lsquic_rechist_next (lsquic_rechist_t *); 67 68lsquic_packno_t 69lsquic_rechist_largest_packno (const lsquic_rechist_t *); 70 71lsquic_packno_t 72lsquic_rechist_cutoff (const lsquic_rechist_t *); 73 74lsquic_time_t 75lsquic_rechist_largest_recv (const lsquic_rechist_t *); 76 77size_t 78lsquic_rechist_mem_used (const struct lsquic_rechist *); 79 80#endif 81