Skip to content

Commit 6efe60a

Browse files
committed
MINOR: mux-quic: add function for ALPN to app-ops conversion
Extract the conversion from ALPN to qcc_app_ops type from quic_conn source file into QUIC MUX. The newly created function is named quic_alpn_to_app_ops(). This change allows to remove extra headers H3/hq-interop in quic_conn source file.
1 parent 6ee1939 commit 6efe60a

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

include/haproxy/mux_quic.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
#include <haproxy/mux_quic-t.h>
1313
#include <haproxy/stconn.h>
1414

15+
#include <haproxy/h3.h>
16+
#include <haproxy/hq_interop.h>
17+
1518
#define qcc_report_glitch(qcc, inc, ...) ({ \
1619
COUNT_GLITCH(__VA_ARGS__); \
1720
_qcc_report_glitch(qcc, inc); \
@@ -115,6 +118,16 @@ void qcc_show_quic(struct qcc *qcc);
115118

116119
void qcc_wakeup(struct qcc *qcc);
117120

121+
static inline const struct qcc_app_ops *quic_alpn_to_app_ops(const char *alpn, int alpn_len)
122+
{
123+
if (alpn_len >= 2 && memcmp(alpn, "h3", 2) == 0)
124+
return &h3_ops;
125+
else if (alpn_len >= 10 && memcmp(alpn, "hq-interop", 10) == 0)
126+
return &hq_interop_ops;
127+
128+
return NULL;
129+
}
130+
118131
#endif /* USE_QUIC */
119132

120133
#endif /* _HAPROXY_MUX_QUIC_H */

src/quic_conn.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
#include <haproxy/freq_ctr.h>
3939
#include <haproxy/frontend.h>
4040
#include <haproxy/global.h>
41-
#include <haproxy/h3.h>
42-
#include <haproxy/hq_interop.h>
4341
#include <haproxy/log.h>
4442
#include <haproxy/mux_quic.h>
4543
#include <haproxy/ncbuf.h>
@@ -274,14 +272,11 @@ void quic_set_tls_alert(struct quic_conn *qc, int alert)
274272
*/
275273
int quic_set_app_ops(struct quic_conn *qc, const char *alpn, int alpn_len)
276274
{
277-
if (alpn_len >= 2 && memcmp(alpn, "h3", 2) == 0)
278-
qc->app_ops = &h3_ops;
279-
else if (alpn_len >= 10 && memcmp(alpn, "hq-interop", 10) == 0)
280-
qc->app_ops = &hq_interop_ops;
281-
else
275+
if (!(qc->app_ops = quic_alpn_to_app_ops(alpn, alpn_len)))
282276
return 0;
283277

284278
return 1;
279+
285280
}
286281

287282
/* Try to reuse <alpn> ALPN and <etps> early transport parameters.

0 commit comments

Comments
 (0)