lsquic_senhist.h revision c51ce338
150aadb33SDmitri Tikhonov/* Copyright (c) 2017 LiteSpeed Technologies Inc.  See LICENSE. */
250aadb33SDmitri Tikhonov/*
350aadb33SDmitri Tikhonov * lsquic_senhist.h -- History sent packets.
450aadb33SDmitri Tikhonov *
550aadb33SDmitri Tikhonov * We only keep track of packet numbers in order to verify ACKs.
650aadb33SDmitri Tikhonov */
750aadb33SDmitri Tikhonov
850aadb33SDmitri Tikhonov#ifndef LSQUIC_SENHIST_H
950aadb33SDmitri Tikhonov#define LSQUIC_SENHIST_H 1
1050aadb33SDmitri Tikhonov
1150aadb33SDmitri Tikhonov#include "lsquic_packints.h"
1250aadb33SDmitri Tikhonov
1350aadb33SDmitri Tikhonovtypedef struct lsquic_senhist {
1450aadb33SDmitri Tikhonov    /* These ranges are ordered from high to low.  While searching this
1550aadb33SDmitri Tikhonov     * structure is O(n), I expect that in practice, a very long search
1650aadb33SDmitri Tikhonov     * could only happen once before the connection is terminated,
1750aadb33SDmitri Tikhonov     * because:
1850aadb33SDmitri Tikhonov     *  a) either the packet number far away is real, but it was so long
1950aadb33SDmitri Tikhonov     *     ago that it would have timed out by now (RTO); or
2050aadb33SDmitri Tikhonov     *  b) the peer sends an invalid ACK.
2150aadb33SDmitri Tikhonov     */
2250aadb33SDmitri Tikhonov    struct packints             sh_pints;
2350aadb33SDmitri Tikhonov#ifndef NDEBUG
2450aadb33SDmitri Tikhonov    enum {
2550aadb33SDmitri Tikhonov        SH_REORDER  = (1 << 0),
2650aadb33SDmitri Tikhonov    }                           sh_flags;
2750aadb33SDmitri Tikhonov#endif
2850aadb33SDmitri Tikhonov} lsquic_senhist_t;
2950aadb33SDmitri Tikhonov
3050aadb33SDmitri Tikhonovvoid
3150aadb33SDmitri Tikhonovlsquic_senhist_init (lsquic_senhist_t *);
3250aadb33SDmitri Tikhonov
3350aadb33SDmitri Tikhonovvoid
3450aadb33SDmitri Tikhonovlsquic_senhist_cleanup (lsquic_senhist_t *);
3550aadb33SDmitri Tikhonov
3650aadb33SDmitri Tikhonovint
3750aadb33SDmitri Tikhonovlsquic_senhist_add (lsquic_senhist_t *, lsquic_packno_t);
3850aadb33SDmitri Tikhonov
3950aadb33SDmitri Tikhonov/* Returns true if history contains all packets numbers in this range.
4050aadb33SDmitri Tikhonov */
4150aadb33SDmitri Tikhonovint
4250aadb33SDmitri Tikhonovlsquic_senhist_sent_range (lsquic_senhist_t *, lsquic_packno_t low,
4350aadb33SDmitri Tikhonov                                               lsquic_packno_t high);
4450aadb33SDmitri Tikhonov
4550aadb33SDmitri Tikhonov/* Returns 0 if no packets have been sent yet */
4650aadb33SDmitri Tikhonovlsquic_packno_t
4750aadb33SDmitri Tikhonovlsquic_senhist_largest (lsquic_senhist_t *hist);
4850aadb33SDmitri Tikhonov
4950aadb33SDmitri Tikhonovvoid
5050aadb33SDmitri Tikhonovlsquic_senhist_tostr (lsquic_senhist_t *hist, char *buf, size_t bufsz);
5150aadb33SDmitri Tikhonov
52c51ce338SDmitri Tikhonovsize_t
53c51ce338SDmitri Tikhonovlsquic_senhist_mem_used (const struct lsquic_senhist *);
54c51ce338SDmitri Tikhonov
5550aadb33SDmitri Tikhonov#endif
56