lsquic_purga.h revision 4580fab7
17d09751dSDmitri Tikhonov/* Copyright (c) 2017 - 2020 LiteSpeed Technologies Inc. See LICENSE. */ 25392f7a3SLiteSpeed Tech/* 35392f7a3SLiteSpeed Tech * lsquic_purga.h -- Purgatory for CIDs 45392f7a3SLiteSpeed Tech * 55392f7a3SLiteSpeed Tech * This module keeps a set of CIDs that should be ignored for a period 65392f7a3SLiteSpeed Tech * of time. It is used when a connection is closed: this way, late 75392f7a3SLiteSpeed Tech * packets will not create a new connection. 85392f7a3SLiteSpeed Tech */ 95392f7a3SLiteSpeed Tech 105392f7a3SLiteSpeed Tech#ifndef LSQUIC_PURGA_H 115392f7a3SLiteSpeed Tech#define LSQUIC_PURGA_H 1 125392f7a3SLiteSpeed Tech 135392f7a3SLiteSpeed Techstruct lsquic_purga; 145392f7a3SLiteSpeed Tech 155392f7a3SLiteSpeed Tech/* Purgatory type is used to tell what action to take when a packet whose 165392f7a3SLiteSpeed Tech * CID is in the purgatory is received. 175392f7a3SLiteSpeed Tech */ 185392f7a3SLiteSpeed Techenum purga_type 195392f7a3SLiteSpeed Tech{ 205392f7a3SLiteSpeed Tech PUTY_CONN_DELETED, /* Connection was deleted */ 215392f7a3SLiteSpeed Tech PUTY_CONN_DRAIN, /* Connection is in the "Drain" state */ 225392f7a3SLiteSpeed Tech PUTY_CID_RETIRED, /* CID was retired */ 235392f7a3SLiteSpeed Tech}; 245392f7a3SLiteSpeed Tech 255392f7a3SLiteSpeed Tech/* User can set these values freely */ 265392f7a3SLiteSpeed Techstruct purga_el 275392f7a3SLiteSpeed Tech{ 285392f7a3SLiteSpeed Tech enum purga_type puel_type; 294580fab7SDmitri Tikhonov /* When puel_type is PUTY_CONN_DRAIN or PUTY_CID_RETIRED, puel_time 304580fab7SDmitri Tikhonov * specifies the time until the end of the drain period. 315392f7a3SLiteSpeed Tech * 325392f7a3SLiteSpeed Tech * When puel_type is PUTY_CONN_DELETED, puel_time specifies the time 335392f7a3SLiteSpeed Tech * until the next time stateless reset can be sent. puel_count is the 345392f7a3SLiteSpeed Tech * number of times puel_time was updated. 355392f7a3SLiteSpeed Tech */ 365392f7a3SLiteSpeed Tech unsigned puel_count; 375392f7a3SLiteSpeed Tech lsquic_time_t puel_time; 385392f7a3SLiteSpeed Tech}; 395392f7a3SLiteSpeed Tech 405392f7a3SLiteSpeed Techstruct lsquic_purga * 415392f7a3SLiteSpeed Techlsquic_purga_new (lsquic_time_t min_life, lsquic_cids_update_f remove_cids, 425392f7a3SLiteSpeed Tech void *remove_ctx); 435392f7a3SLiteSpeed Tech 445392f7a3SLiteSpeed Techstruct purga_el * 455392f7a3SLiteSpeed Techlsquic_purga_add (struct lsquic_purga *, const lsquic_cid_t *, void *peer_ctx, 465392f7a3SLiteSpeed Tech enum purga_type, lsquic_time_t); 475392f7a3SLiteSpeed Tech 485392f7a3SLiteSpeed Techstruct purga_el * 495392f7a3SLiteSpeed Techlsquic_purga_contains (struct lsquic_purga *, const lsquic_cid_t *); 505392f7a3SLiteSpeed Tech 515392f7a3SLiteSpeed Techvoid 525392f7a3SLiteSpeed Techlsquic_purga_destroy (struct lsquic_purga *); 535392f7a3SLiteSpeed Tech 545392f7a3SLiteSpeed Techunsigned 555392f7a3SLiteSpeed Techlsquic_purga_cids_per_page (void); 565392f7a3SLiteSpeed Tech 575392f7a3SLiteSpeed Tech#ifndef NDEBUG 585392f7a3SLiteSpeed Techstruct purga_bloom_stats 595392f7a3SLiteSpeed Tech{ 605392f7a3SLiteSpeed Tech unsigned long searches; 615392f7a3SLiteSpeed Tech unsigned long false_hits; 625392f7a3SLiteSpeed Tech}; 635392f7a3SLiteSpeed Tech 645392f7a3SLiteSpeed Techstruct purga_bloom_stats * 655392f7a3SLiteSpeed Techlsquic_purga_get_bloom_stats (struct lsquic_purga *); 665392f7a3SLiteSpeed Tech#endif 675392f7a3SLiteSpeed Tech 685392f7a3SLiteSpeed Tech#endif 69