]>
Commit | Line | Data |
---|---|---|
99e1cc7b TM |
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 | ||
10 | #ifndef OSSL_QUIC_LOCAL_H | |
11 | # define OSSL_QUIC_LOCAL_H | |
12 | ||
13 | # include <openssl/ssl.h> | |
14 | # include "../ssl_local.h" | |
15 | ||
38b051a1 TM |
16 | typedef struct quic_conn_st { |
17 | /* type identifier and common data */ | |
18 | struct ssl_st ssl; | |
19 | /* the associated tls-1.3 connection data */ | |
20 | SSL *tls; | |
21 | /* just an example member */ | |
22 | uint64_t conn_id; | |
23 | } QUIC_CONNECTION; | |
24 | ||
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) \ | |
29 | : NULL)) | |
30 | ||
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 \ | |
35 | : NULL)) | |
36 | ||
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) | |
45 | ||
99e1cc7b TM |
46 | # define OSSL_QUIC_ANY_VERSION 0xFFFFF |
47 | ||
08e49012 TM |
48 | # define IMPLEMENT_quic_meth_func(version, func_name, q_accept, \ |
49 | q_connect, enc_data) \ | |
99e1cc7b TM |
50 | const SSL_METHOD *func_name(void) \ |
51 | { \ | |
52 | static const SSL_METHOD func_name##_data= { \ | |
53 | version, \ | |
54 | 0, \ | |
55 | 0, \ | |
56 | ossl_quic_new, \ | |
99e1cc7b | 57 | ossl_quic_free, \ |
38b051a1 TM |
58 | ossl_quic_reset, \ |
59 | ossl_quic_init, \ | |
60 | ossl_quic_clear, \ | |
61 | ossl_quic_deinit, \ | |
08e49012 TM |
62 | q_accept, \ |
63 | q_connect, \ | |
99e1cc7b TM |
64 | ossl_quic_read, \ |
65 | ossl_quic_peek, \ | |
66 | ossl_quic_write, \ | |
67 | ossl_quic_shutdown, \ | |
68 | NULL /* renegotiate */, \ | |
e44795bd | 69 | ossl_quic_renegotiate_check, \ |
99e1cc7b TM |
70 | NULL /* read_bytes */, \ |
71 | NULL /* write_bytes */, \ | |
72 | NULL /* dispatch_alert */, \ | |
73 | ossl_quic_ctrl, \ | |
74 | ossl_quic_ctx_ctrl, \ | |
75 | NULL /* get_cipher_by_char */, \ | |
76 | NULL /* put_cipher_by_char */, \ | |
77 | ossl_quic_pending, \ | |
e44795bd TM |
78 | ossl_quic_num_ciphers, \ |
79 | ossl_quic_get_cipher, \ | |
80 | ossl_quic_default_timeout, \ | |
99e1cc7b TM |
81 | &enc_data, \ |
82 | ssl_undefined_void_function, \ | |
83 | ossl_quic_callback_ctrl, \ | |
84 | ossl_quic_ctx_callback_ctrl, \ | |
85 | }; \ | |
86 | return &func_name##_data; \ | |
87 | } | |
88 | ||
38b051a1 TM |
89 | __owur SSL *ossl_quic_new(SSL_CTX *ctx); |
90 | __owur int ossl_quic_init(SSL *s); | |
91 | void ossl_quic_deinit(SSL *s); | |
99e1cc7b | 92 | void ossl_quic_free(SSL *s); |
38b051a1 | 93 | int ossl_quic_reset(SSL *s); |
99e1cc7b TM |
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); | |
38b051a1 | 102 | __owur long ossl_quic_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg); |
99e1cc7b | 103 | __owur long ossl_quic_callback_ctrl(SSL *s, int cmd, void (*fp) (void)); |
38b051a1 | 104 | __owur long ossl_quic_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp) (void)); |
99e1cc7b | 105 | __owur size_t ossl_quic_pending(const SSL *s); |
f0131dc0 | 106 | __owur OSSL_TIME ossl_quic_default_timeout(void); |
e44795bd TM |
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); | |
99e1cc7b | 110 | |
d7fed97e RL |
111 | __owur int ossl_quic_depacketize(QUIC_CONNECTION *connection); |
112 | ||
99e1cc7b | 113 | #endif |