]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
QUIC WIRE: Utility function to determine if PN is in an ACK frame
authorHugo Landau <hlandau@openssl.org>
Tue, 23 May 2023 11:23:05 +0000 (12:23 +0100)
committerPauli <pauli@openssl.org>
Thu, 15 Jun 2023 23:26:27 +0000 (09:26 +1000)
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)

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

index a514d08d3dd0a6c2c218fd4c0fb1572b81693488..e9ff8e6f356fbd1a9ece54aae8e48365b0379700 100644 (file)
@@ -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 */
index 7df32c77b21f2e952b04fdb7cde3c45eb04f45e0..937d16e1c8c7e24de801c6e3c5dae11d44f249e1 100644 (file)
 
 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
  * =========================