Lines Matching refs:ctx
29 static int create_channel(QUIC_CONNECTION *qc, SSL_CTX *ctx);
32 static int qc_try_create_default_xso_for_write(QCTX *ctx);
33 static int qc_wait_for_default_xso_for_read(QCTX *ctx, int peek);
36 static void qctx_lock_for_io(QCTX *ctx);
37 static int quic_do_handshake(QCTX *ctx);
43 static SSL *quic_conn_stream_new(QCTX *ctx, uint64_t flags, int need_lock);
46 static void qctx_maybe_autotick(QCTX *ctx);
47 static int qctx_should_autotick(QCTX *ctx);
79 static void quic_set_last_error(QCTX *ctx, int last_error) in quic_set_last_error() argument
81 if (!ctx->in_io) in quic_set_last_error()
84 if (ctx->is_stream && ctx->xso != NULL) in quic_set_last_error()
85 ctx->xso->last_error = last_error; in quic_set_last_error()
86 else if (!ctx->is_stream && ctx->qc != NULL) in quic_set_last_error()
87 ctx->qc->last_error = last_error; in quic_set_last_error()
96 static int quic_raise_normal_error(QCTX *ctx, in quic_raise_normal_error() argument
99 assert(ctx->in_io); in quic_raise_normal_error()
100 quic_set_last_error(ctx, err); in quic_raise_normal_error()
116 static int quic_raise_non_normal_error(QCTX *ctx, in quic_raise_non_normal_error() argument
126 if (ctx != NULL) { in quic_raise_non_normal_error()
127 quic_set_last_error(ctx, SSL_ERROR_SSL); in quic_raise_non_normal_error()
129 if (reason == SSL_R_PROTOCOL_IS_SHUTDOWN && ctx->qc != NULL) in quic_raise_non_normal_error()
130 ossl_quic_channel_restore_err_state(ctx->qc->ch); in quic_raise_non_normal_error()
143 #define QUIC_RAISE_NORMAL_ERROR(ctx, err) \ argument
144 quic_raise_normal_error((ctx), (err))
146 #define QUIC_RAISE_NON_NORMAL_ERROR(ctx, reason, msg) \ argument
147 quic_raise_non_normal_error((ctx), \
255 static int expect_quic_as(const SSL *s, QCTX *ctx, uint32_t flags) in expect_quic_as() argument
266 ctx->obj = NULL; in expect_quic_as()
267 ctx->qd = NULL; in expect_quic_as()
268 ctx->ql = NULL; in expect_quic_as()
269 ctx->qc = NULL; in expect_quic_as()
270 ctx->xso = NULL; in expect_quic_as()
271 ctx->is_stream = 0; in expect_quic_as()
272 ctx->is_listener = 0; in expect_quic_as()
273 ctx->is_domain = 0; in expect_quic_as()
274 ctx->in_io = ((flags & QCTX_IO) != 0); in expect_quic_as()
289 ctx->obj = &qd->obj; in expect_quic_as()
290 ctx->qd = qd; in expect_quic_as()
291 ctx->is_domain = 1; in expect_quic_as()
301 ctx->obj = &ql->obj; in expect_quic_as()
302 ctx->qd = ql->domain; in expect_quic_as()
303 ctx->ql = ql; in expect_quic_as()
304 ctx->is_listener = 1; in expect_quic_as()
309 ctx->obj = &qc->obj; in expect_quic_as()
310 ctx->qd = qc->domain; in expect_quic_as()
311 ctx->ql = qc->listener; /* never changes, so can be read without lock */ in expect_quic_as()
312 ctx->qc = qc; in expect_quic_as()
316 qctx_lock_for_io(ctx); in expect_quic_as()
318 qctx_lock(ctx); in expect_quic_as()
325 QUIC_RAISE_NON_NORMAL_ERROR(ctx, SSL_R_PROTOCOL_IS_SHUTDOWN, NULL); in expect_quic_as()
330 if (quic_do_handshake(ctx) < 1) in expect_quic_as()
335 if (!qc_wait_for_default_xso_for_read(ctx, /*peek=*/0)) in expect_quic_as()
338 if (!qc_try_create_default_xso_for_write(ctx)) in expect_quic_as()
349 ctx->xso = qc->default_xso; in expect_quic_as()
359 ctx->obj = &xso->obj; in expect_quic_as()
360 ctx->qd = xso->conn->domain; in expect_quic_as()
361 ctx->ql = xso->conn->listener; in expect_quic_as()
362 ctx->qc = xso->conn; in expect_quic_as()
363 ctx->xso = xso; in expect_quic_as()
364 ctx->is_stream = 1; in expect_quic_as()
374 qctx_lock_for_io(ctx); in expect_quic_as()
376 qctx_lock(ctx); in expect_quic_as()
384 qctx_unlock(ctx); in expect_quic_as()
389 static int is_quic_c(const SSL *s, QCTX *ctx, int raiseerrs) in is_quic_c() argument
395 return expect_quic_as(s, ctx, flags); in is_quic_c()
399 static int is_quic_cs(const SSL *s, QCTX *ctx, int raiseerrs) in is_quic_cs() argument
405 return expect_quic_as(s, ctx, flags); in is_quic_cs()
408 static int expect_quic_cs(const SSL *s, QCTX *ctx) in expect_quic_cs() argument
410 return expect_quic_as(s, ctx, QCTX_C | QCTX_S); in expect_quic_cs()
413 static int expect_quic_csl(const SSL *s, QCTX *ctx) in expect_quic_csl() argument
415 return expect_quic_as(s, ctx, QCTX_C | QCTX_S | QCTX_L); in expect_quic_csl()
418 static int expect_quic_csld(const SSL *s, QCTX *ctx) in expect_quic_csld() argument
420 return expect_quic_as(s, ctx, QCTX_C | QCTX_S | QCTX_L | QCTX_D); in expect_quic_csld()
425 static int expect_quic_listener(const SSL *s, QCTX *ctx) in expect_quic_listener() argument
427 return expect_quic_as(s, ctx, QCTX_L); in expect_quic_listener()
430 static int expect_quic_domain(const SSL *s, QCTX *ctx) in expect_quic_domain() argument
432 return expect_quic_as(s, ctx, QCTX_D); in expect_quic_domain()
447 int in_io, QCTX *ctx) in expect_quic_with_stream_lock() argument
460 return expect_quic_as(s, ctx, flags); in expect_quic_with_stream_lock()
467 static int ossl_unused expect_quic_conn_only(const SSL *s, QCTX *ctx) in expect_quic_conn_only() argument
469 return expect_quic_as(s, ctx, QCTX_C); in expect_quic_conn_only()
478 static void qctx_lock(QCTX *ctx) in qctx_lock() argument
481 assert(ctx->obj != NULL); in qctx_lock()
482 ossl_crypto_mutex_lock(ossl_quic_obj_get0_mutex(ctx->obj)); in qctx_lock()
488 static void qctx_unlock(QCTX *ctx) in qctx_unlock() argument
491 assert(ctx->obj != NULL); in qctx_unlock()
492 ossl_crypto_mutex_unlock(ossl_quic_obj_get0_mutex(ctx->obj)); in qctx_unlock()
496 static void qctx_lock_for_io(QCTX *ctx) in qctx_lock_for_io() argument
498 qctx_lock(ctx); in qctx_lock_for_io()
499 ctx->in_io = 1; in qctx_lock_for_io()
507 quic_set_last_error(ctx, SSL_ERROR_NONE); in qctx_lock_for_io()
531 static int qctx_is_top_level(QCTX *ctx) in qctx_is_top_level() argument
533 return ctx->obj->parent_obj == NULL; in qctx_is_top_level()
536 static int qctx_blocking(QCTX *ctx) in qctx_blocking() argument
538 return ossl_quic_obj_blocking(ctx->obj); in qctx_blocking()
548 static int block_until_pred(QCTX *ctx, in block_until_pred() argument
555 qeng = ossl_quic_obj_get0_engine(ctx->obj); in block_until_pred()
586 SSL *ossl_quic_new(SSL_CTX *ctx) in ossl_quic_new() argument
595 if (ctx->method == OSSL_QUIC_server_method()) { in ossl_quic_new()
615 qc->tls = ossl_ssl_connection_new_int(ctx, &qc->obj.ssl, TLS_method()); in ossl_quic_new()
631 = ((ctx->domain_flags & SSL_DOMAIN_FLAG_THREAD_ASSISTED) != 0); in ossl_quic_new()
637 if (!create_channel(qc, ctx)) in ossl_quic_new()
640 ossl_quic_channel_set_msg_callback(qc->ch, ctx->msg_callback, &qc->obj.ssl); in ossl_quic_new()
641 ossl_quic_channel_set_msg_callback_arg(qc->ch, ctx->msg_callback_arg); in ossl_quic_new()
644 if (!ossl_quic_obj_init(&qc->obj, ctx, SSL_TYPE_QUIC_CONNECTION, NULL, in ossl_quic_new()
652 qc->default_ssl_mode = qc->obj.ssl.ctx->mode; in ossl_quic_new()
653 qc->default_ssl_options = qc->obj.ssl.ctx->options & OSSL_QUIC_PERMITTED_OPTIONS; in ossl_quic_new()
721 static void quic_free_listener(QCTX *ctx) in quic_free_listener() argument
723 quic_unref_port_bios(ctx->ql->port); in quic_free_listener()
724 ossl_quic_port_drop_incoming(ctx->ql->port); in quic_free_listener()
725 ossl_quic_port_free(ctx->ql->port); in quic_free_listener()
727 if (ctx->ql->domain == NULL) { in quic_free_listener()
728 ossl_quic_engine_free(ctx->ql->engine); in quic_free_listener()
730 ossl_crypto_mutex_free(&ctx->ql->mutex); in quic_free_listener()
733 SSL_free(&ctx->ql->domain->obj.ssl); in quic_free_listener()
739 static void quic_free_domain(QCTX *ctx) in quic_free_domain() argument
741 ossl_quic_engine_free(ctx->qd->engine); in quic_free_domain()
743 ossl_crypto_mutex_free(&ctx->qd->mutex); in quic_free_domain()
750 QCTX ctx; in ossl_quic_free() local
754 if (!expect_quic_any(s, &ctx)) in ossl_quic_free()
757 if (ctx.is_domain) { in ossl_quic_free()
758 quic_free_domain(&ctx); in ossl_quic_free()
762 if (ctx.is_listener) { in ossl_quic_free()
763 quic_free_listener(&ctx); in ossl_quic_free()
767 qctx_lock(&ctx); in ossl_quic_free()
769 if (ctx.is_stream) { in ossl_quic_free()
777 assert(ctx.qc->num_xso > 0); in ossl_quic_free()
778 --ctx.qc->num_xso; in ossl_quic_free()
781 if (( ctx.xso->stream->send_state == QUIC_SSTREAM_STATE_READY in ossl_quic_free()
782 || ctx.xso->stream->send_state == QUIC_SSTREAM_STATE_SEND) in ossl_quic_free()
783 && !ossl_quic_sstream_get_final_size(ctx.xso->stream->sstream, NULL)) in ossl_quic_free()
784 ossl_quic_stream_map_reset_stream_send_part(ossl_quic_channel_get_qsm(ctx.qc->ch), in ossl_quic_free()
785 ctx.xso->stream, 0); in ossl_quic_free()
788 if ( ctx.xso->stream->recv_state == QUIC_RSTREAM_STATE_RECV in ossl_quic_free()
789 || ctx.xso->stream->recv_state == QUIC_RSTREAM_STATE_SIZE_KNOWN) in ossl_quic_free()
790 ossl_quic_stream_map_stop_sending_recv_part(ossl_quic_channel_get_qsm(ctx.qc->ch), in ossl_quic_free()
791 ctx.xso->stream, 0); in ossl_quic_free()
794 ctx.xso->stream->deleted = 1; in ossl_quic_free()
795 ossl_quic_stream_map_update_state(ossl_quic_channel_get_qsm(ctx.qc->ch), in ossl_quic_free()
796 ctx.xso->stream); in ossl_quic_free()
798 is_default = (ctx.xso == ctx.qc->default_xso); in ossl_quic_free()
799 qctx_unlock(&ctx); in ossl_quic_free()
809 SSL_free(&ctx.qc->obj.ssl); in ossl_quic_free()
819 if (ctx.qc->default_xso != NULL) { in ossl_quic_free()
820 QUIC_XSO *xso = ctx.qc->default_xso; in ossl_quic_free()
822 qctx_unlock(&ctx); in ossl_quic_free()
824 qctx_lock(&ctx); in ossl_quic_free()
825 ctx.qc->default_xso = NULL; in ossl_quic_free()
829 assert(ctx.qc->num_xso == 0); in ossl_quic_free()
832 if (ctx.qc->is_thread_assisted && ctx.qc->started) { in ossl_quic_free()
833 ossl_quic_thread_assist_wait_stopped(&ctx.qc->thread_assist); in ossl_quic_free()
834 ossl_quic_thread_assist_cleanup(&ctx.qc->thread_assist); in ossl_quic_free()
842 qc_cleanup(ctx.qc, /*have_lock=*/1); in ossl_quic_free()
845 if (ctx.qc->listener != NULL) in ossl_quic_free()
846 SSL_free(&ctx.qc->listener->obj.ssl); in ossl_quic_free()
847 if (ctx.qc->domain != NULL) in ossl_quic_free()
848 SSL_free(&ctx.qc->domain->obj.ssl); in ossl_quic_free()
867 QCTX ctx; in ossl_quic_reset() local
869 if (!expect_quic_any(s, &ctx)) in ossl_quic_reset()
879 QCTX ctx; in ossl_quic_clear() local
881 if (!expect_quic_any(s, &ctx)) in ossl_quic_clear()
892 QCTX ctx; in ossl_quic_set_override_now_cb() local
894 if (!expect_quic_any(s, &ctx)) in ossl_quic_set_override_now_cb()
897 qctx_lock(&ctx); in ossl_quic_set_override_now_cb()
899 ossl_quic_engine_set_time_cb(ctx.obj->engine, now_cb, now_cb_arg); in ossl_quic_set_override_now_cb()
901 qctx_unlock(&ctx); in ossl_quic_set_override_now_cb()
907 QCTX ctx; in ossl_quic_conn_force_assist_thread_wake() local
909 if (!expect_quic_conn_only(s, &ctx)) in ossl_quic_conn_force_assist_thread_wake()
913 if (ctx.qc->is_thread_assisted && ctx.qc->started) in ossl_quic_conn_force_assist_thread_wake()
914 ossl_quic_thread_assist_notify_deadline_changed(&ctx.qc->thread_assist); in ossl_quic_conn_force_assist_thread_wake()
1013 QCTX ctx; in quic_mask_or_options() local
1016 if (!expect_quic_cs(ssl, &ctx)) in quic_mask_or_options()
1019 qctx_lock(&ctx); in quic_mask_or_options()
1021 if (!ctx.is_stream) { in quic_mask_or_options()
1029 SSL_clear_options(ctx.qc->tls, hs_mask_value); in quic_mask_or_options()
1030 SSL_set_options(ctx.qc->tls, hs_or_value); in quic_mask_or_options()
1033 ctx.qc->default_ssl_options in quic_mask_or_options()
1034 = ((ctx.qc->default_ssl_options & ~mask_value) | or_value) in quic_mask_or_options()
1038 ret = ctx.qc->default_ssl_options; in quic_mask_or_options()
1039 if (ctx.xso != NULL) { in quic_mask_or_options()
1040 ctx.xso->ssl_options in quic_mask_or_options()
1041 = ((ctx.xso->ssl_options & ~mask_value) | or_value) in quic_mask_or_options()
1044 xso_update_options(ctx.xso); in quic_mask_or_options()
1046 if (ctx.is_stream) in quic_mask_or_options()
1047 ret = ctx.xso->ssl_options; in quic_mask_or_options()
1050 qctx_unlock(&ctx); in quic_mask_or_options()
1184 QCTX ctx; in ossl_quic_conn_set0_net_rbio() local
1186 if (!expect_quic_csl(s, &ctx)) in ossl_quic_conn_set0_net_rbio()
1190 if (!quic_set0_net_rbio(ctx.obj, net_rbio)) in ossl_quic_conn_set0_net_rbio()
1196 QCTX ctx; in ossl_quic_conn_set0_net_wbio() local
1198 if (!expect_quic_csl(s, &ctx)) in ossl_quic_conn_set0_net_wbio()
1202 if (!quic_set0_net_wbio(ctx.obj, net_wbio)) in ossl_quic_conn_set0_net_wbio()
1208 QCTX ctx; in ossl_quic_conn_get_net_rbio() local
1211 if (!expect_quic_csl(s, &ctx)) in ossl_quic_conn_get_net_rbio()
1214 port = ossl_quic_obj_get0_port(ctx.obj); in ossl_quic_conn_get_net_rbio()
1221 QCTX ctx; in ossl_quic_conn_get_net_wbio() local
1224 if (!expect_quic_csl(s, &ctx)) in ossl_quic_conn_get_net_wbio()
1227 port = ossl_quic_obj_get0_port(ctx.obj); in ossl_quic_conn_get_net_wbio()
1234 QCTX ctx; in ossl_quic_conn_get_blocking_mode() local
1236 if (!expect_quic_csl(s, &ctx)) in ossl_quic_conn_get_blocking_mode()
1239 return qctx_blocking(&ctx); in ossl_quic_conn_get_blocking_mode()
1247 QCTX ctx; in ossl_quic_conn_set_blocking_mode() local
1249 if (!expect_quic_csl(s, &ctx)) in ossl_quic_conn_set_blocking_mode()
1252 qctx_lock(&ctx); in ossl_quic_conn_set_blocking_mode()
1260 if (qctx_is_top_level(&ctx)) in ossl_quic_conn_set_blocking_mode()
1261 ossl_quic_engine_update_poll_descriptors(ctx.obj->engine, /*force=*/1); in ossl_quic_conn_set_blocking_mode()
1264 if (!ossl_quic_obj_can_support_blocking(ctx.obj)) { in ossl_quic_conn_set_blocking_mode()
1265 ret = QUIC_RAISE_NON_NORMAL_ERROR(&ctx, ERR_R_UNSUPPORTED, NULL); in ossl_quic_conn_set_blocking_mode()
1274 ossl_quic_obj_set_blocking_mode(ctx.obj, mode); in ossl_quic_conn_set_blocking_mode()
1278 qctx_unlock(&ctx); in ossl_quic_conn_set_blocking_mode()
1285 QCTX ctx; in ossl_quic_conn_set_initial_peer_addr() local
1287 if (!expect_quic_cs(s, &ctx)) in ossl_quic_conn_set_initial_peer_addr()
1290 if (ctx.qc->started) in ossl_quic_conn_set_initial_peer_addr()
1291 return QUIC_RAISE_NON_NORMAL_ERROR(&ctx, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED, in ossl_quic_conn_set_initial_peer_addr()
1295 BIO_ADDR_clear(&ctx.qc->init_peer_addr); in ossl_quic_conn_set_initial_peer_addr()
1299 return BIO_ADDR_copy(&ctx.qc->init_peer_addr, peer_addr); in ossl_quic_conn_set_initial_peer_addr()
1316 QCTX ctx; in ossl_quic_handle_events() local
1318 if (!expect_quic_any(s, &ctx)) in ossl_quic_handle_events()
1321 qctx_lock(&ctx); in ossl_quic_handle_events()
1322 ossl_quic_reactor_tick(ossl_quic_obj_get0_reactor(ctx.obj), 0); in ossl_quic_handle_events()
1323 qctx_unlock(&ctx); in ossl_quic_handle_events()
1337 QCTX ctx; in ossl_quic_get_event_timeout() local
1342 if (!expect_quic_any(s, &ctx)) in ossl_quic_get_event_timeout()
1345 qctx_lock(&ctx); in ossl_quic_get_event_timeout()
1347 reactor = ossl_quic_obj_get0_reactor(ctx.obj); in ossl_quic_get_event_timeout()
1351 qctx_unlock(&ctx); in ossl_quic_get_event_timeout()
1363 basetime = ossl_quic_engine_get_time(ctx.obj->engine); in ossl_quic_get_event_timeout()
1365 qctx_unlock(&ctx); in ossl_quic_get_event_timeout()
1376 QCTX ctx; in ossl_quic_get_rpoll_descriptor() local
1380 if (!expect_quic_csl(s, &ctx)) in ossl_quic_get_rpoll_descriptor()
1383 port = ossl_quic_obj_get0_port(ctx.obj); in ossl_quic_get_rpoll_descriptor()
1386 return QUIC_RAISE_NON_NORMAL_ERROR(&ctx, ERR_R_PASSED_INVALID_ARGUMENT, in ossl_quic_get_rpoll_descriptor()
1395 QCTX ctx; in ossl_quic_get_wpoll_descriptor() local
1399 if (!expect_quic_csl(s, &ctx)) in ossl_quic_get_wpoll_descriptor()
1402 port = ossl_quic_obj_get0_port(ctx.obj); in ossl_quic_get_wpoll_descriptor()
1405 return QUIC_RAISE_NON_NORMAL_ERROR(&ctx, ERR_R_PASSED_INVALID_ARGUMENT, in ossl_quic_get_wpoll_descriptor()
1415 QCTX ctx; in ossl_quic_get_net_read_desired() local
1418 if (!expect_quic_csl(s, &ctx)) in ossl_quic_get_net_read_desired()
1421 qctx_lock(&ctx); in ossl_quic_get_net_read_desired()
1422 ret = ossl_quic_reactor_net_read_desired(ossl_quic_obj_get0_reactor(ctx.obj)); in ossl_quic_get_net_read_desired()
1423 qctx_unlock(&ctx); in ossl_quic_get_net_read_desired()
1432 QCTX ctx; in ossl_quic_get_net_write_desired() local
1434 if (!expect_quic_csl(s, &ctx)) in ossl_quic_get_net_write_desired()
1437 qctx_lock(&ctx); in ossl_quic_get_net_write_desired()
1438 ret = ossl_quic_reactor_net_write_desired(ossl_quic_obj_get0_reactor(ctx.obj)); in ossl_quic_get_net_write_desired()
1439 qctx_unlock(&ctx); in ossl_quic_get_net_write_desired()
1540 QCTX ctx; in ossl_quic_conn_shutdown() local
1545 if (!expect_quic_cs(s, &ctx)) in ossl_quic_conn_shutdown()
1548 if (ctx.is_stream) { in ossl_quic_conn_shutdown()
1549 QUIC_RAISE_NON_NORMAL_ERROR(&ctx, SSL_R_CONN_USE_ONLY, NULL); in ossl_quic_conn_shutdown()
1553 qctx_lock(&ctx); in ossl_quic_conn_shutdown()
1555 if (ossl_quic_channel_is_terminated(ctx.qc->ch)) { in ossl_quic_conn_shutdown()
1556 qctx_unlock(&ctx); in ossl_quic_conn_shutdown()
1568 ossl_quic_channel_set_tcause(ctx.qc->ch, args->quic_error_code, in ossl_quic_conn_shutdown()
1575 qc_shutdown_flush_init(ctx.qc); in ossl_quic_conn_shutdown()
1577 if (!qc_shutdown_flush_finished(ctx.qc)) { in ossl_quic_conn_shutdown()
1578 if (!no_block && qctx_blocking(&ctx)) { in ossl_quic_conn_shutdown()
1579 ret = block_until_pred(&ctx, quic_shutdown_flush_wait, ctx.qc, 0); in ossl_quic_conn_shutdown()
1585 qctx_maybe_autotick(&ctx); in ossl_quic_conn_shutdown()
1589 if (!qc_shutdown_flush_finished(ctx.qc)) { in ossl_quic_conn_shutdown()
1590 qctx_unlock(&ctx); in ossl_quic_conn_shutdown()
1596 if (wait_peer && !ossl_quic_channel_is_term_any(ctx.qc->ch)) { in ossl_quic_conn_shutdown()
1597 if (!no_block && qctx_blocking(&ctx)) { in ossl_quic_conn_shutdown()
1598 ret = block_until_pred(&ctx, quic_shutdown_peer_wait, ctx.qc, 0); in ossl_quic_conn_shutdown()
1604 qctx_maybe_autotick(&ctx); in ossl_quic_conn_shutdown()
1607 if (!ossl_quic_channel_is_term_any(ctx.qc->ch)) { in ossl_quic_conn_shutdown()
1619 ctx.qc->shutting_down = 1; in ossl_quic_conn_shutdown()
1625 ossl_quic_channel_local_close(ctx.qc->ch, in ossl_quic_conn_shutdown()
1629 SSL_set_shutdown(ctx.qc->tls, SSL_SENT_SHUTDOWN); in ossl_quic_conn_shutdown()
1631 if (ossl_quic_channel_is_terminated(ctx.qc->ch)) { in ossl_quic_conn_shutdown()
1632 qctx_unlock(&ctx); in ossl_quic_conn_shutdown()
1637 if (!no_block && qctx_blocking(&ctx) in ossl_quic_conn_shutdown()
1639 ret = block_until_pred(&ctx, quic_shutdown_wait, ctx.qc, 0); in ossl_quic_conn_shutdown()
1645 qctx_maybe_autotick(&ctx); in ossl_quic_conn_shutdown()
1648 ret = ossl_quic_channel_is_terminated(ctx.qc->ch); in ossl_quic_conn_shutdown()
1650 qctx_unlock(&ctx); in ossl_quic_conn_shutdown()
1657 QCTX ctx; in ossl_quic_ctrl() local
1659 if (!expect_quic_csl(s, &ctx)) in ossl_quic_ctrl()
1664 if (ctx.is_listener) in ossl_quic_ctrl()
1665 return QUIC_RAISE_NON_NORMAL_ERROR(&ctx, ERR_R_UNSUPPORTED, NULL); in ossl_quic_ctrl()
1668 if (!ctx.is_stream) in ossl_quic_ctrl()
1669 ctx.qc->default_ssl_mode |= (uint32_t)larg; in ossl_quic_ctrl()
1675 if (ctx.xso != NULL) { in ossl_quic_ctrl()
1677 if (ctx.xso->aon_write_in_progress) in ossl_quic_ctrl()
1680 ctx.xso->ssl_mode |= (uint32_t)larg; in ossl_quic_ctrl()
1681 return ctx.xso->ssl_mode; in ossl_quic_ctrl()
1684 return ctx.qc->default_ssl_mode; in ossl_quic_ctrl()
1686 if (ctx.is_listener) in ossl_quic_ctrl()
1687 return QUIC_RAISE_NON_NORMAL_ERROR(&ctx, ERR_R_UNSUPPORTED, NULL); in ossl_quic_ctrl()
1689 if (!ctx.is_stream) in ossl_quic_ctrl()
1690 ctx.qc->default_ssl_mode &= ~(uint32_t)larg; in ossl_quic_ctrl()
1692 if (ctx.xso != NULL) { in ossl_quic_ctrl()
1693 ctx.xso->ssl_mode &= ~(uint32_t)larg; in ossl_quic_ctrl()
1694 return ctx.xso->ssl_mode; in ossl_quic_ctrl()
1697 return ctx.qc->default_ssl_mode; in ossl_quic_ctrl()
1700 if (ctx.is_listener) in ossl_quic_ctrl()
1701 return QUIC_RAISE_NON_NORMAL_ERROR(&ctx, ERR_R_UNSUPPORTED, NULL); in ossl_quic_ctrl()
1703 ossl_quic_channel_set_msg_callback_arg(ctx.qc->ch, parg); in ossl_quic_ctrl()
1705 return SSL_ctrl(ctx.qc->tls, cmd, larg, parg); in ossl_quic_ctrl()
1737 if (ctx.is_listener) in ossl_quic_ctrl()
1738 return QUIC_RAISE_NON_NORMAL_ERROR(&ctx, ERR_R_UNSUPPORTED, NULL); in ossl_quic_ctrl()
1740 return ossl_ctrl_internal(&ctx.qc->obj.ssl, cmd, larg, parg, /*no_quic=*/1); in ossl_quic_ctrl()
1747 QCTX ctx; in ossl_quic_set_connect_state() local
1749 if (!is_quic_c(s, &ctx, raiseerrs)) in ossl_quic_set_connect_state()
1752 if (ctx.qc->as_server_state == 0) in ossl_quic_set_connect_state()
1756 if (ctx.qc->started) { in ossl_quic_set_connect_state()
1762 ctx.qc->as_server_state = 0; in ossl_quic_set_connect_state()
1769 QCTX ctx; in ossl_quic_set_accept_state() local
1771 if (!is_quic_c(s, &ctx, raiseerrs)) in ossl_quic_set_accept_state()
1774 if (ctx.qc->as_server_state == 1) in ossl_quic_set_accept_state()
1778 if (ctx.qc->started) { in ossl_quic_set_accept_state()
1784 ctx.qc->as_server_state = 1; in ossl_quic_set_accept_state()
1839 static int create_channel(QUIC_CONNECTION *qc, SSL_CTX *ctx) in create_channel() argument
1844 engine_args.libctx = ctx->libctx; in create_channel()
1845 engine_args.propq = ctx->propq; in create_channel()
1850 if (need_notifier_for_domain_flags(ctx->domain_flags)) in create_channel()
1859 port_args.channel_ctx = ctx; in create_channel()
1883 static int ensure_channel_started(QCTX *ctx) in ensure_channel_started() argument
1885 QUIC_CONNECTION *qc = ctx->qc; in ensure_channel_started()
1889 QUIC_RAISE_NON_NORMAL_ERROR(ctx, ERR_R_INTERNAL_ERROR, in ensure_channel_started()
1896 QUIC_RAISE_NON_NORMAL_ERROR(ctx, ERR_R_INTERNAL_ERROR, in ensure_channel_started()
1904 QUIC_RAISE_NON_NORMAL_ERROR(ctx, ERR_R_INTERNAL_ERROR, in ensure_channel_started()
1916 static int quic_do_handshake(QCTX *ctx) in quic_do_handshake() argument
1919 QUIC_CONNECTION *qc = ctx->qc; in quic_do_handshake()
1928 return QUIC_RAISE_NON_NORMAL_ERROR(ctx, SSL_R_PROTOCOL_IS_SHUTDOWN, NULL); in quic_do_handshake()
1931 QUIC_RAISE_NON_NORMAL_ERROR(ctx, ERR_R_PASSED_INVALID_ARGUMENT, NULL); in quic_do_handshake()
1935 port = ossl_quic_obj_get0_port(ctx->obj); in quic_do_handshake()
1940 QUIC_RAISE_NON_NORMAL_ERROR(ctx, SSL_R_BIO_NOT_SET, NULL); in quic_do_handshake()
1972 QUIC_RAISE_NON_NORMAL_ERROR(ctx, SSL_R_REMOTE_PEER_ADDRESS_NOT_SET, NULL); in quic_do_handshake()
1980 if (!ensure_channel_started(ctx)) /* raises on failure */ in quic_do_handshake()
1987 if (!qctx_blocking(ctx)) { in quic_do_handshake()
1989 qctx_maybe_autotick(ctx); in quic_do_handshake()
1996 QUIC_RAISE_NON_NORMAL_ERROR(ctx, SSL_R_PROTOCOL_IS_SHUTDOWN, NULL); in quic_do_handshake()
2013 if (qctx_blocking(ctx)) { in quic_do_handshake()
2019 ret = block_until_pred(ctx, quic_handshake_wait, &args, 0); in quic_do_handshake()
2021 QUIC_RAISE_NON_NORMAL_ERROR(ctx, SSL_R_PROTOCOL_IS_SHUTDOWN, NULL); in quic_do_handshake()
2024 QUIC_RAISE_NON_NORMAL_ERROR(ctx, ERR_R_INTERNAL_ERROR, NULL); in quic_do_handshake()
2029 QUIC_RAISE_NORMAL_ERROR(ctx, SSL_get_error(qc->tls, 0)); in quic_do_handshake()
2038 QUIC_RAISE_NORMAL_ERROR(ctx, SSL_get_error(qc->tls, 0)); in quic_do_handshake()
2046 QUIC_RAISE_NORMAL_ERROR(ctx, SSL_ERROR_WANT_READ); in quic_do_handshake()
2054 QCTX ctx; in ossl_quic_do_handshake() local
2056 if (!expect_quic_cs(s, &ctx)) in ossl_quic_do_handshake()
2059 qctx_lock_for_io(&ctx); in ossl_quic_do_handshake()
2061 ret = quic_do_handshake(&ctx); in ossl_quic_do_handshake()
2062 qctx_unlock(&ctx); in ossl_quic_do_handshake()
2102 static int qc_try_create_default_xso_for_write(QCTX *ctx) in qc_try_create_default_xso_for_write() argument
2105 QUIC_CONNECTION *qc = ctx->qc; in qc_try_create_default_xso_for_write()
2113 return QUIC_RAISE_NON_NORMAL_ERROR(ctx, SSL_R_NO_STREAM, NULL); in qc_try_create_default_xso_for_write()
2119 qc_set_default_xso(qc, (QUIC_XSO *)quic_conn_stream_new(ctx, flags, in qc_try_create_default_xso_for_write()
2123 return QUIC_RAISE_NON_NORMAL_ERROR(ctx, ERR_R_INTERNAL_ERROR, NULL); in qc_try_create_default_xso_for_write()
2132 QCTX *ctx; member
2143 QUIC_RAISE_NON_NORMAL_ERROR(args->ctx, SSL_R_PROTOCOL_IS_SHUTDOWN, NULL); in quic_wait_for_stream()
2160 static int qc_wait_for_default_xso_for_read(QCTX *ctx, int peek) in qc_wait_for_default_xso_for_read() argument
2164 QUIC_CONNECTION *qc = ctx->qc; in qc_wait_for_default_xso_for_read()
2176 return QUIC_RAISE_NON_NORMAL_ERROR(ctx, SSL_R_NO_STREAM, NULL); in qc_wait_for_default_xso_for_read()
2195 qctx_maybe_autotick(ctx); in qc_wait_for_default_xso_for_read()
2206 return QUIC_RAISE_NON_NORMAL_ERROR(ctx, SSL_R_PROTOCOL_IS_SHUTDOWN, NULL); in qc_wait_for_default_xso_for_read()
2207 } else if (!qctx_blocking(ctx)) { in qc_wait_for_default_xso_for_read()
2209 return QUIC_RAISE_NORMAL_ERROR(ctx, SSL_ERROR_WANT_READ); in qc_wait_for_default_xso_for_read()
2215 wargs.ctx = ctx; in qc_wait_for_default_xso_for_read()
2218 res = block_until_pred(ctx, quic_wait_for_stream, &wargs, 0); in qc_wait_for_default_xso_for_read()
2220 return QUIC_RAISE_NON_NORMAL_ERROR(ctx, ERR_R_INTERNAL_ERROR, NULL); in qc_wait_for_default_xso_for_read()
2241 return QUIC_RAISE_NON_NORMAL_ERROR(ctx, ERR_R_INTERNAL_ERROR, NULL); in qc_wait_for_default_xso_for_read()
2257 if (!ossl_quic_obj_init(&xso->obj, qc->obj.ssl.ctx, SSL_TYPE_QUIC_XSO, in create_xso_from_stream()
2306 static SSL *quic_conn_stream_new(QCTX *ctx, uint64_t flags, int need_lock) in quic_conn_stream_new() argument
2309 QUIC_CONNECTION *qc = ctx->qc; in quic_conn_stream_new()
2317 qctx_lock(ctx); in quic_conn_stream_new()
2320 QUIC_RAISE_NON_NORMAL_ERROR(ctx, SSL_R_PROTOCOL_IS_SHUTDOWN, NULL); in quic_conn_stream_new()
2332 if (no_blocking || !qctx_blocking(ctx)) { in quic_conn_stream_new()
2333 QUIC_RAISE_NON_NORMAL_ERROR(ctx, SSL_R_STREAM_COUNT_LIMITED, NULL); in quic_conn_stream_new()
2341 ret = block_until_pred(ctx, quic_new_stream_wait, &args, 0); in quic_conn_stream_new()
2343 QUIC_RAISE_NON_NORMAL_ERROR(ctx, SSL_R_PROTOCOL_IS_SHUTDOWN, NULL); in quic_conn_stream_new()
2346 QUIC_RAISE_NON_NORMAL_ERROR(ctx, ERR_R_INTERNAL_ERROR, NULL); in quic_conn_stream_new()
2353 QUIC_RAISE_NON_NORMAL_ERROR(ctx, ERR_R_INTERNAL_ERROR, NULL); in quic_conn_stream_new()
2363 qctx_unlock(ctx); in quic_conn_stream_new()
2371 qctx_unlock(ctx); in quic_conn_stream_new()
2380 QCTX ctx; in ossl_quic_conn_stream_new() local
2382 if (!expect_quic_conn_only(s, &ctx)) in ossl_quic_conn_stream_new()
2385 return quic_conn_stream_new(&ctx, flags, /*need_lock=*/1); in ossl_quic_conn_stream_new()
2411 QCTX ctx; in ossl_quic_get_error() local
2415 if (!is_quic_cs(s, &ctx, 0 /* suppress errors */)) in ossl_quic_get_error()
2418 qctx_lock(&ctx); in ossl_quic_get_error()
2419 net_error = ossl_quic_channel_net_error(ctx.qc->ch); in ossl_quic_get_error()
2420 last_error = ctx.is_stream ? ctx.xso->last_error : ctx.qc->last_error; in ossl_quic_get_error()
2421 qctx_unlock(&ctx); in ossl_quic_get_error()
2459 QCTX ctx; in ossl_quic_want() local
2462 if (!expect_quic_cs(s, &ctx)) in ossl_quic_want()
2465 qctx_lock(&ctx); in ossl_quic_want()
2467 w = error_to_want(ctx.is_stream ? ctx.xso->last_error : ctx.qc->last_error); in ossl_quic_want()
2469 qctx_unlock(&ctx); in ossl_quic_want()
2612 static int quic_write_blocking(QCTX *ctx, const void *buf, size_t len, in quic_write_blocking() argument
2616 QUIC_XSO *xso = ctx->xso; in quic_write_blocking()
2624 return QUIC_RAISE_NON_NORMAL_ERROR(ctx, ERR_R_INTERNAL_ERROR, NULL); in quic_write_blocking()
2651 res = block_until_pred(ctx, quic_write_again, &args, 0); in quic_write_blocking()
2654 return QUIC_RAISE_NON_NORMAL_ERROR(ctx, SSL_R_PROTOCOL_IS_SHUTDOWN, NULL); in quic_write_blocking()
2656 return QUIC_RAISE_NON_NORMAL_ERROR(ctx, args.err, NULL); in quic_write_blocking()
2694 static int quic_write_nonblocking_aon(QCTX *ctx, const void *buf, in quic_write_nonblocking_aon() argument
2698 QUIC_XSO *xso = ctx->xso; in quic_write_nonblocking_aon()
2716 return QUIC_RAISE_NON_NORMAL_ERROR(ctx, SSL_R_BAD_WRITE_RETRY, NULL); in quic_write_nonblocking_aon()
2730 return QUIC_RAISE_NON_NORMAL_ERROR(ctx, ERR_R_INTERNAL_ERROR, NULL); in quic_write_nonblocking_aon()
2734 flags, qctx_should_autotick(ctx)); in quic_write_nonblocking_aon()
2763 return QUIC_RAISE_NORMAL_ERROR(ctx, SSL_ERROR_WANT_WRITE); in quic_write_nonblocking_aon()
2779 return QUIC_RAISE_NORMAL_ERROR(ctx, SSL_ERROR_WANT_WRITE); in quic_write_nonblocking_aon()
2783 static int quic_write_nonblocking_epw(QCTX *ctx, const void *buf, size_t len, in quic_write_nonblocking_epw() argument
2786 QUIC_XSO *xso = ctx->xso; in quic_write_nonblocking_epw()
2792 return QUIC_RAISE_NON_NORMAL_ERROR(ctx, ERR_R_INTERNAL_ERROR, NULL); in quic_write_nonblocking_epw()
2796 qctx_should_autotick(ctx)); in quic_write_nonblocking_epw()
2800 return QUIC_RAISE_NORMAL_ERROR(ctx, SSL_ERROR_WANT_WRITE); in quic_write_nonblocking_epw()
2854 QCTX ctx; in ossl_quic_write_flags() local
2861 if (!expect_quic_cs(s, &ctx)) in ossl_quic_write_flags()
2864 qctx_lock_for_io(&ctx); in ossl_quic_write_flags()
2866 if (!expect_quic_with_stream_lock(s, /*remote_init=*/0, /*io=*/1, &ctx)) in ossl_quic_write_flags()
2870 partial_write = ((ctx.xso != NULL) in ossl_quic_write_flags()
2871 ? ((ctx.xso->ssl_mode & SSL_MODE_ENABLE_PARTIAL_WRITE) != 0) : 0); in ossl_quic_write_flags()
2874 ret = QUIC_RAISE_NON_NORMAL_ERROR(&ctx, SSL_R_UNSUPPORTED_WRITE_FLAG, NULL); in ossl_quic_write_flags()
2878 if (!quic_mutation_allowed(ctx.qc, /*req_active=*/0)) { in ossl_quic_write_flags()
2879 ret = QUIC_RAISE_NON_NORMAL_ERROR(&ctx, SSL_R_PROTOCOL_IS_SHUTDOWN, NULL); in ossl_quic_write_flags()
2887 if (quic_do_handshake(&ctx) < 1) { in ossl_quic_write_flags()
2893 if (len > 0 && !quic_validate_for_write(ctx.xso, &err)) { in ossl_quic_write_flags()
2894 ret = QUIC_RAISE_NON_NORMAL_ERROR(&ctx, err, NULL); in ossl_quic_write_flags()
2900 quic_post_write(ctx.xso, 0, 1, flags, in ossl_quic_write_flags()
2901 qctx_should_autotick(&ctx)); in ossl_quic_write_flags()
2907 if (qctx_blocking(&ctx)) in ossl_quic_write_flags()
2908 ret = quic_write_blocking(&ctx, buf, len, flags, written); in ossl_quic_write_flags()
2910 ret = quic_write_nonblocking_epw(&ctx, buf, len, flags, written); in ossl_quic_write_flags()
2912 ret = quic_write_nonblocking_aon(&ctx, buf, len, flags, written); in ossl_quic_write_flags()
2915 qctx_unlock(&ctx); in ossl_quic_write_flags()
2930 QCTX *ctx; member
2977 static int quic_read_actual(QCTX *ctx, in quic_read_actual() argument
2984 QUIC_CONNECTION *qc = ctx->qc; in quic_read_actual()
2986 if (!quic_validate_for_read(ctx->xso, &err, &eos)) { in quic_read_actual()
2988 ctx->xso->retired_fin = 1; in quic_read_actual()
2989 return QUIC_RAISE_NORMAL_ERROR(ctx, SSL_ERROR_ZERO_RETURN); in quic_read_actual()
2991 return QUIC_RAISE_NON_NORMAL_ERROR(ctx, err, NULL); in quic_read_actual()
2998 return QUIC_RAISE_NON_NORMAL_ERROR(ctx, ERR_R_INTERNAL_ERROR, NULL); in quic_read_actual()
3003 return QUIC_RAISE_NON_NORMAL_ERROR(ctx, ERR_R_INTERNAL_ERROR, NULL); in quic_read_actual()
3020 return QUIC_RAISE_NON_NORMAL_ERROR(ctx, ERR_R_INTERNAL_ERROR, NULL); in quic_read_actual()
3024 QUIC_STREAM_MAP *qsm = ossl_quic_channel_get_qsm(ctx->qc->ch); in quic_read_actual()
3026 ossl_quic_stream_map_notify_totally_read(qsm, ctx->xso->stream); in quic_read_actual()
3035 ctx->xso->retired_fin = 1; in quic_read_actual()
3036 return QUIC_RAISE_NORMAL_ERROR(ctx, SSL_ERROR_ZERO_RETURN); in quic_read_actual()
3047 if (!quic_mutation_allowed(args->ctx->qc, /*req_active=*/1)) { in quic_read_again()
3049 QUIC_RAISE_NON_NORMAL_ERROR(args->ctx, SSL_R_PROTOCOL_IS_SHUTDOWN, NULL); in quic_read_again()
3053 if (!quic_read_actual(args->ctx, args->stream, in quic_read_again()
3069 QCTX ctx; in quic_read() local
3074 if (!expect_quic_cs(s, &ctx)) in quic_read()
3077 qctx_lock_for_io(&ctx); in quic_read()
3080 if (quic_do_handshake(&ctx) < 1) { in quic_read()
3085 if (ctx.xso == NULL) { in quic_read()
3092 if (!qc_wait_for_default_xso_for_read(&ctx, /*peek=*/0)) { in quic_read()
3097 ctx.xso = ctx.qc->default_xso; in quic_read()
3100 if (!quic_read_actual(&ctx, ctx.xso->stream, buf, len, bytes_read, peek)) { in quic_read()
3110 if (quic_mutation_allowed(ctx.qc, /*req_active=*/0)) in quic_read()
3111 qctx_maybe_autotick(&ctx); in quic_read()
3114 } else if (!quic_mutation_allowed(ctx.qc, /*req_active=*/0)) { in quic_read()
3115 ret = QUIC_RAISE_NON_NORMAL_ERROR(&ctx, SSL_R_PROTOCOL_IS_SHUTDOWN, NULL); in quic_read()
3117 } else if (qctx_blocking(&ctx)) { in quic_read()
3123 args.ctx = &ctx; in quic_read()
3124 args.stream = ctx.xso->stream; in quic_read()
3130 res = block_until_pred(&ctx, quic_read_again, &args, 0); in quic_read()
3132 ret = QUIC_RAISE_NON_NORMAL_ERROR(&ctx, ERR_R_INTERNAL_ERROR, NULL); in quic_read()
3145 qctx_maybe_autotick(&ctx); in quic_read()
3148 if (!quic_read_actual(&ctx, ctx.xso->stream, buf, len, bytes_read, peek)) { in quic_read()
3156 ret = QUIC_RAISE_NORMAL_ERROR(&ctx, SSL_ERROR_WANT_READ); in quic_read()
3160 qctx_unlock(&ctx); in quic_read()
3182 QCTX ctx; in ossl_quic_pending_int() local
3185 if (!expect_quic_cs(s, &ctx)) in ossl_quic_pending_int()
3188 qctx_lock(&ctx); in ossl_quic_pending_int()
3190 if (!ctx.qc->started) in ossl_quic_pending_int()
3193 if (ctx.xso == NULL) { in ossl_quic_pending_int()
3195 if (qc_wait_for_default_xso_for_read(&ctx, /*peek=*/1)) { in ossl_quic_pending_int()
3196 ctx.xso = ctx.qc->default_xso; in ossl_quic_pending_int()
3198 QUIC_RAISE_NON_NORMAL_ERROR(&ctx, SSL_R_NO_STREAM, NULL); in ossl_quic_pending_int()
3203 if (ctx.xso->stream == NULL) { in ossl_quic_pending_int()
3204 QUIC_RAISE_NON_NORMAL_ERROR(&ctx, ERR_R_INTERNAL_ERROR, NULL); in ossl_quic_pending_int()
3210 avail = ossl_quic_stream_recv_pending(ctx.xso->stream, in ossl_quic_pending_int()
3212 || ossl_quic_channel_has_pending(ctx.qc->ch) in ossl_quic_pending_int()
3213 || ossl_quic_channel_is_term_any(ctx.qc->ch); in ossl_quic_pending_int()
3215 avail = ossl_quic_stream_recv_pending(ctx.xso->stream, in ossl_quic_pending_int()
3219 qctx_unlock(&ctx); in ossl_quic_pending_int()
3241 QCTX ctx; in ossl_quic_conn_stream_conclude() local
3245 if (!expect_quic_with_stream_lock(s, /*remote_init=*/0, /*io=*/0, &ctx)) in ossl_quic_conn_stream_conclude()
3248 qs = ctx.xso->stream; in ossl_quic_conn_stream_conclude()
3250 if (!quic_mutation_allowed(ctx.qc, /*req_active=*/1)) { in ossl_quic_conn_stream_conclude()
3251 qctx_unlock(&ctx); in ossl_quic_conn_stream_conclude()
3252 return QUIC_RAISE_NON_NORMAL_ERROR(&ctx, SSL_R_PROTOCOL_IS_SHUTDOWN, NULL); in ossl_quic_conn_stream_conclude()
3255 if (!quic_validate_for_write(ctx.xso, &err)) { in ossl_quic_conn_stream_conclude()
3256 qctx_unlock(&ctx); in ossl_quic_conn_stream_conclude()
3257 return QUIC_RAISE_NON_NORMAL_ERROR(&ctx, err, NULL); in ossl_quic_conn_stream_conclude()
3261 qctx_unlock(&ctx); in ossl_quic_conn_stream_conclude()
3266 quic_post_write(ctx.xso, 1, 0, 0, qctx_should_autotick(&ctx)); in ossl_quic_conn_stream_conclude()
3267 qctx_unlock(&ctx); in ossl_quic_conn_stream_conclude()
3282 QCTX ctx; in SSL_inject_net_dgram() local
3286 if (!expect_quic_csl(s, &ctx)) in SSL_inject_net_dgram()
3289 qctx_lock(&ctx); in SSL_inject_net_dgram()
3291 port = ossl_quic_obj_get0_port(ctx.obj); in SSL_inject_net_dgram()
3293 QUIC_RAISE_NON_NORMAL_ERROR(&ctx, ERR_R_UNSUPPORTED, NULL); in SSL_inject_net_dgram()
3301 qctx_unlock(&ctx); in SSL_inject_net_dgram()
3311 QCTX ctx; in ossl_quic_get0_connection() local
3313 if (!expect_quic_cs(s, &ctx)) in ossl_quic_get0_connection()
3316 return &ctx.qc->obj.ssl; in ossl_quic_get0_connection()
3325 QCTX ctx; in ossl_quic_get0_listener() local
3327 if (!expect_quic_csl(s, &ctx)) in ossl_quic_get0_listener()
3330 return ctx.ql != NULL ? &ctx.ql->obj.ssl : NULL; in ossl_quic_get0_listener()
3339 QCTX ctx; in ossl_quic_get0_domain() local
3341 if (!expect_quic_any(s, &ctx)) in ossl_quic_get0_domain()
3344 return ctx.qd != NULL ? &ctx.qd->obj.ssl : NULL; in ossl_quic_get0_domain()
3353 QCTX ctx; in ossl_quic_get_domain_flags() local
3355 if (!expect_quic_any(ssl, &ctx)) in ossl_quic_get_domain_flags()
3359 *domain_flags = ctx.obj->domain_flags; in ossl_quic_get_domain_flags()
3370 QCTX ctx; in ossl_quic_get_stream_type() local
3372 if (!expect_quic_cs(s, &ctx)) in ossl_quic_get_stream_type()
3375 if (ctx.xso == NULL) { in ossl_quic_get_stream_type()
3383 if (ctx.qc->default_xso_created in ossl_quic_get_stream_type()
3384 || ctx.qc->default_stream_mode == SSL_DEFAULT_STREAM_MODE_NONE) in ossl_quic_get_stream_type()
3390 if (ossl_quic_stream_is_bidi(ctx.xso->stream)) in ossl_quic_get_stream_type()
3393 if (ossl_quic_stream_is_server_init(ctx.xso->stream) != ctx.qc->as_server) in ossl_quic_get_stream_type()
3406 QCTX ctx; in ossl_quic_get_stream_id() local
3409 if (!expect_quic_with_stream_lock(s, /*remote_init=*/-1, /*io=*/0, &ctx)) in ossl_quic_get_stream_id()
3412 id = ctx.xso->stream->id; in ossl_quic_get_stream_id()
3413 qctx_unlock(&ctx); in ossl_quic_get_stream_id()
3425 QCTX ctx; in ossl_quic_is_stream_local() local
3428 if (!expect_quic_with_stream_lock(s, /*remote_init=*/-1, /*io=*/0, &ctx)) in ossl_quic_is_stream_local()
3431 is_local = ossl_quic_stream_is_local_init(ctx.xso->stream); in ossl_quic_is_stream_local()
3432 qctx_unlock(&ctx); in ossl_quic_is_stream_local()
3444 QCTX ctx; in ossl_quic_set_default_stream_mode() local
3446 if (!expect_quic_conn_only(s, &ctx)) in ossl_quic_set_default_stream_mode()
3449 qctx_lock(&ctx); in ossl_quic_set_default_stream_mode()
3451 if (ctx.qc->default_xso_created) { in ossl_quic_set_default_stream_mode()
3452 qctx_unlock(&ctx); in ossl_quic_set_default_stream_mode()
3453 return QUIC_RAISE_NON_NORMAL_ERROR(&ctx, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED, in ossl_quic_set_default_stream_mode()
3461 ctx.qc->default_stream_mode = mode; in ossl_quic_set_default_stream_mode()
3464 qctx_unlock(&ctx); in ossl_quic_set_default_stream_mode()
3465 return QUIC_RAISE_NON_NORMAL_ERROR(&ctx, ERR_R_PASSED_INVALID_ARGUMENT, in ossl_quic_set_default_stream_mode()
3469 qctx_unlock(&ctx); in ossl_quic_set_default_stream_mode()
3480 QCTX ctx; in ossl_quic_detach_stream() local
3483 if (!expect_quic_conn_only(s, &ctx)) in ossl_quic_detach_stream()
3486 qctx_lock(&ctx); in ossl_quic_detach_stream()
3490 qc_set_default_xso_keep_ref(ctx.qc, NULL, /*touch=*/1, &xso); in ossl_quic_detach_stream()
3492 qctx_unlock(&ctx); in ossl_quic_detach_stream()
3504 QCTX ctx; in ossl_quic_attach_stream() local
3508 if (!expect_quic_conn_only(conn, &ctx)) in ossl_quic_attach_stream()
3512 return QUIC_RAISE_NON_NORMAL_ERROR(&ctx, ERR_R_PASSED_NULL_PARAMETER, in ossl_quic_attach_stream()
3517 qctx_lock(&ctx); in ossl_quic_attach_stream()
3519 if (ctx.qc->default_xso != NULL) { in ossl_quic_attach_stream()
3520 qctx_unlock(&ctx); in ossl_quic_attach_stream()
3521 return QUIC_RAISE_NON_NORMAL_ERROR(&ctx, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED, in ossl_quic_attach_stream()
3530 qctx_unlock(&ctx); in ossl_quic_attach_stream()
3531 return QUIC_RAISE_NON_NORMAL_ERROR(&ctx, ERR_R_INTERNAL_ERROR, in ossl_quic_attach_stream()
3536 qctx_unlock(&ctx); in ossl_quic_attach_stream()
3537 return QUIC_RAISE_NON_NORMAL_ERROR(&ctx, ERR_R_PASSED_INVALID_ARGUMENT, in ossl_quic_attach_stream()
3544 qc_set_default_xso(ctx.qc, xso, /*touch=*/1); in ossl_quic_attach_stream()
3546 qctx_unlock(&ctx); in ossl_quic_attach_stream()
3586 QCTX ctx; in ossl_quic_set_incoming_stream_policy() local
3588 if (!expect_quic_conn_only(s, &ctx)) in ossl_quic_set_incoming_stream_policy()
3591 qctx_lock(&ctx); in ossl_quic_set_incoming_stream_policy()
3597 ctx.qc->incoming_stream_policy = policy; in ossl_quic_set_incoming_stream_policy()
3598 ctx.qc->incoming_stream_aec = aec; in ossl_quic_set_incoming_stream_policy()
3602 QUIC_RAISE_NON_NORMAL_ERROR(&ctx, ERR_R_PASSED_INVALID_ARGUMENT, NULL); in ossl_quic_set_incoming_stream_policy()
3607 qc_update_reject_policy(ctx.qc); in ossl_quic_set_incoming_stream_policy()
3608 qctx_unlock(&ctx); in ossl_quic_set_incoming_stream_policy()
3617 static int qc_getset_idle_timeout(QCTX *ctx, uint32_t class_, in qc_getset_idle_timeout() argument
3623 qctx_lock(ctx); in qc_getset_idle_timeout()
3627 value_out = ossl_quic_channel_get_max_idle_timeout_request(ctx->qc->ch); in qc_getset_idle_timeout()
3632 QUIC_RAISE_NON_NORMAL_ERROR(ctx, ERR_R_PASSED_INVALID_ARGUMENT, in qc_getset_idle_timeout()
3637 if (ossl_quic_channel_have_generated_transport_params(ctx->qc->ch)) { in qc_getset_idle_timeout()
3638 QUIC_RAISE_NON_NORMAL_ERROR(ctx, SSL_R_FEATURE_NOT_RENEGOTIABLE, in qc_getset_idle_timeout()
3643 ossl_quic_channel_set_max_idle_timeout_request(ctx->qc->ch, value_in); in qc_getset_idle_timeout()
3650 QUIC_RAISE_NON_NORMAL_ERROR(ctx, SSL_R_UNSUPPORTED_CONFIG_VALUE_OP, in qc_getset_idle_timeout()
3655 if (!ossl_quic_channel_is_handshake_complete(ctx->qc->ch)) { in qc_getset_idle_timeout()
3656 QUIC_RAISE_NON_NORMAL_ERROR(ctx, SSL_R_FEATURE_NEGOTIATION_NOT_COMPLETE, in qc_getset_idle_timeout()
3662 ? ossl_quic_channel_get_max_idle_timeout_actual(ctx->qc->ch) in qc_getset_idle_timeout()
3663 : ossl_quic_channel_get_max_idle_timeout_peer_request(ctx->qc->ch); in qc_getset_idle_timeout()
3667 QUIC_RAISE_NON_NORMAL_ERROR(ctx, SSL_R_UNSUPPORTED_CONFIG_VALUE_CLASS, in qc_getset_idle_timeout()
3674 qctx_unlock(ctx); in qc_getset_idle_timeout()
3682 static int qc_get_stream_avail(QCTX *ctx, uint32_t class_, in qc_get_stream_avail() argument
3689 QUIC_RAISE_NON_NORMAL_ERROR(ctx, SSL_R_UNSUPPORTED_CONFIG_VALUE_CLASS, in qc_get_stream_avail()
3694 qctx_lock(ctx); in qc_get_stream_avail()
3697 ? ossl_quic_channel_get_remote_stream_count_avail(ctx->qc->ch, is_uni) in qc_get_stream_avail()
3698 : ossl_quic_channel_get_local_stream_count_avail(ctx->qc->ch, is_uni); in qc_get_stream_avail()
3701 qctx_unlock(ctx); in qc_get_stream_avail()
3706 static int qctx_should_autotick(QCTX *ctx) in qctx_should_autotick() argument
3709 QUIC_OBJ *obj = ctx->obj; in qctx_should_autotick()
3718 static void qctx_maybe_autotick(QCTX *ctx) in qctx_maybe_autotick() argument
3720 if (!qctx_should_autotick(ctx)) in qctx_maybe_autotick()
3723 ossl_quic_reactor_tick(ossl_quic_obj_get0_reactor(ctx->obj), 0); in qctx_maybe_autotick()
3727 static int qc_getset_event_handling(QCTX *ctx, uint32_t class_, in qc_getset_event_handling() argument
3734 qctx_lock(ctx); in qc_getset_event_handling()
3737 QUIC_RAISE_NON_NORMAL_ERROR(ctx, SSL_R_UNSUPPORTED_CONFIG_VALUE_CLASS, in qc_getset_event_handling()
3749 QUIC_RAISE_NON_NORMAL_ERROR(ctx, ERR_R_PASSED_INVALID_ARGUMENT, in qc_getset_event_handling()
3755 ctx->obj->event_handling_mode = (int)value_out; in qc_getset_event_handling()
3757 value_out = ctx->obj->event_handling_mode; in qc_getset_event_handling()
3762 qctx_unlock(ctx); in qc_getset_event_handling()
3770 static int qc_get_stream_write_buf_stat(QCTX *ctx, uint32_t class_, in qc_get_stream_write_buf_stat() argument
3777 qctx_lock(ctx); in qc_get_stream_write_buf_stat()
3780 QUIC_RAISE_NON_NORMAL_ERROR(ctx, SSL_R_UNSUPPORTED_CONFIG_VALUE_CLASS, in qc_get_stream_write_buf_stat()
3785 if (ctx->xso == NULL) { in qc_get_stream_write_buf_stat()
3786 QUIC_RAISE_NON_NORMAL_ERROR(ctx, SSL_R_NO_STREAM, NULL); in qc_get_stream_write_buf_stat()
3790 if (!ossl_quic_stream_has_send(ctx->xso->stream)) { in qc_get_stream_write_buf_stat()
3791 QUIC_RAISE_NON_NORMAL_ERROR(ctx, SSL_R_STREAM_RECV_ONLY, NULL); in qc_get_stream_write_buf_stat()
3795 if (ossl_quic_stream_has_send_buffer(ctx->xso->stream)) in qc_get_stream_write_buf_stat()
3796 value = getter(ctx->xso->stream->sstream); in qc_get_stream_write_buf_stat()
3800 qctx_unlock(ctx); in qc_get_stream_write_buf_stat()
3806 static int expect_quic_for_value(SSL *s, QCTX *ctx, uint32_t id) in expect_quic_for_value() argument
3813 return expect_quic_cs(s, ctx); in expect_quic_for_value()
3815 return expect_quic_conn_only(s, ctx); in expect_quic_for_value()
3823 QCTX ctx; in ossl_quic_get_value_uint() local
3825 if (!expect_quic_for_value(s, &ctx, id)) in ossl_quic_get_value_uint()
3829 return QUIC_RAISE_NON_NORMAL_ERROR(&ctx, in ossl_quic_get_value_uint()
3834 return qc_getset_idle_timeout(&ctx, class_, value, NULL); in ossl_quic_get_value_uint()
3837 return qc_get_stream_avail(&ctx, class_, /*uni=*/0, /*remote=*/0, value); in ossl_quic_get_value_uint()
3839 return qc_get_stream_avail(&ctx, class_, /*uni=*/0, /*remote=*/1, value); in ossl_quic_get_value_uint()
3841 return qc_get_stream_avail(&ctx, class_, /*uni=*/1, /*remote=*/0, value); in ossl_quic_get_value_uint()
3843 return qc_get_stream_avail(&ctx, class_, /*uni=*/1, /*remote=*/1, value); in ossl_quic_get_value_uint()
3846 return qc_getset_event_handling(&ctx, class_, value, NULL); in ossl_quic_get_value_uint()
3849 return qc_get_stream_write_buf_stat(&ctx, class_, value, in ossl_quic_get_value_uint()
3852 return qc_get_stream_write_buf_stat(&ctx, class_, value, in ossl_quic_get_value_uint()
3855 return qc_get_stream_write_buf_stat(&ctx, class_, value, in ossl_quic_get_value_uint()
3859 return QUIC_RAISE_NON_NORMAL_ERROR(&ctx, in ossl_quic_get_value_uint()
3870 QCTX ctx; in ossl_quic_set_value_uint() local
3872 if (!expect_quic_for_value(s, &ctx, id)) in ossl_quic_set_value_uint()
3877 return qc_getset_idle_timeout(&ctx, class_, NULL, &value); in ossl_quic_set_value_uint()
3880 return qc_getset_event_handling(&ctx, class_, NULL, &value); in ossl_quic_set_value_uint()
3883 return QUIC_RAISE_NON_NORMAL_ERROR(&ctx, in ossl_quic_set_value_uint()
3895 QCTX *ctx; member
3903 QUIC_CONNECTION *qc = args->ctx->qc; in wait_for_incoming_stream()
3908 QUIC_RAISE_NON_NORMAL_ERROR(args->ctx, SSL_R_PROTOCOL_IS_SHUTDOWN, NULL); in wait_for_incoming_stream()
3922 QCTX ctx; in ossl_quic_accept_stream() local
3930 if (!expect_quic_conn_only(s, &ctx)) in ossl_quic_accept_stream()
3933 qctx_lock(&ctx); in ossl_quic_accept_stream()
3935 if (qc_get_effective_incoming_stream_policy(ctx.qc) in ossl_quic_accept_stream()
3937 QUIC_RAISE_NON_NORMAL_ERROR(&ctx, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED, NULL); in ossl_quic_accept_stream()
3941 qsm = ossl_quic_channel_get_qsm(ctx.qc->ch); in ossl_quic_accept_stream()
3953 if (qctx_blocking(&ctx) in ossl_quic_accept_stream()
3957 args.ctx = &ctx; in ossl_quic_accept_stream()
3960 ret = block_until_pred(&ctx, wait_for_incoming_stream, &args, 0); in ossl_quic_accept_stream()
3962 QUIC_RAISE_NON_NORMAL_ERROR(&ctx, ERR_R_INTERNAL_ERROR, NULL); in ossl_quic_accept_stream()
3974 xso = create_xso_from_stream(ctx.qc, qs); in ossl_quic_accept_stream()
3978 ossl_statm_get_rtt_info(ossl_quic_channel_get_statm(ctx.qc->ch), &rtt_info); in ossl_quic_accept_stream()
3984 qc_touch_default_xso(ctx.qc); /* inhibits default XSO */ in ossl_quic_accept_stream()
3987 qctx_unlock(&ctx); in ossl_quic_accept_stream()
3998 QCTX ctx; in ossl_quic_get_accept_stream_queue_len() local
4001 if (!expect_quic_conn_only(s, &ctx)) in ossl_quic_get_accept_stream_queue_len()
4004 qctx_lock(&ctx); in ossl_quic_get_accept_stream_queue_len()
4006 v = ossl_quic_stream_map_get_total_accept_queue_len(ossl_quic_channel_get_qsm(ctx.qc->ch)); in ossl_quic_get_accept_stream_queue_len()
4008 qctx_unlock(&ctx); in ossl_quic_get_accept_stream_queue_len()
4020 QCTX ctx; in ossl_quic_stream_reset() local
4026 if (!expect_quic_with_stream_lock(ssl, /*remote_init=*/0, /*io=*/0, &ctx)) in ossl_quic_stream_reset()
4029 qsm = ossl_quic_channel_get_qsm(ctx.qc->ch); in ossl_quic_stream_reset()
4030 qs = ctx.xso->stream; in ossl_quic_stream_reset()
4033 if (!quic_validate_for_write(ctx.xso, &err)) { in ossl_quic_stream_reset()
4034 ok = QUIC_RAISE_NON_NORMAL_ERROR(&ctx, err, NULL); in ossl_quic_stream_reset()
4040 ctx.xso->requested_reset = 1; in ossl_quic_stream_reset()
4043 qctx_unlock(&ctx); in ossl_quic_stream_reset()
4113 QCTX ctx; in quic_get_stream_state() local
4116 if (!expect_quic_with_stream_lock(ssl, /*remote_init=*/-1, /*io=*/0, &ctx)) in quic_get_stream_state()
4119 quic_classify_stream(ctx.qc, ctx.xso->stream, is_write, &state, NULL); in quic_get_stream_state()
4120 qctx_unlock(&ctx); in quic_get_stream_state()
4145 QCTX ctx; in quic_get_stream_error_code() local
4148 if (!expect_quic_with_stream_lock(ssl, /*remote_init=*/-1, /*io=*/0, &ctx)) in quic_get_stream_error_code()
4151 quic_classify_stream(ctx.qc, ctx.xso->stream, /*is_write=*/0, in quic_get_stream_error_code()
4154 qctx_unlock(&ctx); in quic_get_stream_error_code()
4187 QCTX ctx; in ossl_quic_set_write_buffer_size() local
4189 if (!expect_quic_with_stream_lock(ssl, /*remote_init=*/-1, /*io=*/0, &ctx)) in ossl_quic_set_write_buffer_size()
4192 if (!ossl_quic_stream_has_send(ctx.xso->stream)) { in ossl_quic_set_write_buffer_size()
4194 QUIC_RAISE_NON_NORMAL_ERROR(&ctx, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED, NULL); in ossl_quic_set_write_buffer_size()
4198 if (!ossl_quic_stream_has_send_buffer(ctx.xso->stream)) { in ossl_quic_set_write_buffer_size()
4207 if (!ossl_quic_sstream_set_buffer_size(ctx.xso->stream->sstream, size)) { in ossl_quic_set_write_buffer_size()
4208 QUIC_RAISE_NON_NORMAL_ERROR(&ctx, ERR_R_INTERNAL_ERROR, NULL); in ossl_quic_set_write_buffer_size()
4215 qctx_unlock(&ctx); in ossl_quic_set_write_buffer_size()
4227 QCTX ctx; in ossl_quic_get_conn_close_info() local
4230 if (!expect_quic_conn_only(ssl, &ctx)) in ossl_quic_get_conn_close_info()
4233 tc = ossl_quic_channel_get_terminate_cause(ctx.qc->ch); in ossl_quic_get_conn_close_info()
4255 QCTX ctx; in ossl_quic_key_update() local
4257 if (!expect_quic_conn_only(ssl, &ctx)) in ossl_quic_key_update()
4270 QUIC_RAISE_NON_NORMAL_ERROR(&ctx, ERR_R_PASSED_INVALID_ARGUMENT, NULL); in ossl_quic_key_update()
4274 qctx_lock(&ctx); in ossl_quic_key_update()
4277 if (!ossl_quic_channel_trigger_txku(ctx.qc->ch)) { in ossl_quic_key_update()
4278 QUIC_RAISE_NON_NORMAL_ERROR(&ctx, SSL_R_TOO_MANY_KEY_UPDATES, NULL); in ossl_quic_key_update()
4279 qctx_unlock(&ctx); in ossl_quic_key_update()
4283 qctx_unlock(&ctx); in ossl_quic_key_update()
4335 SSL *ossl_quic_new_listener(SSL_CTX *ctx, uint64_t flags) in ossl_quic_new_listener() argument
4353 engine_args.libctx = ctx->libctx; in ossl_quic_new_listener()
4354 engine_args.propq = ctx->propq; in ossl_quic_new_listener()
4359 if (need_notifier_for_domain_flags(ctx->domain_flags)) in ossl_quic_new_listener()
4367 port_args.channel_ctx = ctx; in ossl_quic_new_listener()
4384 if (!ossl_quic_obj_init(&ql->obj, ctx, SSL_TYPE_QUIC_LISTENER, NULL, in ossl_quic_new_listener()
4407 QCTX ctx; in ossl_quic_new_listener_from() local
4411 if (!expect_quic_domain(ssl, &ctx)) in ossl_quic_new_listener_from()
4414 if (!SSL_up_ref(&ctx.qd->obj.ssl)) in ossl_quic_new_listener_from()
4417 qctx_lock(&ctx); in ossl_quic_new_listener_from()
4424 port_args.channel_ctx = ssl->ctx; in ossl_quic_new_listener_from()
4430 ql->port = ossl_quic_engine_create_port(ctx.qd->engine, &port_args); in ossl_quic_new_listener_from()
4436 ql->domain = ctx.qd; in ossl_quic_new_listener_from()
4437 ql->engine = ctx.qd->engine; in ossl_quic_new_listener_from()
4439 ql->mutex = ctx.qd->mutex; in ossl_quic_new_listener_from()
4454 if (!ossl_quic_obj_init(&ql->obj, ssl->ctx, SSL_TYPE_QUIC_LISTENER, in ossl_quic_new_listener_from()
4455 &ctx.qd->obj.ssl, NULL, ql->port)) in ossl_quic_new_listener_from()
4458 qctx_unlock(&ctx); in ossl_quic_new_listener_from()
4466 qctx_unlock(&ctx); in ossl_quic_new_listener_from()
4467 SSL_free(&ctx.qd->obj.ssl); in ossl_quic_new_listener_from()
4487 QCTX ctx; in ossl_quic_new_from_listener() local
4495 if (!expect_quic_listener(ssl, &ctx)) in ossl_quic_new_from_listener()
4498 if (!SSL_up_ref(&ctx.ql->obj.ssl)) in ossl_quic_new_from_listener()
4501 qctx_lock(&ctx); in ossl_quic_new_from_listener()
4503 ql = ctx.ql; in ossl_quic_new_from_listener()
4511 if (ssl->ctx->tokencache == NULL) in ossl_quic_new_from_listener()
4512 if ((ssl->ctx->tokencache = ossl_quic_new_token_store()) == NULL) in ossl_quic_new_from_listener()
4539 qc->tls = ossl_ssl_connection_new_int(ql->obj.ssl.ctx, NULL, TLS_method()); in ossl_quic_new_from_listener()
4556 ossl_quic_channel_set_msg_callback(qc->ch, ql->obj.ssl.ctx->msg_callback, &qc->obj.ssl); in ossl_quic_new_from_listener()
4557 ossl_quic_channel_set_msg_callback_arg(qc->ch, ql->obj.ssl.ctx->msg_callback_arg); in ossl_quic_new_from_listener()
4565 if (!ossl_quic_obj_init(&qc->obj, ql->obj.ssl.ctx, in ossl_quic_new_from_listener()
4574 qc->default_ssl_mode = qc->obj.ssl.ctx->mode; in ossl_quic_new_from_listener()
4575 qc->default_ssl_options = qc->obj.ssl.ctx->options & OSSL_QUIC_PERMITTED_OPTIONS; in ossl_quic_new_from_listener()
4581 qctx_unlock(&ctx); in ossl_quic_new_from_listener()
4590 qctx_unlock(&ctx); in ossl_quic_new_from_listener()
4591 SSL_free(&ctx.ql->obj.ssl); in ossl_quic_new_from_listener()
4614 QCTX ctx; in ossl_quic_listen() local
4617 if (!expect_quic_listener(ssl, &ctx)) in ossl_quic_listen()
4620 qctx_lock_for_io(&ctx); in ossl_quic_listen()
4622 ret = ql_listen(ctx.ql); in ossl_quic_listen()
4624 qctx_unlock(&ctx); in ossl_quic_listen()
4649 QCTX ctx; in ossl_quic_accept_connection() local
4656 if (!expect_quic_listener(ssl, &ctx)) in ossl_quic_accept_connection()
4659 qctx_lock_for_io(&ctx); in ossl_quic_accept_connection()
4661 if (!ql_listen(ctx.ql)) in ossl_quic_accept_connection()
4665 new_ch = ossl_quic_port_pop_incoming(ctx.ql->port); in ossl_quic_accept_connection()
4666 if (new_ch == NULL && ossl_quic_port_is_running(ctx.ql->port)) { in ossl_quic_accept_connection()
4667 if (!no_block && qctx_blocking(&ctx)) { in ossl_quic_accept_connection()
4668 ret = block_until_pred(&ctx, quic_accept_connection_wait, in ossl_quic_accept_connection()
4669 ctx.ql->port, 0); in ossl_quic_accept_connection()
4673 qctx_maybe_autotick(&ctx); in ossl_quic_accept_connection()
4676 if (!ossl_quic_port_is_running(ctx.ql->port)) in ossl_quic_accept_connection()
4679 new_ch = ossl_quic_port_pop_incoming(ctx.ql->port); in ossl_quic_accept_connection()
4682 if (new_ch == NULL && ossl_quic_port_is_running(ctx.ql->port)) { in ossl_quic_accept_connection()
4684 ossl_quic_reactor_tick(ossl_quic_engine_get0_reactor(ctx.ql->engine), 0); in ossl_quic_accept_connection()
4686 new_ch = ossl_quic_port_pop_incoming(ctx.ql->port); in ossl_quic_accept_connection()
4700 qc->listener = ctx.ql; in ossl_quic_accept_connection()
4702 if (!SSL_up_ref(&ctx.ql->obj.ssl)) { in ossl_quic_accept_connection()
4709 qctx_unlock(&ctx); in ossl_quic_accept_connection()
4722 if (!ossl_quic_obj_init(&qc->obj, ql->obj.ssl.ctx, in create_qc_from_incoming_conn()
4742 qc->default_ssl_options = ql->obj.ssl.ctx->options & OSSL_QUIC_PERMITTED_OPTIONS; in create_qc_from_incoming_conn()
4909 int ossl_quic_set_peer_token(SSL_CTX *ctx, BIO_ADDR *peer, in ossl_quic_set_peer_token() argument
4912 SSL_TOKEN_STORE *c = ctx->tokencache; in ossl_quic_set_peer_token()
4915 if (ctx->tokencache == NULL) in ossl_quic_set_peer_token()
4936 int ossl_quic_get_peer_token(SSL_CTX *ctx, BIO_ADDR *peer, in ossl_quic_get_peer_token() argument
4939 SSL_TOKEN_STORE *c = ctx->tokencache; in ossl_quic_get_peer_token()
4986 QCTX ctx; in ossl_quic_get_accept_connection_queue_len() local
4989 if (!expect_quic_listener(ssl, &ctx)) in ossl_quic_get_accept_connection_queue_len()
4992 qctx_lock(&ctx); in ossl_quic_get_accept_connection_queue_len()
4994 ret = (int)ossl_quic_port_get_num_incoming_channels(ctx.ql->port); in ossl_quic_get_accept_connection_queue_len()
4996 qctx_unlock(&ctx); in ossl_quic_get_accept_connection_queue_len()
5009 SSL *ossl_quic_new_domain(SSL_CTX *ctx, uint64_t flags) in ossl_quic_new_domain() argument
5015 domain_flags = ctx->domain_flags; in ossl_quic_new_domain()
5021 domain_flags = ctx->domain_flags | flags; in ossl_quic_new_domain()
5038 engine_args.libctx = ctx->libctx; in ossl_quic_new_domain()
5039 engine_args.propq = ctx->propq; in ossl_quic_new_domain()
5053 if (!ossl_quic_obj_init(&qd->obj, ctx, SSL_TYPE_QUIC_DOMAIN, NULL, in ossl_quic_new_domain()
5074 long ossl_quic_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg) in ossl_quic_ctx_ctrl() argument
5078 return ssl3_ctx_ctrl(ctx, cmd, larg, parg); in ossl_quic_ctx_ctrl()
5084 QCTX ctx; in ossl_quic_callback_ctrl() local
5086 if (!expect_quic_conn_only(s, &ctx)) in ossl_quic_callback_ctrl()
5091 ossl_quic_channel_set_msg_callback(ctx.qc->ch, (ossl_msg_cb)fp, in ossl_quic_callback_ctrl()
5092 &ctx.qc->obj.ssl); in ossl_quic_callback_ctrl()
5094 return ssl3_callback_ctrl(ctx.qc->tls, cmd, fp);; in ossl_quic_callback_ctrl()
5098 return ssl3_callback_ctrl(ctx.qc->tls, cmd, fp); in ossl_quic_callback_ctrl()
5102 long ossl_quic_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp) (void)) in ossl_quic_ctx_callback_ctrl() argument
5104 return ssl3_ctx_callback_ctrl(ctx, cmd, fp); in ossl_quic_ctx_callback_ctrl()
5144 QCTX ctx; in ossl_quic_get_shutdown() local
5147 if (!expect_quic_conn_only(s, &ctx)) in ossl_quic_get_shutdown()
5150 if (ossl_quic_channel_is_term_any(ctx.qc->ch)) { in ossl_quic_get_shutdown()
5152 if (!ossl_quic_channel_is_closing(ctx.qc->ch)) in ossl_quic_get_shutdown()
5273 QCTX ctx; in ossl_quic_conn_poll_events() local
5276 if (!expect_quic_csl(ssl, &ctx)) in ossl_quic_conn_poll_events()
5279 qctx_lock(&ctx); in ossl_quic_conn_poll_events()
5281 if (ctx.qc != NULL && !ctx.qc->started) { in ossl_quic_conn_poll_events()
5289 ossl_quic_reactor_tick(ossl_quic_obj_get0_reactor(ctx.obj), 0); in ossl_quic_conn_poll_events()
5291 if (ctx.xso != NULL) { in ossl_quic_conn_poll_events()
5295 && test_poll_event_r(ctx.xso)) in ossl_quic_conn_poll_events()
5299 && test_poll_event_er(ctx.xso)) in ossl_quic_conn_poll_events()
5303 && test_poll_event_w(ctx.xso)) in ossl_quic_conn_poll_events()
5307 && test_poll_event_ew(ctx.xso)) in ossl_quic_conn_poll_events()
5311 if (ctx.qc != NULL && !ctx.is_stream) { in ossl_quic_conn_poll_events()
5313 && test_poll_event_ec(ctx.qc)) in ossl_quic_conn_poll_events()
5317 && test_poll_event_ecd(ctx.qc)) in ossl_quic_conn_poll_events()
5321 && test_poll_event_is(ctx.qc, /*uni=*/0)) in ossl_quic_conn_poll_events()
5325 && test_poll_event_is(ctx.qc, /*uni=*/1)) in ossl_quic_conn_poll_events()
5329 && test_poll_event_os(ctx.qc, /*uni=*/0)) in ossl_quic_conn_poll_events()
5333 && test_poll_event_os(ctx.qc, /*uni=*/1)) in ossl_quic_conn_poll_events()
5337 if (ctx.is_listener) { in ossl_quic_conn_poll_events()
5339 && test_poll_event_el(ctx.ql)) in ossl_quic_conn_poll_events()
5343 && test_poll_event_ic(ctx.ql)) in ossl_quic_conn_poll_events()
5348 qctx_unlock(&ctx); in ossl_quic_conn_poll_events()
5356 QCTX ctx; in ossl_quic_get_notifier_fd() local
5361 if (!expect_quic_any(ssl, &ctx)) in ossl_quic_get_notifier_fd()
5364 qctx_lock(&ctx); in ossl_quic_get_notifier_fd()
5365 rtor = ossl_quic_obj_get0_reactor(ctx.obj); in ossl_quic_get_notifier_fd()
5372 qctx_unlock(&ctx); in ossl_quic_get_notifier_fd()
5379 QCTX ctx; in ossl_quic_enter_blocking_section() local
5382 if (!expect_quic_any(ssl, &ctx)) in ossl_quic_enter_blocking_section()
5385 qctx_lock(&ctx); in ossl_quic_enter_blocking_section()
5386 rtor = ossl_quic_obj_get0_reactor(ctx.obj); in ossl_quic_enter_blocking_section()
5388 qctx_unlock(&ctx); in ossl_quic_enter_blocking_section()
5394 QCTX ctx; in ossl_quic_leave_blocking_section() local
5397 if (!expect_quic_any(ssl, &ctx)) in ossl_quic_leave_blocking_section()
5400 qctx_lock(&ctx); in ossl_quic_leave_blocking_section()
5401 rtor = ossl_quic_obj_get0_reactor(ctx.obj); in ossl_quic_leave_blocking_section()
5403 qctx_unlock(&ctx); in ossl_quic_leave_blocking_section()
5413 QCTX ctx; in ossl_quic_conn_get_channel() local
5415 if (!expect_quic_conn_only(s, &ctx)) in ossl_quic_conn_get_channel()
5418 return ctx.qc->ch; in ossl_quic_conn_get_channel()
5421 int ossl_quic_set_diag_title(SSL_CTX *ctx, const char *title) in ossl_quic_set_diag_title() argument
5424 OPENSSL_free(ctx->qlog_title); in ossl_quic_set_diag_title()
5425 ctx->qlog_title = NULL; in ossl_quic_set_diag_title()
5430 if ((ctx->qlog_title = OPENSSL_strdup(title)) == NULL) in ossl_quic_set_diag_title()