Lines Matching refs:ctx
120 static void cf_quiche_ctx_init(struct cf_quiche_ctx *ctx) in cf_quiche_ctx_init() argument
122 DEBUGASSERT(!ctx->initialized); in cf_quiche_ctx_init()
129 Curl_bufcp_init(&ctx->stream_bufcp, H3_STREAM_CHUNK_SIZE, in cf_quiche_ctx_init()
131 Curl_hash_offt_init(&ctx->streams, 63, h3_stream_hash_free); in cf_quiche_ctx_init()
132 ctx->data_recvd = 0; in cf_quiche_ctx_init()
133 ctx->initialized = TRUE; in cf_quiche_ctx_init()
136 static void cf_quiche_ctx_free(struct cf_quiche_ctx *ctx) in cf_quiche_ctx_free() argument
138 if(ctx && ctx->initialized) { in cf_quiche_ctx_free()
140 ctx->tls.ossl.ssl = NULL; in cf_quiche_ctx_free()
141 Curl_vquic_tls_cleanup(&ctx->tls); in cf_quiche_ctx_free()
142 Curl_ssl_peer_cleanup(&ctx->peer); in cf_quiche_ctx_free()
143 vquic_ctx_free(&ctx->q); in cf_quiche_ctx_free()
144 Curl_bufcp_free(&ctx->stream_bufcp); in cf_quiche_ctx_free()
145 Curl_hash_clean(&ctx->streams); in cf_quiche_ctx_free()
146 Curl_hash_destroy(&ctx->streams); in cf_quiche_ctx_free()
148 free(ctx); in cf_quiche_ctx_free()
151 static void cf_quiche_ctx_close(struct cf_quiche_ctx *ctx) in cf_quiche_ctx_close() argument
153 if(ctx->h3c) in cf_quiche_ctx_close()
154 quiche_h3_conn_free(ctx->h3c); in cf_quiche_ctx_close()
155 if(ctx->h3config) in cf_quiche_ctx_close()
156 quiche_h3_config_free(ctx->h3config); in cf_quiche_ctx_close()
157 if(ctx->qconn) in cf_quiche_ctx_close()
158 quiche_conn_free(ctx->qconn); in cf_quiche_ctx_close()
159 if(ctx->cfg) in cf_quiche_ctx_close()
160 quiche_config_free(ctx->cfg); in cf_quiche_ctx_close()
183 #define H3_STREAM_CTX(ctx,data) ((struct stream_ctx *)(\ argument
184 data? Curl_hash_offt_get(&(ctx)->streams, (data)->mid) : NULL))
202 struct cf_quiche_ctx *ctx = cf->ctx; in check_resumes() local
209 struct stream_ctx *stream = H3_STREAM_CTX(ctx, sdata); in check_resumes()
222 struct cf_quiche_ctx *ctx = cf->ctx; in h3_data_setup() local
223 struct stream_ctx *stream = H3_STREAM_CTX(ctx, data); in h3_data_setup()
233 Curl_bufq_initp(&stream->recvbuf, &ctx->stream_bufcp, in h3_data_setup()
237 if(!Curl_hash_offt_set(&ctx->streams, data->mid, stream)) { in h3_data_setup()
247 struct cf_quiche_ctx *ctx = cf->ctx; in h3_data_done() local
248 struct stream_ctx *stream = H3_STREAM_CTX(ctx, data); in h3_data_done()
254 if(ctx->qconn && !stream->closed) { in h3_data_done()
255 quiche_conn_stream_shutdown(ctx->qconn, stream->id, in h3_data_done()
258 quiche_conn_stream_shutdown(ctx->qconn, stream->id, in h3_data_done()
267 Curl_hash_offt_remove(&ctx->streams, data->mid); in h3_data_done()
274 struct cf_quiche_ctx *ctx = cf->ctx; in h3_drain_stream() local
275 struct stream_ctx *stream = H3_STREAM_CTX(ctx, data); in h3_drain_stream()
293 struct cf_quiche_ctx *ctx = cf->ctx; in get_stream_easy() local
297 stream = H3_STREAM_CTX(ctx, data); in get_stream_easy()
309 stream = H3_STREAM_CTX(ctx, sdata); in get_stream_easy()
345 struct cf_quiche_ctx *ctx = cf->ctx; in write_resp_raw() local
346 struct stream_ctx *stream = H3_STREAM_CTX(ctx, data); in write_resp_raw()
376 struct cf_quiche_ctx *ctx = x->cf->ctx; in cb_each_header() local
377 struct stream_ctx *stream = H3_STREAM_CTX(ctx, x->data); in cb_each_header()
416 struct cf_quiche_ctx *ctx = x->cf->ctx; in stream_resp_read() local
417 struct stream_ctx *stream = H3_STREAM_CTX(ctx, x->data); in stream_resp_read()
425 nread = quiche_h3_recv_body(ctx->h3c, ctx->qconn, stream->id, in stream_resp_read()
440 struct cf_quiche_ctx *ctx = cf->ctx; in cf_recv_body() local
441 struct stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cf_recv_body()
563 struct cf_quiche_ctx *ctx = cf->ctx; in cf_poll_events() local
570 while(ctx->h3c) { in cf_poll_events()
571 curl_int64_t stream3_id = quiche_h3_conn_poll(ctx->h3c, ctx->qconn, &ev); in cf_poll_events()
618 struct cf_quiche_ctx *ctx = r->cf->ctx; in recv_pkt() local
625 recv_info.to = (struct sockaddr *)&ctx->q.local_addr; in recv_pkt()
626 recv_info.to_len = ctx->q.local_addrlen; in recv_pkt()
630 nread = quiche_conn_recv(ctx->qconn, (unsigned char *)pkt, pktlen, in recv_pkt()
634 if(quiche_conn_is_draining(ctx->qconn)) { in recv_pkt()
638 if(quiche_conn_is_closed(ctx->qconn)) { in recv_pkt()
646 long verify_ok = SSL_get_verify_result(ctx->tls.ossl.ssl); in recv_pkt()
669 struct cf_quiche_ctx *ctx = cf->ctx; in cf_process_ingress() local
673 DEBUGASSERT(ctx->qconn); in cf_process_ingress()
674 result = Curl_vquic_tls_before_recv(&ctx->tls, cf, data); in cf_process_ingress()
682 result = vquic_recv_packets(cf, data, &ctx->q, 1000, recv_pkt, &rctx); in cf_process_ingress()
705 struct cf_quiche_ctx *ctx = x->cf->ctx; in read_pkt_to_send() local
708 nwritten = quiche_conn_send(ctx->qconn, buf, buflen, &x->send_info); in read_pkt_to_send()
730 struct cf_quiche_ctx *ctx = cf->ctx; in cf_flush_egress() local
738 expiry_ns = quiche_conn_timeout_as_nanos(ctx->qconn); in cf_flush_egress()
740 quiche_conn_on_timeout(ctx->qconn); in cf_flush_egress()
741 if(quiche_conn_is_closed(ctx->qconn)) { in cf_flush_egress()
742 if(quiche_conn_is_timed_out(ctx->qconn)) in cf_flush_egress()
753 result = vquic_flush(cf, data, &ctx->q); in cf_flush_egress()
766 gsolen = quiche_conn_max_send_udp_payload_size(ctx->qconn); in cf_flush_egress()
769 nread = Curl_bufq_sipn(&ctx->q.sendbuf, 0, in cf_flush_egress()
775 result = vquic_send(cf, data, &ctx->q, gsolen); in cf_flush_egress()
788 result = vquic_send(cf, data, &ctx->q, gsolen); in cf_flush_egress()
801 timeout_ns = quiche_conn_timeout_as_nanos(ctx->qconn); in cf_flush_egress()
813 struct cf_quiche_ctx *ctx = cf->ctx; in recv_closed_stream() local
814 struct stream_ctx *stream = H3_STREAM_CTX(ctx, data); in recv_closed_stream()
845 struct cf_quiche_ctx *ctx = cf->ctx; in cf_quiche_recv() local
846 struct stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cf_quiche_recv()
850 vquic_ctx_update_time(&ctx->q); in cf_quiche_recv()
892 else if(quiche_conn_is_draining(ctx->qconn)) { in cf_quiche_recv()
910 ctx->data_recvd += nread; in cf_quiche_recv()
913 stream->id, ctx->data_recvd, nread, *err); in cf_quiche_recv()
923 struct cf_quiche_ctx *ctx = cf->ctx; in cf_quiche_send_body() local
926 nwritten = quiche_h3_send_body(ctx->h3c, ctx->qconn, stream->id, in cf_quiche_send_body()
931 if(!quiche_conn_stream_writable(ctx->qconn, stream->id, len)) { in cf_quiche_send_body()
977 struct cf_quiche_ctx *ctx = cf->ctx; in h3_open_stream() local
978 struct stream_ctx *stream = H3_STREAM_CTX(ctx, data); in h3_open_stream()
990 stream = H3_STREAM_CTX(ctx, data); in h3_open_stream()
1033 stream3_id = quiche_h3_send_request(ctx->h3c, ctx->qconn, nva, nheader, in h3_open_stream()
1097 struct cf_quiche_ctx *ctx = cf->ctx; in cf_quiche_send() local
1098 struct stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cf_quiche_send()
1102 vquic_ctx_update_time(&ctx->q); in cf_quiche_send()
1114 stream = H3_STREAM_CTX(ctx, data); in cf_quiche_send()
1156 struct cf_quiche_ctx *ctx = cf->ctx; in stream_is_writeable() local
1157 struct stream_ctx *stream = H3_STREAM_CTX(ctx, data); in stream_is_writeable()
1160 ctx->qconn, (curl_uint64_t)stream->id, 1) > 0); in stream_is_writeable()
1167 struct cf_quiche_ctx *ctx = cf->ctx; in cf_quiche_adjust_pollset() local
1170 if(!ctx->qconn) in cf_quiche_adjust_pollset()
1173 Curl_pollset_check(data, ps, ctx->q.sockfd, &want_recv, &want_send); in cf_quiche_adjust_pollset()
1175 struct stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cf_quiche_adjust_pollset()
1184 !Curl_bufq_is_empty(&ctx->q.sendbuf); in cf_quiche_adjust_pollset()
1186 Curl_pollset_set(data, ps, ctx->q.sockfd, want_recv, want_send); in cf_quiche_adjust_pollset()
1197 struct cf_quiche_ctx *ctx = cf->ctx; in cf_quiche_data_pending() local
1198 const struct stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cf_quiche_data_pending()
1220 struct cf_quiche_ctx *ctx = cf->ctx; in cf_quiche_data_event() local
1238 struct stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cf_quiche_data_event()
1252 struct stream_ctx *stream = H3_STREAM_CTX(ctx, data); in cf_quiche_data_event()
1269 struct cf_quiche_ctx *ctx = cf->ctx; in cf_quiche_ctx_open() local
1274 DEBUGASSERT(ctx->q.sockfd != CURL_SOCKET_BAD); in cf_quiche_ctx_open()
1275 DEBUGASSERT(ctx->initialized); in cf_quiche_ctx_open()
1277 result = vquic_ctx_init(&ctx->q); in cf_quiche_ctx_open()
1281 result = Curl_ssl_peer_init(&ctx->peer, cf, TRNSPRT_QUIC); in cf_quiche_ctx_open()
1285 ctx->cfg = quiche_config_new(QUICHE_PROTOCOL_VERSION); in cf_quiche_ctx_open()
1286 if(!ctx->cfg) { in cf_quiche_ctx_open()
1290 quiche_config_enable_pacing(ctx->cfg, FALSE); in cf_quiche_ctx_open()
1291 quiche_config_set_max_idle_timeout(ctx->cfg, CURL_QUIC_MAX_IDLE_MS); in cf_quiche_ctx_open()
1292 quiche_config_set_initial_max_data(ctx->cfg, (1 * 1024 * 1024) in cf_quiche_ctx_open()
1294 quiche_config_set_initial_max_streams_bidi(ctx->cfg, QUIC_MAX_STREAMS); in cf_quiche_ctx_open()
1295 quiche_config_set_initial_max_streams_uni(ctx->cfg, QUIC_MAX_STREAMS); in cf_quiche_ctx_open()
1296 quiche_config_set_initial_max_stream_data_bidi_local(ctx->cfg, in cf_quiche_ctx_open()
1298 quiche_config_set_initial_max_stream_data_bidi_remote(ctx->cfg, in cf_quiche_ctx_open()
1300 quiche_config_set_initial_max_stream_data_uni(ctx->cfg, in cf_quiche_ctx_open()
1302 quiche_config_set_disable_active_migration(ctx->cfg, TRUE); in cf_quiche_ctx_open()
1304 quiche_config_set_max_connection_window(ctx->cfg, in cf_quiche_ctx_open()
1306 quiche_config_set_max_stream_window(ctx->cfg, 10 * H3_STREAM_WINDOW_SIZE); in cf_quiche_ctx_open()
1307 quiche_config_set_application_protos(ctx->cfg, in cf_quiche_ctx_open()
1313 result = Curl_vquic_tls_init(&ctx->tls, cf, data, &ctx->peer, in cf_quiche_ctx_open()
1320 result = Curl_rand(data, ctx->scid, sizeof(ctx->scid)); in cf_quiche_ctx_open()
1324 Curl_cf_socket_peek(cf->next, data, &ctx->q.sockfd, &sockaddr, NULL); in cf_quiche_ctx_open()
1325 ctx->q.local_addrlen = sizeof(ctx->q.local_addr); in cf_quiche_ctx_open()
1326 rv = getsockname(ctx->q.sockfd, (struct sockaddr *)&ctx->q.local_addr, in cf_quiche_ctx_open()
1327 &ctx->q.local_addrlen); in cf_quiche_ctx_open()
1331 ctx->qconn = quiche_conn_new_with_tls((const uint8_t *)ctx->scid, in cf_quiche_ctx_open()
1332 sizeof(ctx->scid), NULL, 0, in cf_quiche_ctx_open()
1333 (struct sockaddr *)&ctx->q.local_addr, in cf_quiche_ctx_open()
1334 ctx->q.local_addrlen, in cf_quiche_ctx_open()
1337 ctx->cfg, ctx->tls.ossl.ssl, FALSE); in cf_quiche_ctx_open()
1338 if(!ctx->qconn) { in cf_quiche_ctx_open()
1347 (void)Curl_qlogdir(data, ctx->scid, sizeof(ctx->scid), &qfd); in cf_quiche_ctx_open()
1349 quiche_conn_set_qlog_fd(ctx->qconn, qfd, in cf_quiche_ctx_open()
1379 struct cf_quiche_ctx *ctx = cf->ctx; in cf_quiche_verify_peer() local
1384 return Curl_vquic_tls_verify_peer(&ctx->tls, cf, data, &ctx->peer); in cf_quiche_verify_peer()
1391 struct cf_quiche_ctx *ctx = cf->ctx; in cf_quiche_connect() local
1407 vquic_ctx_update_time(&ctx->q); in cf_quiche_connect()
1409 if(!ctx->qconn) { in cf_quiche_connect()
1413 ctx->started_at = ctx->q.last_op; in cf_quiche_connect()
1427 if(quiche_conn_is_established(ctx->qconn)) { in cf_quiche_connect()
1428 ctx->handshake_at = ctx->q.last_op; in cf_quiche_connect()
1430 (int)Curl_timediff(ctx->handshake_at, ctx->started_at)); in cf_quiche_connect()
1434 ctx->h3config = quiche_h3_config_new(); in cf_quiche_connect()
1435 if(!ctx->h3config) { in cf_quiche_connect()
1441 ctx->h3c = quiche_h3_conn_new_with_transport(ctx->qconn, ctx->h3config); in cf_quiche_connect()
1442 if(!ctx->h3c) { in cf_quiche_connect()
1452 else if(quiche_conn_is_draining(ctx->qconn)) { in cf_quiche_connect()
1476 struct cf_quiche_ctx *ctx = cf->ctx; in cf_quiche_shutdown() local
1479 if(cf->shutdown || !ctx || !ctx->qconn) { in cf_quiche_shutdown()
1485 if(!ctx->shutdown_started) { in cf_quiche_shutdown()
1488 ctx->shutdown_started = TRUE; in cf_quiche_shutdown()
1489 vquic_ctx_update_time(&ctx->q); in cf_quiche_shutdown()
1490 err = quiche_conn_close(ctx->qconn, TRUE, 0, NULL, 0); in cf_quiche_shutdown()
1499 if(!Curl_bufq_is_empty(&ctx->q.sendbuf)) { in cf_quiche_shutdown()
1506 if(Curl_bufq_is_empty(&ctx->q.sendbuf)) { in cf_quiche_shutdown()
1522 if(cf->ctx) { in cf_quiche_close()
1525 cf_quiche_ctx_close(cf->ctx); in cf_quiche_close()
1532 if(cf->ctx) { in cf_quiche_destroy()
1533 cf_quiche_ctx_free(cf->ctx); in cf_quiche_destroy()
1534 cf->ctx = NULL; in cf_quiche_destroy()
1542 struct cf_quiche_ctx *ctx = cf->ctx; in cf_quiche_query() local
1547 if(!ctx->goaway) { in cf_quiche_query()
1548 max_streams += quiche_conn_peer_streams_left_bidi(ctx->qconn); in cf_quiche_query()
1557 if(ctx->q.got_first_byte) { in cf_quiche_query()
1558 timediff_t ms = Curl_timediff(ctx->q.first_byte_at, ctx->started_at); in cf_quiche_query()
1566 if(ctx->q.got_first_byte) in cf_quiche_query()
1567 *when = ctx->q.first_byte_at; in cf_quiche_query()
1573 *when = ctx->handshake_at; in cf_quiche_query()
1588 struct cf_quiche_ctx *ctx = cf->ctx; in cf_quiche_conn_is_alive() local
1592 if(!ctx->qconn) in cf_quiche_conn_is_alive()
1595 if(quiche_conn_is_closed(ctx->qconn)) { in cf_quiche_conn_is_alive()
1596 if(quiche_conn_is_timed_out(ctx->qconn)) in cf_quiche_conn_is_alive()
1645 struct cf_quiche_ctx *ctx = NULL; in Curl_cf_quiche_create() local
1651 ctx = calloc(1, sizeof(*ctx)); in Curl_cf_quiche_create()
1652 if(!ctx) { in Curl_cf_quiche_create()
1656 cf_quiche_ctx_init(ctx); in Curl_cf_quiche_create()
1658 result = Curl_cf_create(&cf, &Curl_cft_http3, ctx); in Curl_cf_quiche_create()
1676 cf_quiche_ctx_free(ctx); in Curl_cf_quiche_create()