]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: qpack: reduce dependencies on other modules
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 14 Jun 2022 14:34:32 +0000 (16:34 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 15 Jun 2022 09:20:48 +0000 (11:20 +0200)
Clean up QPACK decoder API by removing dependencies on ncbuf and
MUX-QUIC. This reduces includes statements. It will also help to
implement a standalone QPACK decoder.

include/haproxy/qpack-dec.h
src/h3.c
src/qpack-dec.c

index 991e1a9f7a513674766e5fb4b40a75f3f08555c4..a5d9ba197d747ead760f0a0e860bf96af89d949f 100644 (file)
@@ -21,8 +21,7 @@
 #ifndef _HAPROXY_QPACK_DEC_H
 #define _HAPROXY_QPACK_DEC_H
 
-#include <haproxy/mux_quic-t.h>
-
+struct buffer;
 struct http_hdr;
 
 /* Internal QPACK processing errors.
@@ -45,7 +44,7 @@ struct qpack_dec {
 
 int qpack_decode_fs(const unsigned char *buf, uint64_t len, struct buffer *tmp,
                     struct http_hdr *list);
-int qpack_decode_enc(struct qcs *qcs, void *ctx);
-int qpack_decode_dec(struct qcs *qcs, void *ctx);
+int qpack_decode_enc(struct buffer *buf, void *ctx);
+int qpack_decode_dec(struct buffer *buf, void *ctx);
 
 #endif /* _HAPROXY_QPACK_DEC_H */
index 3dc9facc5b87394336e827bfbbb933c2b14f949b..a18e7d7e2677a678ec743825f02264f8b092095a 100644 (file)
--- a/src/h3.c
+++ b/src/h3.c
@@ -230,11 +230,11 @@ static ssize_t h3_parse_uni_stream_no_h3(struct qcs *qcs, struct buffer *b)
 
        switch (h3s->type) {
        case H3S_T_QPACK_DEC:
-               if (qpack_decode_dec(qcs, NULL))
+               if (qpack_decode_dec(b, NULL))
                        return -1;
                break;
        case H3S_T_QPACK_ENC:
-               if (qpack_decode_enc(qcs, NULL))
+               if (qpack_decode_enc(b, NULL))
                        return -1;
                break;
        case H3S_T_UNKNOWN:
index 82ffd81e0524bd598a958656fd386477325dd23a..f5ba5514465b2225af454ed09780120bcc7c3865 100644 (file)
@@ -27,7 +27,6 @@
 #include <haproxy/buf.h>
 #include <haproxy/chunk.h>
 #include <haproxy/h3.h>
-#include <haproxy/ncbuf.h>
 #include <haproxy/qpack-t.h>
 #include <haproxy/qpack-dec.h>
 #include <haproxy/qpack-tbl.h>
@@ -97,22 +96,20 @@ static uint64_t qpack_get_varint(const unsigned char **buf, uint64_t *len_in, in
  *
  * Returns 0 on success else non-zero.
  */
-int qpack_decode_enc(struct qcs *qcs, void *ctx)
+int qpack_decode_enc(struct buffer *buf, void *ctx)
 {
        size_t len;
-       struct ncbuf *rxbuf;
        unsigned char inst;
 
-       rxbuf = &qcs->rx.ncbuf;
-       len = ncb_data(rxbuf, 0);
-       qpack_debug_hexdump(stderr, "[QPACK-DEC-ENC] ", ncb_head(rxbuf), 0, len);
+       len = b_data(buf);
+       qpack_debug_hexdump(stderr, "[QPACK-DEC-ENC] ", b_head(buf), 0, len);
 
        if (!len) {
                qpack_debug_printf(stderr, "[QPACK-DEC-ENC] empty stream\n");
                return 0;
        }
 
-       inst = (unsigned char)*ncb_head(rxbuf) & QPACK_ENC_INST_BITMASK;
+       inst = (unsigned char)*b_head(buf) & QPACK_ENC_INST_BITMASK;
        if (inst == QPACK_ENC_INST_DUP) {
                /* Duplicate */
        }
@@ -133,22 +130,20 @@ int qpack_decode_enc(struct qcs *qcs, void *ctx)
  *
  * Returns 0 on success else non-zero.
  */
-int qpack_decode_dec(struct qcs *qcs, void *ctx)
+int qpack_decode_dec(struct buffer *buf, void *ctx)
 {
        size_t len;
-       struct ncbuf *rxbuf;
        unsigned char inst;
 
-       rxbuf = &qcs->rx.ncbuf;
-       len = ncb_data(rxbuf, 0);
-       qpack_debug_hexdump(stderr, "[QPACK-DEC-DEC] ", ncb_head(rxbuf), 0, len);
+       len = b_data(buf);
+       qpack_debug_hexdump(stderr, "[QPACK-DEC-DEC] ", b_head(buf), 0, len);
 
        if (!len) {
                qpack_debug_printf(stderr, "[QPACK-DEC-DEC] empty stream\n");
                return 0;
        }
 
-       inst = (unsigned char)*ncb_head(rxbuf) & QPACK_DEC_INST_BITMASK;
+       inst = (unsigned char)*b_head(buf) & QPACK_DEC_INST_BITMASK;
        if (inst == QPACK_DEC_INST_ICINC) {
                /* Insert count increment */
        }