quic_ssl.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * Copyright 2022-2024 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #ifndef OSSL_QUIC_SSL_H
  10. # define OSSL_QUIC_SSL_H
  11. # include <openssl/ssl.h>
  12. # include <openssl/bio.h>
  13. # include "internal/quic_record_rx.h" /* OSSL_QRX */
  14. # include "internal/quic_ackm.h" /* OSSL_ACKM */
  15. # include "internal/quic_channel.h" /* QUIC_CHANNEL */
  16. # ifndef OPENSSL_NO_QUIC
  17. __owur SSL *ossl_quic_new(SSL_CTX *ctx);
  18. __owur int ossl_quic_init(SSL *s);
  19. void ossl_quic_deinit(SSL *s);
  20. void ossl_quic_free(SSL *s);
  21. int ossl_quic_reset(SSL *s);
  22. int ossl_quic_clear(SSL *s);
  23. __owur int ossl_quic_accept(SSL *s);
  24. __owur int ossl_quic_connect(SSL *s);
  25. __owur int ossl_quic_read(SSL *s, void *buf, size_t len, size_t *readbytes);
  26. __owur int ossl_quic_peek(SSL *s, void *buf, size_t len, size_t *readbytes);
  27. __owur int ossl_quic_write_flags(SSL *s, const void *buf, size_t len,
  28. uint64_t flags, size_t *written);
  29. __owur int ossl_quic_write(SSL *s, const void *buf, size_t len, size_t *written);
  30. __owur long ossl_quic_ctrl(SSL *s, int cmd, long larg, void *parg);
  31. __owur long ossl_quic_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg);
  32. __owur long ossl_quic_callback_ctrl(SSL *s, int cmd, void (*fp) (void));
  33. __owur long ossl_quic_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp) (void));
  34. __owur size_t ossl_quic_pending(const SSL *s);
  35. __owur int ossl_quic_key_update(SSL *s, int update_type);
  36. __owur int ossl_quic_get_key_update_type(const SSL *s);
  37. __owur const SSL_CIPHER *ossl_quic_get_cipher_by_char(const unsigned char *p);
  38. __owur int ossl_quic_num_ciphers(void);
  39. __owur const SSL_CIPHER *ossl_quic_get_cipher(unsigned int u);
  40. int ossl_quic_renegotiate_check(SSL *ssl, int initok);
  41. typedef struct quic_conn_st QUIC_CONNECTION;
  42. typedef struct quic_xso_st QUIC_XSO;
  43. int ossl_quic_do_handshake(SSL *s);
  44. void ossl_quic_set_connect_state(SSL *s);
  45. void ossl_quic_set_accept_state(SSL *s);
  46. __owur int ossl_quic_has_pending(const SSL *s);
  47. __owur int ossl_quic_handle_events(SSL *s);
  48. __owur int ossl_quic_get_event_timeout(SSL *s, struct timeval *tv,
  49. int *is_infinite);
  50. OSSL_TIME ossl_quic_get_event_deadline(SSL *s);
  51. __owur int ossl_quic_get_rpoll_descriptor(SSL *s, BIO_POLL_DESCRIPTOR *d);
  52. __owur int ossl_quic_get_wpoll_descriptor(SSL *s, BIO_POLL_DESCRIPTOR *d);
  53. __owur int ossl_quic_get_net_read_desired(SSL *s);
  54. __owur int ossl_quic_get_net_write_desired(SSL *s);
  55. __owur int ossl_quic_get_error(const SSL *s, int i);
  56. __owur int ossl_quic_want(const SSL *s);
  57. __owur int ossl_quic_conn_get_blocking_mode(const SSL *s);
  58. __owur int ossl_quic_conn_set_blocking_mode(SSL *s, int blocking);
  59. __owur int ossl_quic_conn_shutdown(SSL *s, uint64_t flags,
  60. const SSL_SHUTDOWN_EX_ARGS *args,
  61. size_t args_len);
  62. __owur int ossl_quic_conn_stream_conclude(SSL *s);
  63. void ossl_quic_conn_set0_net_rbio(SSL *s, BIO *net_wbio);
  64. void ossl_quic_conn_set0_net_wbio(SSL *s, BIO *net_wbio);
  65. BIO *ossl_quic_conn_get_net_rbio(const SSL *s);
  66. BIO *ossl_quic_conn_get_net_wbio(const SSL *s);
  67. __owur int ossl_quic_conn_set_initial_peer_addr(SSL *s,
  68. const BIO_ADDR *peer_addr);
  69. __owur SSL *ossl_quic_conn_stream_new(SSL *s, uint64_t flags);
  70. __owur SSL *ossl_quic_get0_connection(SSL *s);
  71. __owur int ossl_quic_get_stream_type(SSL *s);
  72. __owur uint64_t ossl_quic_get_stream_id(SSL *s);
  73. __owur int ossl_quic_is_stream_local(SSL *s);
  74. __owur int ossl_quic_set_default_stream_mode(SSL *s, uint32_t mode);
  75. __owur SSL *ossl_quic_detach_stream(SSL *s);
  76. __owur int ossl_quic_attach_stream(SSL *conn, SSL *stream);
  77. __owur int ossl_quic_set_incoming_stream_policy(SSL *s, int policy,
  78. uint64_t aec);
  79. __owur SSL *ossl_quic_accept_stream(SSL *s, uint64_t flags);
  80. __owur size_t ossl_quic_get_accept_stream_queue_len(SSL *s);
  81. __owur int ossl_quic_get_value_uint(SSL *s, uint32_t class_, uint32_t id,
  82. uint64_t *value);
  83. __owur int ossl_quic_set_value_uint(SSL *s, uint32_t class_, uint32_t id,
  84. uint64_t value);
  85. __owur int ossl_quic_stream_reset(SSL *ssl,
  86. const SSL_STREAM_RESET_ARGS *args,
  87. size_t args_len);
  88. __owur int ossl_quic_get_stream_read_state(SSL *ssl);
  89. __owur int ossl_quic_get_stream_write_state(SSL *ssl);
  90. __owur int ossl_quic_get_stream_read_error_code(SSL *ssl,
  91. uint64_t *app_error_code);
  92. __owur int ossl_quic_get_stream_write_error_code(SSL *ssl,
  93. uint64_t *app_error_code);
  94. __owur int ossl_quic_get_conn_close_info(SSL *ssl,
  95. SSL_CONN_CLOSE_INFO *info,
  96. size_t info_len);
  97. uint64_t ossl_quic_set_options(SSL *s, uint64_t opts);
  98. uint64_t ossl_quic_clear_options(SSL *s, uint64_t opts);
  99. uint64_t ossl_quic_get_options(const SSL *s);
  100. /* Modifies write buffer size for a stream. */
  101. __owur int ossl_quic_set_write_buffer_size(SSL *s, size_t size);
  102. /*
  103. * Used to override ossl_time_now() for debug purposes. While this may be
  104. * overridden at any time, expect strange results if you change it after
  105. * connecting.
  106. */
  107. int ossl_quic_conn_set_override_now_cb(SSL *s,
  108. OSSL_TIME (*now_cb)(void *arg),
  109. void *now_cb_arg);
  110. /*
  111. * Condvar waiting in the assist thread doesn't support time faking as it relies
  112. * on the OS's notion of time, thus this is used in test code to force a
  113. * spurious wakeup instead.
  114. */
  115. void ossl_quic_conn_force_assist_thread_wake(SSL *s);
  116. /* For use by tests only. */
  117. QUIC_CHANNEL *ossl_quic_conn_get_channel(SSL *s);
  118. int ossl_quic_has_pending(const SSL *s);
  119. int ossl_quic_get_shutdown(const SSL *s);
  120. /*
  121. * Set qlog diagnostic title. String is copied internally on success and need
  122. * not remain allocated. Only has any effect if logging has not already begun.
  123. * For use by tests only. Setting this on a context affects any QCSO created
  124. * after this is called but does not affect QCSOs already created from a
  125. * context.
  126. */
  127. int ossl_quic_set_diag_title(SSL_CTX *ctx, const char *title);
  128. /* APIs used by the polling infrastructure */
  129. int ossl_quic_conn_poll_events(SSL *ssl, uint64_t events, int do_tick,
  130. uint64_t *revents);
  131. # endif
  132. #endif