1#ifndef HEADER_CURL_VQUIC_QUIC_INT_H 2#define HEADER_CURL_VQUIC_QUIC_INT_H 3/*************************************************************************** 4 * _ _ ____ _ 5 * Project ___| | | | _ \| | 6 * / __| | | | |_) | | 7 * | (__| |_| | _ <| |___ 8 * \___|\___/|_| \_\_____| 9 * 10 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 11 * 12 * This software is licensed as described in the file COPYING, which 13 * you should have received as part of this distribution. The terms 14 * are also available at https://curl.se/docs/copyright.html. 15 * 16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 * copies of the Software, and permit persons to whom the Software is 18 * furnished to do so, under the terms of the COPYING file. 19 * 20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 * KIND, either express or implied. 22 * 23 * SPDX-License-Identifier: curl 24 * 25 ***************************************************************************/ 26 27#include "curl_setup.h" 28#include "bufq.h" 29 30#ifdef ENABLE_QUIC 31 32#define MAX_PKT_BURST 10 33#define MAX_UDP_PAYLOAD_SIZE 1452 34/* Default QUIC connection timeout we announce from our side */ 35#define CURL_QUIC_MAX_IDLE_MS (120 * 1000) 36 37struct cf_quic_ctx { 38 curl_socket_t sockfd; /* connected UDP socket */ 39 struct sockaddr_storage local_addr; /* address socket is bound to */ 40 socklen_t local_addrlen; /* length of local address */ 41 42 struct bufq sendbuf; /* buffer for sending one or more packets */ 43 struct curltime first_byte_at; /* when first byte was recvd */ 44 struct curltime last_op; /* last (attempted) send/recv operation */ 45 struct curltime last_io; /* last successful socket IO */ 46 size_t gsolen; /* length of individual packets in send buf */ 47 size_t split_len; /* if != 0, buffer length after which GSO differs */ 48 size_t split_gsolen; /* length of individual packets after split_len */ 49#ifdef DEBUGBUILD 50 int wblock_percent; /* percent of writes doing EAGAIN */ 51#endif 52 BIT(got_first_byte); /* if first byte was received */ 53 BIT(no_gso); /* do not use gso on sending */ 54}; 55 56CURLcode vquic_ctx_init(struct cf_quic_ctx *qctx); 57void vquic_ctx_free(struct cf_quic_ctx *qctx); 58 59void vquic_ctx_update_time(struct cf_quic_ctx *qctx); 60 61void vquic_push_blocked_pkt(struct Curl_cfilter *cf, 62 struct cf_quic_ctx *qctx, 63 const uint8_t *pkt, size_t pktlen, size_t gsolen); 64 65CURLcode vquic_send_blocked_pkts(struct Curl_cfilter *cf, 66 struct Curl_easy *data, 67 struct cf_quic_ctx *qctx); 68 69CURLcode vquic_send(struct Curl_cfilter *cf, struct Curl_easy *data, 70 struct cf_quic_ctx *qctx, size_t gsolen); 71 72CURLcode vquic_send_tail_split(struct Curl_cfilter *cf, struct Curl_easy *data, 73 struct cf_quic_ctx *qctx, size_t gsolen, 74 size_t tail_len, size_t tail_gsolen); 75 76CURLcode vquic_flush(struct Curl_cfilter *cf, struct Curl_easy *data, 77 struct cf_quic_ctx *qctx); 78 79 80typedef CURLcode vquic_recv_pkt_cb(const unsigned char *pkt, size_t pktlen, 81 struct sockaddr_storage *remote_addr, 82 socklen_t remote_addrlen, int ecn, 83 void *userp); 84 85CURLcode vquic_recv_packets(struct Curl_cfilter *cf, 86 struct Curl_easy *data, 87 struct cf_quic_ctx *qctx, 88 size_t max_pkts, 89 vquic_recv_pkt_cb *recv_cb, void *userp); 90 91#endif /* !ENABLE_QUIC */ 92 93#endif /* HEADER_CURL_VQUIC_QUIC_INT_H */ 94