quic_local.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 "../ssl_local.h"
  13. typedef struct quic_conn_st {
  14. /* type identifier and common data */
  15. struct ssl_st ssl;
  16. /* the associated tls-1.3 connection data */
  17. SSL *tls;
  18. /* just an example member */
  19. uint64_t conn_id;
  20. } QUIC_CONNECTION;
  21. # define QUIC_CONNECTION_FROM_SSL_int(ssl, c) \
  22. ((ssl) == NULL ? NULL \
  23. : ((ssl)->type == SSL_TYPE_QUIC_CONNECTION \
  24. ? (c QUIC_CONNECTION *)(ssl) \
  25. : NULL))
  26. # define SSL_CONNECTION_FROM_QUIC_SSL_int(ssl, c) \
  27. ((ssl) == NULL ? NULL \
  28. : ((ssl)->type == SSL_TYPE_QUIC_CONNECTION \
  29. ? (c SSL_CONNECTION *)((c QUIC_CONNECTION *)(ssl))->tls \
  30. : NULL))
  31. # define QUIC_CONNECTION_FROM_SSL(ssl) \
  32. QUIC_CONNECTION_FROM_SSL_int(ssl, SSL_CONNECTION_NO_CONST)
  33. # define QUIC_CONNECTION_FROM_CONST_SSL(ssl) \
  34. QUIC_CONNECTION_FROM_SSL_int(ssl, const)
  35. # define SSL_CONNECTION_FROM_QUIC_SSL(ssl) \
  36. SSL_CONNECTION_FROM_QUIC_SSL_int(ssl, SSL_CONNECTION_NO_CONST)
  37. # define SSL_CONNECTION_FROM_CONST_QUIC_SSL(ssl) \
  38. SSL_CONNECTION_FROM_CONST_QUIC_SSL_int(ssl, const)
  39. # define OSSL_QUIC_ANY_VERSION 0xFFFFF
  40. # define IMPLEMENT_quic_meth_func(version, func_name, q_accept, \
  41. q_connect, enc_data) \
  42. const SSL_METHOD *func_name(void) \
  43. { \
  44. static const SSL_METHOD func_name##_data= { \
  45. version, \
  46. 0, \
  47. 0, \
  48. ossl_quic_new, \
  49. ossl_quic_free, \
  50. ossl_quic_reset, \
  51. ossl_quic_init, \
  52. ossl_quic_clear, \
  53. ossl_quic_deinit, \
  54. q_accept, \
  55. q_connect, \
  56. ossl_quic_read, \
  57. ossl_quic_peek, \
  58. ossl_quic_write, \
  59. ossl_quic_shutdown, \
  60. NULL /* renegotiate */, \
  61. ossl_quic_renegotiate_check, \
  62. NULL /* read_bytes */, \
  63. NULL /* write_bytes */, \
  64. NULL /* dispatch_alert */, \
  65. ossl_quic_ctrl, \
  66. ossl_quic_ctx_ctrl, \
  67. NULL /* get_cipher_by_char */, \
  68. NULL /* put_cipher_by_char */, \
  69. ossl_quic_pending, \
  70. ossl_quic_num_ciphers, \
  71. ossl_quic_get_cipher, \
  72. ossl_quic_default_timeout, \
  73. &enc_data, \
  74. ssl_undefined_void_function, \
  75. ossl_quic_callback_ctrl, \
  76. ossl_quic_ctx_callback_ctrl, \
  77. }; \
  78. return &func_name##_data; \
  79. }
  80. __owur SSL *ossl_quic_new(SSL_CTX *ctx);
  81. __owur int ossl_quic_init(SSL *s);
  82. void ossl_quic_deinit(SSL *s);
  83. void ossl_quic_free(SSL *s);
  84. int ossl_quic_reset(SSL *s);
  85. int ossl_quic_clear(SSL *s);
  86. __owur int ossl_quic_accept(SSL *s);
  87. __owur int ossl_quic_connect(SSL *s);
  88. __owur int ossl_quic_read(SSL *s, void *buf, size_t len, size_t *readbytes);
  89. __owur int ossl_quic_peek(SSL *s, void *buf, size_t len, size_t *readbytes);
  90. __owur int ossl_quic_write(SSL *s, const void *buf, size_t len, size_t *written);
  91. __owur int ossl_quic_shutdown(SSL *s);
  92. __owur long ossl_quic_ctrl(SSL *s, int cmd, long larg, void *parg);
  93. __owur long ossl_quic_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg);
  94. __owur long ossl_quic_callback_ctrl(SSL *s, int cmd, void (*fp) (void));
  95. __owur long ossl_quic_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp) (void));
  96. __owur size_t ossl_quic_pending(const SSL *s);
  97. __owur long ossl_quic_default_timeout(void);
  98. __owur int ossl_quic_num_ciphers(void);
  99. __owur const SSL_CIPHER *ossl_quic_get_cipher(unsigned int u);
  100. int ossl_quic_renegotiate_check(SSL *ssl, int initok);
  101. __owur int ossl_quic_depacketize(QUIC_CONNECTION *connection);
  102. #endif