Lines Matching refs:ctx
148 ((struct cf_ngtcp2_ctx *)(cf)->ctx)->call_data
152 static void cf_ngtcp2_ctx_init(struct cf_ngtcp2_ctx *ctx) in cf_ngtcp2_ctx_init() argument
154 DEBUGASSERT(!ctx->initialized); in cf_ngtcp2_ctx_init()
155 ctx->qlogfd = -1; in cf_ngtcp2_ctx_init()
156 ctx->version = NGTCP2_PROTO_VER_MAX; in cf_ngtcp2_ctx_init()
157 ctx->max_stream_window = H3_STREAM_WINDOW_SIZE; in cf_ngtcp2_ctx_init()
158 ctx->max_idle_ms = CURL_QUIC_MAX_IDLE_MS; in cf_ngtcp2_ctx_init()
159 Curl_bufcp_init(&ctx->stream_bufcp, H3_STREAM_CHUNK_SIZE, in cf_ngtcp2_ctx_init()
161 Curl_dyn_init(&ctx->scratch, CURL_MAX_HTTP_HEADER); in cf_ngtcp2_ctx_init()
162 Curl_hash_offt_init(&ctx->streams, 63, h3_stream_hash_free); in cf_ngtcp2_ctx_init()
163 ctx->initialized = TRUE; in cf_ngtcp2_ctx_init()
166 static void cf_ngtcp2_ctx_free(struct cf_ngtcp2_ctx *ctx) in cf_ngtcp2_ctx_free() argument
168 if(ctx && ctx->initialized) { in cf_ngtcp2_ctx_free()
169 Curl_bufcp_free(&ctx->stream_bufcp); in cf_ngtcp2_ctx_free()
170 Curl_dyn_free(&ctx->scratch); in cf_ngtcp2_ctx_free()
171 Curl_hash_clean(&ctx->streams); in cf_ngtcp2_ctx_free()
172 Curl_hash_destroy(&ctx->streams); in cf_ngtcp2_ctx_free()
173 Curl_ssl_peer_cleanup(&ctx->peer); in cf_ngtcp2_ctx_free()
175 free(ctx); in cf_ngtcp2_ctx_free()
205 #define H3_STREAM_CTX(ctx,data) ((struct h3_stream_ctx *)(\ argument
206 data? Curl_hash_offt_get(&(ctx)->streams, (data)->mid) : NULL))
207 #define H3_STREAM_CTX_ID(ctx,id) ((struct h3_stream_ctx *)(\ argument
208 Curl_hash_offt_get(&(ctx)->streams, (id))))
226 struct cf_ngtcp2_ctx *ctx = cf->ctx; in h3_data_setup() local
227 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in h3_data_setup()
241 Curl_bufq_initp(&stream->sendbuf, &ctx->stream_bufcp, in h3_data_setup()
246 if(!Curl_hash_offt_set(&ctx->streams, data->mid, stream)) { in h3_data_setup()
258 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cf_ngtcp2_stream_close() local
261 if(!stream->closed && ctx->qconn && ctx->h3conn) { in cf_ngtcp2_stream_close()
264 nghttp3_conn_set_stream_user_data(ctx->h3conn, stream->id, NULL); in cf_ngtcp2_stream_close()
265 ngtcp2_conn_set_stream_user_data(ctx->qconn, stream->id, NULL); in cf_ngtcp2_stream_close()
267 (void)ngtcp2_conn_shutdown_stream(ctx->qconn, 0, stream->id, in cf_ngtcp2_stream_close()
278 struct cf_ngtcp2_ctx *ctx = cf->ctx; in h3_data_done() local
279 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in h3_data_done()
285 Curl_hash_offt_remove(&ctx->streams, data->mid); in h3_data_done()
294 struct cf_ngtcp2_ctx *ctx = cf->ctx; in get_stream_easy() local
298 stream = H3_STREAM_CTX(ctx, data); in get_stream_easy()
310 stream = H3_STREAM_CTX(ctx, sdata); in get_stream_easy()
324 struct cf_ngtcp2_ctx *ctx = cf->ctx; in h3_drain_stream() local
325 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in h3_drain_stream()
352 struct cf_ngtcp2_ctx *ctx = cf->ctx; in pktx_update_time() local
354 vquic_ctx_update_time(&ctx->q); in pktx_update_time()
355 pktx->ts = (ngtcp2_tstamp)ctx->q.last_op.tv_sec * NGTCP2_SECONDS + in pktx_update_time()
356 (ngtcp2_tstamp)ctx->q.last_op.tv_usec * NGTCP2_MICROSECONDS; in pktx_update_time()
376 struct cf_ngtcp2_ctx *ctx = cf->ctx; in get_conn() local
377 return ctx->qconn; in get_conn()
384 struct cf_ngtcp2_ctx *ctx = cf->ctx; in quic_printf() local
386 (void)ctx; /* TODO: need an easy handle to infof() message */ in quic_printf()
399 struct cf_ngtcp2_ctx *ctx = cf->ctx; in qlog_callback() local
401 if(ctx->qlogfd != -1) { in qlog_callback()
402 ssize_t rc = write(ctx->qlogfd, data, datalen); in qlog_callback()
405 close(ctx->qlogfd); in qlog_callback()
406 ctx->qlogfd = -1; in qlog_callback()
412 static void quic_settings(struct cf_ngtcp2_ctx *ctx, in quic_settings() argument
416 ngtcp2_settings *s = &ctx->settings; in quic_settings()
417 ngtcp2_transport_params *t = &ctx->transport_params; in quic_settings()
430 s->max_window = 100 * ctx->max_stream_window; in quic_settings()
431 s->max_stream_window = 10 * ctx->max_stream_window; in quic_settings()
433 t->initial_max_data = 10 * ctx->max_stream_window; in quic_settings()
434 t->initial_max_stream_data_bidi_local = ctx->max_stream_window; in quic_settings()
435 t->initial_max_stream_data_bidi_remote = ctx->max_stream_window; in quic_settings()
436 t->initial_max_stream_data_uni = ctx->max_stream_window; in quic_settings()
439 t->max_idle_timeout = (ctx->max_idle_ms * NGTCP2_MILLISECONDS); in quic_settings()
440 if(ctx->qlogfd != -1) { in quic_settings()
467 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cf_ngtcp2_err_set() local
468 if(!ctx->last_error.error_code) { in cf_ngtcp2_err_set()
470 ngtcp2_ccerr_set_tls_alert(&ctx->last_error, in cf_ngtcp2_err_set()
471 ngtcp2_conn_get_tls_alert(ctx->qconn), in cf_ngtcp2_err_set()
475 ngtcp2_ccerr_set_liberr(&ctx->last_error, code, NULL, 0); in cf_ngtcp2_err_set()
491 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cf_ngtcp2_h3_err_set() local
492 if(!ctx->last_error.error_code) { in cf_ngtcp2_h3_err_set()
493 ngtcp2_ccerr_set_application_error(&ctx->last_error, in cf_ngtcp2_h3_err_set()
506 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cb_recv_stream_data() local
515 nghttp3_conn_read_stream(ctx->h3conn, stream_id, buf, buflen, fin); in cb_recv_stream_data()
522 struct h3_stream_ctx *stream = H3_STREAM_CTX_ID(ctx, stream_id); in cb_recv_stream_data()
546 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cb_acked_stream_data_offset() local
554 rv = nghttp3_conn_add_ack_offset(ctx->h3conn, stream_id, datalen); in cb_acked_stream_data_offset()
567 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cb_stream_close() local
583 rv = nghttp3_conn_close_stream(ctx->h3conn, stream_id, app_error_code); in cb_stream_close()
600 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cb_stream_reset() local
609 rv = nghttp3_conn_shutdown_stream_read(ctx->h3conn, stream_id); in cb_stream_reset()
623 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cb_stream_stop_sending() local
629 rv = nghttp3_conn_shutdown_stream_read(ctx->h3conn, stream_id); in cb_stream_stop_sending()
642 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cb_extend_max_local_streams_bidi() local
646 ctx->max_bidi_streams = max_streams; in cb_extend_max_local_streams_bidi()
649 ", used %" FMT_PRIu64, (curl_uint64_t)ctx->max_bidi_streams, in cb_extend_max_local_streams_bidi()
650 (curl_uint64_t)ctx->used_bidi_streams); in cb_extend_max_local_streams_bidi()
659 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cb_extend_max_stream_data() local
669 rv = nghttp3_conn_unblock_stream(ctx->h3conn, stream_id); in cb_extend_max_stream_data()
796 struct cf_ngtcp2_ctx *ctx = cf->ctx; in check_and_set_expiry() local
808 expiry = ngtcp2_conn_get_expiry(ctx->qconn); in check_and_set_expiry()
812 int rv = ngtcp2_conn_handle_expiry(ctx->qconn, pktx->ts); in check_and_set_expiry()
826 expiry = ngtcp2_conn_get_expiry(ctx->qconn); in check_and_set_expiry()
845 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cf_ngtcp2_adjust_pollset() local
848 if(!ctx->qconn) in cf_ngtcp2_adjust_pollset()
851 Curl_pollset_check(data, ps, ctx->q.sockfd, &want_recv, &want_send); in cf_ngtcp2_adjust_pollset()
852 if(!want_send && !Curl_bufq_is_empty(&ctx->q.sendbuf)) in cf_ngtcp2_adjust_pollset()
856 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cf_ngtcp2_adjust_pollset()
861 c_exhaust = want_send && (!ngtcp2_conn_get_cwnd_left(ctx->qconn) || in cf_ngtcp2_adjust_pollset()
862 !ngtcp2_conn_get_max_data_left(ctx->qconn)); in cf_ngtcp2_adjust_pollset()
867 !Curl_bufq_is_empty(&ctx->q.sendbuf); in cf_ngtcp2_adjust_pollset()
869 Curl_pollset_set(data, ps, ctx->q.sockfd, want_recv, want_send); in cf_ngtcp2_adjust_pollset()
879 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cb_h3_stream_close() local
882 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cb_h3_stream_close()
942 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cb_h3_recv_data() local
944 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cb_h3_recv_data()
956 ngtcp2_conn_extend_max_stream_offset(ctx->qconn, stream->id, blen); in cb_h3_recv_data()
957 ngtcp2_conn_extend_max_offset(ctx->qconn, blen); in cb_h3_recv_data()
968 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cb_h3_deferred_consume() local
974 ngtcp2_conn_extend_max_stream_offset(ctx->qconn, stream3_id, consumed); in cb_h3_deferred_consume()
975 ngtcp2_conn_extend_max_offset(ctx->qconn, consumed); in cb_h3_deferred_consume()
983 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cb_h3_end_headers() local
986 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cb_h3_end_headers()
1012 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cb_h3_recv_header() local
1017 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cb_h3_recv_header()
1035 Curl_dyn_reset(&ctx->scratch); in cb_h3_recv_header()
1036 result = Curl_dyn_addn(&ctx->scratch, STRCONST("HTTP/3 ")); in cb_h3_recv_header()
1038 result = Curl_dyn_addn(&ctx->scratch, in cb_h3_recv_header()
1041 result = Curl_dyn_addn(&ctx->scratch, STRCONST(" \r\n")); in cb_h3_recv_header()
1043 h3_xfer_write_resp_hd(cf, data, stream, Curl_dyn_ptr(&ctx->scratch), in cb_h3_recv_header()
1044 Curl_dyn_len(&ctx->scratch), FALSE); in cb_h3_recv_header()
1046 stream_id, Curl_dyn_ptr(&ctx->scratch)); in cb_h3_recv_header()
1056 Curl_dyn_reset(&ctx->scratch); in cb_h3_recv_header()
1057 result = Curl_dyn_addn(&ctx->scratch, in cb_h3_recv_header()
1060 result = Curl_dyn_addn(&ctx->scratch, STRCONST(": ")); in cb_h3_recv_header()
1062 result = Curl_dyn_addn(&ctx->scratch, in cb_h3_recv_header()
1065 result = Curl_dyn_addn(&ctx->scratch, STRCONST("\r\n")); in cb_h3_recv_header()
1067 h3_xfer_write_resp_hd(cf, data, stream, Curl_dyn_ptr(&ctx->scratch), in cb_h3_recv_header()
1068 Curl_dyn_len(&ctx->scratch), FALSE); in cb_h3_recv_header()
1078 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cb_h3_stop_sending() local
1083 rv = ngtcp2_conn_shutdown_stream_read(ctx->qconn, 0, stream_id, in cb_h3_stop_sending()
1096 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cb_h3_reset_stream() local
1103 rv = ngtcp2_conn_shutdown_stream_write(ctx->qconn, 0, stream_id, in cb_h3_reset_stream()
1133 struct cf_ngtcp2_ctx *ctx = cf->ctx; in init_ngh3_conn() local
1138 if(ngtcp2_conn_get_streams_uni_left(ctx->qconn) < 3) { in init_ngh3_conn()
1142 nghttp3_settings_default(&ctx->h3settings); in init_ngh3_conn()
1144 rc = nghttp3_conn_client_new(&ctx->h3conn, in init_ngh3_conn()
1146 &ctx->h3settings, in init_ngh3_conn()
1154 rc = ngtcp2_conn_open_uni_stream(ctx->qconn, &ctrl_stream_id, NULL); in init_ngh3_conn()
1160 rc = nghttp3_conn_bind_control_stream(ctx->h3conn, ctrl_stream_id); in init_ngh3_conn()
1166 rc = ngtcp2_conn_open_uni_stream(ctx->qconn, &qpack_enc_stream_id, NULL); in init_ngh3_conn()
1172 rc = ngtcp2_conn_open_uni_stream(ctx->qconn, &qpack_dec_stream_id, NULL); in init_ngh3_conn()
1178 rc = nghttp3_conn_bind_qpack_streams(ctx->h3conn, qpack_enc_stream_id, in init_ngh3_conn()
1223 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cf_ngtcp2_recv() local
1224 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cf_ngtcp2_recv()
1229 (void)ctx; in cf_ngtcp2_recv()
1234 DEBUGASSERT(ctx); in cf_ngtcp2_recv()
1235 DEBUGASSERT(ctx->qconn); in cf_ngtcp2_recv()
1236 DEBUGASSERT(ctx->h3conn); in cf_ngtcp2_recv()
1241 if(!stream || ctx->shutdown_started) { in cf_ngtcp2_recv()
1289 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cb_h3_acked_req_body() local
1291 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cb_h3_acked_req_body()
1324 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cb_h3_read_req_body() local
1326 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cb_h3_read_req_body()
1392 struct cf_ngtcp2_ctx *ctx = cf->ctx; in h3_stream_open() local
1409 stream = H3_STREAM_CTX(ctx, data); in h3_stream_open()
1450 rc = ngtcp2_conn_open_bidi_stream(ctx->qconn, &sid, data); in h3_stream_open()
1458 ++ctx->used_bidi_streams; in h3_stream_open()
1484 rc = nghttp3_conn_submit_request(ctx->h3conn, stream->id, in h3_stream_open()
1522 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cf_ngtcp2_send() local
1523 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cf_ngtcp2_send()
1531 DEBUGASSERT(ctx->qconn); in cf_ngtcp2_send()
1532 DEBUGASSERT(ctx->h3conn); in cf_ngtcp2_send()
1544 if(ctx->shutdown_started) { in cf_ngtcp2_send()
1555 stream = H3_STREAM_CTX(ctx, data); in cf_ngtcp2_send()
1583 else if(ctx->shutdown_started) { in cf_ngtcp2_send()
1598 (void)nghttp3_conn_resume_stream(ctx->h3conn, stream->id); in cf_ngtcp2_send()
1622 struct cf_ngtcp2_ctx *ctx = cf->ctx; in qng_verify_peer() local
1627 return Curl_vquic_tls_verify_peer(&ctx->tls, cf, data, &ctx->peer); in qng_verify_peer()
1636 struct cf_ngtcp2_ctx *ctx = pktx->cf->ctx; in recv_pkt() local
1641 ngtcp2_addr_init(&path.local, (struct sockaddr *)&ctx->q.local_addr, in recv_pkt()
1642 (socklen_t)ctx->q.local_addrlen); in recv_pkt()
1647 rv = ngtcp2_conn_read_pkt(ctx->qconn, &path, &pi, pkt, pktlen, pktx->ts); in recv_pkt()
1667 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cf_progress_ingress() local
1676 result = Curl_vquic_tls_before_recv(&ctx->tls, cf, data); in cf_progress_ingress()
1680 return vquic_recv_packets(cf, data, &ctx->q, 1000, recv_pkt, pktx); in cf_progress_ingress()
1692 struct cf_ngtcp2_ctx *ctx = x->cf->ctx; in read_pkt_to_send() local
1715 if(ctx->h3conn && ngtcp2_conn_get_max_data_left(ctx->qconn)) { in read_pkt_to_send()
1716 veccnt = nghttp3_conn_writev_stream(ctx->h3conn, &stream_id, &fin, vec, in read_pkt_to_send()
1729 n = ngtcp2_conn_writev_stream(ctx->qconn, &x->ps.path, in read_pkt_to_send()
1742 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, x->data); in read_pkt_to_send()
1744 nghttp3_conn_block_stream(ctx->h3conn, stream_id); in read_pkt_to_send()
1755 nghttp3_conn_shutdown_stream_write(ctx->h3conn, stream_id); in read_pkt_to_send()
1777 int rv = nghttp3_conn_add_write_offset(ctx->h3conn, stream_id, ndatalen); in read_pkt_to_send()
1799 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cf_progress_egress() local
1816 curlcode = vquic_flush(cf, data, &ctx->q); in cf_progress_egress()
1836 max_payload_size = ngtcp2_conn_get_max_tx_udp_payload_size(ctx->qconn); in cf_progress_egress()
1838 ngtcp2_conn_get_path_max_tx_udp_payload_size(ctx->qconn); in cf_progress_egress()
1841 ctx->q.sendbuf.chunk_size / max_payload_size); in cf_progress_egress()
1845 nread = Curl_bufq_sipn(&ctx->q.sendbuf, max_payload_size, in cf_progress_egress()
1851 curlcode = vquic_send(cf, data, &ctx->q, gsolen); in cf_progress_egress()
1873 curlcode = vquic_send_tail_split(cf, data, &ctx->q, in cf_progress_egress()
1890 curlcode = vquic_send(cf, data, &ctx->q, gsolen); in cf_progress_egress()
1936 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cf_ngtcp2_data_event() local
1956 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cf_ngtcp2_data_event()
1961 (void)nghttp3_conn_resume_stream(ctx->h3conn, stream->id); in cf_ngtcp2_data_event()
1966 struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cf_ngtcp2_data_event()
1982 static void cf_ngtcp2_ctx_close(struct cf_ngtcp2_ctx *ctx) in cf_ngtcp2_ctx_close() argument
1984 struct cf_call_data save = ctx->call_data; in cf_ngtcp2_ctx_close()
1986 if(!ctx->initialized) in cf_ngtcp2_ctx_close()
1988 if(ctx->qlogfd != -1) { in cf_ngtcp2_ctx_close()
1989 close(ctx->qlogfd); in cf_ngtcp2_ctx_close()
1991 ctx->qlogfd = -1; in cf_ngtcp2_ctx_close()
1992 Curl_vquic_tls_cleanup(&ctx->tls); in cf_ngtcp2_ctx_close()
1993 vquic_ctx_free(&ctx->q); in cf_ngtcp2_ctx_close()
1994 if(ctx->h3conn) in cf_ngtcp2_ctx_close()
1995 nghttp3_conn_del(ctx->h3conn); in cf_ngtcp2_ctx_close()
1996 if(ctx->qconn) in cf_ngtcp2_ctx_close()
1997 ngtcp2_conn_del(ctx->qconn); in cf_ngtcp2_ctx_close()
1998 ctx->call_data = save; in cf_ngtcp2_ctx_close()
2004 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cf_ngtcp2_shutdown() local
2009 if(cf->shutdown || !ctx->qconn) { in cf_ngtcp2_shutdown()
2018 if(!ctx->shutdown_started) { in cf_ngtcp2_shutdown()
2022 if(!Curl_bufq_is_empty(&ctx->q.sendbuf)) { in cf_ngtcp2_shutdown()
2025 if(!Curl_bufq_is_empty(&ctx->q.sendbuf)) { in cf_ngtcp2_shutdown()
2037 ctx->shutdown_started = TRUE; in cf_ngtcp2_shutdown()
2039 ctx->qconn, NULL, /* path */ in cf_ngtcp2_shutdown()
2042 &ctx->last_error, pktx.ts); in cf_ngtcp2_shutdown()
2044 FMT_PRIu64 ") -> %d", ctx->last_error.type, in cf_ngtcp2_shutdown()
2045 (curl_uint64_t)ctx->last_error.error_code, (int)nwritten); in cf_ngtcp2_shutdown()
2047 Curl_bufq_write(&ctx->q.sendbuf, (const unsigned char *)buffer, in cf_ngtcp2_shutdown()
2054 ctx->q.no_gso = TRUE; in cf_ngtcp2_shutdown()
2055 ctx->q.gsolen = (size_t)nwritten; in cf_ngtcp2_shutdown()
2056 ctx->q.split_len = 0; in cf_ngtcp2_shutdown()
2060 if(!Curl_bufq_is_empty(&ctx->q.sendbuf)) { in cf_ngtcp2_shutdown()
2062 result = vquic_flush(cf, data, &ctx->q); in cf_ngtcp2_shutdown()
2075 if(Curl_bufq_is_empty(&ctx->q.sendbuf)) { in cf_ngtcp2_shutdown()
2096 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cf_ngtcp2_close() local
2100 if(ctx && ctx->qconn) { in cf_ngtcp2_close()
2102 cf_ngtcp2_ctx_close(ctx); in cf_ngtcp2_close()
2112 if(cf->ctx) { in cf_ngtcp2_destroy()
2113 cf_ngtcp2_ctx_free(cf->ctx); in cf_ngtcp2_destroy()
2114 cf->ctx = NULL; in cf_ngtcp2_destroy()
2125 struct cf_ngtcp2_ctx *ctx; in quic_ossl_new_session_cb() local
2131 ctx = cf ? cf->ctx : NULL; in quic_ossl_new_session_cb()
2133 if(cf && data && ctx) { in quic_ossl_new_session_cb()
2134 Curl_ossl_add_session(cf, data, &ctx->peer, ssl_sessionid); in quic_ossl_new_session_cb()
2148 struct cf_ngtcp2_ctx *ctx = cf ? cf->ctx : NULL; in quic_gtls_handshake_cb() local
2152 if(when && cf && ctx) { /* after message has been processed */ in quic_gtls_handshake_cb()
2161 (void)Curl_gtls_update_session_id(cf, data, session, &ctx->peer, "h3"); in quic_gtls_handshake_cb()
2180 struct cf_ngtcp2_ctx *ctx = cf->ctx; in wssl_quic_new_session_cb() local
2183 if(data && ctx) { in wssl_quic_new_session_cb()
2184 (void)wssl_cache_session(cf, data, &ctx->peer, session); in wssl_quic_new_session_cb()
2195 struct curl_tls_ctx *ctx = user_data; in tls_ctx_setup() local
2200 if(ngtcp2_crypto_boringssl_configure_client_context(ctx->ossl.ssl_ctx) in tls_ctx_setup()
2206 if(ngtcp2_crypto_quictls_configure_client_context(ctx->ossl.ssl_ctx) != 0) { in tls_ctx_setup()
2216 SSL_CTX_set_session_cache_mode(ctx->ossl.ssl_ctx, in tls_ctx_setup()
2219 SSL_CTX_sess_set_new_cb(ctx->ossl.ssl_ctx, quic_ossl_new_session_cb); in tls_ctx_setup()
2223 if(ngtcp2_crypto_gnutls_configure_client_session(ctx->gtls.session) != 0) { in tls_ctx_setup()
2228 gnutls_handshake_set_hook_function(ctx->gtls.session, in tls_ctx_setup()
2234 if(ngtcp2_crypto_wolfssl_configure_client_context(ctx->wssl.ctx) != 0) { in tls_ctx_setup()
2240 wolfSSL_CTX_sess_set_new_cb(ctx->wssl.ctx, wssl_quic_new_session_cb); in tls_ctx_setup()
2253 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cf_connect_start() local
2260 DEBUGASSERT(ctx->initialized); in cf_connect_start()
2261 result = Curl_ssl_peer_init(&ctx->peer, cf, TRNSPRT_QUIC); in cf_connect_start()
2266 result = Curl_vquic_tls_init(&ctx->tls, cf, data, &ctx->peer, in cf_connect_start()
2268 tls_ctx_setup, &ctx->tls, &ctx->conn_ref); in cf_connect_start()
2273 SSL_set_quic_use_legacy_codepoint(ctx->tls.ossl.ssl, 0); in cf_connect_start()
2276 ctx->dcid.datalen = NGTCP2_MAX_CIDLEN; in cf_connect_start()
2277 result = Curl_rand(data, ctx->dcid.data, NGTCP2_MAX_CIDLEN); in cf_connect_start()
2281 ctx->scid.datalen = NGTCP2_MAX_CIDLEN; in cf_connect_start()
2282 result = Curl_rand(data, ctx->scid.data, NGTCP2_MAX_CIDLEN); in cf_connect_start()
2286 (void)Curl_qlogdir(data, ctx->scid.data, NGTCP2_MAX_CIDLEN, &qfd); in cf_connect_start()
2287 ctx->qlogfd = qfd; /* -1 if failure above */ in cf_connect_start()
2288 quic_settings(ctx, data, pktx); in cf_connect_start()
2290 result = vquic_ctx_init(&ctx->q); in cf_connect_start()
2294 Curl_cf_socket_peek(cf->next, data, &ctx->q.sockfd, &sockaddr, NULL); in cf_connect_start()
2297 ctx->q.local_addrlen = sizeof(ctx->q.local_addr); in cf_connect_start()
2298 rv = getsockname(ctx->q.sockfd, (struct sockaddr *)&ctx->q.local_addr, in cf_connect_start()
2299 &ctx->q.local_addrlen); in cf_connect_start()
2303 ngtcp2_addr_init(&ctx->connected_path.local, in cf_connect_start()
2304 (struct sockaddr *)&ctx->q.local_addr, in cf_connect_start()
2305 ctx->q.local_addrlen); in cf_connect_start()
2306 ngtcp2_addr_init(&ctx->connected_path.remote, in cf_connect_start()
2309 rc = ngtcp2_conn_client_new(&ctx->qconn, &ctx->dcid, &ctx->scid, in cf_connect_start()
2310 &ctx->connected_path, in cf_connect_start()
2312 &ctx->settings, &ctx->transport_params, in cf_connect_start()
2318 ngtcp2_conn_set_tls_native_handle(ctx->qconn, ctx->tls.ossl.ssl); in cf_connect_start()
2320 ngtcp2_conn_set_tls_native_handle(ctx->qconn, ctx->tls.gtls.session); in cf_connect_start()
2322 ngtcp2_conn_set_tls_native_handle(ctx->qconn, ctx->tls.wssl.handle); in cf_connect_start()
2327 ngtcp2_ccerr_default(&ctx->last_error); in cf_connect_start()
2329 ctx->conn_ref.get_conn = get_conn; in cf_connect_start()
2330 ctx->conn_ref.user_data = cf; in cf_connect_start()
2339 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cf_ngtcp2_connect() local
2363 if(!ctx->qconn) { in cf_ngtcp2_connect()
2364 ctx->started_at = now; in cf_ngtcp2_connect()
2381 if(ngtcp2_conn_get_handshake_completed(ctx->qconn)) { in cf_ngtcp2_connect()
2382 ctx->handshake_at = now; in cf_ngtcp2_connect()
2384 (int)Curl_timediff(now, ctx->started_at)); in cf_ngtcp2_connect()
2396 if(result == CURLE_RECV_ERROR && ctx->qconn && in cf_ngtcp2_connect()
2397 ngtcp2_conn_in_draining_period(ctx->qconn)) { in cf_ngtcp2_connect()
2414 if(!result && ctx->qconn) { in cf_ngtcp2_connect()
2427 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cf_ngtcp2_query() local
2438 if(!ctx->qconn || ctx->shutdown_started) { in cf_ngtcp2_query()
2441 else if(ctx->max_bidi_streams) { in cf_ngtcp2_query()
2444 if(ctx->max_bidi_streams > ctx->used_bidi_streams) in cf_ngtcp2_query()
2445 avail_bidi_streams = ctx->max_bidi_streams - ctx->used_bidi_streams; in cf_ngtcp2_query()
2458 if(ctx->q.got_first_byte) { in cf_ngtcp2_query()
2459 timediff_t ms = Curl_timediff(ctx->q.first_byte_at, ctx->started_at); in cf_ngtcp2_query()
2467 if(ctx->q.got_first_byte) in cf_ngtcp2_query()
2468 *when = ctx->q.first_byte_at; in cf_ngtcp2_query()
2474 *when = ctx->handshake_at; in cf_ngtcp2_query()
2489 struct cf_ngtcp2_ctx *ctx = cf->ctx; in cf_ngtcp2_conn_is_alive() local
2496 if(!ctx->qconn || ctx->shutdown_started) in cf_ngtcp2_conn_is_alive()
2504 rp = ngtcp2_conn_get_remote_transport_params(ctx->qconn); in cf_ngtcp2_conn_is_alive()
2507 uint64_t idle_ms = ctx->max_idle_ms; in cf_ngtcp2_conn_is_alive()
2512 idletime = Curl_timediff(Curl_now(), ctx->q.last_io); in cf_ngtcp2_conn_is_alive()
2561 struct cf_ngtcp2_ctx *ctx = NULL; in Curl_cf_ngtcp2_create() local
2566 ctx = calloc(1, sizeof(*ctx)); in Curl_cf_ngtcp2_create()
2567 if(!ctx) { in Curl_cf_ngtcp2_create()
2571 cf_ngtcp2_ctx_init(ctx); in Curl_cf_ngtcp2_create()
2573 result = Curl_cf_create(&cf, &Curl_cft_http3, ctx); in Curl_cf_ngtcp2_create()
2592 cf_ngtcp2_ctx_free(ctx); in Curl_cf_ngtcp2_create()