summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Landau <hlandau@openssl.org>2023-05-23 12:23:05 +0100
committerPauli <pauli@openssl.org>2023-06-16 09:26:27 +1000
commitdfd8176f2556ca7ad0029012a048a3adc840bca5 (patch)
tree780ef5d906a9b4766cf77f74c7db8cfc2956baa1
parent5633a323df5a533e003163b9f556a476b9f9df45 (diff)
QUIC WIRE: Utility function to determine if PN is in an ACK frame
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/21029)
-rw-r--r--include/internal/quic_wire.h3
-rw-r--r--ssl/quic/quic_wire.c12
2 files changed, 15 insertions, 0 deletions
diff --git a/include/internal/quic_wire.h b/include/internal/quic_wire.h
index a514d08d3d..e9ff8e6f35 100644
--- a/include/internal/quic_wire.h
+++ b/include/internal/quic_wire.h
@@ -159,6 +159,9 @@ typedef struct ossl_quic_frame_ack_st {
unsigned int ecn_present : 1;
} OSSL_QUIC_FRAME_ACK;
+/* Returns 1 if the given frame contains the given PN. */
+int ossl_quic_frame_ack_contains_pn(const OSSL_QUIC_FRAME_ACK *ack, QUIC_PN pn);
+
/* QUIC Frame: STREAM */
typedef struct ossl_quic_frame_stream_st {
uint64_t stream_id; /* Stream ID */
diff --git a/ssl/quic/quic_wire.c b/ssl/quic/quic_wire.c
index 7df32c77b2..937d16e1c8 100644
--- a/ssl/quic/quic_wire.c
+++ b/ssl/quic/quic_wire.c
@@ -15,6 +15,18 @@
OSSL_SAFE_MATH_UNSIGNED(uint64_t, uint64_t)
+int ossl_quic_frame_ack_contains_pn(const OSSL_QUIC_FRAME_ACK *ack, QUIC_PN pn)
+{
+ size_t i;
+
+ for (i = 0; i < ack->num_ack_ranges; ++i)
+ if (pn >= ack->ack_ranges[i].start
+ && pn <= ack->ack_ranges[i].end)
+ return 1;
+
+ return 0;
+}
+
/*
* QUIC Wire Format Encoding
* =========================