]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
REORG: quic: Move ncbuf related function from quic_rx to quic_conn
authorFrédéric Lécaille <flecaille@haproxy.com>
Tue, 28 Nov 2023 08:09:36 +0000 (09:09 +0100)
committerFrédéric Lécaille <flecaille@haproxy.com>
Tue, 28 Nov 2023 14:47:18 +0000 (15:47 +0100)
Move quic_get_ncbuf() and quic_free_ncbuf() from quic_rx.c to quic_conn.h
as static inlined functions.

include/haproxy/quic_conn.h
include/haproxy/quic_rx.h
src/quic_rx.c

index 2f2d446591410c37855ec7c48160ee29f1703de8..1cd17d7665952ded58171d11ced03469082d837b 100644 (file)
@@ -30,9 +30,9 @@
 #include <import/eb64tree.h>
 #include <import/ebmbtree.h>
 
-#include <haproxy/buf.h>
 #include <haproxy/chunk.h>
-#include <haproxy/ncbuf-t.h>
+#include <haproxy/dynbuf.h>
+#include <haproxy/ncbuf.h>
 #include <haproxy/net_helper.h>
 #include <haproxy/openssl-compat.h>
 #include <haproxy/ticks.h>
@@ -130,6 +130,38 @@ static inline void quic_conn_mv_cids_to_cc_conn(struct quic_conn_closed *cc_conn
 
 }
 
+/* Allocate the underlying required memory for <ncbuf> non-contiguous buffer */
+static inline struct ncbuf *quic_get_ncbuf(struct ncbuf *ncbuf)
+{
+       struct buffer buf = BUF_NULL;
+
+       if (!ncb_is_null(ncbuf))
+               return ncbuf;
+
+       b_alloc(&buf);
+       BUG_ON(b_is_null(&buf));
+
+       *ncbuf = ncb_make(buf.area, buf.size, 0);
+       ncb_init(ncbuf, 0);
+
+       return ncbuf;
+}
+
+/* Release the underlying memory use by <ncbuf> non-contiguous buffer */
+static inline void quic_free_ncbuf(struct ncbuf *ncbuf)
+{
+       struct buffer buf;
+
+       if (ncb_is_null(ncbuf))
+               return;
+
+       buf = b_make(ncbuf->area, ncbuf->size, 0, 0);
+       b_free(&buf);
+       offer_buffers(NULL, 1);
+
+       *ncbuf = NCBUF_NULL;
+}
+
 void chunk_frm_appendf(struct buffer *buf, const struct quic_frame *frm);
 void quic_set_connection_close(struct quic_conn *qc, const struct quic_err err);
 void quic_set_tls_alert(struct quic_conn *qc, int alert);
index dd2d6289c720922d50daf9e5499dd004c777d592..494bc4a2d59d8a2e390921958266081bdd9a1e64 100644 (file)
@@ -30,7 +30,6 @@ int quic_dgram_parse(struct quic_dgram *dgram, struct quic_conn *from_qc,
 int qc_treat_rx_pkts(struct quic_conn *qc);
 int qc_parse_hd_form(struct quic_rx_packet *pkt,
                      unsigned char **pos, const unsigned char *end);
-void quic_free_ncbuf(struct ncbuf *ncbuf);
 int qc_treat_rx_crypto_frms(struct quic_conn *qc, struct quic_enc_level *el,
                             struct ssl_sock_ctx *ctx);
 int qc_handle_frms_of_lost_pkt(struct quic_conn *qc,
index e49e6dc95257bd78ed2d9af503dc70da3e94db46..0c313446c3f9f8b95b4cdc50291809e641568259 100644 (file)
@@ -674,38 +674,6 @@ static int qc_handle_strm_frm(struct quic_rx_packet *pkt,
        return !ret;
 }
 
-/* Release the underlying memory use by <ncbuf> non-contiguous buffer */
-void quic_free_ncbuf(struct ncbuf *ncbuf)
-{
-       struct buffer buf;
-
-       if (ncb_is_null(ncbuf))
-               return;
-
-       buf = b_make(ncbuf->area, ncbuf->size, 0, 0);
-       b_free(&buf);
-       offer_buffers(NULL, 1);
-
-       *ncbuf = NCBUF_NULL;
-}
-
-/* Allocate the underlying required memory for <ncbuf> non-contiguous buffer */
-static struct ncbuf *quic_get_ncbuf(struct ncbuf *ncbuf)
-{
-       struct buffer buf = BUF_NULL;
-
-       if (!ncb_is_null(ncbuf))
-               return ncbuf;
-
-       b_alloc(&buf);
-       BUG_ON(b_is_null(&buf));
-
-       *ncbuf = ncb_make(buf.area, buf.size, 0);
-       ncb_init(ncbuf, 0);
-
-       return ncbuf;
-}
-
 /* Parse <frm> CRYPTO frame coming with <pkt> packet at <qel> <qc> connectionn.
  * Returns 1 if succeeded, 0 if not. Also set <*fast_retrans> to 1 if the
  * speed up handshake completion may be run after having received duplicated