QUIC RXFC: Add accessor for credit
authorHugo Landau <hlandau@openssl.org>
Mon, 22 Jan 2024 13:15:08 +0000 (13:15 +0000)
committerHugo Landau <hlandau@openssl.org>
Thu, 8 Feb 2024 16:50:00 +0000 (16:50 +0000)
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23360)

include/internal/quic_fc.h
ssl/quic/quic_fc.c

index 49b448a3a489e72da0b4128529e10d7e98e0841a..db55bb745582ee7608b8aeadff53e10d69151208 100644 (file)
@@ -229,20 +229,26 @@ int ossl_quic_rxfc_on_retire(QUIC_RXFC *rxfc,
  *
  * This value increases monotonically.
  */
-uint64_t ossl_quic_rxfc_get_cwm(QUIC_RXFC *rxfc);
+uint64_t ossl_quic_rxfc_get_cwm(const QUIC_RXFC *rxfc);
 
 /*
  * Returns the current SWM. This is the total number of bytes the peer has
  * transmitted to us. This is intended for diagnostic use only; you should
  * not need it.
  */
-uint64_t ossl_quic_rxfc_get_swm(QUIC_RXFC *rxfc);
+uint64_t ossl_quic_rxfc_get_swm(const QUIC_RXFC *rxfc);
 
 /*
  * Returns the current RWM. This is the total number of bytes that has been
  * retired. This is intended for diagnostic use only; you should not need it.
  */
-uint64_t ossl_quic_rxfc_get_rwm(QUIC_RXFC *rxfc);
+uint64_t ossl_quic_rxfc_get_rwm(const QUIC_RXFC *rxfc);
+
+/*
+ * Returns the current credit. This is the CWM minus the SWM. This is intended
+ * for diagnostic use only; you should not need it.
+ */
+uint64_t ossl_quic_rxfc_get_credit(const QUIC_RXFC *rxfc);
 
 /*
  * Returns the CWM changed flag. If clear is 1, the flag is cleared and the old
index 750e896306f7e9d123c00f12652ae019342cebe0..7e36aab09ee21a815bc496be37ea968887fe1eec 100644 (file)
@@ -359,21 +359,26 @@ int ossl_quic_rxfc_on_retire(QUIC_RXFC *rxfc,
     return 1;
 }
 
-uint64_t ossl_quic_rxfc_get_cwm(QUIC_RXFC *rxfc)
+uint64_t ossl_quic_rxfc_get_cwm(const QUIC_RXFC *rxfc)
 {
     return rxfc->cwm;
 }
 
-uint64_t ossl_quic_rxfc_get_swm(QUIC_RXFC *rxfc)
+uint64_t ossl_quic_rxfc_get_swm(const QUIC_RXFC *rxfc)
 {
     return rxfc->swm;
 }
 
-uint64_t ossl_quic_rxfc_get_rwm(QUIC_RXFC *rxfc)
+uint64_t ossl_quic_rxfc_get_rwm(const QUIC_RXFC *rxfc)
 {
     return rxfc->rwm;
 }
 
+uint64_t ossl_quic_rxfc_get_credit(const QUIC_RXFC *rxfc)
+{
+    return ossl_quic_rxfc_get_cwm(rxfc) - ossl_quic_rxfc_get_swm(rxfc);
+}
+
 int ossl_quic_rxfc_has_cwm_changed(QUIC_RXFC *rxfc, int clear)
 {
     int r = rxfc->has_cwm_changed;