vquic_int.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. #include "curl_setup.h"
  27. #include "bufq.h"
  28. #ifdef USE_HTTP3
  29. #define MAX_PKT_BURST 10
  30. #define MAX_UDP_PAYLOAD_SIZE 1452
  31. /* Default QUIC connection timeout we announce from our side */
  32. #define CURL_QUIC_MAX_IDLE_MS (120 * 1000)
  33. struct cf_quic_ctx {
  34. curl_socket_t sockfd; /* connected UDP socket */
  35. struct sockaddr_storage local_addr; /* address socket is bound to */
  36. socklen_t local_addrlen; /* length of local address */
  37. struct bufq sendbuf; /* buffer for sending one or more packets */
  38. struct curltime first_byte_at; /* when first byte was recvd */
  39. struct curltime last_op; /* last (attempted) send/recv operation */
  40. struct curltime last_io; /* last successful socket IO */
  41. size_t gsolen; /* length of individual packets in send buf */
  42. size_t split_len; /* if != 0, buffer length after which GSO differs */
  43. size_t split_gsolen; /* length of individual packets after split_len */
  44. #ifdef DEBUGBUILD
  45. int wblock_percent; /* percent of writes doing EAGAIN */
  46. #endif
  47. BIT(got_first_byte); /* if first byte was received */
  48. BIT(no_gso); /* do not use gso on sending */
  49. };
  50. CURLcode vquic_ctx_init(struct cf_quic_ctx *qctx);
  51. void vquic_ctx_free(struct cf_quic_ctx *qctx);
  52. void vquic_ctx_update_time(struct cf_quic_ctx *qctx);
  53. void vquic_push_blocked_pkt(struct Curl_cfilter *cf,
  54. struct cf_quic_ctx *qctx,
  55. const uint8_t *pkt, size_t pktlen, size_t gsolen);
  56. CURLcode vquic_send_blocked_pkts(struct Curl_cfilter *cf,
  57. struct Curl_easy *data,
  58. struct cf_quic_ctx *qctx);
  59. CURLcode vquic_send(struct Curl_cfilter *cf, struct Curl_easy *data,
  60. struct cf_quic_ctx *qctx, size_t gsolen);
  61. CURLcode vquic_send_tail_split(struct Curl_cfilter *cf, struct Curl_easy *data,
  62. struct cf_quic_ctx *qctx, size_t gsolen,
  63. size_t tail_len, size_t tail_gsolen);
  64. CURLcode vquic_flush(struct Curl_cfilter *cf, struct Curl_easy *data,
  65. struct cf_quic_ctx *qctx);
  66. typedef CURLcode vquic_recv_pkt_cb(const unsigned char *pkt, size_t pktlen,
  67. struct sockaddr_storage *remote_addr,
  68. socklen_t remote_addrlen, int ecn,
  69. void *userp);
  70. CURLcode vquic_recv_packets(struct Curl_cfilter *cf,
  71. struct Curl_easy *data,
  72. struct cf_quic_ctx *qctx,
  73. size_t max_pkts,
  74. vquic_recv_pkt_cb *recv_cb, void *userp);
  75. #endif /* !USE_HTTP3 */
  76. #endif /* HEADER_CURL_VQUIC_QUIC_INT_H */