quic_local.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * Copyright 2022 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_LOCAL_H
  10. # define OSSL_QUIC_LOCAL_H
  11. # include <openssl/ssl.h>
  12. # include "internal/quic_ssl.h" /* QUIC_CONNECTION */
  13. # include "internal/quic_fc.h"
  14. # include "internal/quic_stream.h"
  15. # include "../ssl_local.h"
  16. struct quic_stream_st {
  17. /* type identifier and common data for the public SSL object */
  18. struct ssl_st ssl;
  19. /* QUIC_CONNECTION that this stream belongs to */
  20. QUIC_CONNECTION *conn;
  21. /* receive flow controller */
  22. QUIC_RXFC *rxfc;
  23. /* receive and send stream objects */
  24. QUIC_RSTREAM *rstream;
  25. QUIC_SSTREAM *sstream;
  26. };
  27. struct quic_conn_st {
  28. /* QUIC connection is always a stream (the stream id 0) */
  29. struct quic_stream_st stream;
  30. /* the associated tls-1.3 connection data */
  31. SSL *tls;
  32. /* QUIC ack manager */
  33. OSSL_ACKM *ackm;
  34. /* QUIC receive record layer */
  35. OSSL_QRX *qrx;
  36. };
  37. # define QUIC_CONNECTION_FROM_SSL_int(ssl, c) \
  38. ((ssl) == NULL ? NULL \
  39. : ((ssl)->type == SSL_TYPE_QUIC_CONNECTION \
  40. ? (c QUIC_CONNECTION *)(ssl) \
  41. : NULL))
  42. # define QUIC_STREAM_FROM_SSL_int(ssl, c) \
  43. ((ssl) == NULL ? NULL \
  44. : ((ssl)->type == SSL_TYPE_QUIC_CONNECTION \
  45. || (ssl)->type == SSL_TYPE_QUIC_STREAM \
  46. ? (c QUIC_STREAM *)(ssl) \
  47. : NULL))
  48. # define SSL_CONNECTION_FROM_QUIC_SSL_int(ssl, c) \
  49. ((ssl) == NULL ? NULL \
  50. : ((ssl)->type == SSL_TYPE_QUIC_CONNECTION \
  51. ? (c SSL_CONNECTION *)((c QUIC_CONNECTION *)(ssl))->tls \
  52. : NULL))
  53. # define QUIC_CONNECTION_FROM_SSL(ssl) \
  54. QUIC_CONNECTION_FROM_SSL_int(ssl, SSL_CONNECTION_NO_CONST)
  55. # define QUIC_CONNECTION_FROM_CONST_SSL(ssl) \
  56. QUIC_CONNECTION_FROM_SSL_int(ssl, const)
  57. # define QUIC_STREAM_FROM_SSL(ssl) \
  58. QUIC_STREAM_FROM_SSL_int(ssl, SSL_CONNECTION_NO_CONST)
  59. # define QUIC_STREAM_FROM_CONST_SSL(ssl) \
  60. QUIC_STREAM_FROM_SSL_int(ssl, const)
  61. # define SSL_CONNECTION_FROM_QUIC_SSL(ssl) \
  62. SSL_CONNECTION_FROM_QUIC_SSL_int(ssl, SSL_CONNECTION_NO_CONST)
  63. # define SSL_CONNECTION_FROM_CONST_QUIC_SSL(ssl) \
  64. SSL_CONNECTION_FROM_CONST_QUIC_SSL_int(ssl, const)
  65. # define OSSL_QUIC_ANY_VERSION 0xFFFFF
  66. # define IMPLEMENT_quic_meth_func(version, func_name, q_accept, \
  67. q_connect, enc_data) \
  68. const SSL_METHOD *func_name(void) \
  69. { \
  70. static const SSL_METHOD func_name##_data= { \
  71. version, \
  72. 0, \
  73. 0, \
  74. ossl_quic_new, \
  75. ossl_quic_free, \
  76. ossl_quic_reset, \
  77. ossl_quic_init, \
  78. ossl_quic_clear, \
  79. ossl_quic_deinit, \
  80. q_accept, \
  81. q_connect, \
  82. ossl_quic_read, \
  83. ossl_quic_peek, \
  84. ossl_quic_write, \
  85. ossl_quic_shutdown, \
  86. NULL /* renegotiate */, \
  87. ossl_quic_renegotiate_check, \
  88. NULL /* read_bytes */, \
  89. NULL /* write_bytes */, \
  90. NULL /* dispatch_alert */, \
  91. ossl_quic_ctrl, \
  92. ossl_quic_ctx_ctrl, \
  93. NULL /* get_cipher_by_char */, \
  94. NULL /* put_cipher_by_char */, \
  95. ossl_quic_pending, \
  96. ossl_quic_num_ciphers, \
  97. ossl_quic_get_cipher, \
  98. ossl_quic_default_timeout, \
  99. &enc_data, \
  100. ssl_undefined_void_function, \
  101. ossl_quic_callback_ctrl, \
  102. ossl_quic_ctx_callback_ctrl, \
  103. }; \
  104. return &func_name##_data; \
  105. }
  106. #endif