]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Extend tracing of frames to transmitted frames
authorMatt Caswell <matt@openssl.org>
Fri, 5 May 2023 13:46:01 +0000 (14:46 +0100)
committerMatt Caswell <matt@openssl.org>
Wed, 24 May 2023 11:18:33 +0000 (12:18 +0100)
Previously we were only doing tracing of frames received from the peer.
Now we do that for transmitted frames as well.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20914)

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

index 0e4fd5cc49d03d5374ce77117226b136ea208461..54c25754eb87b5bb623ddc32cb0e1a4dd3a4912f 100644 (file)
@@ -49,6 +49,11 @@ typedef struct ossl_quic_tx_packetiser_args_st {
     OSSL_TIME       (*now)(void *arg);  /* Callback to get current time. */
     void            *now_arg;
 
+    /* Message callback related arguments */
+    ossl_msg_cb msg_callback;
+    void *msg_callback_arg;
+    SSL *msg_callback_s;
+
     /*
      * Injected dependencies - crypto streams.
      *
index 2f655f61cddd87bc50cb6e7feb68962661452e99..cb24bd0c1ae7cb9f817015e63ff5778d054276a6 100644 (file)
@@ -208,6 +208,11 @@ static int ch_init(QUIC_CHANNEL *ch)
     txp_args.cc_data                = ch->cc_data;
     txp_args.now                    = get_time;
     txp_args.now_arg                = ch;
+    /* Callback related arguments */
+    txp_args.msg_callback           = ch->msg_callback;
+    txp_args.msg_callback_arg       = ch->msg_callback_arg;
+    txp_args.msg_callback_s         = ch->msg_callback_s;
+
     for (pn_space = QUIC_PN_SPACE_INITIAL; pn_space < QUIC_PN_SPACE_NUM; ++pn_space) {
         ch->crypto_send[pn_space] = ossl_quic_sstream_new(INIT_CRYPTO_BUF_LEN);
         if (ch->crypto_send[pn_space] == NULL)
index a1341d8b13e16a35d99f9d228401154be15acbff..b8bfb3592eaf0123e7ac0b23f59555b7ad1357aa 100644 (file)
@@ -301,6 +301,28 @@ static int tx_helper_commit(struct tx_helper *h)
         return 0;
     }
 
+    if (h->txp->args.msg_callback != NULL && l > 0) {
+        uint64_t ftype;
+        int ctype = SSL3_RT_QUIC_FRAME_FULL;
+        PACKET pkt;
+
+        if (!PACKET_buf_init(&pkt, h->txn.data, l)
+                || !ossl_quic_wire_peek_frame_header(&pkt, &ftype)) {
+            tx_helper_end(h, 0);
+            return 0;
+        }
+
+        if (ftype == OSSL_QUIC_FRAME_TYPE_PADDING)
+            ctype = SSL3_RT_QUIC_FRAME_PADDING;
+        else if (OSSL_QUIC_FRAME_TYPE_IS_STREAM(ftype)
+                || ftype == OSSL_QUIC_FRAME_TYPE_CRYPTO)
+            ctype = SSL3_RT_QUIC_FRAME_HEADER;
+
+        h->txp->args.msg_callback(1, OSSL_QUIC1_VERSION, ctype, h->txn.data, l,
+                                  h->txp->args.msg_callback_s,
+                                  h->txp->args.msg_callback_arg);
+    }
+
     h->scratch_bytes += l;
     tx_helper_end(h, 1);
     return 1;