QUIC Refactor: Fix ANSI - struct definition duplications
[openssl.git] / include / internal / quic_port.h
index 86614d607c72863fb88c0bbcb4d1bcc940d040ad..9e52a1e77ccea8cc0a078bfade1ca1257d062705 100644 (file)
@@ -13,6 +13,7 @@
 # include "internal/quic_types.h"
 # include "internal/quic_reactor.h"
 # include "internal/quic_demux.h"
+# include "internal/quic_predef.h"
 # include "internal/thread_arch.h"
 
 # ifndef OPENSSL_NO_QUIC
  * zero or more subsidiary QUIC_CHANNEL instances, each of which represents a
  * single QUIC connection. All QUIC_CHANNEL instances must belong to a
  * QUIC_PORT.
+ *
+ * A QUIC port is responsible for managing a set of channels which all use the
+ * same UDP socket, and (in future) for automatically creating new channels when
+ * incoming connections are received.
+ *
+ * In order to retain compatibility with QUIC_TSERVER, it also supports a point
+ * of legacy compatibility where a caller can create an incoming (server role)
+ * channel and that channel will be automatically be bound to the next incoming
+ * connection. In the future this will go away once QUIC_TSERVER is removed.
  */
 typedef struct quic_port_args_st {
     /* All channels in a QUIC event domain share the same (libctx, propq). */
@@ -50,14 +60,39 @@ typedef struct quic_port_args_st {
      */
     OSSL_TIME       (*now_cb)(void *arg);
     void            *now_cb_arg;
-} QUIC_PORT_ARGS;
 
-typedef struct quic_port_st QUIC_PORT;
+    /*
+     * This SSL_CTX will be used when constructing the handshake layer object
+     * inside newly created channels.
+     */
+    SSL_CTX         *channel_ctx;
+
+    /*
+     * If 1, this port is to be used for multiple connections, so
+     * non-zero-length CIDs should be used. If 0, this port will only be used
+     * for a single connection, so a zero-length local CID can be used.
+     */
+    int             is_multi_conn;
+} QUIC_PORT_ARGS;
 
 QUIC_PORT *ossl_quic_port_new(const QUIC_PORT_ARGS *args);
 
 void ossl_quic_port_free(QUIC_PORT *port);
 
+/*
+ * Operations
+ * ==========
+ */
+
+/* Create an outgoing channel using this port. */
+QUIC_CHANNEL *ossl_quic_port_create_outgoing(QUIC_PORT *port, SSL *tls);
+
+/*
+ * Create an incoming channel using this port. XXX for temporary TSERVER use
+ * only - will be removed.
+ */
+QUIC_CHANNEL *ossl_quic_port_create_incoming(QUIC_PORT *port, SSL *tls);
+
 /*
  * Queries and Accessors
  * =====================
@@ -69,6 +104,10 @@ BIO *ossl_quic_port_get_net_wbio(QUIC_PORT *port);
 int ossl_quic_port_set_net_rbio(QUIC_PORT *port, BIO *net_rbio);
 int ossl_quic_port_set_net_wbio(QUIC_PORT *port, BIO *net_wbio);
 
+/*
+ * Re-poll the network BIOs already set to determine if their support
+ * for polling has changed.
+ */
 int ossl_quic_port_update_poll_descriptors(QUIC_PORT *port);
 
 /* Gets the reactor which can be used to tick/poll on the port. */
@@ -83,6 +122,34 @@ CRYPTO_MUTEX *ossl_quic_port_get0_mutex(QUIC_PORT *port);
 /* Gets the current time. */
 OSSL_TIME ossl_quic_port_get_time(QUIC_PORT *port);
 
+int ossl_quic_port_get_rx_short_dcid_len(const QUIC_PORT *port);
+int ossl_quic_port_get_tx_init_dcid_len(const QUIC_PORT *port);
+
+/* For testing use. While enabled, ticking is not performed. */
+void ossl_quic_port_set_inhibit_tick(QUIC_PORT *port, int inhibit);
+
+/* Returns 1 if the port is running/healthy, 0 if it has failed. */
+int ossl_quic_port_is_running(const QUIC_PORT *port);
+
+/*
+ * Restores port-level error to the error stack. To be called only if
+ * the port is no longer running.
+ */
+void ossl_quic_port_restore_err_state(const QUIC_PORT *port);
+
+/*
+ * Events
+ * ======
+ */
+
+/*
+ * Called if a permanent network error occurs. Terminates all channels
+ * immediately. triggering_ch is an optional argument designating
+ * a channel which encountered the network error.
+ */
+void ossl_quic_port_raise_net_error(QUIC_PORT *port,
+                                    QUIC_CHANNEL *triggering_ch);
+
 # endif
 
 #endif