2 * Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.
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
10 #ifndef OSSL_QUIC_LOCAL_H
11 # define OSSL_QUIC_LOCAL_H
13 # include <openssl/ssl.h>
14 # include "../ssl_local.h"
16 typedef struct quic_conn_st {
17 /* type identifier and common data */
19 /* the associated tls-1.3 connection data */
21 /* just an example member */
25 # define QUIC_CONNECTION_FROM_SSL_int(ssl, c) \
26 ((ssl) == NULL ? NULL \
27 : ((ssl)->type == SSL_TYPE_QUIC_CONNECTION \
28 ? (c QUIC_CONNECTION *)(ssl) \
31 # define SSL_CONNECTION_FROM_QUIC_SSL_int(ssl, c) \
32 ((ssl) == NULL ? NULL \
33 : ((ssl)->type == SSL_TYPE_QUIC_CONNECTION \
34 ? (c SSL_CONNECTION *)((c QUIC_CONNECTION *)(ssl))->tls \
37 # define QUIC_CONNECTION_FROM_SSL(ssl) \
38 QUIC_CONNECTION_FROM_SSL_int(ssl, SSL_CONNECTION_NO_CONST)
39 # define QUIC_CONNECTION_FROM_CONST_SSL(ssl) \
40 QUIC_CONNECTION_FROM_SSL_int(ssl, const)
41 # define SSL_CONNECTION_FROM_QUIC_SSL(ssl) \
42 SSL_CONNECTION_FROM_QUIC_SSL_int(ssl, SSL_CONNECTION_NO_CONST)
43 # define SSL_CONNECTION_FROM_CONST_QUIC_SSL(ssl) \
44 SSL_CONNECTION_FROM_CONST_QUIC_SSL_int(ssl, const)
46 # define OSSL_QUIC_ANY_VERSION 0xFFFFF
48 # define IMPLEMENT_quic_meth_func(version, func_name, q_accept, \
49 q_connect, enc_data) \
50 const SSL_METHOD *func_name(void) \
52 static const SSL_METHOD func_name##_data= { \
68 NULL /* renegotiate */, \
69 ossl_quic_renegotiate_check, \
70 NULL /* read_bytes */, \
71 NULL /* write_bytes */, \
72 NULL /* dispatch_alert */, \
75 NULL /* get_cipher_by_char */, \
76 NULL /* put_cipher_by_char */, \
78 ossl_quic_num_ciphers, \
79 ossl_quic_get_cipher, \
80 ossl_quic_default_timeout, \
82 ssl_undefined_void_function, \
83 ossl_quic_callback_ctrl, \
84 ossl_quic_ctx_callback_ctrl, \
86 return &func_name##_data; \
89 __owur SSL *ossl_quic_new(SSL_CTX *ctx);
90 __owur int ossl_quic_init(SSL *s);
91 void ossl_quic_deinit(SSL *s);
92 void ossl_quic_free(SSL *s);
93 int ossl_quic_reset(SSL *s);
94 int ossl_quic_clear(SSL *s);
95 __owur int ossl_quic_accept(SSL *s);
96 __owur int ossl_quic_connect(SSL *s);
97 __owur int ossl_quic_read(SSL *s, void *buf, size_t len, size_t *readbytes);
98 __owur int ossl_quic_peek(SSL *s, void *buf, size_t len, size_t *readbytes);
99 __owur int ossl_quic_write(SSL *s, const void *buf, size_t len, size_t *written);
100 __owur int ossl_quic_shutdown(SSL *s);
101 __owur long ossl_quic_ctrl(SSL *s, int cmd, long larg, void *parg);
102 __owur long ossl_quic_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg);
103 __owur long ossl_quic_callback_ctrl(SSL *s, int cmd, void (*fp) (void));
104 __owur long ossl_quic_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp) (void));
105 __owur size_t ossl_quic_pending(const SSL *s);
106 __owur OSSL_TIME ossl_quic_default_timeout(void);
107 __owur int ossl_quic_num_ciphers(void);
108 __owur const SSL_CIPHER *ossl_quic_get_cipher(unsigned int u);
109 int ossl_quic_renegotiate_check(SSL *ssl, int initok);
111 __owur int ossl_quic_depacketize(QUIC_CONNECTION *connection);