QUIC CHANNEL, PORT: Abstract time retrieval
authorHugo Landau <hlandau@openssl.org>
Thu, 9 Nov 2023 10:27:13 +0000 (10:27 +0000)
committerHugo Landau <hlandau@openssl.org>
Thu, 21 Dec 2023 08:11:59 +0000 (08:11 +0000)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22674)

include/internal/quic_port.h
ssl/quic/quic_channel.c
ssl/quic/quic_port.c

index a42d2138f5677905d298f15cd2df1106ab4868a2..86614d607c72863fb88c0bbcb4d1bcc940d040ad 100644 (file)
@@ -80,6 +80,9 @@ QUIC_DEMUX *ossl_quic_port_get0_demux(QUIC_PORT *port);
 /* Gets the mutex used by the port. */
 CRYPTO_MUTEX *ossl_quic_port_get0_mutex(QUIC_PORT *port);
 
+/* Gets the current time. */
+OSSL_TIME ossl_quic_port_get_time(QUIC_PORT *port);
+
 # endif
 
 #endif
index e266a552e39298fbc551d70abe09a987dd662247..02ef8454967f6dadc87c2532918942a63b2c5e87 100644 (file)
@@ -692,7 +692,7 @@ QUIC_PORT *ossl_quic_channel_get0_port(QUIC_CHANNEL *ch)
 
 CRYPTO_MUTEX *ossl_quic_channel_get_mutex(QUIC_CHANNEL *ch)
 {
-    return ch->port->mutex;
+    return ossl_quic_port_get0_mutex(ch->port);
 }
 
 int ossl_quic_channel_has_pending(const QUIC_CHANNEL *ch)
@@ -711,10 +711,7 @@ static OSSL_TIME get_time(void *arg)
 {
     QUIC_CHANNEL *ch = arg;
 
-    if (ch->port->now_cb == NULL)
-        return ossl_time_now();
-
-    return ch->port->now_cb(ch->port->now_cb_arg);
+    return ossl_quic_port_get_time(ch->port);
 }
 
 /* Used by QSM. */
index a5858d009ac9a87cc324d733e56aa738f1aeda5c..0beb69835bbaecaeb7b14a128827cefe457bd5a0 100644 (file)
@@ -101,16 +101,20 @@ CRYPTO_MUTEX *ossl_quic_port_get0_mutex(QUIC_PORT *port)
     return port->mutex;
 }
 
-static OSSL_TIME get_time(void *arg)
+OSSL_TIME ossl_quic_port_get_time(QUIC_PORT *port)
 {
-    QUIC_PORT *port = arg;
-
     if (port->now_cb == NULL)
         return ossl_time_now();
 
     return port->now_cb(port->now_cb_arg);
 }
 
+static OSSL_TIME get_time(void *port)
+{
+    return ossl_quic_port_get_time(port);
+}
+
+
 /*
  * QUIC Port: Network BIO Configuration
  * ====================================