From 3236a8e85c882a54e28f39c32a794d11d3c58380 Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Tue, 24 May 2022 15:24:03 +0200 Subject: [PATCH] MINOR: h3: define stream type 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 | 14 ++++++++++++++ src/h3.c | 9 +++++++++ src/mux_quic.c | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/include/haproxy/h3.h b/include/haproxy/h3.h index 5524d79cf..e16de6729 100644 --- a/include/haproxy/h3.h +++ b/include/haproxy/h3.h @@ -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 */ diff --git a/src/h3.c b/src/h3.c index 13dbc7035..67ffcb1e4 100644 --- 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; } diff --git a/src/mux_quic.c b/src/mux_quic.c index c4c2e46b9..206307f55 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -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);