Lines Matching refs:ctx

140   ((struct cf_ngtcp2_ctx *)(cf)->ctx)->call_data
173 struct cf_ngtcp2_ctx *ctx = cf->ctx;
190 Curl_bufq_initp(&stream->sendbuf, &ctx->stream_bufcp,
195 Curl_bufq_initp(&stream->recvbuf, &ctx->stream_bufcp,
206 struct cf_ngtcp2_ctx *ctx = cf->ctx;
212 if(ctx->h3conn && !stream->closed) {
213 nghttp3_conn_shutdown_stream_read(ctx->h3conn, stream->id);
214 nghttp3_conn_close_stream(ctx->h3conn, stream->id,
216 nghttp3_conn_set_stream_user_data(ctx->h3conn, stream->id, NULL);
217 ngtcp2_conn_set_stream_user_data(ctx->qconn, stream->id, NULL);
281 struct cf_ngtcp2_ctx *ctx = cf->ctx;
283 vquic_ctx_update_time(&ctx->q);
284 pktx->ts = ctx->q.last_op.tv_sec * NGTCP2_SECONDS +
285 ctx->q.last_op.tv_usec * NGTCP2_MICROSECONDS;
312 struct cf_ngtcp2_ctx *ctx = cf->ctx;
313 return ctx->qconn;
320 struct cf_ngtcp2_ctx *ctx = cf->ctx;
322 (void)ctx; /* TODO: need an easy handle to infof() message */
335 struct cf_ngtcp2_ctx *ctx = cf->ctx;
337 if(ctx->qlogfd != -1) {
338 ssize_t rc = write(ctx->qlogfd, data, datalen);
341 close(ctx->qlogfd);
342 ctx->qlogfd = -1;
348 static void quic_settings(struct cf_ngtcp2_ctx *ctx,
352 ngtcp2_settings *s = &ctx->settings;
353 ngtcp2_transport_params *t = &ctx->transport_params;
366 s->max_window = 100 * ctx->max_stream_window;
367 s->max_stream_window = ctx->max_stream_window;
369 t->initial_max_data = 10 * ctx->max_stream_window;
370 t->initial_max_stream_data_bidi_local = ctx->max_stream_window;
371 t->initial_max_stream_data_bidi_remote = ctx->max_stream_window;
372 t->initial_max_stream_data_uni = ctx->max_stream_window;
375 t->max_idle_timeout = (ctx->max_idle_ms * NGTCP2_MILLISECONDS);
376 if(ctx->qlogfd != -1) {
395 struct cf_ngtcp2_ctx *ctx = cf->ctx;
414 ngtcp2_conn_extend_max_stream_offset(ctx->qconn, stream->id,
416 ngtcp2_conn_extend_max_offset(ctx->qconn, consumed);
426 struct cf_ngtcp2_ctx *ctx = cf->ctx;
434 nghttp3_conn_read_stream(ctx->h3conn, stream_id, buf, buflen, fin);
445 &ctx->last_error,
465 struct cf_ngtcp2_ctx *ctx = cf->ctx;
473 rv = nghttp3_conn_add_ack_offset(ctx->h3conn, stream_id, datalen);
487 struct cf_ngtcp2_ctx *ctx = cf->ctx;
498 rv = nghttp3_conn_close_stream(ctx->h3conn, stream3_id,
504 &ctx->last_error, nghttp3_err_infer_quic_app_error_code(rv), NULL, 0);
516 struct cf_ngtcp2_ctx *ctx = cf->ctx;
524 rv = nghttp3_conn_shutdown_stream_read(ctx->h3conn, stream_id);
538 struct cf_ngtcp2_ctx *ctx = cf->ctx;
544 rv = nghttp3_conn_shutdown_stream_read(ctx->h3conn, stream_id);
568 struct cf_ngtcp2_ctx *ctx = cf->ctx;
577 rv = nghttp3_conn_unblock_stream(ctx->h3conn, stream_id);
696 struct cf_ngtcp2_ctx *ctx = cf->ctx;
708 expiry = ngtcp2_conn_get_expiry(ctx->qconn);
712 int rv = ngtcp2_conn_handle_expiry(ctx->qconn, pktx->ts);
716 ngtcp2_ccerr_set_liberr(&ctx->last_error, rv, NULL, 0);
726 expiry = ngtcp2_conn_get_expiry(ctx->qconn);
744 struct cf_ngtcp2_ctx *ctx = cf->ctx;
747 if(!ctx->qconn)
750 Curl_pollset_check(data, ps, ctx->q.sockfd, &want_recv, &want_send);
757 c_exhaust = want_send && (!ngtcp2_conn_get_cwnd_left(ctx->qconn) ||
758 !ngtcp2_conn_get_max_data_left(ctx->qconn));
763 !Curl_bufq_is_empty(&ctx->q.sendbuf);
765 Curl_pollset_set(data, ps, ctx->q.sockfd, want_recv, want_send);
865 struct cf_ngtcp2_ctx *ctx = cf->ctx;
871 ngtcp2_conn_extend_max_stream_offset(ctx->qconn, stream3_id, consumed);
872 ngtcp2_conn_extend_max_offset(ctx->qconn, consumed);
972 struct cf_ngtcp2_ctx *ctx = cf->ctx;
977 rv = ngtcp2_conn_shutdown_stream_read(ctx->qconn, 0, stream_id,
990 struct cf_ngtcp2_ctx *ctx = cf->ctx;
996 rv = ngtcp2_conn_shutdown_stream_write(ctx->qconn, 0, stream_id,
1026 struct cf_ngtcp2_ctx *ctx = cf->ctx;
1031 if(ngtcp2_conn_get_streams_uni_left(ctx->qconn) < 3) {
1035 nghttp3_settings_default(&ctx->h3settings);
1037 rc = nghttp3_conn_client_new(&ctx->h3conn,
1039 &ctx->h3settings,
1047 rc = ngtcp2_conn_open_uni_stream(ctx->qconn, &ctrl_stream_id, NULL);
1053 rc = nghttp3_conn_bind_control_stream(ctx->h3conn, ctrl_stream_id);
1059 rc = ngtcp2_conn_open_uni_stream(ctx->qconn, &qpack_enc_stream_id, NULL);
1065 rc = ngtcp2_conn_open_uni_stream(ctx->qconn, &qpack_dec_stream_id, NULL);
1071 rc = nghttp3_conn_bind_qpack_streams(ctx->h3conn, qpack_enc_stream_id,
1117 struct cf_ngtcp2_ctx *ctx = cf->ctx;
1123 (void)ctx;
1127 DEBUGASSERT(ctx);
1128 DEBUGASSERT(ctx->qconn);
1129 DEBUGASSERT(ctx->h3conn);
1305 struct cf_ngtcp2_ctx *ctx = cf->ctx;
1362 rc = ngtcp2_conn_open_bidi_stream(ctx->qconn, &stream->id, data);
1393 rc = nghttp3_conn_submit_request(ctx->h3conn, stream->id,
1430 struct cf_ngtcp2_ctx *ctx = cf->ctx;
1439 DEBUGASSERT(ctx->qconn);
1440 DEBUGASSERT(ctx->h3conn);
1501 (void)nghttp3_conn_resume_stream(ctx->h3conn, stream->id);
1537 struct cf_ngtcp2_ctx *ctx = cf->ctx;
1543 return Curl_vquic_tls_verify_peer(&ctx->tls, cf, data, &ctx->peer);
1552 struct cf_ngtcp2_ctx *ctx = pktx->cf->ctx;
1558 ngtcp2_addr_init(&path.local, (struct sockaddr *)&ctx->q.local_addr,
1559 ctx->q.local_addrlen);
1564 rv = ngtcp2_conn_read_pkt(ctx->qconn, &path, &pi, pkt, pktlen, pktx->ts);
1568 if(!ctx->last_error.error_code) {
1570 ngtcp2_ccerr_set_tls_alert(&ctx->last_error,
1571 ngtcp2_conn_get_tls_alert(ctx->qconn),
1575 ngtcp2_ccerr_set_liberr(&ctx->last_error, rv, NULL, 0);
1593 struct cf_ngtcp2_ctx *ctx = cf->ctx;
1607 result = Curl_vquic_tls_before_recv(&ctx->tls, cf, data);
1613 result = vquic_recv_packets(cf, data, &ctx->q, pkts_chunk,
1636 struct cf_ngtcp2_ctx *ctx = x->cf->ctx;
1659 if(ctx->h3conn && ngtcp2_conn_get_max_data_left(ctx->qconn)) {
1660 veccnt = nghttp3_conn_writev_stream(ctx->h3conn, &stream_id, &fin, vec,
1666 &ctx->last_error,
1675 n = ngtcp2_conn_writev_stream(ctx->qconn, &x->ps.path,
1690 nghttp3_conn_block_stream(ctx->h3conn, stream_id);
1701 nghttp3_conn_shutdown_stream_write(ctx->h3conn, stream_id);
1714 ngtcp2_ccerr_set_liberr(&ctx->last_error, (int)n, NULL, 0);
1723 int rv = nghttp3_conn_add_write_offset(ctx->h3conn, stream_id, ndatalen);
1745 struct cf_ngtcp2_ctx *ctx = cf->ctx;
1762 curlcode = vquic_flush(cf, data, &ctx->q);
1782 max_payload_size = ngtcp2_conn_get_max_tx_udp_payload_size(ctx->qconn);
1784 ngtcp2_conn_get_path_max_tx_udp_payload_size(ctx->qconn);
1787 ctx->q.sendbuf.chunk_size / max_payload_size);
1791 nread = Curl_bufq_sipn(&ctx->q.sendbuf, max_payload_size,
1797 curlcode = vquic_send(cf, data, &ctx->q, gsolen);
1819 curlcode = vquic_send_tail_split(cf, data, &ctx->q,
1836 curlcode = vquic_send(cf, data, &ctx->q, gsolen);
1882 struct cf_ngtcp2_ctx *ctx = cf->ctx;
1906 (void)nghttp3_conn_resume_stream(ctx->h3conn, stream->id);
1927 static void cf_ngtcp2_ctx_clear(struct cf_ngtcp2_ctx *ctx)
1929 struct cf_call_data save = ctx->call_data;
1931 if(ctx->qlogfd != -1) {
1932 close(ctx->qlogfd);
1934 Curl_vquic_tls_cleanup(&ctx->tls);
1935 vquic_ctx_free(&ctx->q);
1936 if(ctx->h3conn)
1937 nghttp3_conn_del(ctx->h3conn);
1938 if(ctx->qconn)
1939 ngtcp2_conn_del(ctx->qconn);
1940 Curl_bufcp_free(&ctx->stream_bufcp);
1941 Curl_ssl_peer_cleanup(&ctx->peer);
1943 memset(ctx, 0, sizeof(*ctx));
1944 ctx->qlogfd = -1;
1945 ctx->call_data = save;
1950 struct cf_ngtcp2_ctx *ctx = cf->ctx;
1954 if(ctx && ctx->qconn) {
1961 rc = ngtcp2_conn_write_connection_close(ctx->qconn, NULL, /* path */
1964 &ctx->last_error, pktx.ts);
1966 while((send(ctx->q.sockfd, buffer, (SEND_TYPE_ARG3)rc, 0) == -1) &&
1970 cf_ngtcp2_ctx_clear(ctx);
1979 struct cf_ngtcp2_ctx *ctx = cf->ctx;
1984 if(ctx) {
1985 cf_ngtcp2_ctx_clear(ctx);
1986 free(ctx);
1988 cf->ctx = NULL;
1993 static CURLcode tls_ctx_setup(struct quic_tls_ctx *ctx,
2000 if(ngtcp2_crypto_boringssl_configure_client_context(ctx->ssl_ctx) != 0) {
2005 if(ngtcp2_crypto_quictls_configure_client_context(ctx->ssl_ctx) != 0) {
2011 if(ngtcp2_crypto_gnutls_configure_client_session(ctx->gtls->session) != 0) {
2016 if(ngtcp2_crypto_wolfssl_configure_client_context(ctx->ssl_ctx) != 0) {
2031 struct cf_ngtcp2_ctx *ctx = cf->ctx;
2038 ctx->version = NGTCP2_PROTO_VER_MAX;
2039 ctx->max_stream_window = H3_STREAM_WINDOW_SIZE;
2040 ctx->max_idle_ms = CURL_QUIC_MAX_IDLE_MS;
2041 Curl_bufcp_init(&ctx->stream_bufcp, H3_STREAM_CHUNK_SIZE,
2044 result = Curl_ssl_peer_init(&ctx->peer, cf);
2049 result = Curl_vquic_tls_init(&ctx->tls, cf, data, &ctx->peer,
2051 tls_ctx_setup, &ctx->conn_ref);
2055 ctx->dcid.datalen = NGTCP2_MAX_CIDLEN;
2056 result = Curl_rand(data, ctx->dcid.data, NGTCP2_MAX_CIDLEN);
2060 ctx->scid.datalen = NGTCP2_MAX_CIDLEN;
2061 result = Curl_rand(data, ctx->scid.data, NGTCP2_MAX_CIDLEN);
2065 (void)Curl_qlogdir(data, ctx->scid.data, NGTCP2_MAX_CIDLEN, &qfd);
2066 ctx->qlogfd = qfd; /* -1 if failure above */
2067 quic_settings(ctx, data, pktx);
2069 result = vquic_ctx_init(&ctx->q);
2073 Curl_cf_socket_peek(cf->next, data, &ctx->q.sockfd,
2077 ctx->q.local_addrlen = sizeof(ctx->q.local_addr);
2078 rv = getsockname(ctx->q.sockfd, (struct sockaddr *)&ctx->q.local_addr,
2079 &ctx->q.local_addrlen);
2083 ngtcp2_addr_init(&ctx->connected_path.local,
2084 (struct sockaddr *)&ctx->q.local_addr,
2085 ctx->q.local_addrlen);
2086 ngtcp2_addr_init(&ctx->connected_path.remote,
2089 rc = ngtcp2_conn_client_new(&ctx->qconn, &ctx->dcid, &ctx->scid,
2090 &ctx->connected_path,
2092 &ctx->settings, &ctx->transport_params,
2098 ngtcp2_conn_set_tls_native_handle(ctx->qconn, ctx->tls.gtls->session);
2100 ngtcp2_conn_set_tls_native_handle(ctx->qconn, ctx->tls.ssl);
2103 ngtcp2_ccerr_default(&ctx->last_error);
2105 ctx->conn_ref.get_conn = get_conn;
2106 ctx->conn_ref.user_data = cf;
2115 struct cf_ngtcp2_ctx *ctx = cf->ctx;
2139 if(ctx->reconnect_at.tv_sec && Curl_timediff(now, ctx->reconnect_at) < 0) {
2145 if(!ctx->qconn) {
2146 ctx->started_at = now;
2163 if(ngtcp2_conn_get_handshake_completed(ctx->qconn)) {
2164 ctx->handshake_at = now;
2166 (int)Curl_timediff(now, ctx->started_at));
2178 if(result == CURLE_RECV_ERROR && ctx->qconn &&
2179 ngtcp2_conn_in_draining_period(ctx->qconn)) {
2198 if(!result && ctx->qconn) {
2211 struct cf_ngtcp2_ctx *ctx = cf->ctx;
2220 rp = ngtcp2_conn_get_remote_transport_params(ctx->qconn);
2231 if(ctx->q.got_first_byte) {
2232 timediff_t ms = Curl_timediff(ctx->q.first_byte_at, ctx->started_at);
2240 if(ctx->q.got_first_byte)
2241 *when = ctx->q.first_byte_at;
2247 *when = ctx->handshake_at;
2262 struct cf_ngtcp2_ctx *ctx = cf->ctx;
2269 if(!ctx->qconn)
2277 rp = ngtcp2_conn_get_remote_transport_params(ctx->qconn);
2280 uint64_t idle_ms = ctx->max_idle_ms;
2285 idletime = Curl_timediff(Curl_now(), ctx->q.last_io);
2333 struct cf_ngtcp2_ctx *ctx = NULL;
2338 ctx = calloc(1, sizeof(*ctx));
2339 if(!ctx) {
2343 ctx->qlogfd = -1;
2344 cf_ngtcp2_ctx_clear(ctx);
2346 result = Curl_cf_create(&cf, &Curl_cft_http3, ctx);
2365 Curl_safefree(ctx);