Move the QUIC_CONNECTION typedef to internal headers
authorRichard Levitte <levitte@openssl.org>
Tue, 6 Sep 2022 11:59:25 +0000 (13:59 +0200)
committerRichard Levitte <levitte@openssl.org>
Fri, 23 Sep 2022 15:48:54 +0000 (17:48 +0200)
Also add internal functionality to get a QUIC_CONNECTION pointer from
an SSL pointer, and setters / getters for the GQX and ACKM fields.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18838)

doc/designs/quic-design/rx-depacketizer.md
include/internal/quic_ssl.h [new file with mode: 0644]
ssl/quic/quic_impl.c
ssl/quic/quic_local.h
ssl/quic/quic_wire.c

index b5a1f21541cd7086c09c2ee652467560b6d9707e..1222973c1ba80c8a7e1385b32fb44d4c9c9332bc 100644 (file)
@@ -13,7 +13,7 @@ Main structures
 ### Connection
 
 Represented by an `QUIC_CONNECTION` object, defined in
-[`ssl/quic/quic_local.h`](../../../ssl/quic/quic_local.h).
+[`include/internal/quic_ssl.h`](../../../include/internal/quic_ssl.h).
 
 ### Stream
 
diff --git a/include/internal/quic_ssl.h b/include/internal/quic_ssl.h
new file mode 100644 (file)
index 0000000..d9a0ade
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License").  You may not use
+ * this file except in compliance with the License.  You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#ifndef OSSL_QUIC_SSL_H
+# define OSSL_QUIC_SSL_H
+
+# include <openssl/ssl.h>
+# include "internal/quic_record_rx.h" /* OSSL_QRX */
+# include "internal/quic_ackm.h"      /* OSSL_ACKM */
+
+__owur SSL *ossl_quic_new(SSL_CTX *ctx);
+__owur int ossl_quic_init(SSL *s);
+void ossl_quic_deinit(SSL *s);
+void ossl_quic_free(SSL *s);
+int ossl_quic_reset(SSL *s);
+int ossl_quic_clear(SSL *s);
+__owur int ossl_quic_accept(SSL *s);
+__owur int ossl_quic_connect(SSL *s);
+__owur int ossl_quic_read(SSL *s, void *buf, size_t len, size_t *readbytes);
+__owur int ossl_quic_peek(SSL *s, void *buf, size_t len, size_t *readbytes);
+__owur int ossl_quic_write(SSL *s, const void *buf, size_t len, size_t *written);
+__owur int ossl_quic_shutdown(SSL *s);
+__owur long ossl_quic_ctrl(SSL *s, int cmd, long larg, void *parg);
+__owur long ossl_quic_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg);
+__owur long ossl_quic_callback_ctrl(SSL *s, int cmd, void (*fp) (void));
+__owur long ossl_quic_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp) (void));
+__owur size_t ossl_quic_pending(const SSL *s);
+__owur OSSL_TIME ossl_quic_default_timeout(void);
+__owur int ossl_quic_num_ciphers(void);
+__owur const SSL_CIPHER *ossl_quic_get_cipher(unsigned int u);
+int ossl_quic_renegotiate_check(SSL *ssl, int initok);
+
+typedef struct quic_conn_st QUIC_CONNECTION;
+
+__owur QUIC_CONNECTION *ossl_quic_conn_from_ssl(SSL *ssl);
+int ossl_quic_conn_set_qrx(QUIC_CONNECTION *qc, OSSL_QRX *qrx);
+OSSL_QRX *ossl_quic_conn_get_qrx(QUIC_CONNECTION *qc);
+int ossl_quic_conn_set_ackm(QUIC_CONNECTION *qc, OSSL_ACKM *ackm);
+OSSL_ACKM *ossl_quic_conn_set_akcm(QUIC_CONNECTION *qc);
+
+#endif
index 6d5c1995f8b439e3a15b2c27bdeaabfb1bfcb5c7..ed3b07e63d85dcdeb7765059303a354f11eaf896 100644 (file)
@@ -239,3 +239,39 @@ int ossl_quic_renegotiate_check(SSL *ssl, int initok)
 {
     return 1;
 }
+
+QUIC_CONNECTION *ossl_quic_conn_from_ssl(SSL *ssl)
+{
+    return QUIC_CONNECTION_FROM_SSL(ssl);
+}
+
+/*
+ * The following are getters and setters of pointers, but they don't affect
+ * the objects being pointed at.  They are CURRENTLY to be freed separately
+ * by the caller the set them in the first place.
+ */
+int ossl_quic_conn_set_qrx(QUIC_CONNECTION *qc, OSSL_QRX *qrx)
+{
+    if (qc == NULL)
+        return 0;
+    qc->qrx = qrx;
+    return 1;
+}
+
+OSSL_QRX *ossl_quic_conn_get_qrx(QUIC_CONNECTION *qc)
+{
+    return qc != NULL ? qc->qrx : NULL;
+}
+
+int ossl_quic_conn_set_ackm(QUIC_CONNECTION *qc, OSSL_ACKM *ackm)
+{
+    if (qc == NULL)
+        return 0;
+    qc->ackm = ackm;
+    return 1;
+}
+
+OSSL_ACKM *ossl_quic_conn_set_akcm(QUIC_CONNECTION *qc)
+{
+    return qc != NULL ? qc->ackm : NULL;
+}
index 3f589bba0ba0b7511ee9d69d5793611116479e0e..3305b03aec6db2e3f23360ee87928264bfa1d101 100644 (file)
 # define OSSL_QUIC_LOCAL_H
 
 # include <openssl/ssl.h>
+# include "internal/quic_ssl.h"       /* QUIC_CONNECTION */
 # include "../ssl_local.h"
 
-typedef struct quic_conn_st {
+struct quic_conn_st {
     /* type identifier and common data */
     struct ssl_st ssl;
     /* the associated tls-1.3 connection data */
     SSL *tls;
-    /* just an example member */
-    uint64_t conn_id;
-} QUIC_CONNECTION;
+
+    /* For QUIC, diverse handlers */
+    OSSL_ACKM *ackm;
+    OSSL_QRX *qrx;
+};
 
 # define QUIC_CONNECTION_FROM_SSL_int(ssl, c)   \
     ((ssl) == NULL ? NULL                       \
@@ -86,28 +89,4 @@ const SSL_METHOD *func_name(void)  \
         return &func_name##_data; \
         }
 
-__owur SSL *ossl_quic_new(SSL_CTX *ctx);
-__owur int ossl_quic_init(SSL *s);
-void ossl_quic_deinit(SSL *s);
-void ossl_quic_free(SSL *s);
-int ossl_quic_reset(SSL *s);
-int ossl_quic_clear(SSL *s);
-__owur int ossl_quic_accept(SSL *s);
-__owur int ossl_quic_connect(SSL *s);
-__owur int ossl_quic_read(SSL *s, void *buf, size_t len, size_t *readbytes);
-__owur int ossl_quic_peek(SSL *s, void *buf, size_t len, size_t *readbytes);
-__owur int ossl_quic_write(SSL *s, const void *buf, size_t len, size_t *written);
-__owur int ossl_quic_shutdown(SSL *s);
-__owur long ossl_quic_ctrl(SSL *s, int cmd, long larg, void *parg);
-__owur long ossl_quic_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg);
-__owur long ossl_quic_callback_ctrl(SSL *s, int cmd, void (*fp) (void));
-__owur long ossl_quic_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp) (void));
-__owur size_t ossl_quic_pending(const SSL *s);
-__owur OSSL_TIME ossl_quic_default_timeout(void);
-__owur int ossl_quic_num_ciphers(void);
-__owur const SSL_CIPHER *ossl_quic_get_cipher(unsigned int u);
-int ossl_quic_renegotiate_check(SSL *ssl, int initok);
-
-__owur int ossl_quic_depacketize(QUIC_CONNECTION *connection);
-
 #endif
index 4d19ad6013efbb7d91d03e4ef8c5ee9d885bcbff..2e7e785b7dc5c6ad9e41f6af0b56ea871474c559 100644 (file)
@@ -9,7 +9,7 @@
 
 #include <openssl/macros.h>
 #include <openssl/objects.h>
-#include "quic_local.h"
+#include "internal/quic_ssl.h"
 #include "internal/quic_vlint.h"
 #include "internal/quic_wire.h"