]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: h3: define stream type
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 24 May 2022 13:24:03 +0000 (15:24 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 25 May 2022 13:41:25 +0000 (15:41 +0200)
Define a new enum h3s_t. This is used to differentiate between the
different stream types used in a HTTP/3 connection, including the QPACK
encoder/decoder streams.

For the moment, only bidirectional streams is positioned. This patch
will be useful to unify reception of uni streams with bidirectional
ones.

include/haproxy/h3.h
src/h3.c
src/mux_quic.c

index 5524d79cf2b4b8fb74867a822d4b1318835a84c2..e16de6729f20779c85e22d8b73e9ce6839f3b34d 100644 (file)
@@ -84,6 +84,20 @@ enum h3_ft       {
        H3_FT_MAX_PUSH_ID  = 0x07,
 };
 
+/* Stream types */
+enum h3s_t {
+       /* unidirectional streams */
+       H3S_T_CTRL,
+       H3S_T_PUSH,
+       H3S_T_QPACK_DEC,
+       H3S_T_QPACK_ENC,
+
+       /* bidirectional streams */
+       H3S_T_REQ,
+
+       H3S_T_UNKNOWN
+};
+
 /* H3 unidirectional QUIC stream */
 struct h3_uqs {
        /* Underlying incoming QUIC uni-stream */
index 13dbc70353d1e87cb33879382e2f4a234c0392f9..67ffcb1e461c2df71e0ca71b1a5c9e9be1f8625f 100644 (file)
--- a/src/h3.c
+++ b/src/h3.c
@@ -70,6 +70,7 @@ struct h3c {
 DECLARE_STATIC_POOL(pool_head_h3c, "h3c", sizeof(struct h3c));
 
 struct h3s {
+       enum h3s_t type;
        int demux_frame_len;
        int demux_frame_type;
 };
@@ -778,6 +779,14 @@ static int h3_attach(struct qcs *qcs)
        h3s->demux_frame_len = 0;
        h3s->demux_frame_type = 0;
 
+       if (quic_stream_is_bidi(qcs->id)) {
+               h3s->type = H3S_T_REQ;
+       }
+       else {
+               /* stream type must be decoded for unidirectional streams */
+               h3s->type = H3S_T_UNKNOWN;
+       }
+
        return 0;
 }
 
index c4c2e46b902d5817f06316cb53fdc86b4c733c52..206307f55a3ba55cd82bda19a79206df7a90da44 100644 (file)
@@ -136,12 +136,12 @@ struct qcs *qcs_new(struct qcc *qcc, uint64_t id, enum qcs_type type)
                        goto err;
        }
 
+       qcs->id = qcs->by_id.key = id;
        if (qcc->app_ops->attach) {
                if (qcc->app_ops->attach(qcs))
                        goto err;
        }
 
-       qcs->id = qcs->by_id.key = id;
        /* store transport layer stream descriptor in qcc tree */
        eb64_insert(&qcc->streams_by_id, &qcs->by_id);