Lines Matching refs:ctx

99   ((struct cf_osslq_ctx *)(cf)->ctx)->call_data
305 static void cf_osslq_ctx_init(struct cf_osslq_ctx *ctx) in cf_osslq_ctx_init() argument
307 DEBUGASSERT(!ctx->initialized); in cf_osslq_ctx_init()
308 Curl_bufcp_init(&ctx->stream_bufcp, H3_STREAM_CHUNK_SIZE, in cf_osslq_ctx_init()
310 Curl_hash_offt_init(&ctx->streams, 63, h3_stream_hash_free); in cf_osslq_ctx_init()
311 ctx->initialized = TRUE; in cf_osslq_ctx_init()
314 static void cf_osslq_ctx_free(struct cf_osslq_ctx *ctx) in cf_osslq_ctx_free() argument
316 if(ctx && ctx->initialized) { in cf_osslq_ctx_free()
317 Curl_bufcp_free(&ctx->stream_bufcp); in cf_osslq_ctx_free()
318 Curl_hash_clean(&ctx->streams); in cf_osslq_ctx_free()
319 Curl_hash_destroy(&ctx->streams); in cf_osslq_ctx_free()
320 Curl_ssl_peer_cleanup(&ctx->peer); in cf_osslq_ctx_free()
322 free(ctx); in cf_osslq_ctx_free()
325 static void cf_osslq_ctx_close(struct cf_osslq_ctx *ctx) in cf_osslq_ctx_close() argument
327 struct cf_call_data save = ctx->call_data; in cf_osslq_ctx_close()
329 cf_osslq_h3conn_cleanup(&ctx->h3); in cf_osslq_ctx_close()
330 Curl_vquic_tls_cleanup(&ctx->tls); in cf_osslq_ctx_close()
331 vquic_ctx_free(&ctx->q); in cf_osslq_ctx_close()
332 ctx->call_data = save; in cf_osslq_ctx_close()
338 struct cf_osslq_ctx *ctx = cf->ctx; in cf_osslq_shutdown() local
345 if(cf->shutdown || ctx->protocol_shutdown) { in cf_osslq_shutdown()
352 ctx->need_send = FALSE; in cf_osslq_shutdown()
353 ctx->need_recv = FALSE; in cf_osslq_shutdown()
355 rc = SSL_shutdown_ex(ctx->tls.ossl.ssl, in cf_osslq_shutdown()
359 ctx->need_recv = TRUE; in cf_osslq_shutdown()
370 int err = SSL_get_error(ctx->tls.ossl.ssl, rc); in cf_osslq_shutdown()
382 ctx->need_recv = TRUE; in cf_osslq_shutdown()
386 ctx->need_send = TRUE; in cf_osslq_shutdown()
408 struct cf_osslq_ctx *ctx = cf->ctx; in cf_osslq_close() local
412 if(ctx && ctx->tls.ossl.ssl) { in cf_osslq_close()
414 if(!cf->shutdown && !ctx->protocol_shutdown) { in cf_osslq_close()
416 SSL_shutdown_ex(ctx->tls.ossl.ssl, in cf_osslq_close()
420 cf_osslq_ctx_close(ctx); in cf_osslq_close()
429 struct cf_osslq_ctx *ctx = cf->ctx; in cf_osslq_destroy() local
434 if(ctx) { in cf_osslq_destroy()
436 if(ctx->tls.ossl.ssl) in cf_osslq_destroy()
437 cf_osslq_ctx_close(ctx); in cf_osslq_destroy()
438 cf_osslq_ctx_free(ctx); in cf_osslq_destroy()
440 cf->ctx = NULL; in cf_osslq_destroy()
450 struct cf_osslq_ctx *ctx = cf->ctx; in cf_osslq_h3conn_add_stream() local
465 Curl_bufq_initp(&nstream->recvbuf, &ctx->stream_bufcp, 1, BUFQ_OPT_NONE); in cf_osslq_h3conn_add_stream()
484 struct cf_osslq_ctx *ctx = cf->ctx; in cf_osslq_ssl_err() local
503 lerr = SSL_get_verify_result(ctx->tls.ossl.ssl); in cf_osslq_ssl_err()
525 ctx->protocol_shutdown = TRUE; in cf_osslq_ssl_err()
550 ctx->peer.dispname, ip.remote_port, ip.remote_ip); in cf_osslq_ssl_err()
562 struct cf_osslq_ctx *ctx = cf->ctx; in cf_osslq_verify_peer() local
567 return Curl_vquic_tls_verify_peer(&ctx->tls, cf, data, &ctx->peer); in cf_osslq_verify_peer()
591 #define H3_STREAM_CTX(ctx,data) ((struct h3_stream_ctx *)(\ argument
592 data? Curl_hash_offt_get(&(ctx)->streams, (data)->mid) : NULL))
612 struct cf_osslq_ctx *ctx = cf->ctx; in h3_data_setup() local
613 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in h3_data_setup()
627 Curl_bufq_initp(&stream->sendbuf, &ctx->stream_bufcp, in h3_data_setup()
632 Curl_bufq_initp(&stream->recvbuf, &ctx->stream_bufcp, in h3_data_setup()
637 if(!Curl_hash_offt_set(&ctx->streams, data->mid, stream)) { in h3_data_setup()
647 struct cf_osslq_ctx *ctx = cf->ctx; in h3_data_done() local
648 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in h3_data_done()
654 if(ctx->h3.conn && !stream->closed) { in h3_data_done()
655 nghttp3_conn_shutdown_stream_read(ctx->h3.conn, stream->s.id); in h3_data_done()
656 nghttp3_conn_close_stream(ctx->h3.conn, stream->s.id, in h3_data_done()
658 nghttp3_conn_set_stream_user_data(ctx->h3.conn, stream->s.id, NULL); in h3_data_done()
662 Curl_hash_offt_remove(&ctx->streams, data->mid); in h3_data_done()
670 struct cf_osslq_ctx *ctx = cf->ctx; in cf_osslq_get_qstream() local
671 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cf_osslq_get_qstream()
676 else if(ctx->h3.s_ctrl.id == stream_id) { in cf_osslq_get_qstream()
677 return &ctx->h3.s_ctrl; in cf_osslq_get_qstream()
679 else if(ctx->h3.s_qpack_enc.id == stream_id) { in cf_osslq_get_qstream()
680 return &ctx->h3.s_qpack_enc; in cf_osslq_get_qstream()
682 else if(ctx->h3.s_qpack_dec.id == stream_id) { in cf_osslq_get_qstream()
683 return &ctx->h3.s_qpack_dec; in cf_osslq_get_qstream()
692 stream = H3_STREAM_CTX(ctx, sdata); in cf_osslq_get_qstream()
704 struct cf_osslq_ctx *ctx = cf->ctx; in h3_drain_stream() local
705 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in h3_drain_stream()
735 struct cf_osslq_ctx *ctx = cf->ctx; in cb_h3_stream_close() local
737 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cb_h3_stream_close()
770 struct cf_osslq_ctx *ctx = cf->ctx; in write_resp_raw() local
771 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in write_resp_raw()
801 struct cf_osslq_ctx *ctx = cf->ctx; in cb_h3_recv_data() local
803 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cb_h3_recv_data()
830 struct cf_osslq_ctx *ctx = cf->ctx; in cb_h3_deferred_consume() local
832 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cb_h3_deferred_consume()
849 struct cf_osslq_ctx *ctx = cf->ctx; in cb_h3_recv_header() local
853 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cb_h3_recv_header()
910 struct cf_osslq_ctx *ctx = cf->ctx; in cb_h3_end_headers() local
913 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cb_h3_end_headers()
942 struct cf_osslq_ctx *ctx = cf->ctx; in cb_h3_stop_sending() local
945 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cb_h3_stop_sending()
961 struct cf_osslq_ctx *ctx = cf->ctx; in cb_h3_reset_stream() local
964 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cb_h3_reset_stream()
987 struct cf_osslq_ctx *ctx = cf->ctx; in cb_h3_read_req_body() local
989 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cb_h3_read_req_body()
1051 struct cf_osslq_ctx *ctx = cf->ctx; in cb_h3_acked_stream_data() local
1053 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cb_h3_acked_stream_data()
1097 static CURLcode cf_osslq_h3conn_init(struct cf_osslq_ctx *ctx, SSL *conn, in cf_osslq_h3conn_init() argument
1100 struct cf_osslq_h3conn *h3 = &ctx->h3; in cf_osslq_h3conn_init()
1117 &ctx->stream_bufcp, NULL); in cf_osslq_h3conn_init()
1124 &ctx->stream_bufcp, NULL); in cf_osslq_h3conn_init()
1131 &ctx->stream_bufcp, NULL); in cf_osslq_h3conn_init()
1157 struct cf_osslq_ctx *ctx = cf->ctx; in cf_osslq_ctx_start() local
1164 DEBUGASSERT(ctx->initialized); in cf_osslq_ctx_start()
1165 result = Curl_ssl_peer_init(&ctx->peer, cf, TRNSPRT_QUIC); in cf_osslq_ctx_start()
1170 result = Curl_vquic_tls_init(&ctx->tls, cf, data, &ctx->peer, in cf_osslq_ctx_start()
1176 result = vquic_ctx_init(&ctx->q); in cf_osslq_ctx_start()
1181 Curl_cf_socket_peek(cf->next, data, &ctx->q.sockfd, &peer_addr, NULL); in cf_osslq_ctx_start()
1185 ctx->q.local_addrlen = sizeof(ctx->q.local_addr); in cf_osslq_ctx_start()
1186 rv = getsockname(ctx->q.sockfd, (struct sockaddr *)&ctx->q.local_addr, in cf_osslq_ctx_start()
1187 &ctx->q.local_addrlen); in cf_osslq_ctx_start()
1201 if(ctx->q.sockfd > INT_MAX) { in cf_osslq_ctx_start()
1207 bio = BIO_new_dgram((int)ctx->q.sockfd, BIO_NOCLOSE); in cf_osslq_ctx_start()
1209 bio = BIO_new_dgram(ctx->q.sockfd, BIO_NOCLOSE); in cf_osslq_ctx_start()
1216 if(!SSL_set1_initial_peer_addr(ctx->tls.ossl.ssl, baddr)) { in cf_osslq_ctx_start()
1221 if(!SSL_set_blocking_mode(ctx->tls.ossl.ssl, 0)) { in cf_osslq_ctx_start()
1229 if(!SSL_set_feature_request_uint(ctx->tls.ossl.ssl, in cf_osslq_ctx_start()
1238 SSL_set_bio(ctx->tls.ossl.ssl, bio, bio); in cf_osslq_ctx_start()
1240 SSL_set_connect_state(ctx->tls.ossl.ssl); in cf_osslq_ctx_start()
1241 SSL_set_incoming_stream_policy(ctx->tls.ossl.ssl, in cf_osslq_ctx_start()
1244 result = cf_osslq_h3conn_init(ctx, ctx->tls.ossl.ssl, cf); in cf_osslq_ctx_start()
1308 struct cf_osslq_ctx *ctx = cf->ctx; in cf_osslq_stream_recv() local
1342 nread = nghttp3_conn_read_stream(ctx->h3.conn, s->id, in cf_osslq_stream_recv()
1371 rv = nghttp3_conn_close_stream(ctx->h3.conn, s->id, app_error); in cf_osslq_stream_recv()
1381 rv = nghttp3_conn_close_stream(ctx->h3.conn, s->id, in cf_osslq_stream_recv()
1405 struct cf_osslq_ctx *ctx = cf->ctx; in cf_progress_ingress() local
1408 if(!ctx->tls.ossl.ssl) in cf_progress_ingress()
1415 SSL *snew = SSL_accept_stream(ctx->tls.ossl.ssl, in cf_progress_ingress()
1420 (void)cf_osslq_h3conn_add_stream(&ctx->h3, snew, cf, data); in cf_progress_ingress()
1423 if(!SSL_handle_events(ctx->tls.ossl.ssl)) { in cf_progress_ingress()
1424 int detail = SSL_get_error(ctx->tls.ossl.ssl, 0); in cf_progress_ingress()
1428 if(ctx->h3.conn) { in cf_progress_ingress()
1430 for(i = 0; i < ctx->h3.remote_ctrl_n; ++i) { in cf_progress_ingress()
1431 result = cf_osslq_stream_recv(&ctx->h3.remote_ctrl[i], cf, data); in cf_progress_ingress()
1437 if(ctx->h3.conn) { in cf_progress_ingress()
1445 stream = H3_STREAM_CTX(ctx, sdata); in cf_progress_ingress()
1465 struct cf_osslq_ctx *ctx = cf->ctx; in cf_osslq_check_and_unblock() local
1468 if(ctx->h3.conn) { in cf_osslq_check_and_unblock()
1473 stream = H3_STREAM_CTX(ctx, sdata); in cf_osslq_check_and_unblock()
1476 nghttp3_conn_unblock_stream(ctx->h3.conn, stream->s.id); in cf_osslq_check_and_unblock()
1490 struct cf_osslq_ctx *ctx = cf->ctx; in h3_send_streams() local
1493 if(!ctx->tls.ossl.ssl || !ctx->h3.conn) in h3_send_streams()
1506 n = nghttp3_conn_writev_stream(ctx->h3.conn, &stream_id, &eos, in h3_send_streams()
1557 nghttp3_conn_block_stream(ctx->h3.conn, s->id); in h3_send_streams()
1572 ctx->q.last_io = Curl_now(); in h3_send_streams()
1573 rv = nghttp3_conn_add_write_offset(ctx->h3.conn, s->id, acked_len); in h3_send_streams()
1580 rv = nghttp3_conn_add_ack_offset(ctx->h3.conn, s->id, acked_len); in h3_send_streams()
1606 struct cf_osslq_ctx *ctx = cf->ctx; in cf_progress_egress() local
1609 if(!ctx->tls.ossl.ssl) in cf_progress_egress()
1617 if(!SSL_handle_events(ctx->tls.ossl.ssl)) { in cf_progress_egress()
1618 int detail = SSL_get_error(ctx->tls.ossl.ssl, 0); in cf_progress_egress()
1632 struct cf_osslq_ctx *ctx = cf->ctx; in check_and_set_expiry() local
1638 if(ctx->tls.ossl.ssl && in check_and_set_expiry()
1639 SSL_get_event_timeout(ctx->tls.ossl.ssl, &tv, &is_infinite) && in check_and_set_expiry()
1650 if(SSL_get_event_timeout(ctx->tls.ossl.ssl, &tv, &is_infinite)) { in check_and_set_expiry()
1667 struct cf_osslq_ctx *ctx = cf->ctx; in cf_osslq_connect() local
1689 if(!ctx->tls.ossl.ssl) { in cf_osslq_connect()
1690 ctx->started_at = now; in cf_osslq_connect()
1696 if(!ctx->got_first_byte) { in cf_osslq_connect()
1697 int readable = SOCKET_READABLE(ctx->q.sockfd, 0); in cf_osslq_connect()
1699 ctx->got_first_byte = TRUE; in cf_osslq_connect()
1700 ctx->first_byte_at = Curl_now(); in cf_osslq_connect()
1708 result = Curl_vquic_tls_before_recv(&ctx->tls, cf, data); in cf_osslq_connect()
1713 err = SSL_do_handshake(ctx->tls.ossl.ssl); in cf_osslq_connect()
1717 ctx->handshake_at = now; in cf_osslq_connect()
1718 ctx->q.last_io = now; in cf_osslq_connect()
1720 (int)Curl_timediff(now, ctx->started_at)); in cf_osslq_connect()
1731 int detail = SSL_get_error(ctx->tls.ossl.ssl, err); in cf_osslq_connect()
1734 ctx->q.last_io = now; in cf_osslq_connect()
1738 ctx->q.last_io = now; in cf_osslq_connect()
1744 ctx->q.last_io = now; in cf_osslq_connect()
1761 if(result == CURLE_RECV_ERROR && ctx->tls.ossl.ssl && in cf_osslq_connect()
1762 ctx->protocol_shutdown) { in cf_osslq_connect()
1792 struct cf_osslq_ctx *ctx = cf->ctx; in h3_stream_open() local
1808 stream = H3_STREAM_CTX(ctx, data); in h3_stream_open()
1850 *err = cf_osslq_stream_open(&stream->s, ctx->tls.ossl.ssl, 0, in h3_stream_open()
1851 &ctx->stream_bufcp, data); in h3_stream_open()
1882 rc = nghttp3_conn_submit_request(ctx->h3.conn, stream->s.id, in h3_stream_open()
1921 struct cf_osslq_ctx *ctx = cf->ctx; in cf_osslq_send() local
1922 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cf_osslq_send()
1930 DEBUGASSERT(ctx->tls.ossl.ssl); in cf_osslq_send()
1931 DEBUGASSERT(ctx->h3.conn); in cf_osslq_send()
1954 stream = H3_STREAM_CTX(ctx, data); in cf_osslq_send()
1984 (void)nghttp3_conn_resume_stream(ctx->h3.conn, stream->s.id); in cf_osslq_send()
2035 struct cf_osslq_ctx *ctx = cf->ctx; in cf_osslq_recv() local
2036 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cf_osslq_recv()
2041 (void)ctx; in cf_osslq_recv()
2044 DEBUGASSERT(ctx); in cf_osslq_recv()
2045 DEBUGASSERT(ctx->tls.ossl.ssl); in cf_osslq_recv()
2046 DEBUGASSERT(ctx->h3.conn); in cf_osslq_recv()
2119 struct cf_osslq_ctx *ctx = cf->ctx; in cf_osslq_data_pending() local
2120 const struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cf_osslq_data_pending()
2129 struct cf_osslq_ctx *ctx = cf->ctx; in cf_osslq_data_event() local
2149 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cf_osslq_data_event()
2154 (void)nghttp3_conn_resume_stream(ctx->h3.conn, stream->s.id); in cf_osslq_data_event()
2159 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cf_osslq_data_event()
2177 struct cf_osslq_ctx *ctx = cf->ctx; in cf_osslq_conn_is_alive() local
2183 if(!ctx->tls.ossl.ssl) in cf_osslq_conn_is_alive()
2190 uint64_t idle_ms = ctx->max_idle_ms; in cf_osslq_conn_is_alive()
2191 if(!SSL_get_value_uint(ctx->tls.ossl.ssl, in cf_osslq_conn_is_alive()
2199 idletime = Curl_timediff(Curl_now(), ctx->q.last_io); in cf_osslq_conn_is_alive()
2230 struct cf_osslq_ctx *ctx = cf->ctx; in cf_osslq_adjust_pollset() local
2232 if(!ctx->tls.ossl.ssl) { in cf_osslq_adjust_pollset()
2238 Curl_pollset_set(data, ps, ctx->q.sockfd, in cf_osslq_adjust_pollset()
2239 SSL_net_read_desired(ctx->tls.ossl.ssl), in cf_osslq_adjust_pollset()
2240 SSL_net_write_desired(ctx->tls.ossl.ssl)); in cf_osslq_adjust_pollset()
2246 Curl_pollset_check(data, ps, ctx->q.sockfd, &want_recv, &want_send); in cf_osslq_adjust_pollset()
2248 Curl_pollset_set(data, ps, ctx->q.sockfd, in cf_osslq_adjust_pollset()
2249 SSL_net_read_desired(ctx->tls.ossl.ssl), in cf_osslq_adjust_pollset()
2250 SSL_net_write_desired(ctx->tls.ossl.ssl)); in cf_osslq_adjust_pollset()
2252 else if(ctx->need_recv || ctx->need_send) { in cf_osslq_adjust_pollset()
2253 Curl_pollset_set(data, ps, ctx->q.sockfd, in cf_osslq_adjust_pollset()
2254 ctx->need_recv, ctx->need_send); in cf_osslq_adjust_pollset()
2263 struct cf_osslq_ctx *ctx = cf->ctx; in cf_osslq_query() local
2270 if(!SSL_get_value_uint(ctx->tls.ossl.ssl, SSL_VALUE_CLASS_GENERIC, in cf_osslq_query()
2285 if(ctx->got_first_byte) { in cf_osslq_query()
2286 timediff_t ms = Curl_timediff(ctx->first_byte_at, ctx->started_at); in cf_osslq_query()
2294 if(ctx->got_first_byte) in cf_osslq_query()
2295 *when = ctx->first_byte_at; in cf_osslq_query()
2301 *when = ctx->handshake_at; in cf_osslq_query()
2336 struct cf_osslq_ctx *ctx = NULL; in Curl_cf_osslq_create() local
2341 ctx = calloc(1, sizeof(*ctx)); in Curl_cf_osslq_create()
2342 if(!ctx) { in Curl_cf_osslq_create()
2346 cf_osslq_ctx_init(ctx); in Curl_cf_osslq_create()
2348 result = Curl_cf_create(&cf, &Curl_cft_http3, ctx); in Curl_cf_osslq_create()
2367 cf_osslq_ctx_free(ctx); in Curl_cf_osslq_create()