lsquic_senhist.h revision bfc7bfd8
1/* Copyright (c) 2017 LiteSpeed Technologies Inc. See LICENSE. */ 2/* 3 * lsquic_senhist.h -- History sent packets. 4 * 5 * We only keep track of packet numbers in order to verify ACKs. 6 */ 7 8#ifndef LSQUIC_SENHIST_H 9#define LSQUIC_SENHIST_H 1 10 11#include "lsquic_packints.h" 12 13typedef struct lsquic_senhist { 14 /* These ranges are ordered from high to low. While searching this 15 * structure is O(n), I expect that in practice, a very long search 16 * could only happen once before the connection is terminated, 17 * because: 18 * a) either the packet number far away is real, but it was so long 19 * ago that it would have timed out by now (RTO); or 20 * b) the peer sends an invalid ACK. 21 */ 22 struct packints sh_pints; 23} lsquic_senhist_t; 24 25void 26lsquic_senhist_init (lsquic_senhist_t *); 27 28void 29lsquic_senhist_cleanup (lsquic_senhist_t *); 30 31int 32lsquic_senhist_add (lsquic_senhist_t *, lsquic_packno_t); 33 34/* Returns true if history contains all packets numbers in this range. 35 */ 36int 37lsquic_senhist_sent_range (lsquic_senhist_t *, lsquic_packno_t low, 38 lsquic_packno_t high); 39 40/* Returns 0 if no packets have been sent yet */ 41lsquic_packno_t 42lsquic_senhist_largest (lsquic_senhist_t *hist); 43 44void 45lsquic_senhist_tostr (lsquic_senhist_t *hist, char *buf, size_t bufsz); 46 47size_t 48lsquic_senhist_mem_used (const struct lsquic_senhist *); 49 50#endif 51