Lines Matching refs:ctx

115 static void cf_quiche_ctx_clear(struct cf_quiche_ctx *ctx)
117 if(ctx) {
118 if(ctx->h3c)
119 quiche_h3_conn_free(ctx->h3c);
120 if(ctx->h3config)
121 quiche_h3_config_free(ctx->h3config);
122 if(ctx->qconn)
123 quiche_conn_free(ctx->qconn);
124 if(ctx->cfg)
125 quiche_config_free(ctx->cfg);
126 /* quiche just freed ctx->tls.ssl */
127 ctx->tls.ssl = NULL;
128 Curl_vquic_tls_cleanup(&ctx->tls);
129 Curl_ssl_peer_cleanup(&ctx->peer);
130 vquic_ctx_free(&ctx->q);
131 Curl_bufcp_free(&ctx->stream_bufcp);
133 memset(ctx, 0, sizeof(*ctx));
183 struct cf_quiche_ctx *ctx = cf->ctx;
195 Curl_bufq_initp(&stream->recvbuf, &ctx->stream_bufcp,
203 struct cf_quiche_ctx *ctx = cf->ctx;
209 if(ctx->qconn && !stream->closed) {
210 quiche_conn_stream_shutdown(ctx->qconn, stream->id,
213 quiche_conn_stream_shutdown(ctx->qconn, stream->id,
341 struct cf_quiche_ctx *ctx = x->cf->ctx;
350 nread = quiche_h3_recv_body(ctx->h3c, ctx->qconn, stream->id,
489 struct cf_quiche_ctx *ctx = cf->ctx;
496 while(ctx->h3c) {
497 int64_t stream3_id = quiche_h3_conn_poll(ctx->h3c, ctx->qconn, &ev);
547 struct cf_quiche_ctx *ctx = r->cf->ctx;
554 recv_info.to = (struct sockaddr *)&ctx->q.local_addr;
555 recv_info.to_len = ctx->q.local_addrlen;
559 nread = quiche_conn_recv(ctx->qconn, (unsigned char *)pkt, pktlen,
567 long verify_ok = SSL_get_verify_result(ctx->tls.ssl);
590 struct cf_quiche_ctx *ctx = cf->ctx;
594 DEBUGASSERT(ctx->qconn);
595 result = Curl_vquic_tls_before_recv(&ctx->tls, cf, data);
603 result = vquic_recv_packets(cf, data, &ctx->q, 1000, recv_pkt, &rctx);
626 struct cf_quiche_ctx *ctx = x->cf->ctx;
629 nwritten = quiche_conn_send(ctx->qconn, buf, buflen, &x->send_info);
651 struct cf_quiche_ctx *ctx = cf->ctx;
659 expiry_ns = quiche_conn_timeout_as_nanos(ctx->qconn);
661 quiche_conn_on_timeout(ctx->qconn);
662 if(quiche_conn_is_closed(ctx->qconn)) {
668 result = vquic_flush(cf, data, &ctx->q);
681 gsolen = quiche_conn_max_send_udp_payload_size(ctx->qconn);
684 nread = Curl_bufq_sipn(&ctx->q.sendbuf, 0,
690 result = vquic_send(cf, data, &ctx->q, gsolen);
703 result = vquic_send(cf, data, &ctx->q, gsolen);
716 timeout_ns = quiche_conn_timeout_as_nanos(ctx->qconn);
759 struct cf_quiche_ctx *ctx = cf->ctx;
764 vquic_ctx_update_time(&ctx->q);
806 else if(quiche_conn_is_draining(ctx->qconn)) {
824 ctx->data_recvd += nread;
827 stream->id, ctx->data_recvd, nread, *err);
840 struct cf_quiche_ctx *ctx = cf->ctx;
912 stream3_id = quiche_h3_send_request(ctx->h3c, ctx->qconn, nva, nheader,
958 struct cf_quiche_ctx *ctx = cf->ctx;
963 vquic_ctx_update_time(&ctx->q);
1002 nwritten = quiche_h3_send_body(ctx->h3c, ctx->qconn, stream->id,
1007 if(!quiche_conn_stream_writable(ctx->qconn, stream->id, len)) {
1067 struct cf_quiche_ctx *ctx = cf->ctx;
1070 return stream && (quiche_conn_stream_writable(ctx->qconn,
1078 struct cf_quiche_ctx *ctx = cf->ctx;
1081 if(!ctx->qconn)
1084 Curl_pollset_check(data, ps, ctx->q.sockfd, &want_recv, &want_send);
1095 !Curl_bufq_is_empty(&ctx->q.sendbuf);
1097 Curl_pollset_set(data, ps, ctx->q.sockfd, want_recv, want_send);
1179 struct cf_quiche_ctx *ctx = cf->ctx;
1184 DEBUGASSERT(ctx->q.sockfd != CURL_SOCKET_BAD);
1194 ctx->max_idle_ms = CURL_QUIC_MAX_IDLE_MS;
1195 Curl_bufcp_init(&ctx->stream_bufcp, H3_STREAM_CHUNK_SIZE,
1197 ctx->data_recvd = 0;
1199 result = vquic_ctx_init(&ctx->q);
1203 result = Curl_ssl_peer_init(&ctx->peer, cf);
1207 ctx->cfg = quiche_config_new(QUICHE_PROTOCOL_VERSION);
1208 if(!ctx->cfg) {
1212 quiche_config_enable_pacing(ctx->cfg, false);
1213 quiche_config_set_max_idle_timeout(ctx->cfg, ctx->max_idle_ms * 1000);
1214 quiche_config_set_initial_max_data(ctx->cfg, (1 * 1024 * 1024)
1216 quiche_config_set_initial_max_streams_bidi(ctx->cfg, QUIC_MAX_STREAMS);
1217 quiche_config_set_initial_max_streams_uni(ctx->cfg, QUIC_MAX_STREAMS);
1218 quiche_config_set_initial_max_stream_data_bidi_local(ctx->cfg,
1220 quiche_config_set_initial_max_stream_data_bidi_remote(ctx->cfg,
1222 quiche_config_set_initial_max_stream_data_uni(ctx->cfg,
1224 quiche_config_set_disable_active_migration(ctx->cfg, TRUE);
1226 quiche_config_set_max_connection_window(ctx->cfg,
1228 quiche_config_set_max_stream_window(ctx->cfg, 10 * H3_STREAM_WINDOW_SIZE);
1229 quiche_config_set_application_protos(ctx->cfg,
1235 result = Curl_vquic_tls_init(&ctx->tls, cf, data, &ctx->peer,
1242 result = Curl_rand(data, ctx->scid, sizeof(ctx->scid));
1246 Curl_cf_socket_peek(cf->next, data, &ctx->q.sockfd,
1248 ctx->q.local_addrlen = sizeof(ctx->q.local_addr);
1249 rv = getsockname(ctx->q.sockfd, (struct sockaddr *)&ctx->q.local_addr,
1250 &ctx->q.local_addrlen);
1254 ctx->qconn = quiche_conn_new_with_tls((const uint8_t *)ctx->scid,
1255 sizeof(ctx->scid), NULL, 0,
1256 (struct sockaddr *)&ctx->q.local_addr,
1257 ctx->q.local_addrlen,
1259 ctx->cfg, ctx->tls.ssl, false);
1260 if(!ctx->qconn) {
1269 (void)Curl_qlogdir(data, ctx->scid, sizeof(ctx->scid), &qfd);
1271 quiche_conn_set_qlog_fd(ctx->qconn, qfd,
1301 struct cf_quiche_ctx *ctx = cf->ctx;
1307 return Curl_vquic_tls_verify_peer(&ctx->tls, cf, data, &ctx->peer);
1314 struct cf_quiche_ctx *ctx = cf->ctx;
1330 vquic_ctx_update_time(&ctx->q);
1332 if(ctx->reconnect_at.tv_sec &&
1333 Curl_timediff(ctx->q.last_op, ctx->reconnect_at) < 0) {
1339 if(!ctx->qconn) {
1343 ctx->started_at = ctx->q.last_op;
1357 if(quiche_conn_is_established(ctx->qconn)) {
1358 ctx->handshake_at = ctx->q.last_op;
1360 (int)Curl_timediff(ctx->handshake_at, ctx->started_at));
1364 ctx->h3config = quiche_h3_config_new();
1365 if(!ctx->h3config) {
1371 ctx->h3c = quiche_h3_conn_new_with_transport(ctx->qconn, ctx->h3config);
1372 if(!ctx->h3c) {
1382 else if(quiche_conn_is_draining(ctx->qconn)) {
1407 struct cf_quiche_ctx *ctx = cf->ctx;
1409 if(ctx) {
1410 if(ctx->qconn) {
1411 vquic_ctx_update_time(&ctx->q);
1412 (void)quiche_conn_close(ctx->qconn, TRUE, 0, NULL, 0);
1417 cf_quiche_ctx_clear(ctx);
1423 struct cf_quiche_ctx *ctx = cf->ctx;
1426 cf_quiche_ctx_clear(ctx);
1427 free(ctx);
1428 cf->ctx = NULL;
1435 struct cf_quiche_ctx *ctx = cf->ctx;
1440 if(!ctx->goaway) {
1441 max_streams += quiche_conn_peer_streams_left_bidi(ctx->qconn);
1448 if(ctx->q.got_first_byte) {
1449 timediff_t ms = Curl_timediff(ctx->q.first_byte_at, ctx->started_at);
1457 if(ctx->q.got_first_byte)
1458 *when = ctx->q.first_byte_at;
1464 *when = ctx->handshake_at;
1479 struct cf_quiche_ctx *ctx = cf->ctx;
1483 if(!ctx->qconn)
1494 uint64_t idle_ms = ctx->max_idle_ms;
1496 if(quiche_conn_peer_transport_params(ctx->qconn, &qpeerparams) &&
1546 struct cf_quiche_ctx *ctx = NULL;
1552 ctx = calloc(1, sizeof(*ctx));
1553 if(!ctx) {
1558 result = Curl_cf_create(&cf, &Curl_cft_http3, ctx);
1576 Curl_safefree(ctx);