From: Amaury Denoyelle Date: Mon, 7 Feb 2022 10:44:17 +0000 (+0100) Subject: MINOR: mux-quic: complete functions to detect stream type X-Git-Tag: v2.6-dev3~60 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0dc40f06d1ed51e8412c40aa5d8a8707216bd70b;p=thirdparty%2Fhaproxy.git MINOR: mux-quic: complete functions to detect stream type Improve the functions used to detect the stream characteristics : uni/bidirectional and local/remote initiated. Most notably, these functions are now designed to work transparently for a MUX in the frontend or backend side. For this, we use the connection to determine the current MUX side. This will be useful if QUIC is implemented on the server side. --- diff --git a/include/haproxy/mux_quic.h b/include/haproxy/mux_quic.h index 4e588bc3e5..56bbad5db7 100644 --- a/include/haproxy/mux_quic.h +++ b/include/haproxy/mux_quic.h @@ -7,6 +7,7 @@ #endif #include +#include #include #include @@ -42,12 +43,26 @@ static inline enum qcs_type qcs_id_type(uint64_t id) return id & QCS_ID_TYPE_MASK; } -/* Return 1 if the stream with as ID attached to connection - * has been locally initiated, 0 if not. - */ -static inline int qc_local_stream_id(struct qcc *qcc, uint64_t id) +/* Return true if stream has been opened locally. */ +static inline int quic_stream_is_local(struct qcc *qcc, uint64_t id) +{ + return conn_is_back(qcc->conn) == !(id & QCS_ID_SRV_INTIATOR_BIT); +} + +/* Return true if stream is opened by peer. */ +static inline int quic_stream_is_remote(struct qcc *qcc, uint64_t id) +{ + return !quic_stream_is_local(qcc, id); +} + +static inline int quic_stream_is_uni(uint64_t id) +{ + return id & QCS_ID_DIR_BIT; +} + +static inline int quic_stream_is_bidi(uint64_t id) { - return id & QCS_ID_SRV_INTIATOR_BIT; + return !quic_stream_is_uni(id); } struct eb64_node *qcc_get_qcs(struct qcc *qcc, uint64_t id); diff --git a/src/mux_quic.c b/src/mux_quic.c index c16e3d2c61..7c52ac0136 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -113,7 +113,7 @@ struct eb64_node *qcc_get_qcs(struct qcc *qcc, uint64_t id) strm_type = id & QCS_ID_TYPE_MASK; sub_id = id >> QCS_ID_TYPE_SHIFT; strm_node = NULL; - if (qc_local_stream_id(qcc, id)) { + if (quic_stream_is_local(qcc, id)) { /* Local streams: this stream must be already opened. */ strm_node = eb64_lookup(&qcc->streams_by_id, id); if (!strm_node) {