lsquic_rechist.h revision 7d09751d
17d09751dSDmitri Tikhonov/* Copyright (c) 2017 - 2020 LiteSpeed Technologies Inc. See LICENSE. */ 250aadb33SDmitri Tikhonov/* 350aadb33SDmitri Tikhonov * lsquic_rechist.h -- History of received packets. 450aadb33SDmitri Tikhonov * 550aadb33SDmitri Tikhonov * The purpose of received packet history is to generate ACK frames. 650aadb33SDmitri Tikhonov */ 750aadb33SDmitri Tikhonov 850aadb33SDmitri Tikhonov#ifndef LSQUIC_RECHIST_H 950aadb33SDmitri Tikhonov#define LSQUIC_RECHIST_H 1 1050aadb33SDmitri Tikhonov 115392f7a3SLiteSpeed Techstruct lsquic_conn; 125392f7a3SLiteSpeed Tech 1350aadb33SDmitri Tikhonov#include "lsquic_packints.h" 1450aadb33SDmitri Tikhonov 1550aadb33SDmitri Tikhonovstruct lsquic_rechist { 1650aadb33SDmitri Tikhonov struct packints rh_pints; 1750aadb33SDmitri Tikhonov lsquic_packno_t rh_cutoff; 1850aadb33SDmitri Tikhonov lsquic_time_t rh_largest_acked_received; 195392f7a3SLiteSpeed Tech const struct lsquic_conn *rh_conn; /* Used for logging */ 2050aadb33SDmitri Tikhonov /* Chromium limits the number of tracked packets (see 2150aadb33SDmitri Tikhonov * kMaxTrackedPackets). We could do this, too. 2250aadb33SDmitri Tikhonov */ 2350aadb33SDmitri Tikhonov unsigned rh_n_packets; 2450aadb33SDmitri Tikhonov enum { 2550aadb33SDmitri Tikhonov RH_CUTOFF_SET = (1 << 0), 26de46bf2fSDmitri Tikhonov#if LSQUIC_ACK_ATTACK 27de46bf2fSDmitri Tikhonov RH_ACK_ATTACK = (1 << 1), 28de46bf2fSDmitri Tikhonov#endif 2950aadb33SDmitri Tikhonov } rh_flags; 30de46bf2fSDmitri Tikhonov#if LSQUIC_ACK_ATTACK 31de46bf2fSDmitri Tikhonov struct lsquic_packno_range rh_first; 32de46bf2fSDmitri Tikhonov#endif 3350aadb33SDmitri Tikhonov}; 3450aadb33SDmitri Tikhonov 3550aadb33SDmitri Tikhonovtypedef struct lsquic_rechist lsquic_rechist_t; 3650aadb33SDmitri Tikhonov 3750aadb33SDmitri Tikhonovvoid 385392f7a3SLiteSpeed Techlsquic_rechist_init (struct lsquic_rechist *, const struct lsquic_conn *, int); 3950aadb33SDmitri Tikhonov 4050aadb33SDmitri Tikhonovvoid 4150aadb33SDmitri Tikhonovlsquic_rechist_cleanup (struct lsquic_rechist *); 4250aadb33SDmitri Tikhonov 4350aadb33SDmitri Tikhonovenum received_st { 4450aadb33SDmitri Tikhonov REC_ST_OK, 4550aadb33SDmitri Tikhonov REC_ST_DUP, 4650aadb33SDmitri Tikhonov REC_ST_ERR, 4750aadb33SDmitri Tikhonov}; 4850aadb33SDmitri Tikhonov 4950aadb33SDmitri Tikhonovenum received_st 5050aadb33SDmitri Tikhonovlsquic_rechist_received (lsquic_rechist_t *, lsquic_packno_t, 5150aadb33SDmitri Tikhonov lsquic_time_t now); 5250aadb33SDmitri Tikhonov 5350aadb33SDmitri Tikhonovvoid 5450aadb33SDmitri Tikhonovlsquic_rechist_stop_wait (lsquic_rechist_t *, lsquic_packno_t); 5550aadb33SDmitri Tikhonov 5650aadb33SDmitri Tikhonov/* Returns number of bytes written on success, -1 on failure */ 5750aadb33SDmitri Tikhonovint 5850aadb33SDmitri Tikhonovlsquic_rechist_make_ackframe (lsquic_rechist_t *, 5950aadb33SDmitri Tikhonov void *outbuf, size_t outbuf_sz, int *has_missing, 6050aadb33SDmitri Tikhonov lsquic_time_t now); 6150aadb33SDmitri Tikhonov 6250aadb33SDmitri Tikhonovconst struct lsquic_packno_range * 6350aadb33SDmitri Tikhonovlsquic_rechist_first (lsquic_rechist_t *); 6450aadb33SDmitri Tikhonov 6550aadb33SDmitri Tikhonovconst struct lsquic_packno_range * 6650aadb33SDmitri Tikhonovlsquic_rechist_next (lsquic_rechist_t *); 6750aadb33SDmitri Tikhonov 6850aadb33SDmitri Tikhonovlsquic_packno_t 6950aadb33SDmitri Tikhonovlsquic_rechist_largest_packno (const lsquic_rechist_t *); 7050aadb33SDmitri Tikhonov 7150aadb33SDmitri Tikhonovlsquic_packno_t 7250aadb33SDmitri Tikhonovlsquic_rechist_cutoff (const lsquic_rechist_t *); 7350aadb33SDmitri Tikhonov 7450aadb33SDmitri Tikhonovlsquic_time_t 7550aadb33SDmitri Tikhonovlsquic_rechist_largest_recv (const lsquic_rechist_t *); 7650aadb33SDmitri Tikhonov 77c51ce338SDmitri Tikhonovsize_t 78c51ce338SDmitri Tikhonovlsquic_rechist_mem_used (const struct lsquic_rechist *); 79c51ce338SDmitri Tikhonov 8050aadb33SDmitri Tikhonov#endif 81