Lines Matching refs:xso
28 static void aon_write_finish(QUIC_XSO *xso);
40 static void qc_set_default_xso(QUIC_CONNECTION *qc, QUIC_XSO *xso, int touch);
41 static void qc_set_default_xso_keep_ref(QUIC_CONNECTION *qc, QUIC_XSO *xso,
44 static int quic_validate_for_write(QUIC_XSO *xso, int *err);
57 * - whether a QSSO was passed (xso == NULL must not be used to determine this
74 QUIC_XSO *xso;
84 if (ctx->is_stream && ctx->xso != NULL)
85 ctx->xso->last_error = last_error;
171 * If QCTX_REMOTE_INIT is set, an auto-created default XSO is
174 * If it is not set, an auto-created default XSO is
249 * xso NULL NULL maybe non-NULL
261 QUIC_XSO *xso;
270 ctx->xso = NULL;
349 ctx->xso = qc->default_xso;
358 xso = (QUIC_XSO *)s;
359 ctx->obj = &xso->obj;
360 ctx->qd = xso->conn->domain;
361 ctx->ql = xso->conn->listener;
362 ctx->qc = xso->conn;
363 ctx->xso = xso;
440 * remote_init determines if we expect the default XSO to be remotely created or
441 * not. If it is -1, do not instantiate a default XSO if one does not yet exist.
464 * Like expect_quic_cs(), but fails if called on a QUIC_XSO. ctx->xso may still
660 * We do not create the default XSO yet. The reason for this is that the
661 * stream ID of the default XSO will depend on whether the stream is client
664 * or server-transmits-first protocol, we defer default XSO creation until
771 * When a QSSO is freed, the XSO is freed immediately, because the XSO
781 if ((ctx.xso->stream->send_state == QUIC_SSTREAM_STATE_READY
782 || ctx.xso->stream->send_state == QUIC_SSTREAM_STATE_SEND)
783 && !ossl_quic_sstream_get_final_size(ctx.xso->stream->sstream, NULL))
785 ctx.xso->stream, 0);
788 if (ctx.xso->stream->recv_state == QUIC_RSTREAM_STATE_RECV
789 || ctx.xso->stream->recv_state == QUIC_RSTREAM_STATE_SIZE_KNOWN)
791 ctx.xso->stream, 0);
794 ctx.xso->stream->deleted = 1;
796 ctx.xso->stream);
798 is_default = (ctx.xso == ctx.qc->default_xso);
802 * Unref the connection in most cases; the XSO has a ref to the QC and
803 * not vice versa. But for a default XSO, to avoid circular references,
804 * the QC refs the XSO but the XSO does not ref the QC. If we are the
805 * default XSO, we only get here when the QC is being torn down anyway,
811 /* Note: SSL_free calls OPENSSL_free(xso) for us */
816 * Free the default XSO, if any. The QUIC_STREAM is not deleted at this
820 QUIC_XSO *xso = ctx.qc->default_xso;
823 SSL_free(&xso->obj.ssl);
926 * Changes default XSO. Allows caller to keep reference to the old default XSO
927 * (if any). Reference to new XSO is transferred from caller.
930 static void qc_set_default_xso_keep_ref(QUIC_CONNECTION *qc, QUIC_XSO *xso,
938 if (qc->default_xso != xso) {
939 *old_xso = qc->default_xso; /* transfer old XSO ref to caller */
941 qc->default_xso = xso;
943 if (xso == NULL) {
945 * Changing to not having a default XSO. XSO becomes standalone and
952 * Changing from not having a default XSO to having one. The new XSO
956 * Currently we never change directly from one default XSO to
972 * Changes default XSO, releasing the reference to any previous default XSO.
973 * Reference to new XSO is transferred from caller.
976 static void qc_set_default_xso(QUIC_CONNECTION *qc, QUIC_XSO *xso, int touch)
980 qc_set_default_xso_keep_ref(qc, xso, touch, &old_xso);
987 static void xso_update_options(QUIC_XSO *xso)
989 int cleanse = ((xso->ssl_options & SSL_OP_CLEANSE_PLAINTEXT) != 0);
991 if (xso->stream->rstream != NULL)
992 ossl_quic_rstream_set_cleanse(xso->stream->rstream, cleanse);
994 if (xso->stream->sstream != NULL)
995 ossl_quic_sstream_set_cleanse(xso->stream->sstream, cleanse);
1005 * - configures the data-plane options on the default XSO, if there is one.
1039 if (ctx.xso != NULL) {
1040 ctx.xso->ssl_options
1041 = ((ctx.xso->ssl_options & ~mask_value) | or_value)
1044 xso_update_options(ctx.xso);
1047 ret = ctx.xso->ssl_options;
1632 if (ctx.xso != NULL) {
1634 if (ctx.xso->aon_write_in_progress)
1637 ctx.xso->ssl_mode |= (uint32_t)larg;
1638 return ctx.xso->ssl_mode;
1649 if (ctx.xso != NULL) {
1650 ctx.xso->ssl_mode &= ~(uint32_t)larg;
1651 return ctx.xso->ssl_mode;
2054 * Try to create the default XSO if it doesn't already exist. Returns 1 if the
2055 * default XSO was created. Returns 0 if it was not (e.g. because it already
2068 * default XSO we don't auto-create another one.
2194 * Now make qs the default stream, creating the necessary XSO.
2200 qc_touch_default_xso(qc); /* inhibits default XSO */
2207 QUIC_XSO *xso = NULL;
2209 if ((xso = OPENSSL_zalloc(sizeof(*xso))) == NULL) {
2214 if (!ossl_quic_obj_init(&xso->obj, qc->obj.ssl.ctx, SSL_TYPE_QUIC_XSO,
2220 /* XSO refs QC */
2226 xso->conn = qc;
2227 xso->ssl_mode = qc->default_ssl_mode;
2228 xso->ssl_options
2230 xso->last_error = SSL_ERROR_NONE;
2232 xso->stream = qs;
2235 xso_update_options(xso);
2236 return xso;
2239 OPENSSL_free(xso);
2267 QUIC_XSO *xso = NULL;
2314 xso = create_xso_from_stream(qc, qs);
2315 if (xso == NULL)
2318 qc_touch_default_xso(qc); /* inhibits default XSO */
2322 return &xso->obj.ssl;
2325 OPENSSL_free(xso);
2376 last_error = ctx.is_stream ? ctx.xso->last_error : ctx.qc->last_error;
2423 w = error_to_want(ctx.is_stream ? ctx.xso->last_error : ctx.qc->last_error);
2445 static void quic_post_write(QUIC_XSO *xso, int did_append,
2454 ossl_quic_stream_map_update_state(ossl_quic_channel_get_qsm(xso->conn->ch),
2455 xso->stream);
2458 ossl_quic_sstream_fin(xso->stream->sstream);
2467 ossl_quic_reactor_tick(ossl_quic_channel_get_reactor(xso->conn->ch), 0);
2471 QUIC_XSO *xso;
2514 static int xso_sstream_append(QUIC_XSO *xso, const unsigned char *buf,
2517 QUIC_SSTREAM *sstream = xso->stream->sstream;
2519 uint64_t cwm = ossl_quic_txfc_get_cwm(&xso->stream->txfc);
2537 if (!quic_mutation_allowed(args->xso->conn, /*req_active=*/1))
2541 if (!quic_validate_for_write(args->xso, &args->err))
2549 if (!xso_sstream_append(args->xso, args->buf, args->len, &actual_written))
2552 quic_post_write(args->xso, actual_written > 0,
2572 QUIC_XSO *xso = ctx->xso;
2577 if (!xso_sstream_append(xso, buf, len, &actual_written)) {
2583 quic_post_write(xso, actual_written > 0, actual_written == len, flags, 1);
2600 args.xso = xso;
2609 if (!quic_mutation_allowed(xso->conn, /*req_active=*/1))
2630 static void aon_write_begin(QUIC_XSO *xso, const unsigned char *buf,
2633 assert(!xso->aon_write_in_progress);
2635 xso->aon_write_in_progress = 1;
2636 xso->aon_buf_base = buf;
2637 xso->aon_buf_pos = already_sent;
2638 xso->aon_buf_len = buf_len;
2641 static void aon_write_finish(QUIC_XSO *xso)
2643 xso->aon_write_in_progress = 0;
2644 xso->aon_buf_base = NULL;
2645 xso->aon_buf_pos = 0;
2646 xso->aon_buf_len = 0;
2654 QUIC_XSO *xso = ctx->xso;
2658 = ((xso->ssl_mode & SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER) != 0);
2660 if (xso->aon_write_in_progress) {
2666 if ((!accept_moving_buffer && xso->aon_buf_base != buf)
2667 || len != xso->aon_buf_len)
2674 actual_buf = (unsigned char *)buf + xso->aon_buf_pos;
2675 actual_len = len - xso->aon_buf_pos;
2683 if (!xso_sstream_append(xso, actual_buf, actual_len, &actual_written)) {
2689 quic_post_write(xso, actual_written > 0, actual_written == actual_len,
2694 if (xso->aon_write_in_progress) {
2701 *written = xso->aon_buf_len;
2702 aon_write_finish(xso);
2710 if (xso->aon_write_in_progress) {
2717 xso->aon_buf_pos += actual_written;
2718 assert(xso->aon_buf_pos < xso->aon_buf_len);
2728 aon_write_begin(xso, buf, len, actual_written);
2742 QUIC_XSO *xso = ctx->xso;
2745 if (!xso_sstream_append(xso, buf, len, written)) {
2751 quic_post_write(xso, *written > 0, *written == len, flags,
2762 static int quic_validate_for_write(QUIC_XSO *xso, int *err)
2766 if (xso == NULL || xso->stream == NULL) {
2771 switch (xso->stream->send_state) {
2778 qsm = ossl_quic_channel_get_qsm(xso->conn->ch);
2780 if (!ossl_quic_stream_map_ensure_send_part_id(qsm, xso->stream)) {
2788 if (ossl_quic_sstream_get_final_size(xso->stream->sstream, NULL)) {
2816 /* Do not autocreate default XSO for zero-length writes. */
2826 partial_write = ((ctx.xso != NULL)
2827 ? ((ctx.xso->ssl_mode & SSL_MODE_ENABLE_PARTIAL_WRITE) != 0)
2850 if (len > 0 && !quic_validate_for_write(ctx.xso, &err)) {
2857 quic_post_write(ctx.xso, 0, 1, flags,
2896 static int quic_validate_for_read(QUIC_XSO *xso, int *err, int *eos)
2902 if (xso == NULL || xso->stream == NULL) {
2907 switch (xso->stream->recv_state) {
2923 qsm = ossl_quic_channel_get_qsm(xso->conn->ch);
2924 ossl_quic_stream_map_notify_app_read_reset_recv_part(qsm, xso->stream);
2943 if (!quic_validate_for_read(ctx->xso, &err, &eos)) {
2945 ctx->xso->retired_fin = 1;
2983 ossl_quic_stream_map_notify_totally_read(qsm, ctx->xso->stream);
2992 ctx->xso->retired_fin = 1;
3042 if (ctx.xso == NULL) {
3054 ctx.xso = ctx.qc->default_xso;
3057 if (!quic_read_actual(&ctx, ctx.xso->stream, buf, len, bytes_read, peek)) {
3081 args.stream = ctx.xso->stream;
3105 if (!quic_read_actual(&ctx, ctx.xso->stream, buf, len, bytes_read, peek)) {
3150 if (ctx.xso == NULL) {
3151 /* No XSO yet, but there might be a default XSO eligible to be created. */
3153 ctx.xso = ctx.qc->default_xso;
3160 if (ctx.xso->stream == NULL) {
3166 avail = ossl_quic_stream_recv_pending(ctx.xso->stream,
3171 avail = ossl_quic_stream_recv_pending(ctx.xso->stream,
3205 qs = ctx.xso->stream;
3213 if (!quic_validate_for_write(ctx.xso, &err)) {
3225 quic_post_write(ctx.xso, 1, 0, 0, qctx_should_autotick(&ctx));
3334 if (ctx.xso == NULL) {
3336 * If deferred XSO creation has yet to occur, proceed according to the
3349 if (ossl_quic_stream_is_bidi(ctx.xso->stream))
3352 if (ossl_quic_stream_is_server_init(ctx.xso->stream) != ctx.qc->as_server)
3371 id = ctx.xso->stream->id;
3390 is_local = ossl_quic_stream_is_local_init(ctx.xso->stream);
3440 QUIC_XSO *xso = NULL;
3447 /* Calling this function inhibits default XSO autocreation. */
3448 /* QC ref to any default XSO is transferred to us and to caller. */
3449 qc_set_default_xso_keep_ref(ctx.qc, NULL, /*touch=*/1, &xso);
3453 return xso != NULL ? &xso->obj.ssl : NULL;
3464 QUIC_XSO *xso;
3474 xso = (QUIC_XSO *)stream;
3485 * It is a caller error for the XSO being attached as a default XSO to have
3488 if (!CRYPTO_GET_REF(&xso->obj.ssl.references, &nref)) {
3501 /* Caller's reference to the XSO is transferred to us. */
3502 /* Calling this function inhibits default XSO autocreation. */
3503 qc_set_default_xso(ctx.qc, xso, /*touch=*/1);
3746 if (ctx->xso == NULL) {
3751 if (!ossl_quic_stream_has_send(ctx->xso->stream)) {
3756 if (ossl_quic_stream_has_send_buffer(ctx->xso->stream))
3757 value = getter(ctx->xso->stream->sstream);
3888 QUIC_XSO *xso;
3927 xso = create_xso_from_stream(ctx.qc, qs);
3928 if (xso == NULL)
3934 new_s = &xso->obj.ssl;
3936 /* Calling this function inhibits default XSO autocreation. */
3937 qc_touch_default_xso(ctx.qc); /* inhibits default XSO */
3983 qs = ctx.xso->stream;
3986 if (!quic_validate_for_write(ctx.xso, &err)) {
3993 ctx.xso->requested_reset = 1;
4071 quic_classify_stream(ctx.qc, ctx.xso->stream, is_write, &state, NULL);
4103 quic_classify_stream(ctx.qc, ctx.xso->stream, is_write,
4144 if (!ossl_quic_stream_has_send(ctx.xso->stream)) {
4150 if (!ossl_quic_stream_has_send_buffer(ctx.xso->stream)) {
4159 if (!ossl_quic_sstream_set_buffer_size(ctx.xso->stream->sstream, size)) {
5133 static int test_poll_event_r(QUIC_XSO *xso)
5151 if (xso->stream->recv_state == QUIC_RSTREAM_STATE_DATA_READ)
5154 return ossl_quic_stream_has_recv_buffer(xso->stream)
5155 && ossl_quic_rstream_available(xso->stream->rstream, &avail, &fin)
5156 && (avail > 0 || (fin && !xso->retired_fin));
5161 static int test_poll_event_er(QUIC_XSO *xso)
5163 return ossl_quic_stream_has_recv(xso->stream)
5164 && ossl_quic_stream_recv_is_reset(xso->stream)
5165 && !xso->retired_fin;
5170 static int test_poll_event_w(QUIC_XSO *xso)
5172 return !xso->conn->shutting_down
5173 && ossl_quic_stream_has_send_buffer(xso->stream)
5174 && ossl_quic_sstream_get_buffer_avail(xso->stream->sstream)
5175 && !ossl_quic_sstream_get_final_size(xso->stream->sstream, NULL)
5176 && ossl_quic_txfc_get_cwm(&xso->stream->txfc)
5177 > ossl_quic_sstream_get_cur_size(xso->stream->sstream)
5178 && quic_mutation_allowed(xso->conn, /*req_active=*/1);
5183 static int test_poll_event_ew(QUIC_XSO *xso)
5185 return ossl_quic_stream_has_send(xso->stream)
5186 && xso->stream->peer_stop_sending
5187 && !xso->requested_reset
5188 && !xso->conn->shutting_down;
5258 if (ctx.xso != NULL) {
5262 && test_poll_event_r(ctx.xso))
5266 && test_poll_event_er(ctx.xso))
5270 && test_poll_event_w(ctx.xso))
5274 && test_poll_event_ew(ctx.xso))