/src/h2o/deps/quicly/include/quicly/recvstate.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2017 Fastly, Kazuho Oku |
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_recvstate_h |
23 | | #define quicly_recvstate_h |
24 | | |
25 | | #ifdef __cplusplus |
26 | | extern "C" { |
27 | | #endif |
28 | | |
29 | | #include <assert.h> |
30 | | #include <stddef.h> |
31 | | #include "picotls.h" |
32 | | #include "quicly/ranges.h" |
33 | | |
34 | | typedef struct st_quicly_recvstate_t { |
35 | | /** |
36 | | * ranges that have been received (starts and remains non-empty until transfer completes) |
37 | | */ |
38 | | quicly_ranges_t received; |
39 | | /** |
40 | | * starting offset of data |
41 | | */ |
42 | | uint64_t data_off; |
43 | | /** |
44 | | * end_of_stream offset (or UINT64_MAX) |
45 | | */ |
46 | | uint64_t eos; |
47 | | } quicly_recvstate_t; |
48 | | |
49 | | void quicly_recvstate_init(quicly_recvstate_t *state); |
50 | | void quicly_recvstate_init_closed(quicly_recvstate_t *state); |
51 | | void quicly_recvstate_dispose(quicly_recvstate_t *state); |
52 | | static int quicly_recvstate_transfer_complete(quicly_recvstate_t *state); |
53 | | static size_t quicly_recvstate_bytes_available(quicly_recvstate_t *state); |
54 | | /** |
55 | | * Records that the range identified by (off, *len) has been received. When 0 (success) is returned, *len contains the number of |
56 | | * bytes that might have been newly received and therefore need to be written to the receive buffer (this number of bytes counts |
57 | | * backward from the end of given range). |
58 | | */ |
59 | | quicly_error_t quicly_recvstate_update(quicly_recvstate_t *state, uint64_t off, size_t *len, int is_fin, size_t max_ranges); |
60 | | quicly_error_t quicly_recvstate_reset(quicly_recvstate_t *state, uint64_t eos_at, uint64_t *bytes_missing); |
61 | | |
62 | | /* inline definitions */ |
63 | | |
64 | | inline int quicly_recvstate_transfer_complete(quicly_recvstate_t *state) |
65 | 0 | { |
66 | 0 | return state->received.num_ranges == 0; |
67 | 0 | } Unexecuted instantiation: driver.cc:quicly_recvstate_transfer_complete(st_quicly_recvstate_t*) Unexecuted instantiation: driver_common.cc:quicly_recvstate_transfer_complete(st_quicly_recvstate_t*) Unexecuted instantiation: socket.c:quicly_recvstate_transfer_complete Unexecuted instantiation: config.c:quicly_recvstate_transfer_complete Unexecuted instantiation: configurator.c:quicly_recvstate_transfer_complete Unexecuted instantiation: context.c:quicly_recvstate_transfer_complete Unexecuted instantiation: headers.c:quicly_recvstate_transfer_complete Unexecuted instantiation: request.c:quicly_recvstate_transfer_complete Unexecuted instantiation: util.c:quicly_recvstate_transfer_complete Unexecuted instantiation: access_log.c:quicly_recvstate_transfer_complete Unexecuted instantiation: file.c:quicly_recvstate_transfer_complete Unexecuted instantiation: mimemap.c:quicly_recvstate_transfer_complete Unexecuted instantiation: proxy.c:quicly_recvstate_transfer_complete Unexecuted instantiation: http1.c:quicly_recvstate_transfer_complete Unexecuted instantiation: connection.c:quicly_recvstate_transfer_complete Unexecuted instantiation: scheduler.c:quicly_recvstate_transfer_complete Unexecuted instantiation: stream.c:quicly_recvstate_transfer_complete Unexecuted instantiation: http2_debug_state.c:quicly_recvstate_transfer_complete Unexecuted instantiation: common.c:quicly_recvstate_transfer_complete Unexecuted instantiation: server.c:quicly_recvstate_transfer_complete Unexecuted instantiation: cc-reno.c:quicly_recvstate_transfer_complete Unexecuted instantiation: defaults.c:quicly_recvstate_transfer_complete Unexecuted instantiation: quicly.c:quicly_recvstate_transfer_complete Unexecuted instantiation: recvstate.c:quicly_recvstate_transfer_complete Unexecuted instantiation: streambuf.c:quicly_recvstate_transfer_complete Unexecuted instantiation: http3client.c:quicly_recvstate_transfer_complete Unexecuted instantiation: httpclient.c:quicly_recvstate_transfer_complete Unexecuted instantiation: absprio.c:quicly_recvstate_transfer_complete Unexecuted instantiation: logconf.c:quicly_recvstate_transfer_complete Unexecuted instantiation: compress.c:quicly_recvstate_transfer_complete Unexecuted instantiation: gzip.c:quicly_recvstate_transfer_complete Unexecuted instantiation: headers_util.c:quicly_recvstate_transfer_complete Unexecuted instantiation: frame.c:quicly_recvstate_transfer_complete Unexecuted instantiation: qpack.c:quicly_recvstate_transfer_complete Unexecuted instantiation: cc-cubic.c:quicly_recvstate_transfer_complete Unexecuted instantiation: cc-pico.c:quicly_recvstate_transfer_complete Unexecuted instantiation: http1client.c:quicly_recvstate_transfer_complete Unexecuted instantiation: http2client.c:quicly_recvstate_transfer_complete |
68 | | |
69 | | inline size_t quicly_recvstate_bytes_available(quicly_recvstate_t *state) |
70 | 0 | { |
71 | 0 | uint64_t total = quicly_recvstate_transfer_complete(state) ? state->eos : state->received.ranges[0].end; |
72 | 0 | assert(state->data_off <= total); |
73 | 0 | return total - state->data_off; |
74 | 0 | } Unexecuted instantiation: driver.cc:quicly_recvstate_bytes_available(st_quicly_recvstate_t*) Unexecuted instantiation: driver_common.cc:quicly_recvstate_bytes_available(st_quicly_recvstate_t*) Unexecuted instantiation: socket.c:quicly_recvstate_bytes_available Unexecuted instantiation: config.c:quicly_recvstate_bytes_available Unexecuted instantiation: configurator.c:quicly_recvstate_bytes_available Unexecuted instantiation: context.c:quicly_recvstate_bytes_available Unexecuted instantiation: headers.c:quicly_recvstate_bytes_available Unexecuted instantiation: request.c:quicly_recvstate_bytes_available Unexecuted instantiation: util.c:quicly_recvstate_bytes_available Unexecuted instantiation: access_log.c:quicly_recvstate_bytes_available Unexecuted instantiation: file.c:quicly_recvstate_bytes_available Unexecuted instantiation: mimemap.c:quicly_recvstate_bytes_available Unexecuted instantiation: proxy.c:quicly_recvstate_bytes_available Unexecuted instantiation: http1.c:quicly_recvstate_bytes_available Unexecuted instantiation: connection.c:quicly_recvstate_bytes_available Unexecuted instantiation: scheduler.c:quicly_recvstate_bytes_available Unexecuted instantiation: stream.c:quicly_recvstate_bytes_available Unexecuted instantiation: http2_debug_state.c:quicly_recvstate_bytes_available Unexecuted instantiation: common.c:quicly_recvstate_bytes_available Unexecuted instantiation: server.c:quicly_recvstate_bytes_available Unexecuted instantiation: cc-reno.c:quicly_recvstate_bytes_available Unexecuted instantiation: defaults.c:quicly_recvstate_bytes_available Unexecuted instantiation: quicly.c:quicly_recvstate_bytes_available Unexecuted instantiation: recvstate.c:quicly_recvstate_bytes_available Unexecuted instantiation: streambuf.c:quicly_recvstate_bytes_available Unexecuted instantiation: http3client.c:quicly_recvstate_bytes_available Unexecuted instantiation: httpclient.c:quicly_recvstate_bytes_available Unexecuted instantiation: absprio.c:quicly_recvstate_bytes_available Unexecuted instantiation: logconf.c:quicly_recvstate_bytes_available Unexecuted instantiation: compress.c:quicly_recvstate_bytes_available Unexecuted instantiation: gzip.c:quicly_recvstate_bytes_available Unexecuted instantiation: headers_util.c:quicly_recvstate_bytes_available Unexecuted instantiation: frame.c:quicly_recvstate_bytes_available Unexecuted instantiation: qpack.c:quicly_recvstate_bytes_available Unexecuted instantiation: cc-cubic.c:quicly_recvstate_bytes_available Unexecuted instantiation: cc-pico.c:quicly_recvstate_bytes_available Unexecuted instantiation: http1client.c:quicly_recvstate_bytes_available Unexecuted instantiation: http2client.c:quicly_recvstate_bytes_available |
75 | | |
76 | | #ifdef __cplusplus |
77 | | } |
78 | | #endif |
79 | | |
80 | | #endif |