summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Landau <hlandau@openssl.org>2022-10-31 16:03:03 +0000
committerHugo Landau <hlandau@openssl.org>2023-01-13 13:20:12 +0000
commit04e5226f6549683a8362ae1af2445987d699540a (patch)
tree19130fa5b6822f7f65a31e777a11c8c742c9c9a8
parentb2c94b93994bc079ed3aa7f700adc7782bd0bb64 (diff)
QUIC TXP: Add a function to query if the TXP wants to generate a packet
For use by QUIC CSM. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19703)
-rw-r--r--include/internal/quic_txp.h13
-rw-r--r--ssl/quic/quic_txp.c19
2 files changed, 32 insertions, 0 deletions
diff --git a/include/internal/quic_txp.h b/include/internal/quic_txp.h
index e1983a57c7..0ba14d356f 100644
--- a/include/internal/quic_txp.h
+++ b/include/internal/quic_txp.h
@@ -87,6 +87,19 @@ int ossl_quic_tx_packetiser_generate(OSSL_QUIC_TX_PACKETISER *txp,
uint32_t archetype);
/*
+ * Returns 1 if one or more packets would be generated if
+ * ossl_quic_tx_packetiser_generate were called.
+ *
+ * If TX_PACKETISER_BYPASS_CC is set in flags, congestion control is
+ * ignored for the purposes of making this determination.
+ */
+#define TX_PACKETISER_BYPASS_CC (1U << 0)
+
+int ossl_quic_tx_packetiser_has_pending(OSSL_QUIC_TX_PACKETISER *txp,
+ uint32_t archetype,
+ uint32_t flags);
+
+/*
* Set the token used in Initial packets. The callback is called when the buffer
* is no longer needed; for example, when the TXP is freed or when this function
* is called again with a new buffer.
diff --git a/ssl/quic/quic_txp.c b/ssl/quic/quic_txp.c
index 8508e87503..6224891a35 100644
--- a/ssl/quic/quic_txp.c
+++ b/ssl/quic/quic_txp.c
@@ -460,6 +460,25 @@ void ossl_quic_tx_packetiser_schedule_ack_eliciting(OSSL_QUIC_TX_PACKETISER *txp
#define TXP_ERR_SPACE 2 /* Not enough room for another packet */
#define TXP_ERR_INPUT 3 /* Invalid/malformed input */
+int ossl_quic_tx_packetiser_has_pending(OSSL_QUIC_TX_PACKETISER *txp,
+ uint32_t archetype,
+ uint32_t flags)
+{
+ uint32_t enc_level;
+ int bypass_cc = ((flags & TX_PACKETISER_BYPASS_CC) != 0);
+
+ if (!bypass_cc && !txp->args.cc_method->can_send(txp->args.cc_data))
+ return 0;
+
+ for (enc_level = QUIC_ENC_LEVEL_INITIAL;
+ enc_level < QUIC_ENC_LEVEL_NUM;
+ ++enc_level)
+ if (txp_el_pending(txp, enc_level, archetype))
+ return 1;
+
+ return 0;
+}
+
/*
* Generates a datagram by polling the various ELs to determine if they want to
* generate any frames, and generating a datagram which coalesces packets for