]> git.ipfire.org Git - thirdparty/openssl.git/blame - ssl/quic/quic_local.h
ssl: modify libssl so that it uses OSSL_TIME
[thirdparty/openssl.git] / ssl / quic / quic_local.h
CommitLineData
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
16typedef 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
50const 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);
91void ossl_quic_deinit(SSL *s);
99e1cc7b 92void ossl_quic_free(SSL *s);
38b051a1 93int ossl_quic_reset(SSL *s);
99e1cc7b
TM
94int 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);
109int 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