Lines Matching +full:use +full:- +full:ring +full:- +full:sense
2 * Copyright 2022-2023 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
25 * - NEW: The byte has not yet been transmitted, or has been lost and is
28 * - IN_FLIGHT: The byte has been transmitted but is awaiting
32 * - ACKED: The byte has been acknowledged and we can cease storing it.
39 * - in the NEW state if it is in new_set;
40 * - is in the ACKED state if it is in acked_set
42 * - is in the IN_FLIGHT state otherwise.
68 ring_buf_init(&qss->ring_buf); in ossl_quic_sstream_new()
69 if (!ring_buf_resize(&qss->ring_buf, init_buf_size, 0)) { in ossl_quic_sstream_new()
70 ring_buf_destroy(&qss->ring_buf, 0); in ossl_quic_sstream_new()
75 ossl_uint_set_init(&qss->new_set); in ossl_quic_sstream_new()
76 ossl_uint_set_init(&qss->acked_set); in ossl_quic_sstream_new()
85 ossl_uint_set_destroy(&qss->new_set); in ossl_quic_sstream_free()
86 ossl_uint_set_destroy(&qss->acked_set); in ossl_quic_sstream_free()
87 ring_buf_destroy(&qss->ring_buf, qss->cleanse); in ossl_quic_sstream_free()
100 UINT_SET_ITEM *range = ossl_list_uint_set_head(&qss->new_set); in ossl_quic_sstream_get_stream_frame()
114 if (!qss->have_final_size || qss->sent_final_size) in ossl_quic_sstream_get_stream_frame()
117 hdr->offset = qss->ring_buf.head_offset; in ossl_quic_sstream_get_stream_frame()
118 hdr->len = 0; in ossl_quic_sstream_get_stream_frame()
119 hdr->is_fin = 1; in ossl_quic_sstream_get_stream_frame()
131 max_len = range->range.end - range->range.start + 1; in ossl_quic_sstream_get_stream_frame()
137 if (!ring_buf_get_buf_at(&qss->ring_buf, in ossl_quic_sstream_get_stream_frame()
138 range->range.start + total_len, in ossl_quic_sstream_get_stream_frame()
148 src_len = (size_t)(max_len - total_len); in ossl_quic_sstream_get_stream_frame()
157 hdr->offset = range->range.start; in ossl_quic_sstream_get_stream_frame()
158 hdr->len = total_len; in ossl_quic_sstream_get_stream_frame()
159 hdr->is_fin = qss->have_final_size in ossl_quic_sstream_get_stream_frame()
160 && hdr->offset + hdr->len == qss->ring_buf.head_offset; in ossl_quic_sstream_get_stream_frame()
177 return qss->ring_buf.head_offset; in ossl_quic_sstream_get_cur_size()
189 if (!ossl_uint_set_remove(&qss->new_set, &r)) in ossl_quic_sstream_mark_transmitted()
202 if (!qss->have_final_size || final_size != qss->ring_buf.head_offset) in ossl_quic_sstream_mark_transmitted_fin()
205 qss->sent_final_size = 1; in ossl_quic_sstream_mark_transmitted_fin()
221 if (!ossl_uint_set_insert(&qss->new_set, &r)) in ossl_quic_sstream_mark_lost()
229 if (qss->acked_final_size) in ossl_quic_sstream_mark_lost_fin()
230 /* Does not make sense to lose a FIN after it has been ACKed */ in ossl_quic_sstream_mark_lost_fin()
234 qss->sent_final_size = 0; in ossl_quic_sstream_mark_lost_fin()
246 if (!ossl_uint_set_insert(&qss->acked_set, &r)) in ossl_quic_sstream_mark_acked()
255 if (!qss->have_final_size) in ossl_quic_sstream_mark_acked_fin()
259 qss->acked_final_size = 1; in ossl_quic_sstream_mark_acked_fin()
265 if (qss->have_final_size) in ossl_quic_sstream_fin()
268 qss->have_final_size = 1; in ossl_quic_sstream_fin()
273 if (!qss->have_final_size) in ossl_quic_sstream_get_final_size()
277 *final_size = qss->ring_buf.head_offset; in ossl_quic_sstream_get_final_size()
289 struct ring_buf old_ring_buf = qss->ring_buf; in ossl_quic_sstream_append()
291 if (qss->have_final_size) { in ossl_quic_sstream_append()
301 * the data here. We will later copy-and-encrypt the data during packet in ossl_quic_sstream_append()
302 * encryption, so this is a two-copy design. Supporting a one-copy design in in ossl_quic_sstream_append()
303 * the future will require applications to use a different kind of API. in ossl_quic_sstream_append()
308 l = ring_buf_push(&qss->ring_buf, buf, buf_len); in ossl_quic_sstream_append()
313 buf_len -= l; in ossl_quic_sstream_append()
319 r.end = r.start + consumed_ - 1; in ossl_quic_sstream_append()
320 assert(r.end + 1 == qss->ring_buf.head_offset); in ossl_quic_sstream_append()
321 if (!ossl_uint_set_insert(&qss->new_set, &r)) { in ossl_quic_sstream_append()
322 qss->ring_buf = old_ring_buf; in ossl_quic_sstream_append()
334 UINT_SET_ITEM *h = ossl_list_uint_set_head(&qss->acked_set); in qss_cull()
337 * Potentially cull data from our ring buffer. This can happen once data has in qss_cull()
340 * Since we use a ring buffer design for simplicity, we cannot cull byte n + in qss_cull()
341 * k (for k > 0) from the ring buffer until byte n has also been culled. in qss_cull()
345 * duration, and doesn't justify the use of a more complex design. in qss_cull()
350 * can only cull contiguous areas at the start of the ring buffer anyway. in qss_cull()
353 ring_buf_cpop_range(&qss->ring_buf, h->range.start, h->range.end, in qss_cull()
354 qss->cleanse); in qss_cull()
359 return ring_buf_resize(&qss->ring_buf, num_bytes, qss->cleanse); in ossl_quic_sstream_set_buffer_size()
364 return qss->ring_buf.alloc; in ossl_quic_sstream_get_buffer_size()
369 return ring_buf_used(&qss->ring_buf); in ossl_quic_sstream_get_buffer_used()
374 return ring_buf_avail(&qss->ring_buf); in ossl_quic_sstream_get_buffer_avail()
382 if (qss->have_final_size && !qss->acked_final_size) in ossl_quic_sstream_is_totally_acked()
388 if (ossl_list_uint_set_num(&qss->acked_set) != 1) in ossl_quic_sstream_is_totally_acked()
391 r = ossl_list_uint_set_head(&qss->acked_set)->range; in ossl_quic_sstream_is_totally_acked()
392 cur_size = qss->ring_buf.head_offset; in ossl_quic_sstream_is_totally_acked()
415 iov[i].buf_len = len - running; in ossl_quic_sstream_adjust_iov()
423 qss->cleanse = cleanse; in ossl_quic_sstream_set_cleanse()