From 7ad81403d05a1defdb0124aa1c191e2970301b5f Mon Sep 17 00:00:00 2001 From: Frederic Lecaille Date: Wed, 27 May 2026 18:38:32 +0200 Subject: [PATCH] CLEANUP: qpack: move encoded macros to qpack-t.h to avoid duplication QPACK_LFL_WLN_BIT and related encoded field line bitmasks were defined in both qpack-enc.c and qpack-dec.c. Moved them to qpack-t.h where they are shared between encoder and decoder, eliminating the duplicate definitions. Should be backported to ease any further commit to come. --- include/haproxy/qpack-t.h | 8 ++++++++ src/qpack-dec.c | 8 -------- src/qpack-enc.c | 3 +-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/include/haproxy/qpack-t.h b/include/haproxy/qpack-t.h index 1cc6dabaa..495ef5bc5 100644 --- a/include/haproxy/qpack-t.h +++ b/include/haproxy/qpack-t.h @@ -43,6 +43,14 @@ #define QPACK_DEC_INST_SCCL 0x40 // Stream Cancellation #define QPACK_DEC_INST_SACK 0x80 // Section Acknowledgment +/* Encoded field line bitmasks (shared between encoder and decoder) */ +#define QPACK_EFL_BITMASK 0xf0 +#define QPACK_LFL_WPBNM 0x00 // Literal field line with post-base name reference +#define QPACK_IFL_WPBI 0x10 // Indexed field line with post-based index +#define QPACK_LFL_WLN_BIT 0x20 // Literal field line with literal name +#define QPACK_LFL_WNR_BIT 0x40 // Literal field line with name reference +#define QPACK_IFL_BIT 0x80 // Indexed field line + /* RFC 9204 6. Error Handling */ enum qpack_err { QPACK_ERR_DECOMPRESSION_FAILED = 0x200, diff --git a/src/qpack-dec.c b/src/qpack-dec.c index f70206f4a..7016553f1 100644 --- a/src/qpack-dec.c +++ b/src/qpack-dec.c @@ -44,14 +44,6 @@ #define qpack_debug_hexdump(...) do { } while (0) #endif -/* Encoded field line bitmask */ -#define QPACK_EFL_BITMASK 0xf0 -#define QPACK_LFL_WPBNM 0x00 // Literal field line with post-base name reference -#define QPACK_IFL_WPBI 0x10 // Indexed field line with post-based index -#define QPACK_LFL_WLN_BIT 0x20 // Literal field line with literal name -#define QPACK_LFL_WNR_BIT 0x40 // Literal field line with name reference -#define QPACK_IFL_BIT 0x80 // Indexed field line - /* reads a varint from 's lowest bits and bytes max (raw included). * returns the 64-bit value on success after updating buf and len_in. Forces * len_in to (uint64_t)-1 on truncated input. diff --git a/src/qpack-enc.c b/src/qpack-enc.c index 3877b7b94..75244c0b5 100644 --- a/src/qpack-enc.c +++ b/src/qpack-enc.c @@ -1,6 +1,7 @@ #include #include +#include #include /* Returns the byte size required to encode as a -prefix @@ -265,8 +266,6 @@ int qpack_encode_field_section_line(struct buffer *out) return 0; } -#define QPACK_LFL_WLN_BIT 0x20 // Literal field line with literal name - /* Encode a header in literal field line with literal name. * Returns 0 on success else non-zero. */