Coverage Report

Created: 2025-07-18 06:41

/src/h2o/deps/quicly/lib/retire_cid.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (c) 2020 Fastly, Inc.
3
 *
4
 * Permission is hereby granted, free of charge, to any person obtaining a copy
5
 * of this software and associated documentation files (the "Software"), to
6
 * deal in the Software without restriction, including without limitation the
7
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8
 * sell copies of the Software, and to permit persons to whom the Software is
9
 * furnished to do so, subject to the following conditions:
10
 *
11
 * The above copyright notice and this permission notice shall be included in
12
 * all copies or substantial portions of the Software.
13
 *
14
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20
 * IN THE SOFTWARE.
21
 */
22
23
#include "quicly/retire_cid.h"
24
25
void quicly_retire_cid_init(quicly_retire_cid_set_t *set)
26
0
{
27
0
    set->_num_pending = 0;
28
0
}
29
30
void quicly_retire_cid_push(quicly_retire_cid_set_t *set, uint64_t sequence)
31
0
{
32
0
    if (set->_num_pending == PTLS_ELEMENTSOF(set->sequences)) {
33
        /* in case we don't find an empty slot, we'll just drop this sequence (never send RETIRE_CONNECTION_ID frame) */
34
0
        return;
35
0
    }
36
37
0
    for (size_t i = 0; i < set->_num_pending; i++) {
38
0
        if (set->sequences[i] == sequence) {
39
            /* already scheduled */
40
0
            return;
41
0
        }
42
0
    }
43
44
0
    set->sequences[set->_num_pending] = sequence;
45
0
    set->_num_pending++;
46
0
}
47
48
void quicly_retire_cid_shift(quicly_retire_cid_set_t *set, size_t num_shift)
49
0
{
50
0
    assert(num_shift <= PTLS_ELEMENTSOF(set->sequences));
51
0
    assert(num_shift <= set->_num_pending);
52
    /* move the remaining pending sequence numbers to the front */
53
0
    memmove(set->sequences, set->sequences + num_shift, sizeof(set->sequences[0]) * (set->_num_pending - num_shift));
54
0
    set->_num_pending -= num_shift;
55
0
}