113498266Sopenharmony_ci#ifndef HEADER_CURL_VQUIC_QUIC_INT_H
213498266Sopenharmony_ci#define HEADER_CURL_VQUIC_QUIC_INT_H
313498266Sopenharmony_ci/***************************************************************************
413498266Sopenharmony_ci *                                  _   _ ____  _
513498266Sopenharmony_ci *  Project                     ___| | | |  _ \| |
613498266Sopenharmony_ci *                             / __| | | | |_) | |
713498266Sopenharmony_ci *                            | (__| |_| |  _ <| |___
813498266Sopenharmony_ci *                             \___|\___/|_| \_\_____|
913498266Sopenharmony_ci *
1013498266Sopenharmony_ci * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
1113498266Sopenharmony_ci *
1213498266Sopenharmony_ci * This software is licensed as described in the file COPYING, which
1313498266Sopenharmony_ci * you should have received as part of this distribution. The terms
1413498266Sopenharmony_ci * are also available at https://curl.se/docs/copyright.html.
1513498266Sopenharmony_ci *
1613498266Sopenharmony_ci * You may opt to use, copy, modify, merge, publish, distribute and/or sell
1713498266Sopenharmony_ci * copies of the Software, and permit persons to whom the Software is
1813498266Sopenharmony_ci * furnished to do so, under the terms of the COPYING file.
1913498266Sopenharmony_ci *
2013498266Sopenharmony_ci * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
2113498266Sopenharmony_ci * KIND, either express or implied.
2213498266Sopenharmony_ci *
2313498266Sopenharmony_ci * SPDX-License-Identifier: curl
2413498266Sopenharmony_ci *
2513498266Sopenharmony_ci ***************************************************************************/
2613498266Sopenharmony_ci
2713498266Sopenharmony_ci#include "curl_setup.h"
2813498266Sopenharmony_ci#include "bufq.h"
2913498266Sopenharmony_ci
3013498266Sopenharmony_ci#ifdef ENABLE_QUIC
3113498266Sopenharmony_ci
3213498266Sopenharmony_ci#define MAX_PKT_BURST 10
3313498266Sopenharmony_ci#define MAX_UDP_PAYLOAD_SIZE  1452
3413498266Sopenharmony_ci/* Default QUIC connection timeout we announce from our side */
3513498266Sopenharmony_ci#define CURL_QUIC_MAX_IDLE_MS   (120 * 1000)
3613498266Sopenharmony_ci
3713498266Sopenharmony_cistruct cf_quic_ctx {
3813498266Sopenharmony_ci  curl_socket_t sockfd; /* connected UDP socket */
3913498266Sopenharmony_ci  struct sockaddr_storage local_addr; /* address socket is bound to */
4013498266Sopenharmony_ci  socklen_t local_addrlen; /* length of local address */
4113498266Sopenharmony_ci
4213498266Sopenharmony_ci  struct bufq sendbuf; /* buffer for sending one or more packets */
4313498266Sopenharmony_ci  struct curltime first_byte_at;     /* when first byte was recvd */
4413498266Sopenharmony_ci  struct curltime last_op; /* last (attempted) send/recv operation */
4513498266Sopenharmony_ci  struct curltime last_io; /* last successful socket IO */
4613498266Sopenharmony_ci  size_t gsolen; /* length of individual packets in send buf */
4713498266Sopenharmony_ci  size_t split_len; /* if != 0, buffer length after which GSO differs */
4813498266Sopenharmony_ci  size_t split_gsolen; /* length of individual packets after split_len */
4913498266Sopenharmony_ci#ifdef DEBUGBUILD
5013498266Sopenharmony_ci  int wblock_percent; /* percent of writes doing EAGAIN */
5113498266Sopenharmony_ci#endif
5213498266Sopenharmony_ci  BIT(got_first_byte); /* if first byte was received */
5313498266Sopenharmony_ci  BIT(no_gso); /* do not use gso on sending */
5413498266Sopenharmony_ci};
5513498266Sopenharmony_ci
5613498266Sopenharmony_ciCURLcode vquic_ctx_init(struct cf_quic_ctx *qctx);
5713498266Sopenharmony_civoid vquic_ctx_free(struct cf_quic_ctx *qctx);
5813498266Sopenharmony_ci
5913498266Sopenharmony_civoid vquic_ctx_update_time(struct cf_quic_ctx *qctx);
6013498266Sopenharmony_ci
6113498266Sopenharmony_civoid vquic_push_blocked_pkt(struct Curl_cfilter *cf,
6213498266Sopenharmony_ci                            struct cf_quic_ctx *qctx,
6313498266Sopenharmony_ci                            const uint8_t *pkt, size_t pktlen, size_t gsolen);
6413498266Sopenharmony_ci
6513498266Sopenharmony_ciCURLcode vquic_send_blocked_pkts(struct Curl_cfilter *cf,
6613498266Sopenharmony_ci                                 struct Curl_easy *data,
6713498266Sopenharmony_ci                                 struct cf_quic_ctx *qctx);
6813498266Sopenharmony_ci
6913498266Sopenharmony_ciCURLcode vquic_send(struct Curl_cfilter *cf, struct Curl_easy *data,
7013498266Sopenharmony_ci                        struct cf_quic_ctx *qctx, size_t gsolen);
7113498266Sopenharmony_ci
7213498266Sopenharmony_ciCURLcode vquic_send_tail_split(struct Curl_cfilter *cf, struct Curl_easy *data,
7313498266Sopenharmony_ci                               struct cf_quic_ctx *qctx, size_t gsolen,
7413498266Sopenharmony_ci                               size_t tail_len, size_t tail_gsolen);
7513498266Sopenharmony_ci
7613498266Sopenharmony_ciCURLcode vquic_flush(struct Curl_cfilter *cf, struct Curl_easy *data,
7713498266Sopenharmony_ci                     struct cf_quic_ctx *qctx);
7813498266Sopenharmony_ci
7913498266Sopenharmony_ci
8013498266Sopenharmony_citypedef CURLcode vquic_recv_pkt_cb(const unsigned char *pkt, size_t pktlen,
8113498266Sopenharmony_ci                                   struct sockaddr_storage *remote_addr,
8213498266Sopenharmony_ci                                   socklen_t remote_addrlen, int ecn,
8313498266Sopenharmony_ci                                   void *userp);
8413498266Sopenharmony_ci
8513498266Sopenharmony_ciCURLcode vquic_recv_packets(struct Curl_cfilter *cf,
8613498266Sopenharmony_ci                            struct Curl_easy *data,
8713498266Sopenharmony_ci                            struct cf_quic_ctx *qctx,
8813498266Sopenharmony_ci                            size_t max_pkts,
8913498266Sopenharmony_ci                            vquic_recv_pkt_cb *recv_cb, void *userp);
9013498266Sopenharmony_ci
9113498266Sopenharmony_ci#endif /* !ENABLE_QUIC */
9213498266Sopenharmony_ci
9313498266Sopenharmony_ci#endif /* HEADER_CURL_VQUIC_QUIC_INT_H */
94