]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: h2: add h2_set_frame_size() to update the size in a binary frame
authorWilly Tarreau <w@1wt.eu>
Thu, 27 Jul 2017 11:37:23 +0000 (13:37 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 31 Oct 2017 17:12:14 +0000 (18:12 +0100)
This function is called after preparing a frame, in order to update the
frame's size in the frame header. It takes the frame payload length in
argument.

It simply writes a 24-bit frame size into a buffer, making use of the
net_helper functions which try to optimize per platform (this is a
frequently used operation).

src/mux_h2.c

index 6268465d8f7300022ecb137a669f49ed1cf12101..7cdf31c3251c1c571db3411ae12624e2e1218562 100644 (file)
@@ -14,6 +14,7 @@
 #include <common/config.h>
 #include <common/h2.h>
 #include <common/hpack-tbl.h>
+#include <common/net_helper.h>
 #include <proto/applet.h>
 #include <proto/connection.h>
 #include <proto/stream.h>
@@ -391,6 +392,15 @@ static inline void h2s_error(struct h2s *h2s, enum h2_err err)
        }
 }
 
+/* writes the 24-bit frame size <len> at address <frame> */
+static inline void h2_set_frame_size(void *frame, uint32_t len)
+{
+       uint8_t *out = frame;
+
+       *out = len >> 16;
+       write_n16(out + 1, len);
+}
+
 
 /*********************************************************/
 /* functions below are I/O callbacks from the connection */