lsquic_purga.h revision 4580fab7
1/* Copyright (c) 2017 - 2020 LiteSpeed Technologies Inc.  See LICENSE. */
2/*
3 * lsquic_purga.h -- Purgatory for CIDs
4 *
5 * This module keeps a set of CIDs that should be ignored for a period
6 * of time.  It is used when a connection is closed: this way, late
7 * packets will not create a new connection.
8 */
9
10#ifndef LSQUIC_PURGA_H
11#define LSQUIC_PURGA_H 1
12
13struct lsquic_purga;
14
15/* Purgatory type is used to tell what action to take when a packet whose
16 * CID is in the purgatory is received.
17 */
18enum purga_type
19{
20    PUTY_CONN_DELETED,  /* Connection was deleted */
21    PUTY_CONN_DRAIN,    /* Connection is in the "Drain" state */
22    PUTY_CID_RETIRED,   /* CID was retired */
23};
24
25/* User can set these values freely */
26struct purga_el
27{
28    enum purga_type             puel_type;
29    /* When puel_type is PUTY_CONN_DRAIN or PUTY_CID_RETIRED, puel_time
30     * specifies the time until the end of the drain period.
31     *
32     * When puel_type is PUTY_CONN_DELETED, puel_time specifies the time
33     * until the next time stateless reset can be sent.  puel_count is the
34     * number of times puel_time was updated.
35     */
36    unsigned                    puel_count;
37    lsquic_time_t               puel_time;
38};
39
40struct lsquic_purga *
41lsquic_purga_new (lsquic_time_t min_life, lsquic_cids_update_f remove_cids,
42                                                            void *remove_ctx);
43
44struct purga_el *
45lsquic_purga_add (struct lsquic_purga *, const lsquic_cid_t *, void *peer_ctx,
46                                                enum purga_type, lsquic_time_t);
47
48struct purga_el *
49lsquic_purga_contains (struct lsquic_purga *, const lsquic_cid_t *);
50
51void
52lsquic_purga_destroy (struct lsquic_purga *);
53
54unsigned
55lsquic_purga_cids_per_page (void);
56
57#ifndef NDEBUG
58struct purga_bloom_stats
59{
60    unsigned long   searches;
61    unsigned long   false_hits;
62};
63
64struct purga_bloom_stats *
65lsquic_purga_get_bloom_stats (struct lsquic_purga *);
66#endif
67
68#endif
69