/src/h2o/deps/quicly/include/quicly/local_cid.h
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 | | #ifndef quicly_local_cid_h |
23 | | #define quicly_local_cid_h |
24 | | |
25 | | #include "quicly/cid.h" |
26 | | |
27 | | #ifdef __cplusplus |
28 | | extern "C" { |
29 | | #endif |
30 | | |
31 | | enum en_quicly_local_cid_state_t { |
32 | | /** |
33 | | * this entry is free for use |
34 | | */ |
35 | | QUICLY_LOCAL_CID_STATE_IDLE, |
36 | | /** |
37 | | * this entry is to be sent at the next round of send operation |
38 | | */ |
39 | | QUICLY_LOCAL_CID_STATE_PENDING, |
40 | | /** |
41 | | * this entry has been sent and is waiting for ACK (or to be deemed lost) |
42 | | */ |
43 | | QUICLY_LOCAL_CID_STATE_INFLIGHT, |
44 | | /** |
45 | | * this CID has been delivered to the remote peer (ACKed) and in use |
46 | | */ |
47 | | QUICLY_LOCAL_CID_STATE_DELIVERED, |
48 | | }; |
49 | | |
50 | | /** |
51 | | * records information for sending NEW_CONNECTION_ID frame |
52 | | */ |
53 | | typedef struct st_quicly_local_cid_t { |
54 | | enum en_quicly_local_cid_state_t state; |
55 | | uint64_t sequence; |
56 | | quicly_cid_t cid; |
57 | | uint8_t stateless_reset_token[QUICLY_STATELESS_RESET_TOKEN_LEN]; |
58 | | } quicly_local_cid_t; |
59 | | |
60 | | /** |
61 | | * manages a list of connection IDs we issue to the remote peer |
62 | | */ |
63 | | typedef struct st_quicly_local_cid_set_t { |
64 | | /** |
65 | | * Identifier of the connection used by quicly. Three tuple of (node_id, thread_id, master_id) is used to identify the |
66 | | * connection. `path_id` is maintained by the "local_cid" module, and used for identifying each CID being issued. |
67 | | */ |
68 | | quicly_cid_plaintext_t plaintext; |
69 | | /** |
70 | | * storage to retain local CIDs |
71 | | * |
72 | | * Pending CIDs (state == STATE_PENDING) are moved to the front of the array, in the order it was marked as pending. |
73 | | * This ensures that pending CIDs are sent in FIFO manner. Order of CIDs with other states is not defined. |
74 | | * |
75 | | * Actual size of the array is constrained by _size. |
76 | | */ |
77 | | quicly_local_cid_t cids[QUICLY_LOCAL_ACTIVE_CONNECTION_ID_LIMIT]; |
78 | | /** |
79 | | * how many entries are actually usable in `cids`? |
80 | | */ |
81 | | size_t _size; |
82 | | quicly_cid_encryptor_t *_encryptor; |
83 | | } quicly_local_cid_set_t; |
84 | | |
85 | | /** |
86 | | * initialize the structure |
87 | | * |
88 | | * If `encryptor` is non-NULL, it is initialized with size==1 (sequence==0 is registered as DELIVERED). |
89 | | * Otherwise, it is initialized with size==0, and the size shall never be increased. |
90 | | */ |
91 | | void quicly_local_cid_init_set(quicly_local_cid_set_t *set, quicly_cid_encryptor_t *encryptor, |
92 | | const quicly_cid_plaintext_t *new_cid); |
93 | | /** |
94 | | * sets a new size of locally issued CIDs. |
95 | | * |
96 | | * The new size must be equal to or grater than the current size, and must be equal to or less than the elements of `cids`. |
97 | | * |
98 | | * Returns true if there is something to send. |
99 | | */ |
100 | | int quicly_local_cid_set_size(quicly_local_cid_set_t *set, size_t new_cap); |
101 | | /** |
102 | | * returns true if all entries in the given set is in IDLE state |
103 | | */ |
104 | | static size_t quicly_local_cid_get_size(const quicly_local_cid_set_t *set); |
105 | | /** |
106 | | * tells the module that the first `num_sent` pending CIDs have been sent |
107 | | */ |
108 | | void quicly_local_cid_on_sent(quicly_local_cid_set_t *set, size_t num_sent); |
109 | | /** |
110 | | * tells the module that the given sequence number was ACKed |
111 | | */ |
112 | | void quicly_local_cid_on_acked(quicly_local_cid_set_t *set, uint64_t sequence); |
113 | | /** |
114 | | * tells the module that the given sequence number was lost |
115 | | * |
116 | | * returns true if there is something to send |
117 | | */ |
118 | | int quicly_local_cid_on_lost(quicly_local_cid_set_t *set, uint64_t sequence); |
119 | | /** |
120 | | * remove the specified CID from the storage. |
121 | | * |
122 | | * This makes one slot for CIDs empty. The CID generator callback is then called to fill the slot with a new CID. |
123 | | * @return 0 if the request was legal, otherwise an error code |
124 | | */ |
125 | | quicly_error_t quicly_local_cid_retire(quicly_local_cid_set_t *set, uint64_t sequence, int *has_pending); |
126 | | |
127 | | /* inline definitions */ |
128 | | |
129 | | inline size_t quicly_local_cid_get_size(const quicly_local_cid_set_t *set) |
130 | 0 | { |
131 | 0 | return set->_size; |
132 | 0 | } Unexecuted instantiation: driver.cc:quicly_local_cid_get_size(st_quicly_local_cid_set_t const*) Unexecuted instantiation: driver_common.cc:quicly_local_cid_get_size(st_quicly_local_cid_set_t const*) Unexecuted instantiation: socket.c:quicly_local_cid_get_size Unexecuted instantiation: config.c:quicly_local_cid_get_size Unexecuted instantiation: configurator.c:quicly_local_cid_get_size Unexecuted instantiation: context.c:quicly_local_cid_get_size Unexecuted instantiation: headers.c:quicly_local_cid_get_size Unexecuted instantiation: request.c:quicly_local_cid_get_size Unexecuted instantiation: util.c:quicly_local_cid_get_size Unexecuted instantiation: access_log.c:quicly_local_cid_get_size Unexecuted instantiation: file.c:quicly_local_cid_get_size Unexecuted instantiation: mimemap.c:quicly_local_cid_get_size Unexecuted instantiation: proxy.c:quicly_local_cid_get_size Unexecuted instantiation: http1.c:quicly_local_cid_get_size Unexecuted instantiation: connection.c:quicly_local_cid_get_size Unexecuted instantiation: scheduler.c:quicly_local_cid_get_size Unexecuted instantiation: stream.c:quicly_local_cid_get_size Unexecuted instantiation: http2_debug_state.c:quicly_local_cid_get_size Unexecuted instantiation: common.c:quicly_local_cid_get_size Unexecuted instantiation: server.c:quicly_local_cid_get_size Unexecuted instantiation: cc-reno.c:quicly_local_cid_get_size Unexecuted instantiation: defaults.c:quicly_local_cid_get_size Unexecuted instantiation: quicly.c:quicly_local_cid_get_size Unexecuted instantiation: streambuf.c:quicly_local_cid_get_size Unexecuted instantiation: http3client.c:quicly_local_cid_get_size Unexecuted instantiation: httpclient.c:quicly_local_cid_get_size Unexecuted instantiation: absprio.c:quicly_local_cid_get_size Unexecuted instantiation: logconf.c:quicly_local_cid_get_size Unexecuted instantiation: compress.c:quicly_local_cid_get_size Unexecuted instantiation: gzip.c:quicly_local_cid_get_size Unexecuted instantiation: headers_util.c:quicly_local_cid_get_size Unexecuted instantiation: frame.c:quicly_local_cid_get_size Unexecuted instantiation: qpack.c:quicly_local_cid_get_size Unexecuted instantiation: cc-cubic.c:quicly_local_cid_get_size Unexecuted instantiation: cc-pico.c:quicly_local_cid_get_size Unexecuted instantiation: local_cid.c:quicly_local_cid_get_size Unexecuted instantiation: http1client.c:quicly_local_cid_get_size Unexecuted instantiation: http2client.c:quicly_local_cid_get_size Unexecuted instantiation: driver_url.cc:quicly_local_cid_get_size(st_quicly_local_cid_set_t const*) Unexecuted instantiation: driver_h3.cc:quicly_local_cid_get_size(st_quicly_local_cid_set_t const*) Unexecuted instantiation: quicly_mock.c:quicly_local_cid_get_size Unexecuted instantiation: errordoc.c:quicly_local_cid_get_size Unexecuted instantiation: expires.c:quicly_local_cid_get_size Unexecuted instantiation: fastcgi.c:quicly_local_cid_get_size Unexecuted instantiation: h2olog.c:quicly_local_cid_get_size Unexecuted instantiation: connect.c:quicly_local_cid_get_size Unexecuted instantiation: redirect.c:quicly_local_cid_get_size Unexecuted instantiation: reproxy.c:quicly_local_cid_get_size Unexecuted instantiation: throttle_resp.c:quicly_local_cid_get_size Unexecuted instantiation: self_trace.c:quicly_local_cid_get_size Unexecuted instantiation: server_timing.c:quicly_local_cid_get_size Unexecuted instantiation: status.c:quicly_local_cid_get_size Unexecuted instantiation: events.c:quicly_local_cid_get_size Unexecuted instantiation: memory.c:quicly_local_cid_get_size Unexecuted instantiation: requests.c:quicly_local_cid_get_size Unexecuted instantiation: ssl.c:quicly_local_cid_get_size Unexecuted instantiation: durations.c:quicly_local_cid_get_size Unexecuted instantiation: brotli.c:quicly_local_cid_get_size |
133 | | |
134 | | #ifdef __cplusplus |
135 | | } |
136 | | #endif |
137 | | |
138 | | #endif |